/* mobile.css — the phone and tablet layout.
 *
 * Rules sit under html.sfa-phone (phones and small tablets: up to 760px wide,
 * a touch screen up to 900px wide, or a short touch screen held sideways) or
 * html.sfa-touch (any touch screen), classes index.html's <head> sets; the
 * <link> loads this file only for narrow or touch screens. A desktop with a
 * mouse never applies a rule of it. Much of the game's UI is styled inline by
 * JavaScript, hence the !important overrides. js/mobile.js adds the phone-only
 * behaviour (sheets that open and close, tabs, long press, pinch).
 */

html.sfa-phone {
    --m-bar: 56px;                                         /* the bottom toolbar */
    --m-safe-t: env(safe-area-inset-top, 0px);
    --m-safe-b: env(safe-area-inset-bottom, 0px);
    --m-top: calc(70px + var(--m-safe-t));                 /* below the turn bar */
    --m-bottom: calc(var(--m-bar) + var(--m-safe-b));      /* above the toolbar */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}
html.sfa-phone body {
    touch-action: manipulation;                            /* no double-tap zoom */
    overscroll-behavior: none;
}
html.sfa-phone #canvas-container,
html.sfa-phone #canvas-container canvas { touch-action: none; }   /* the 3D view takes every gesture */
html.sfa-phone input,
html.sfa-phone select,
html.sfa-phone textarea { font-size: 16px !important; }            /* iOS zooms into smaller inputs */

/* ── Turn bar: the whole top row; the status text wraps to a second line ── */
html.sfa-phone #turn-bar {
    top: calc(6px + var(--m-safe-t)) !important;
    left: 6px !important;
    right: 6px !important;
    flex-wrap: wrap;
    row-gap: 2px !important;
    gap: 6px !important;
    padding: 5px 8px !important;
    border-radius: 12px !important;
}
html.sfa-phone #turn-bar .tb-label { display: none; }
html.sfa-phone #turn-bar .tb-status {
    order: 20;
    flex: 1 0 100%;
    max-width: none !important;
    font-size: 10px;
    text-align: center;
}
html.sfa-phone #turn-bar .tb-age {                         /* its icon only */
    max-width: 30px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: clip;
    padding: 2px 6px !important;
}
html.sfa-phone #turn-bar #tb-btn { margin-left: auto; padding: 7px 12px !important; }
html.sfa-phone #turn-bar #tb-store,
html.sfa-phone #turn-bar #tb-galaxy { padding: 6px 9px !important; }

/* the status line: a slim strip under the turn bar */
html.sfa-phone #top-bar {
    top: calc(66px + var(--m-safe-t)) !important;
    height: 20px !important;
    background: none !important;
    border: none !important;
    backdrop-filter: none !important;
    pointer-events: none;
    padding: 0 10px;
}
html.sfa-phone #status-text {
    font-size: 11px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* ── Bottom toolbar: one row of icon buttons with short labels ── */
html.sfa-phone #bottom-toolbar {
    height: var(--m-bottom) !important;
    padding: 0 2px var(--m-safe-b) !important;
    gap: 0 !important;
    justify-content: space-between !important;
}
html.sfa-phone #bottom-toolbar .toolbar-turn-info,
html.sfa-phone #bottom-toolbar .toolbar-divider,
html.sfa-phone #bottom-toolbar #end-turn-btn { display: none !important; }   /* the turn bar has these */
html.sfa-phone #bottom-toolbar .toolbar-section { display: contents; }
html.sfa-phone #bottom-toolbar .toolbar-btn {
    flex: 1 1 0;
    min-width: 0;
    height: calc(var(--m-bar) - 8px);
    margin: 0 1px;
    padding: 2px 1px !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    font-size: 9.5px !important;
    line-height: 1.1;
    letter-spacing: 0 !important;
    white-space: normal;
    text-align: center;
    overflow: hidden;
}
html.sfa-phone #bottom-toolbar .toolbar-btn .btn-icon { font-size: 17px; margin: 0 !important; }

/* ── Your Fleets: a sheet above the toolbar; its header opens and closes it ── */
html.sfa-phone #fleet-list-panel {
    top: auto !important;
    left: 0 !important;
    right: 0 !important;
    bottom: var(--m-bottom) !important;
    width: auto !important;
    height: 46px;
    max-height: 46px;
    padding: 0 10px !important;
    border-radius: 14px 14px 0 0 !important;
    overflow: hidden !important;
    transition: max-height .25s ease, height .25s ease;
}
html.sfa-phone #fleet-list-panel.m-open {
    height: 62vh;
    max-height: 62vh;
    padding-bottom: 8px !important;
}
html.sfa-phone #fleet-list-panel .fleet-list-header {
    min-height: 46px;
    margin: 0 !important;
    cursor: pointer;
}
html.sfa-phone #fleet-list-panel .fleet-list-header::after {
    content: '▲';
    color: #00d4ff;
    font-size: 12px;
    margin-left: 10px;
    transition: transform .25s;
}
html.sfa-phone #fleet-list-panel.m-open .fleet-list-header::after { transform: rotate(180deg); }
html.sfa-phone #fleet-list-panel .fleet-list-header .fleet-count-badge { margin-left: auto; }
html.sfa-phone #fleet-list-panel #player-fleet-list { overflow-y: auto; -webkit-overflow-scrolling: touch; }
html.sfa-phone .m-hide-fleets #fleet-list-panel { display: none !important; }

/* ── Floating buttons: small, out of the 3D view's way ── */
html.sfa-phone #chronicles-btn {                           /* 📜, under the turn bar on the right */
    top: calc(88px + var(--m-safe-t)) !important;
    right: 6px !important;
    padding: 7px 9px !important;
}
html.sfa-phone #chronicles-btn span { display: none; }
html.sfa-phone #galaxy-minimap {                           /* the galaxy map, smaller */
    top: calc(88px + var(--m-safe-t)) !important;
    left: 6px !important;
    transform: scale(.62);
    transform-origin: 0 0;
}
html.sfa-phone #voice-toggle {
    width: 40px !important;
    height: 40px !important;
    font-size: 18px !important;
    right: 8px !important;
    bottom: calc(var(--m-bottom) + 56px) !important;
}
html.sfa-phone #feedback-btn {
    left: 8px !important;
    bottom: calc(var(--m-bottom) + 56px) !important;
    padding: 5px 10px !important;
    font-size: 12px !important;
}

/* chat: a round 💬 button; open, a sheet over the lower screen */
html.sfa-phone #faction-chat-panel.collapsed {
    left: auto !important;
    right: 56px !important;
    bottom: calc(var(--m-bottom) + 56px) !important;
    width: 40px !important;
    height: 40px !important;
    min-width: 0 !important;
    border-radius: 50% !important;
    overflow: visible !important;
}
html.sfa-phone #faction-chat-panel.collapsed .chat-header {
    width: 40px;
    height: 40px;
    padding: 0 !important;
    justify-content: center;
    border-radius: 50%;
}
html.sfa-phone #faction-chat-panel.collapsed .chat-title {
    font-size: 0 !important;                               /* the icon only */
    width: auto !important;
    letter-spacing: 0 !important;
}
html.sfa-phone #faction-chat-panel.collapsed .chat-title::before { content: '💬'; font-size: 18px; }
html.sfa-phone #faction-chat-panel.collapsed .chat-arrow { display: none; }
html.sfa-phone #faction-chat-panel.collapsed .chat-badge { position: absolute; top: -4px; right: -4px; }
html.sfa-phone #faction-chat-panel:not(.collapsed) {
    left: 0 !important;
    right: 0 !important;
    bottom: var(--m-bottom) !important;
    top: auto !important;
    width: auto !important;
    max-width: none !important;
    height: 60vh !important;
    max-height: 60vh !important;
    border-radius: 14px 14px 0 0 !important;
    z-index: 10020 !important;
}

/* ── Planet view: the planet above, one panel at a time below it; the tab
      strip (js/mobile.js) picks Structures, the tile (build) or the planet ── */
html.sfa-phone #pv-exit-galaxy-btn {
    top: calc(72px + var(--m-safe-t)) !important;
    left: 6px !important;
    padding: 8px 12px !important;
    font-size: 12px !important;
}
html.sfa-phone #pv-surface-small-btn {
    top: calc(72px + var(--m-safe-t)) !important;
    bottom: auto !important;
    left: auto !important;
    right: 6px !important;
    width: 42px !important;
    height: 42px !important;
}
html.sfa-phone #planet-view-buildings-panel,
html.sfa-phone #planet-view-build-panel,
html.sfa-phone #planet-view-stats-panel {
    top: auto !important;
    left: 0 !important;
    right: 0 !important;
    bottom: calc(46px + var(--m-safe-b)) !important;
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    max-height: 48vh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    border-radius: 14px 14px 0 0 !important;
    padding: 10px 12px !important;
    z-index: 30 !important;
}
html.sfa-phone #planet-view-container:not([data-m-tab="buildings"]) #planet-view-buildings-panel,
html.sfa-phone #planet-view-container:not([data-m-tab="build"]) #planet-view-build-panel,
html.sfa-phone #planet-view-container:not([data-m-tab="stats"]) #planet-view-stats-panel { display: none !important; }
html.sfa-phone #planet-view-stats-panel .pv-toolbar-row { flex-wrap: wrap; row-gap: 6px; }

html.sfa-phone #m-pv-tabs {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(46px + var(--m-safe-b));
    padding: 0 4px var(--m-safe-b);
    display: flex;
    gap: 4px;
    align-items: center;
    background: rgba(0, 12, 26, .96);
    border-top: 1px solid rgba(0, 212, 255, .3);
    z-index: 40;
}
html:not(.sfa-phone) #m-pv-tabs { display: none; }
html.sfa-phone #m-pv-tabs button {
    flex: 1 1 0;
    height: 36px;
    background: rgba(0, 40, 70, .6);
    border: 1px solid rgba(0, 212, 255, .3);
    border-radius: 8px;
    color: #b8d8ff;
    font: 600 12px Rajdhani, Orbitron, sans-serif;
    letter-spacing: .5px;
}
html.sfa-phone #m-pv-tabs button.on {
    background: rgba(0, 212, 255, .22);
    border-color: #00d4ff;
    color: #fff;
}
html.sfa-phone #planet-view-stats-panel .pv-income-section,
html.sfa-phone #planet-view-stats-panel .pv-multipliers { flex-wrap: wrap !important; row-gap: 6px; }

/* in the planet view the floating buttons sit by the picture button, top right */
html.sfa-phone body:has(#planet-view-container.visible) #voice-toggle {
    top: calc(122px + var(--m-safe-t)) !important;
    bottom: auto !important;
    right: 7px !important;
}
html.sfa-phone body:has(#planet-view-container.visible) #faction-chat-panel.collapsed {
    top: calc(170px + var(--m-safe-t)) !important;
    bottom: auto !important;
    right: 7px !important;
}
html.sfa-phone body:has(#planet-view-container.visible) #feedback-btn { display: none !important; }

/* ── Corners: the credits badge and Chronicles under the turn bar, right ── */
html.sfa-phone #akashic-credits-badge {
    top: calc(88px + var(--m-safe-t)) !important;
    right: 6px !important;
}
html.sfa-phone body:has(#akashic-credits-badge) #chronicles-btn { top: calc(132px + var(--m-safe-t)) !important; }
html.sfa-phone #event-cards,
html.sfa-phone #notification-container {
    top: calc(72px + var(--m-safe-t)) !important;
    left: 6px !important;
    right: 6px !important;
    width: auto !important;
    max-width: none !important;
}
html.sfa-phone #notification-container > * { max-width: none !important; }
html.sfa-phone .mp-notification { top: calc(72px + var(--m-safe-t)) !important; left: 6px !important; right: 6px !important; }

/* what you tapped (world, star): a card above Your Fleets */
html.sfa-phone #selection-panel {
    top: auto !important;
    left: 6px !important;
    right: 6px !important;
    bottom: calc(var(--m-bottom) + 52px) !important;
    width: auto !important;
    max-height: 38vh !important;
}

/* full-screen screens take the whole phone: the bars and floating buttons step aside */
html.sfa-phone body:has(#fleet-manager.visible, #planet-manager-dashboard.visible, #battle-dashboard.visible, #battle-simulation.visible,
        #help-panel.visible, #tech-inventory-modal.visible, #upgrade-panel.visible, #merge-fleet-window.visible, #split-fleet-modal.visible,
        #store-overlay, #galaxy-overlay, #faction-overlay, #diplo-overlay, #account-dialog, #pv-ship-order,
        #chronicles-modal:not([style*="display: none"]))
    :is(#turn-bar, #top-bar, #chronicles-btn, #akashic-credits-badge, #voice-toggle, #feedback-btn,
        #faction-chat-panel, #fleet-list-panel, #event-cards, #galaxy-minimap, #selection-panel) { display: none !important; }

/* ── Help ── */
html.sfa-phone #help-panel {
    width: calc(100vw - 16px) !important;
    max-width: none !important;
    max-height: calc(100vh - 24px) !important;
    overflow-y: auto !important;
    padding: 16px 14px !important;
}
html.sfa-phone #help-panel li { font-size: 13px !important; }

/* ── Fleet Manager: one column that scrolls ── */
html.sfa-phone #fleet-manager .fleet-manager-header {
    flex-wrap: wrap !important;
    gap: 8px !important;
    padding: calc(10px + var(--m-safe-t)) 12px 10px !important;
}
html.sfa-phone #fleet-manager .fleet-manager-header h2 { font-size: 15px !important; }
html.sfa-phone #fleet-manager .fleet-resources { gap: 10px !important; flex-wrap: wrap; font-size: 12px; order: 3; flex: 1 0 100%; }
html.sfa-phone #fleet-manager-close { padding: 8px 14px !important; margin-left: auto; }
html.sfa-phone #fleet-manager .fleet-manager-header,
html.sfa-phone #fleet-manager .fleet-manager-tabs { flex-shrink: 0 !important; }
html.sfa-phone #fleet-manager .fleet-manager-tabs { overflow-x: auto; flex-wrap: nowrap; }
html.sfa-phone #fleet-manager .fleet-tab { padding: 8px 12px !important; white-space: nowrap; }
html.sfa-phone #fleet-manager .fleet-tab-content.active {
    display: block !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
    min-height: 0;
}
html.sfa-phone #fleet-manager .fleet-sidebar,
html.sfa-phone #fleet-manager .fleet-view {
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    border-right: none !important;
}
html.sfa-phone #fleet-manager .fleet-view-header { flex-wrap: wrap !important; gap: 8px !important; }
html.sfa-phone #fleet-manager .fleet-stats-summary { flex-wrap: wrap; gap: 10px !important; }
html.sfa-phone #fleet-manager .ship-build-cost { flex-wrap: wrap; gap: 8px; }

/* ── Planets dashboard ── */
html.sfa-phone #planet-manager-dashboard .pmd-header { flex-wrap: wrap !important; gap: 8px; padding: calc(10px + var(--m-safe-t)) 12px 10px !important; }
html.sfa-phone #planet-manager-dashboard .pmd-header h2 { font-size: 16px !important; }
html.sfa-phone #planet-manager-dashboard .pmd-header-stats { gap: 12px !important; font-size: 12px; order: 3; flex: 1 0 100%; }
html.sfa-phone #planet-manager-dashboard .pmd-content { padding: 12px !important; }
html.sfa-phone #planet-manager-dashboard .pmd-search-box { min-width: 0 !important; flex: 1 1 100%; }
html.sfa-phone #planet-manager-dashboard .pmd-filters select { min-width: 0 !important; flex: 1 1 40%; }
html.sfa-phone #planet-manager-dashboard .pmd-summary { grid-template-columns: repeat(2, 1fr) !important; gap: 8px !important; }
html.sfa-phone #planet-manager-dashboard .pmd-summary > * { padding: 10px 8px !important; }
html.sfa-phone #planet-manager-dashboard .pmd-planet-grid { grid-template-columns: 1fr !important; }
html.sfa-phone #planet-manager-dashboard .pmd-planet-actions { flex-wrap: wrap; }

/* ── Tech, refits, music ── */
html.sfa-phone .modal-overlay .modal-content { width: calc(100% - 16px) !important; max-height: 90vh !important; }
html.sfa-phone #upgrade-panel {
    width: calc(100vw - 12px) !important;
    max-height: 88vh !important;
    padding: 12px !important;
}
html.sfa-phone #upgrade-panel .upgrade-ship-info { flex-wrap: wrap; gap: 10px !important; }
html.sfa-phone #upgrade-panel .upgrade-options { grid-template-columns: 1fr !important; }
html.sfa-phone #music-widget {
    left: 6px !important;
    right: 6px !important;
    bottom: calc(var(--m-bottom) + 8px) !important;
    width: auto !important;
}

/* ── Battle setup ── */
html.sfa-phone #battle-dashboard { padding: calc(10px + var(--m-safe-t)) 8px 16px !important; }
html.sfa-phone #battle-dashboard .param-item label { flex: 0 0 96px !important; }
html.sfa-phone #battle-dashboard .battle-dashboard-footer { flex-wrap: wrap; gap: 10px !important; }
html.sfa-phone #battle-dashboard .battle-action-btn { flex: 1 1 40%; padding: 14px 12px !important; font-size: 14px !important; }

/* ── The battle: a compact HUD, the deployment bar fitted, the end card smaller ── */
html.sfa-phone #battle-simulation .battle-hud {
    flex-wrap: wrap !important;
    gap: 6px !important;
    padding: calc(6px + var(--m-safe-t)) 8px 6px !important;
}
html.sfa-phone #battle-simulation .battle-title { font-size: 15px !important; }
html.sfa-phone #battle-simulation .battle-timer { font-size: 13px !important; }
html.sfa-phone #battle-simulation .fleet-status { gap: 8px !important; }
html.sfa-phone #battle-simulation .fleet-panel { min-width: 0 !important; padding: 5px 9px !important; }
html.sfa-phone #battle-simulation .fleet-ships { font-size: 16px !important; }
html.sfa-phone #battle-simulation .battle-controls { flex-wrap: wrap; gap: 6px !important; }
html.sfa-phone #battle-simulation .speed-btn { padding: 5px 8px !important; }
html.sfa-phone #battle-simulation .battle-btn { padding: 6px 10px !important; }
html.sfa-phone #prep-phase-ui {
    left: 6px !important;
    right: 6px !important;
    bottom: calc(8px + var(--m-safe-b)) !important;
    transform: none !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    justify-content: center;
}
html.sfa-phone #prep-phase-ui h2 { white-space: normal !important; font-size: 14px !important; }
html.sfa-phone #prep-phase-ui .prep-controls-row { flex-wrap: wrap !important; gap: 8px !important; justify-content: center; }
html.sfa-phone #prep-phase-ui .prep-instructions-compact { display: none !important; }   /* keyboard and mouse hints */
html.sfa-phone .battle-loading-overlay .battle-loading-content { padding: 24px 16px !important; max-width: calc(100vw - 24px); }
html.sfa-phone #battle-end-overlay .battle-end-content { padding: 20px 14px !important; max-width: calc(100vw - 12px); }
html.sfa-phone #battle-end-overlay .battle-end-title { font-size: 30px !important; }
html.sfa-phone #battle-end-overlay .battle-end-reason { font-size: 14px !important; }
html.sfa-phone #battle-end-overlay .battle-stat-value { font-size: 18px !important; }
html.sfa-phone #battle-end-overlay .tech-drop-item { min-width: 0 !important; }
html.sfa-phone #battle-end-overlay .battle-end-buttons { flex-wrap: wrap; gap: 10px !important; }
html.sfa-phone #battle-end-overlay .battle-end-btn { flex: 1 1 40%; padding: 12px 14px !important; font-size: 14px !important; }
html.sfa-phone .battle-replay-controls,
html.sfa-phone #replay-controls-overlay {
    left: 6px !important;
    right: 6px !important;
    transform: none !important;
    min-width: 0 !important;
    width: auto !important;
}
html.sfa-phone .battle-replay-controls .replay-buttons,
html.sfa-phone #replay-controls-overlay .replay-controls-bar { min-width: 0 !important; flex-wrap: wrap; gap: 6px; justify-content: center; }

/* ── Dialogs ── */
html.sfa-phone .arrival-dialogue-container {
    width: calc(100% - 12px) !important;
    max-height: 88vh !important;
    overflow-y: auto !important;
}
html.sfa-phone .arrival-content { max-height: none !important; }
html.sfa-phone .arrival-btn { flex: 1 1 42%; padding: 10px 10px !important; }
html.sfa-phone #send-fleet-panel { bottom: calc(var(--m-bottom) + 52px) !important; }
html.sfa-phone .merge-fleet-window { width: calc(100vw - 12px) !important; max-height: 88vh; overflow-y: auto; }
html.sfa-phone .merge-fleet-window .merge-fleet-content { flex-direction: column !important; }
html.sfa-phone .mp-overlay { overflow-y: auto !important; align-items: flex-start !important; padding: 12px 0 !important; }
html.sfa-phone .mp-panel { width: calc(100% - 16px) !important; padding: 18px 14px !important; margin: auto; }
html.sfa-phone .mp-title { font-size: 1.3em !important; letter-spacing: 1px !important; }
html.sfa-phone .mp-tabs { flex-wrap: wrap !important; gap: 6px !important; margin-left: 0 !important; margin-right: 0 !important; }
html.sfa-phone .mp-tabs > * { white-space: nowrap; flex: 1 1 40%; padding: 8px 10px !important; }
html.sfa-phone #conduct-notice { width: calc(100vw - 16px) !important; max-width: none !important; }
html.sfa-phone #game-tip {
    left: 6px !important;
    right: 6px !important;
    width: auto !important;
    bottom: calc(var(--m-bottom) + 104px) !important;
}
html.sfa-phone #tutorial-card {
    left: 6px !important;
    right: 6px !important;
    width: auto !important;
    bottom: calc(var(--m-bottom) + 52px) !important;
}
html.sfa-phone #feedback-panel { left: 6px !important; right: 6px !important; width: auto !important; bottom: calc(var(--m-bottom) + 100px) !important; }
html.sfa-phone .chat-msg .chat-msg-actions { display: flex !important; }       /* no hover on a phone */
html.sfa-phone #scenario-popup .modal-body { padding: 16px 14px !important; }
html.sfa-phone #planet-view-result-popup { padding: 16px !important; }
html.sfa-phone #pv-result-content { max-width: calc(100vw - 16px) !important; }
html.sfa-phone #pv-gallery-modal { padding: 14px 10px !important; }
html.sfa-phone #fleet-manager .ship-build-queue-section { font-size: 12px !important; }
html.sfa-phone #fleet-manager .ship-queue-item { font-size: 12px !important; line-height: 1.35; }
html.sfa-phone #planet-manager-dashboard .pmd-header { background: rgba(0, 10, 22, .98) !important; z-index: 5; }
html.sfa-phone .arrival-stats-bar { flex-wrap: wrap !important; row-gap: 8px; }
html.sfa-phone .arrival-stats-bar > * { flex: 1 1 45% !important; }
html.sfa-phone #battle-dashboard .battle-dashboard-header { flex-wrap: wrap !important; gap: 8px !important; align-items: center; }
html.sfa-phone #battle-dashboard .battle-dashboard-header h2 { flex: 1 1 auto; font-size: 15px !important; }
html.sfa-phone #battle-dashboard .battle-dashboard-header .fleet-info { flex: 1 0 100% !important; max-width: none !important; text-align: left !important; font-size: 12px !important; }

/* ── Loading splash: the whole picture (its title is part of it), not a crop ── */
html.sfa-phone #loading {
    background-size: contain !important;
    background-position: center 38% !important;
    padding-bottom: calc(6vh + var(--m-safe-b)) !important;
}

/* ── Sign-in screen: scrolls when the console is taller than the phone ── */
html.sfa-phone #intro-screen { overflow-y: auto !important; -webkit-overflow-scrolling: touch; }
html.sfa-phone #intro-screen .intro-center {
    height: auto !important;
    min-height: 100%;
    justify-content: flex-start !important;
    padding: calc(22px + var(--m-safe-t)) 14px calc(22px + var(--m-safe-b)) !important;
}
html.sfa-phone #intro-screen .intro-hud { display: none !important; }    /* the corner read-outs */

/* ── Any touch screen (a big tablet keeps the desktop layout): the 3D view
      takes the fingers, hover-only bits show, the toolbar fits ── */
html.sfa-touch #canvas-container,
html.sfa-touch #canvas-container canvas { touch-action: none; }
html.sfa-touch .chat-msg .chat-msg-actions { display: flex !important; }
html.sfa-touch:not(.sfa-phone) #bottom-toolbar { gap: 4px !important; padding: 0 8px !important; }
html.sfa-touch:not(.sfa-phone) #bottom-toolbar .toolbar-turn-info { display: none !important; }   /* the turn bar has it */
html.sfa-touch:not(.sfa-phone) #bottom-toolbar .toolbar-divider { margin: 0 4px !important; }
html.sfa-touch:not(.sfa-phone) #bottom-toolbar .toolbar-btn { padding: 10px 12px !important; }
html.sfa-phone #faction-chat-panel.collapsed .chat-body { display: none !important; }
@media (min-width: 600px) { html.sfa-phone #galaxy-minimap { transform: scale(.85); } }

/* wide enough (a tablet, a phone held sideways): the turn bar on one line */
@media (min-width: 600px) {
    html.sfa-phone #turn-bar { flex-wrap: nowrap; }
    html.sfa-phone #turn-bar .tb-status { order: 0; flex: 1 1 auto; min-width: 0; text-align: left; }
    html.sfa-phone #top-bar { top: calc(46px + var(--m-safe-t)) !important; }
}
/* short (a phone held sideways): a smaller galaxy map */
@media (max-height: 500px) { html.sfa-phone #galaxy-minimap { transform: scale(.5); } }
html.sfa-phone body:has(#fleet-list-panel.m-open) :is(#feedback-btn, #voice-toggle, #faction-chat-panel.collapsed, #galaxy-minimap) { display: none !important; }

/* the selected fleet's details: a compact card top right, beside the galaxy map */
html.sfa-phone #fleet-attributes-panel {
    top: calc(132px + var(--m-safe-t)) !important;
    bottom: auto !important;
    left: auto !important;
    right: 6px !important;
    transform: none !important;
    width: min(210px, calc(100vw - 160px)) !important;
    max-height: calc(100vh - 132px - var(--m-bottom) - 110px) !important;
    overflow-y: auto !important;
    padding: 8px 10px !important;
}
html.sfa-phone #fleet-attributes-panel .fleet-attr-header {
    font-size: 13px !important;
    margin-bottom: 4px !important;
    padding-bottom: 4px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
html.sfa-phone #fleet-attributes-panel .fleet-attr-row { padding: 2px 0 !important; }
html.sfa-phone #fleet-attributes-panel .fleet-attr-label,
html.sfa-phone #fleet-attributes-panel .fleet-attr-value { font-size: 11px !important; }
html.sfa-phone body:has(#akashic-credits-badge) #fleet-attributes-panel { top: calc(176px + var(--m-safe-t)) !important; }
