:root {
    /* --- ATOMIC AGE PALETTE --- */
    --color-teal: #2A9D8F;      /* Retro Teal - Primary Accent */
    --color-teal-bright: #4ECDC4; /* Hover state */
    --color-charcoal: #000000;  /* Background Deep */
    --color-dark: #1a2e38;      /* Panel Background */
    --color-orange: #F4A261;    /* Secondary Accent / Highlight */
    --color-red: #E76F51;       /* Alert / Danger */
    --color-yellow: #E9C46A;    /* Info / Gold */
    --color-cream: #FDF6E3;     /* Text / Paper White */
    
    /* UI Variables */
    --bg-main: var(--color-charcoal);
    --bg-panel: var(--color-dark);
    --border-color: var(--color-teal);
    --text-main: var(--color-cream);
    --shadow-retro: 6px 6px 0px 0px rgba(0,0,0,0.5);
    --shadow-retro-hover: 8px 8px 0px 0px rgba(0,0,0,0.6);
}

/* Font Imports handled in HTML, applied here */
body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--color-charcoal);
    color: var(--color-cream);
    /* Disable accidental text highlighting/drag-select across the whole UI. */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Keep real text fields selectable/editable so chat, search and auth still work. */
input, textarea, [contenteditable="true"] {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

body.is-desktop { overflow: hidden; }
body.is-mobile { overflow-x: hidden; overflow-y: auto; }

canvas { display: block; position: absolute; top: 0; left: 0; }

/* Prevent the browser from interpreting touch gestures so the game owns them. */
#gameCanvas { touch-action: none; -ms-touch-action: none; }

/* In-game widescreen letterbox bars: solid black top + bottom bands (no left/right),
   above the canvas but below the HUD (z-index >= 10). Visual only — never intercept
   aim/click/touch. They slide into place when #game-container gets .letterbox-in at
   game start (top descends, bottom rises); off-screen otherwise. */
.letterbox-bar {
    position: absolute;
    left: 0; right: 0;
    height: 48px;
    background: #000;
    pointer-events: none;
    z-index: 5;
    will-change: transform;
}
#letterbox-top    { top: 0;    --hidden: -100%; transform: translateY(var(--hidden)); }
#letterbox-bottom { bottom: 0; --hidden:  100%; transform: translateY(var(--hidden)); }
/* Slow cinematic entrance: hold off-screen for 1s, then glide in over 2s. */
.letterbox-in .letterbox-bar { animation: letterboxIn 2s cubic-bezier(0.22, 1, 0.36, 1) 1s both; }
@keyframes letterboxIn {
    from { transform: translateY(var(--hidden)); }
    to   { transform: translateY(0); }
}

/* Black-hole proximity warning. Sits above the border frame (z 5) and most HUD.
   Opacity is driven inline by game.js (ramps up toward the core); the keyframe
   pulse keeps it alive/urgent. pointer-events:none so it never blocks input. */
#black-hole-warning {
    position: absolute;
    top: 12%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    pointer-events: none;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    letter-spacing: 0.15em;
    font-size: clamp(1rem, 2.5vw, 1.75rem);
    color: #ff4d4d;
    text-shadow: 0 0 12px rgba(255, 77, 77, 0.9);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    animation: bhw-pulse 0.8s ease-in-out infinite;
}
#black-hole-warning.hidden { display: none; }
.bhw-icon { font-size: 1.3em; }
@keyframes bhw-pulse { 0%, 100% { filter: brightness(0.8); } 50% { filter: brightness(1.4); } }

/* --- Helper Utility Classes --- */
.text-teal { color: var(--color-teal) !important; }
.text-orange { color: var(--color-orange) !important; }
.text-yellow { color: var(--color-yellow) !important; }
.text-red { color: var(--color-red) !important; }
.text-cream { color: var(--color-cream) !important; }
.bg-charcoal { background-color: var(--color-charcoal) !important; }
.bg-dark { background-color: var(--color-dark) !important; }

/* --- Panel Styling (The Retro Look) --- */
.panel {
    background-color: var(--bg-panel);
    border: 4px solid #000;
    border-radius: 16px; /* Modern rounded corners */
    box-shadow: var(--shadow-retro);
    padding: 24px;
    display: flex;
    flex-direction: column;
    max-width: 1200px;
    width: 100%;
    height: 650px;
    position: relative;
    overflow: hidden;
    /* Render main-menu panels at 90% size. Kept in sync with the panel-fade
       keyframes below so the entrance/exit animation doesn't drop the scale. */
    transform: scale(0.9);
    transform-origin: center center;
}

/* Decorative Striped Bar at Bottom of Panels */
.panel::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; width: 100%; height: 12px;
    background: repeating-linear-gradient(
        45deg,
        var(--color-orange),
        var(--color-orange) 10px,
        var(--color-charcoal) 10px,
        var(--color-charcoal) 20px
    );
    border-top: 2px solid var(--color-charcoal);
    z-index: 1;
}

.panel-header {
    padding-bottom: 1rem;
    border-bottom: 3px solid #000;
    margin-bottom: 1.5rem;
    letter-spacing: 1px;
    text-transform: uppercase;
}
/* Comic-book headers everywhere: menu panel headings, in-game pause/end-screen headings,
   panel headers, and any .comic-title. !important beats the inline font-['Orbitron'] utility
   that many headings carry. Buttons / nav / body text stay Orbitron/Inter for readability. */
.panel h1, .panel h2, .panel h3, .panel h4,
#pause-menu h1, #pause-menu h2, #pause-menu h3,
#end-game-screen h1, #end-game-screen h2, #end-game-screen h3,
.panel-header, .comic-title {
    font-family: 'Bangers', Impact, sans-serif !important;
    letter-spacing: 1px;
}

.panel-content-area {
    flex-grow: 1;
    overflow-y: auto;
    min-height: 0;
    padding-right: 8px;
}

/* Settings subpanels aren't wrapped in a .panel-content-area, so the active one
   must flex to fill the fixed-height .panel and scroll when its content (mobile
   steering + bindings + gamepad legend + controller test) overflows — otherwise
   the panel's overflow:hidden clips it. The .hidden siblings stay display:none. */
#settings-panel .subpanel:not(.hidden) {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-right: 8px;
}

/* Safety net for item-4: any panel whose direct content overflows the fixed
   height should scroll rather than clip. Panels that wrap their content in
   .panel-content-area already handle this; this catches simple panels that put
   a single scrollable block right under the header. */
.panel > .panel-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-right: 8px;
}

/* --- Retro Buttons --- */
.retro-btn-primary {
    background-color: var(--color-orange);
    color: var(--color-charcoal);
    border: 3px solid #000;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    box-shadow: 4px 4px 0px 0px #000;
    transition: transform 0.1s, box-shadow 0.1s, background-color 0.2s;
    cursor: pointer;
}
.retro-btn-primary:hover {
    background-color: #ffb074; /* Lighter orange */
    transform: translate(-1px, -1px);
    box-shadow: 6px 6px 0px 0px #000;
}
.retro-btn-primary:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0px 0px #000;
}

.retro-btn-secondary {
    background-color: var(--color-teal);
    color: var(--color-charcoal);
    border: 3px solid #000;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    box-shadow: 4px 4px 0px 0px #000;
    transition: all 0.1s;
    cursor: pointer;
}
.retro-btn-secondary:hover {
    background-color: var(--color-teal-bright);
    transform: translate(-1px, -1px);
    box-shadow: 6px 6px 0px 0px #000;
}

/* --- Navigation Buttons --- */
.nav-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 16px;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    color: var(--color-cream);
    border-left: 4px solid transparent;
    transition: all 0.2s;
    opacity: 0.7;
    cursor: pointer;
}
.nav-btn:hover {
    background: linear-gradient(90deg, rgba(42, 157, 143, 0.2), transparent);
    border-left-color: var(--color-yellow);
    opacity: 1;
    color: var(--color-yellow);
}
.nav-btn.active {
    background: linear-gradient(90deg, rgba(244, 162, 97, 0.2), transparent);
    border-left-color: var(--color-orange);
    color: var(--color-orange);
    opacity: 1;
    text-shadow: 0 0 5px rgba(244, 162, 97, 0.5);
}

/* Sub-nav as actual comic folder-tabs. The active tab is JS-driven via the `.active` class
   (see the sub-nav handler in main.js); styling is fully CSS so the highlight follows the
   selected tab. Active tab fills with the panel's --panel-accent and lifts to "connect" to
   the content below; inactive tabs sit recessed. */
.sub-nav-container { align-items: flex-end; }
.sub-nav-btn, .skin-tab, .store-tab {
    cursor: pointer;
    font-family: 'Orbitron', sans-serif; font-weight: 700;
    padding: .45rem 1.15rem;
    color: var(--color-cream); opacity: .55;
    background: rgba(0,0,0,.35);
    border: 3px solid #000; border-bottom: none;
    border-radius: 10px 10px 0 0;
    box-shadow: 3px -2px 0 rgba(0,0,0,.35);
    transform: translateY(3px);
    transition: transform .15s ease, opacity .15s ease, background .15s ease, color .15s ease;
}
.sub-nav-btn:hover, .skin-tab:hover, .store-tab:hover { opacity: .9; transform: translateY(1px); }
.sub-nav-btn.active, .skin-tab.active, .store-tab.active {
    opacity: 1;
    color: #1a1a1a;
    background: var(--panel-accent, var(--color-orange));
    transform: translateY(0);
    box-shadow: 4px -3px 0 rgba(0,0,0,.5);
}

/* --- Game Mode Cards --- */
/* Comic-book mode panels: a diagonal two-color split (per-mode --mode-accent vs a dark
   contrast) inside a thick black border, big icon top-left, mode name bottom-right. */
.game-mode-btn {
    background:
        linear-gradient(125deg,
            var(--mode-accent, var(--color-teal)) 0%,
            var(--mode-accent, var(--color-teal)) 44%,
            #15171c 44%,
            #15171c 100%);
    border: 4px solid #000;
    border-radius: 6px;
    transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    min-height: 12rem;
    padding: 0;
    box-shadow: 5px 5px 0 rgba(0,0,0,0.55);
}
/* Halftone-ish scanline texture over the panel */
.game-mode-btn::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: repeating-linear-gradient(45deg, transparent, transparent 5px, rgba(255,255,255,0.04) 5px, rgba(255,255,255,0.04) 10px);
    opacity: 0.5;
    pointer-events: none;
    z-index: 1;
}
.game-mode-btn:hover {
    transform: translate(-2px, -2px);
    box-shadow: 8px 8px 0 rgba(0,0,0,0.65);
}
.game-mode-btn .mode-icon {
    position: absolute;
    top: 1.8rem; left: 0.7rem;
    height: 8rem; width: 8rem;            /* doubled from the old h-16 */
    filter: drop-shadow(2px 2px 0 rgba(0,0,0,0.5));
    z-index: 2;
}
.game-mode-btn .mode-name {
    position: absolute;
    right: 0.8rem; bottom: 0.5rem;
    font-family: 'Bangers', Impact, sans-serif;
    font-size: 2.6rem; line-height: 1; letter-spacing: 1px;
    color: #fff;
    text-shadow: 3px 3px 0 #000, -1.5px -1.5px 0 #000, 1.5px -1.5px 0 #000, -1.5px 1.5px 0 #000;
    z-index: 2;
}
/* Corner ribbon badges */
.mode-badge {
    position: absolute;
    top: 0; left: 0;
    background: #000; color: #fff;
    font-family: 'Bangers', Impact, sans-serif;
    letter-spacing: 1px;
    font-size: 0.95rem;
    padding: 3px 12px;
    border-bottom-right-radius: 8px;
    z-index: 3;
}
.mode-badge.badge-soon { background: #b91c1c; }
/* Registered users own an account: hide the "ACCOUNT REQUIRED" badges (keep COMING SOON). */
body.is-registered .mode-badge:not(.badge-soon) { display: none; }
/* "Coming Soon" mode: dimmed + non-interactive (also gated in JS) */
.game-mode-btn.coming-soon { filter: grayscale(0.75) brightness(0.6); cursor: not-allowed; }
.game-mode-btn.coming-soon:hover { transform: none; box-shadow: 5px 5px 0 rgba(0,0,0,0.55); }

/* Comic-book display font for titles/back-buttons */
.comic-title { font-family: 'Bangers', Impact, sans-serif; letter-spacing: 1px; }

/* --- Auth / login redesign --- */
/* Segmented LOG IN / SIGN UP tabs inside the auth modal */
.auth-tab {
    background: #11211f;
    color: rgba(245, 233, 208, 0.55);
    border: none;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.auth-tab:not(.active):hover { color: #f4f1de; background: #16302c; }
.auth-tab.active { background: #e76f51; color: #1a1a1a; }
#auth-tab-login { border-right: 2px solid #2a9d8f; }

/* Big comic CTA buttons on the full-screen login gate */
.auth-cta {
    font-family: 'Bangers', Impact, sans-serif;
    letter-spacing: 1px;
    font-size: 1.5rem;
    padding: 1.1rem 0.5rem;
    border: 3px solid #1a1a1a;
    box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.55);
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
}
.auth-cta:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 rgba(0, 0, 0, 0.6); }
.auth-cta:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5); }
.auth-cta--login { background: #2a9d8f; color: #f4f1de; }
.auth-cta--signup { background: #e76f51; color: #1a1a1a; }

/* Dark-matter "SUMMER SALE" button: same comic-panel language as the mode cards, in a
   purple/black scheme. Diagonal split + scanline + a slow purple glow to catch the eye. */
.sale-panel {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border: 4px solid #000;
    border-radius: 6px;
    background: linear-gradient(125deg, #7c3aed 0%, #7c3aed 44%, #120c1c 44%, #120c1c 100%);
    transition: transform 0.12s ease;
    animation: salePulse 2.2s ease-in-out infinite;
}
.sale-panel:hover { transform: translate(-2px, -2px); }
@keyframes salePulse {
    0%, 100% { box-shadow: 5px 5px 0 rgba(0,0,0,0.55), 0 0 0 rgba(168,85,247,0.0); }
    50%      { box-shadow: 5px 5px 0 rgba(0,0,0,0.55), 0 0 24px rgba(168,85,247,0.6); }
}
.sale-panel::before {
    content: '';
    position: absolute; inset: 0;
    background: repeating-linear-gradient(45deg, transparent, transparent 5px, rgba(255,255,255,0.05) 5px, rgba(255,255,255,0.05) 10px);
    opacity: 0.5; pointer-events: none; z-index: 1;
}
.sale-panel .sale-icon {
    position: absolute; top: 50%; left: 1rem; transform: translateY(-50%);
    height: 5rem; width: 5rem;
    filter: drop-shadow(2px 2px 0 rgba(0,0,0,0.55));
    z-index: 2;
}
.sale-panel .sale-name {
    position: absolute; right: 1rem; bottom: 0.4rem;
    font-family: 'Bangers', Impact, sans-serif; font-size: 2rem; line-height: 1; letter-spacing: 1px;
    color: #fff;
    text-shadow: 3px 3px 0 #000, -1.5px -1.5px 0 #000, 1.5px -1.5px 0 #000, -1.5px 1.5px 0 #000;
    z-index: 2;
}
.sale-badge {
    position: absolute; top: 0; left: 0;
    background: #000; color: #ffd23f;
    font-family: 'Bangers', Impact, sans-serif; letter-spacing: 1px;
    font-size: 1rem; padding: 3px 12px;
    border-bottom-right-radius: 8px; z-index: 3;
}

/* --- Main Menu Buttons --- */
.main-menu-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    text-align: center;
    transition: background-color 0.3s;
    cursor: pointer;
}
.main-menu-btn-title {
    font-size: 2.5rem;
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
}

/* --- News Items --- */
.news-item {
    background-color: rgba(0,0,0,0.2);
    border-left: 4px solid var(--color-yellow);
    padding: 12px;
    margin-bottom: 8px;
    font-family: 'Inter', sans-serif;
}
.news-title {
    color: var(--color-yellow);
    font-family: 'Orbitron', sans-serif;
    font-weight: bold;
    margin-bottom: 4px;
}
.news-date {
    color: var(--color-teal);
    font-size: 0.75rem;
    text-transform: uppercase;
    margin-bottom: 4px;
}
.news-content {
    font-size: 0.9rem;
    color: #ddd;
    line-height: 1.4;
}
/* Clickable preview cards (open the full post in #news-modal) */
.news-item--clickable {
    display: block;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.1s, background-color 0.1s;
}
.news-item--clickable:hover {
    background-color: rgba(0,0,0,0.35);
    border-left-color: var(--color-orange);
    transform: translateX(2px);
}
/* Truncate the preview body to 2 lines */
.news-preview {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.news-read-more {
    display: inline-block;
    margin-top: 6px;
    color: var(--color-orange);
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
}

/* --- Form Elements / Sliders --- */
.custom-slider {
    -webkit-appearance: none;
    height: 12px;
    background: var(--color-charcoal);
    border: 1px solid var(--color-teal);
    outline: none;
    border-radius: 6px;
}
.custom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    background: var(--color-orange);
    border: 2px solid var(--color-cream);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
}

/* --- Custom Scrollbars --- */
.custom-scrollbar::-webkit-scrollbar { width: 10px; }
.custom-scrollbar::-webkit-scrollbar-track { background: var(--color-charcoal); }
.custom-scrollbar::-webkit-scrollbar-thumb { 
    background: var(--color-teal); 
    border: 2px solid var(--color-charcoal); 
    border-radius: 5px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover { background: var(--color-orange); }

/* --- Effects & Animations --- */
.shadow-retro { box-shadow: var(--shadow-retro); border-radius: 14px; }
.drop-shadow-retro { text-shadow: 4px 4px 0px rgba(0,0,0,0.8); }

/* Panel Transitions */
.panel-entering { animation: panel-fade-in 0.4s ease-out forwards; }
.panel-exiting { animation: panel-fade-out 0.3s ease-in forwards; }

@keyframes panel-fade-in {
    from { opacity: 0; transform: translateY(20px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(0.9); }
}
@keyframes panel-fade-out {
    from { opacity: 1; transform: translateY(0) scale(0.9); }
    to { opacity: 0; transform: translateY(20px) scale(0.9); }
}

/* Login / Join (auth) modal at 90% size, matching the main panels. */
#auth-modal > div {
    transform: scale(0.9);
    transform-origin: center center;
}

/* Chevron for Collapsibles */
.chevron {
    border-style: solid;
    border-width: 0 3px 3px 0;
    display: inline-block;
    padding: 4px;
    transition: transform 0.3s;
    margin-left: auto;
}
.chevron.down { transform: translateY(-2px) rotate(45deg); }
.chevron.right { transform: translateY(0px) rotate(-45deg); }

.collapsible-content {
    transition: max-height 0.4s ease-in-out, opacity 0.3s ease-in-out;
    max-height: 1000px;
    opacity: 1;
}
.collapsible-content.collapsed {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
}

/* Loading Mask Helper */
#loading-mask {
    /* Height manipulated by JS, transition handled here */
    transition: height 0.05s linear; 
}

/* Event Log Styling */
.log-entry {
    font-weight: bold;
    text-shadow: 1px 1px 0 #000;
    margin-bottom: 2px;
    animation: slideUpFade 0.3s ease-out forwards;
}
.log-user { color: var(--color-teal-bright); }
.log-other { color: var(--color-yellow); }
.log-entry.fade-out { opacity: 0; transition: opacity 1s; }

@keyframes slideUpFade {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Device Visibility */
body.is-desktop .is-desktop-hidden { display: none !important; }
body.is-mobile .is-mobile-hidden { display: none !important; }

/* --- Mobile Virtual Controls --- */
#joystick-base {
    position: fixed;
    width: 160px;
    height: 160px;
    border: 2px solid rgba(253, 246, 227, 0.35);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(42,157,143,0.10), rgba(0,0,0,0.25));
    pointer-events: none;
    z-index: 20;
    box-shadow: 0 0 12px rgba(0,0,0,0.4);
}
#joystick-stick {
    position: fixed;
    width: 80px;
    height: 80px;
    border: 2px solid rgba(253, 246, 227, 0.7);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(244,162,97,0.65), rgba(42,157,143,0.45));
    pointer-events: none;
    z-index: 21;
    box-shadow: 0 0 8px rgba(0,0,0,0.5);
}

/* Mobile-only: show a faint resting joystick so the player can find it. */
body.is-mobile #joystick-base.joystick-resting {
    display: block !important;
    left: calc(env(safe-area-inset-left, 0px) + 80px - 80px);
    bottom: calc(env(safe-area-inset-bottom, 0px) + 140px - 80px);
    top: auto;
    opacity: 0.35;
}
body.is-mobile #joystick-stick.joystick-resting {
    display: block !important;
    left: calc(env(safe-area-inset-left, 0px) + 80px - 40px);
    bottom: calc(env(safe-area-inset-bottom, 0px) + 140px - 40px);
    top: auto;
    opacity: 0.45;
}

/* Safe-area padding for the ability bar on iPhones with home indicators. */
body.is-mobile #bottom-ui {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 32px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}
body.is-mobile #mobile-hud-top {
    top: calc(env(safe-area-inset-top, 0px) + 20px);
    left: calc(env(safe-area-inset-left, 0px) + 20px);
    right: calc(env(safe-area-inset-right, 0px) + 20px);
}
.hidden { display: none !important; }
/* ===== Comic toolkit (shared by the restyled lobby panels) ===== */
/* Each panel sets --panel-accent to drive its identity colour. */
#profile-panel      { --panel-accent: var(--color-orange); }
#rankings-panel     { --panel-accent: #f4c542; }   /* gold */
#friends-panel      { --panel-accent: var(--color-teal); }
#customization-panel{ --panel-accent: #e76f51; }   /* hangar red-orange */
#settings-panel     { --panel-accent: #5b8fb0; }   /* steel blue */

.comic-card {
  background: var(--color-charcoal);
  border: 3px solid #000;
  border-radius: 12px;
  box-shadow: var(--shadow-retro);
  position: relative;
  transition: transform .12s ease, box-shadow .12s ease;
}
.comic-card:hover { transform: translate(-2px,-2px) rotate(-.4deg); box-shadow: var(--shadow-retro-hover); }

.comic-chip {
  display: inline-flex; align-items: center; gap: .4rem;
  background: rgba(0,0,0,.35);
  border: 2px solid var(--panel-accent, var(--color-teal));
  border-radius: 999px;
  padding: .25rem .7rem;
  font-family: 'Orbitron', sans-serif; font-weight: 700;
}

.comic-section {
  font-family: 'Bangers', Impact, sans-serif; letter-spacing: 1px;
  display: inline-block; padding: .15rem .8rem; margin-bottom: .75rem;
  background: var(--panel-accent, var(--color-teal)); color: #1a1a1a;
  border: 2px solid #000; box-shadow: 3px 3px 0 rgba(0,0,0,.5);
  transform: rotate(-1deg);
}

/* ===== Comic medal ===== */
.comic-medal {
  display: flex; flex-direction: column; align-items: center; gap: .25rem;
  padding: .5rem; min-width: 84px;
  background: var(--color-dark); border: 3px solid var(--medal-ring,#aaa);
  border-radius: 10px; box-shadow: var(--shadow-retro); text-align: center;
}
.comic-medal-disc {
  font-size: 1.6rem; line-height: 1; color: var(--medal-ring,#aaa);
  text-shadow: 0 0 8px var(--medal-ring,#aaa);
}
.comic-medal-name { font-size: .65rem; font-weight: 700; color: var(--color-cream); }
.comic-medal-count { font-family: 'Bangers'; color: var(--color-orange); }
.comic-medal[data-tier="bronze"]    { --medal-ring: #cd7f32; }
.comic-medal[data-tier="silver"]    { --medal-ring: #c0c7d0; }
.comic-medal[data-tier="gold"]      { --medal-ring: #f4c542; }
.comic-medal[data-tier="legendary"] { --medal-ring: #b06bff; }
.comic-medal[data-tier="legendary"] .comic-medal-disc { animation: medal-shine 1.6s ease-in-out infinite; }
@keyframes medal-shine { 0%,100% { transform: scale(1); } 50% { transform: scale(1.18); } }

/* ===== End-game reveal ===== */
@keyframes medal-pop {
  0%   { transform: scale(0) rotate(-12deg); opacity: 0; }
  70%  { transform: scale(1.18) rotate(3deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.comic-medal.medal-pop-in { animation: medal-pop .32s cubic-bezier(.34,1.56,.64,1) both; }

/* Mission Report panel: keep it inside the viewport so the footer buttons never clip. */
#end-game-screen .mission-report-panel { max-height: 90vh; overflow-y: auto; }
#level-up-notification.show-promotion { animation: medal-shine 1.6s ease-in-out infinite; }

/* ===== Email-verify banner nudge ===== */
@keyframes verify-flash { 0%,100% { filter: brightness(1); } 50% { filter: brightness(1.5); } }
#verify-email-banner.verify-flash { animation: verify-flash .4s ease-in-out 2; }

/* ===== Leaderboards podium (top 3) ===== */
.rankings-table tbody tr.rank-1 td { background: rgba(244,197,66,.18); border-left: 4px solid #f4c542; }
.rankings-table tbody tr.rank-2 td { background: rgba(192,199,208,.15); border-left: 4px solid #c0c7d0; }
.rankings-table tbody tr.rank-3 td { background: rgba(205,127,50,.15);  border-left: 4px solid #cd7f32; }

/* Equipped highlight for comic-card tiles (cosmetics/skins) */
.comic-card.equipped { outline: 3px solid var(--panel-accent); outline-offset: 1px; }

/* ===== Skin slots: square cells with the icon filling the space ===== */
.skin-slot { aspect-ratio: 1 / 1; height: auto !important; overflow: hidden; }
.skin-slot img { width: 100%; height: 100%; object-fit: cover; padding: 0 !important; }
.skin-slot > span { font-size: clamp(1.75rem, 5vw, 3rem); line-height: 1; }

/* Equipped skin: thick green rounded box highlight (no border on the others). */
.skin-slot { border-radius: 0; }
.skin-slot.equipped { box-shadow: inset 0 0 0 4px #34d399; border-radius: 12px; z-index: 1; }

/* --- Comic store cards (procedural-skins/pricing/store-redesign) --- */
.store-card { position: relative; background: var(--color-charcoal, #14181c); border: 3px solid #000;
  border-radius: 10px; box-shadow: 4px 4px 0 rgba(0,0,0,.5); padding: 12px; display: flex; flex-direction: column;
  align-items: center; gap: 8px; transition: transform .12s ease, box-shadow .12s ease; overflow: hidden; }
.store-card:hover { transform: translateY(-3px); box-shadow: 6px 8px 0 rgba(0,0,0,.55); }
.store-card__preview { width: 100%; height: 90px; display: flex; align-items: center; justify-content: center; }
.store-card__preview canvas, .store-card__preview img { width: 80px; height: 80px; border: 2px solid #000; border-radius: 6px; }
.store-card__name { font-weight: 800; color: var(--color-cream, #f4ecd8); font-size: .9rem; text-align: center; }
.rarity-ribbon { position: absolute; top: 8px; left: -28px; transform: rotate(-45deg); width: 100px; text-align: center;
  font: 700 9px 'Orbitron', sans-serif; color: #000; padding: 2px 0; }
.store-card--grey   { border-color:#000; } .store-card--grey   .rarity-ribbon { background:#9aa3ab; }
.store-card--teal   { box-shadow: 0 0 14px rgba(45,212,191,.25), 4px 4px 0 rgba(0,0,0,.5); } .store-card--teal   .rarity-ribbon { background:#2dd4bf; }
.store-card--purple { box-shadow: 0 0 16px rgba(157,77,255,.3), 4px 4px 0 rgba(0,0,0,.5); border-color:#3a1a5a; } .store-card--purple .rarity-ribbon { background:#9d4dff; color:#fff; }
.store-card--gold   { box-shadow: 0 0 18px rgba(255,209,102,.4), 4px 4px 0 rgba(0,0,0,.5); border-color:#5a4500; } .store-card--gold   .rarity-ribbon { background:#ffd166; }
.price-row { display: flex; gap: 6px; width: 100%; }
.price-btn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 4px; font: 800 .8rem 'Orbitron', sans-serif;
  padding: 7px 6px; border: 2px solid #000; border-radius: 6px; cursor: pointer; color: #1a1a1a; }
.price-sd { background: #ffd166; } .price-dm { background: #e76f51; color:#fff; }
.price-btn:disabled { opacity: .45; cursor: not-allowed; }
.owned-stamp { font: 800 .85rem 'Orbitron', sans-serif; color: #2dd4bf; border: 2px dashed #2dd4bf; border-radius: 6px; padding: 6px 14px; }

/* --- Locked cosmetic previews (direct-buy skins/banners) --- */
.locked-preview { filter: grayscale(1) brightness(.5); }
.skin-slot { position: relative; }
.lock-badge { position: absolute; top: 2px; right: 4px; font-size: .8rem; line-height: 1; text-shadow: 0 1px 2px #000; pointer-events: none; z-index: 3; }
.store-rarity-grey { color: #9aa3ab; } .store-rarity-teal { color: #2dd4bf; }
.store-rarity-purple { color: #9d4dff; } .store-rarity-gold { color: #ffd166; }

/* Skin slot caption + lock badge. Scoped to `.skin-slot .X` so they BEAT the emoji-icon rule
   `.skin-slot > span { font-size: clamp(1.75rem,5vw,3rem) }` on specificity (both targets are spans). */
.skin-slot .skin-name-label { position: absolute; bottom: 0; left: 0; right: 0; z-index: 3;
  padding: 1px 3px; font: 700 9px 'Orbitron', sans-serif; line-height: 1.3; color: #fdf6e3;
  background: rgba(0,0,0,.65); text-align: center; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; pointer-events: none; }
.skin-slot .lock-badge { font-size: .85rem; }

/* --- Mode lobby pop-art (Drills/Skirmish/Ranked/Custom) --- */
.mode-lobby { --accent: var(--color-teal); position: relative;
  /* Break out of the right Game-Modes section's p-6 (1.5rem) so the scene background fills the
     whole section: reaches the vertical divider on the left + the panel edges top/bottom/right.
     Re-add the padding inside so the content keeps its original position. */
  margin: -1.5rem; padding: 1.5rem; box-sizing: border-box; }
.mode-drills   { --accent: #2a9d8f; }
.mode-skirmish { --accent: #e9c46a; }
.mode-ranked   { --accent: #f4a261; }
.mode-custom   { --accent: #e76f51; }
.mode-lobby .lobby-banner { border-color: var(--accent) !important; }
.mode-lobby .lobby-banner p { color: var(--accent) !important; text-shadow: 2px 2px 0 #000; }

/* DRILLS: blueprint/console — faint grid backdrop + control panel */
.mode-drills { background-image:
  linear-gradient(rgba(42,157,143,.06) 1px, transparent 1px),
  linear-gradient(90deg, rgba(42,157,143,.06) 1px, transparent 1px);
  background-size: 26px 26px; }
.drills-params-header { border-bottom: none; box-shadow: 0 -3px 0 #000 inset; }
.drills-params-panel { border-radius: 0 0 8px 8px; box-shadow: 4px 4px 0 rgba(0,0,0,.4); }

/* SKIRMISH: energetic comic pill behind the countdown. Fully filled (no transparent
   cutoff) so dark text stays legible at ANY width — the old radial cut to transparent at
   61%, which left long text like "CONNECTING…" sitting on the dark panel (unreadable). */
/* color needs !important: the element also carries the `.text-yellow` utility, which is
   itself `!important`, so without this the text renders yellow-on-yellow (unreadable). */
.mode-skirmish #skirmish-countdown { position: relative; display: inline-block; padding: 8px 22px; color: #1a1a1a !important;
  background: radial-gradient(circle at 50% 38%, #ffe08a 0%, var(--color-yellow) 80%);
  border-radius: 999px; border: 2px solid #1a1a1a;
  filter: drop-shadow(3px 3px 0 #000); }
.mode-skirmish .border-cream\/30 { border-color: var(--color-yellow) !important; box-shadow: 4px 4px 0 rgba(0,0,0,.4); }

/* RANKED: aggressive angular frame + glowing queue button */
.mode-ranked #ranked-actions { border: 3px solid var(--color-orange); clip-path: polygon(0 0, 100% 0, 100% 88%, 96% 100%, 0 100%);
  background: linear-gradient(160deg, rgba(244,162,97,.08), transparent 60%); box-shadow: inset 0 0 30px rgba(244,162,97,.15); }
.mode-ranked #ranked-points { font-family: 'Orbitron', sans-serif; letter-spacing: .1em; text-shadow: 0 0 10px rgba(244,162,97,.6); }
.mode-ranked .find-match-btn { box-shadow: 0 0 16px rgba(244,162,97,.5), 4px 4px 0 #000; }

/* CUSTOM: radio/console board */
.mode-custom #lobby-browser-list > * { border-left: 4px solid var(--color-red); box-shadow: 3px 3px 0 rgba(0,0,0,.35); }
.mode-custom #create-lobby-btn, .mode-custom #join-code-btn { box-shadow: 0 0 12px rgba(231,111,81,.4), 4px 4px 0 #000; }

/* Skin icons (lobby player avatars) */
.skin-icon { object-fit: cover; border-radius: 4px; display: inline-block; }

/* --- Lobby scene backgrounds + panel surfaces --- */
/* Scenes sit on the subpanel wrapper; .lobby-card surfaces layer on top. */
.mode-lobby > * { position: relative; z-index: 1; }

/* DRILLS: holo-deck — grid + radar rings + teal vignette */
.mode-drills {
  background-color: #0b1a1f;
  background-image:
    radial-gradient(circle at 50% 42%, rgba(42,157,143,.18), transparent 60%),
    repeating-radial-gradient(circle at 50% 42%, transparent 0 38px, rgba(42,157,143,.08) 38px 39px),
    linear-gradient(rgba(42,157,143,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(42,157,143,.06) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 26px 26px, 26px 26px;
}

/* SKIRMISH: comic arena — halftone dots + warm glow + speed streaks */
.mode-skirmish {
  background-color: #1a1606;
  background-image:
    radial-gradient(circle at 50% 30%, rgba(233,196,106,.16), transparent 60%),
    repeating-linear-gradient(115deg, rgba(233,196,106,.05) 0 2px, transparent 2px 26px),
    radial-gradient(rgba(233,196,106,.12) 1.5px, transparent 1.6px);
  background-size: 100% 100%, 100% 100%, 16px 16px;
}

/* RANKED: stadium — vignette + spotlights + starfield */
.mode-ranked {
  background-color: #150d06;
  background-image:
    linear-gradient(160deg, rgba(244,162,97,.14), transparent 45%),
    linear-gradient(-160deg, rgba(244,162,97,.10), transparent 45%),
    radial-gradient(rgba(253,246,227,.5) 1px, transparent 1.3px),
    radial-gradient(120% 90% at 50% 50%, transparent 55%, rgba(0,0,0,.6));
  background-size: 100% 100%, 100% 100%, 60px 60px, 100% 100%;
}

/* CUSTOM: control room — scanlines + red signal-glow corners */
.mode-custom {
  background-color: #1a0a07;
  background-image:
    radial-gradient(circle at 0 0, rgba(231,111,81,.18), transparent 25%),
    radial-gradient(circle at 100% 100%, rgba(231,111,81,.18), transparent 25%),
    repeating-linear-gradient(0deg, rgba(0,0,0,.22) 0 2px, transparent 2px 4px);
  background-size: 100% 100%, 100% 100%, 100% 4px;
}

/* Shared panel surface — semi-transparent dark, comic border kept, mode-tinted glow + micro-texture */
.lobby-card {
  position: relative; z-index: 1;
  background-color: rgba(8,10,12,.72);
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.5), 4px 4px 0 rgba(0,0,0,.4), 0 0 14px var(--card-glow, rgba(45,212,191,.12));
  backdrop-filter: blur(1px);
}
.mode-drills   .lobby-card { --card-glow: rgba(42,157,143,.18);
  background-image: linear-gradient(rgba(42,157,143,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(42,157,143,.05) 1px, transparent 1px); background-size: 18px 18px; }
.mode-skirmish .lobby-card { --card-glow: rgba(233,196,106,.22);
  background-image: radial-gradient(rgba(233,196,106,.08) 1px, transparent 1.2px); background-size: 12px 12px; }
.mode-ranked   .lobby-card { --card-glow: rgba(244,162,97,.22);
  background-image: linear-gradient(160deg, rgba(244,162,97,.06), transparent 60%); }
.mode-custom   .lobby-card { --card-glow: rgba(231,111,81,.22);
  background-image: repeating-linear-gradient(0deg, rgba(0,0,0,.18) 0 2px, transparent 2px 4px); }

/* Variants */
.lobby-card--countdown { padding: 8px 12px; }
.lobby-card--roster, .lobby-card--chat { border-color: var(--accent) !important; }
.lobby-card--browser { padding: 8px; }
.lobby-card--footer { padding: 12px; }

/* ---- Universal music player — slim transport bar (bottom-left, draggable) ----
   A compact dark "control deck": one row (disc · title · transport · shuffle/repeat
   · collapse) over a thin read-only progress fill. Distinct from the comic panels. */
.music-player {
    position: fixed;
    left: 16px;
    bottom: 16px;
    z-index: 55;
    width: 300px;
    max-width: calc(100vw - 32px);
    display: flex;
    flex-direction: column;
    background: rgba(26, 46, 56, 0.85);          /* --color-dark @ ~85% */
    border: 1px solid var(--color-teal);
    border-left: 3px solid var(--color-teal-bright);
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
    color: var(--color-cream);
    pointer-events: auto;
    overflow: hidden;
    cursor: grab; /* draggable from anywhere; buttons/vinyl override below */
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.music-player.dragging { cursor: grabbing; }
.music-player.hidden { display: none; }

.mp-main { display: flex; align-items: center; gap: 8px; padding: 7px 10px; }

/* Small spinning disc */
.mp-vinyl {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid #000;
    box-shadow: 0 0 0 1px rgba(78, 205, 196, 0.4);
    cursor: grab;
    background:
        radial-gradient(circle, var(--color-orange) 0 4px, #00000000 4px),
        repeating-radial-gradient(circle, #07070d 0 1.5px, #20202c 1.5px 3px);
}
@keyframes mp-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.music-player.playing .mp-vinyl { animation: mp-spin 4s linear infinite; }

.music-track-title {
    flex: 1 1 auto;
    min-width: 0;
    color: var(--color-cream);
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mp-transport { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.mp-secondary { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; opacity: 0.7; }

.music-btn {
    background: transparent;
    border: none;
    color: var(--color-cream);
    font-size: 16px;
    line-height: 1;
    padding: 4px 5px;
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 0.15s, transform 0.1s, color 0.15s;
}
.music-btn:hover { opacity: 1; transform: scale(1.15); }
.music-btn:active { transform: scale(0.92); }
.music-btn.active { opacity: 1; color: var(--color-teal-bright); }
.mp-btn-primary { font-size: 20px; color: var(--color-teal-bright); }
.mp-btn-mini { font-size: 13px; }

.mp-collapse {
    flex: 0 0 auto;
    background: transparent;
    border: none;
    color: var(--color-cream);
    opacity: 0.5;
    font-size: 14px;
    line-height: 1;
    padding: 2px 4px;
    cursor: pointer;
    margin-left: 2px;
}
.mp-collapse:hover { opacity: 1; color: var(--color-red); }

/* Read-only progress fill */
.mp-progress { height: 3px; width: 100%; background: rgba(0, 0, 0, 0.4); }
.mp-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--color-teal-bright), var(--color-orange));
    box-shadow: 0 0 6px rgba(78, 205, 196, 0.6);
    transition: width 0.2s linear;
}

/* Collapsed: only the spinning disc shows; click it to reopen. */
.music-player.collapsed { width: auto; max-width: none; }
.music-player.collapsed .music-track-title,
.music-player.collapsed .mp-transport,
.music-player.collapsed .mp-secondary,
.music-player.collapsed .mp-collapse,
.music-player.collapsed .mp-progress { display: none; }
.music-player.collapsed .mp-main { padding: 6px; }
.music-player.collapsed .mp-vinyl { cursor: pointer; }

/* ---- Badge-earned toast ---------------------------------------------- */
#medal-toast {
    position: fixed;
    top: 72px;
    left: 50%;
    z-index: 80;
    pointer-events: none;
    transform: translateX(-50%) translateY(-180%); /* parked off-screen above */
    transition: transform 0.38s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#medal-toast.medal-toast-in { transform: translateX(-50%) translateY(0); }
.medal-toast-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px 10px 12px;
    background: var(--color-charcoal);
    border: 3px solid #000;
    border-radius: 12px;
    box-shadow: var(--shadow-retro);
}
.medal-toast-label {
    font-family: 'Bangers', Impact, sans-serif;
    letter-spacing: 1px;
    font-size: 1.1rem;
    color: var(--color-yellow);
    text-shadow: 2px 2px 0 #000;
    white-space: nowrap;
}
/* The toast embeds a comic-medal; keep it from animating its hover/idle transforms. */
#medal-toast .comic-medal { min-width: 72px; }

/* ---- Controller support ---------------------------------------------- */
/* No custom selection box: left-nav items and tabs open on focus, and other items rely
   on the browser's native focus outline (controller.js calls el.focus()). */

/* Button-glyph pills (Xbox/standard). Face buttons round + coloured; shoulders/
   triggers/start are rectangular. Used by the hint bar + the Settings legend. */
.cbtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5em;
    height: 1.5em;
    padding: 0 0.35em;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 0.8em;
    line-height: 1;
    color: #000;
    background: var(--color-cream);
    border: 2px solid #000;
    border-radius: 4px;
}
.cbtn[data-btn="A"] { background: #6cc24a; color: #000; border-radius: 50%; }
.cbtn[data-btn="B"] { background: #e5413f; color: #fff; border-radius: 50%; }
.cbtn[data-btn="X"] { background: #2e6fdb; color: #fff; border-radius: 50%; }
.cbtn[data-btn="Y"] { background: #f0c020; color: #000; border-radius: 50%; }
.cbtn[data-btn="L"], .cbtn[data-btn="R"] { border-radius: 50%; }

/* Contextual hint bar (bottom-centre, above HUD; never intercepts input). */
#controller-hints {
    position: fixed;
    left: 50%;
    bottom: 10px;
    transform: translateX(-50%);
    z-index: 75;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 14px;
    max-width: 96vw;
    padding: 6px 14px;
    background: rgba(0, 0, 0, 0.72);
    border: 1px solid rgba(253, 246, 227, 0.25);
    border-radius: 10px;
    color: var(--color-cream);
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    pointer-events: none;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
#controller-hints .chint { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }

/* =====================================================================
   MOBILE / RESPONSIVE  (added for full mobile support)
   ---------------------------------------------------------------------
   The stylesheet historically had zero @media queries; lobby panels were
   locked to a desktop 650px height at scale(0.9). Everything below adapts
   the lobby + in-game HUD for phones/tablets and touch input. Appended at
   the end so these overrides win the cascade.
   ===================================================================== */

/* ---- Phase 1: Lobby panels fit small screens -------------------------- */
@media (max-width: 640px) {
    /* Drop the fixed 650px height + 0.9 scale so panels flow to viewport
       height with their own internal scroll. dvh where supported, vh fallback. */
    .panel {
        height: auto;
        max-height: calc(100vh - 16px);
        max-height: calc(100dvh - 16px);
        transform: none;
        padding: 12px;
        border-width: 3px;
    }
    /* The panel-fade keyframes bake in scale(0.9); on mobile we re-point the
       entrance/exit animations to non-scaling variants so they don't undo the
       transform:none above (otherwise the panel snaps back to 90% after fade). */
    .panel-entering { animation: panel-fade-in-mobile 0.4s ease-out forwards; }
    .panel-exiting  { animation: panel-fade-out-mobile 0.3s ease-in forwards; }

    .panel-header { margin-bottom: 1rem; padding-bottom: 0.6rem; }

    /* Leaderboard tables: tighten the wide p-3 cells and let long pilot names
       truncate instead of forcing horizontal overflow. */
    .rankings-table th, .rankings-table td { padding: 0.4rem 0.5rem; font-size: 0.8rem; }
    .rankings-table td.player-rank-name, .rankings-table .player-rank-name {
        max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }

    /* Auth modal matched the panels' 0.9 scale; let it fill the small screen. */
    #auth-modal > div { transform: none; }
    .auth-panel { max-height: calc(100dvh - 24px); overflow-y: auto; }

    /* Game-mode cards: smaller so two fit without giant icons overflowing. */
    .game-mode-btn { min-height: 8.5rem; }
    .game-mode-btn .mode-icon { height: 5rem; width: 5rem; top: 1rem; left: 0.5rem; }
    .game-mode-btn .mode-name { font-size: 1.9rem; }

    /* Play panel: scrollable column. The left column is flattened (display:contents)
       so its two children join the panel's flex flow; flex order then yields the
       requested mobile sequence: DARK MATTER banner -> 4 modes -> TRANSMISSIONS. */
    #play-panel { overflow-y: auto; padding: 12px !important; }
    #play-panel .play-left { display: contents; }
    #play-panel #sale-banner { order: 1; margin: 0 0 0.75rem; }
    #play-panel .play-right { order: 2; padding: 0 !important; }
    #play-panel .play-transmissions { order: 3; flex: 0 0 auto; }
    /* Replace the desktop full-height centring with natural, top-aligned heights. */
    #play-panel #game-modes-grid { height: auto; justify-content: flex-start; }
    #play-panel #game-modes-grid > h4 { font-size: 2.25rem; margin-bottom: 1rem; padding-bottom: 0.5rem; }
    #play-panel #game-modes-grid .grid { gap: 0.75rem; }
    #play-panel .play-right .lobby-banner p { font-size: 1.5rem; }

    /* --- Generic panel structure on phones --- */
    .panel > h2.panel-header { font-size: 1.75rem; }

    /* Sub-nav tab rows scroll horizontally instead of wrapping/overflowing. */
    .sub-nav-container {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .sub-nav-container::-webkit-scrollbar { display: none; }
    .sub-nav-container .sub-nav-btn { white-space: nowrap; flex: 0 0 auto; }

    /* SOCIAL: the contacts/chat two-column layout stacks vertically. */
    #friends-panel > .flex.gap-4 { flex-direction: column; }
    #friends-panel > .flex.gap-4 > div { width: 100% !important; min-width: 0 !important; }
    #friends-panel > .flex.gap-4 > div:last-child {
        border-left: none;
        padding-left: 0;
        border-top: 1px solid rgba(42,157,143,0.3);
        padding-top: 0.75rem;
        margin-top: 0.75rem;
        min-height: 40vh;
    }

    /* PROFILE: banner card stacks and its absolute EDIT buttons become inline. */
    #profile-banner-card { flex-direction: column; text-align: center; }
    #profile-banner-card > div:not(:first-child) { margin-left: 0; }
    #profile-banner-card #edit-profile-btn,
    #profile-banner-card #edit-banner-btn {
        position: static;
        display: inline-block;
        margin: 0.25rem 0.25rem 0;
    }
}

@keyframes panel-fade-in-mobile {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes panel-fade-out-mobile {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(20px); }
}

/* Mobile-steering segmented toggle (Settings > CONTROLS). Active option gets the
   teal fill via the .bg-teal/.text-charcoal utilities toggled in main.js. */
.steering-mode-opt {
    background: transparent;
    color: var(--color-cream);
    font-family: 'Orbitron', sans-serif;
    letter-spacing: 1px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

/* ---- Phase 2: Touch feedback (hover -> tap) --------------------------- */
/* On touch devices :hover sticks to the last-tapped element, leaving buttons
   stuck in their lifted/enlarged state. Neutralise the hover transforms (but
   not the .active selected state) when the device has no real hover. */
@media (hover: none) {
    .retro-btn-primary:hover,
    .retro-btn-secondary:hover { transform: none; box-shadow: 4px 4px 0 0 #000; }
    .game-mode-btn:hover { transform: none; box-shadow: 5px 5px 0 rgba(0,0,0,0.55); }
    .comic-card:hover { transform: none; box-shadow: var(--shadow-retro); }
    .store-card:hover { transform: none; box-shadow: 4px 4px 0 rgba(0,0,0,.5); }
    .auth-cta:hover { transform: none; box-shadow: 4px 4px 0 rgba(0,0,0,.5); }
    .news-item--clickable:hover { transform: none; }
    .sub-nav-btn:hover, .skin-tab:hover, .store-tab:hover { transform: none; opacity: 1; }
    .music-btn:hover { transform: none; }
    .nav-btn:hover:not(.active) {
        background: none;
        border-left-color: transparent;
        color: var(--color-cream);
        opacity: 0.85;
    }
}

/* Press feedback on tap (also pleasant with a desktop mouse). */
.nav-btn:active { opacity: 1; }
.game-mode-btn:active:not(.coming-soon) { transform: translate(-2px, -2px); box-shadow: 8px 8px 0 rgba(0,0,0,0.65); }
.comic-card:active { transform: translate(-1px, -1px); }
.store-card:active { transform: translateY(-2px); }

/* Coarse pointers: comfortable tap targets + kill the 300ms tap delay / double
   tap zoom on interactive controls. */
@media (pointer: coarse) {
    button, .nav-btn, .sub-nav-btn, .skin-tab, .store-tab,
    .game-mode-btn, .comic-card, .store-card, .auth-cta { touch-action: manipulation; }
    .nav-btn { padding-top: 12px; padding-bottom: 12px; }
    .sub-nav-btn, .skin-tab, .store-tab { min-height: 44px; }
    .retro-btn-primary, .retro-btn-secondary { min-height: 44px; }
    .custom-slider { height: 16px; }
    .custom-slider::-webkit-slider-thumb { width: 30px; height: 30px; }
}

/* ---- Phase 3: In-game touch HUD --------------------------------------- */
/* Secondary action buttons (satellite / weapon cycle) — comic chips on the right. */
.mobile-action-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--color-charcoal);
    border: 2px solid var(--color-teal);
    color: var(--color-cream);
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    box-shadow: 3px 3px 0 rgba(0,0,0,0.55);
    touch-action: manipulation;
    user-select: none;
}
.mobile-action-btn:active { transform: translate(2px, 2px); box-shadow: none; border-color: var(--color-orange); }

/* The dash/phase/pulse ability buttons relied on `group hover:` for feedback,
   which never fires on touch. Give them a clear pressed state on mobile. */
body.is-mobile #abilities-container > div:active {
    border-color: var(--color-orange);
    transform: translateY(1px);
}

/* Short landscape (phones held sideways): shrink HUD so it fits above the thumbs. */
@media (orientation: landscape) and (max-height: 480px) {
    #abilities-container > div { width: 56px !important; height: 56px !important; }
    #abilities-container { gap: 0.75rem; }
    #abilities-container img { width: 28px !important; height: 28px !important; }
    #bottom-ui { bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); }
    #game-timer, #desktop-game-timer { font-size: 1.75rem; }
    .mobile-action-btn { width: 52px; height: 52px; font-size: 0.7rem; }
    #mobile-action-cluster { bottom: 18px; gap: 0.5rem; }
    #phase-prompt { bottom: 22%; }
}

/* ---- Phase 4: Landscape enforcement ----------------------------------- */
#rotate-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;          /* above the HUD and joystick */
    background: var(--color-dark, #0a0c10);
    color: var(--color-cream);
    text-align: center;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.rotate-overlay__icon { font-size: 4rem; animation: rotate-hint 2.2s ease-in-out infinite; }
.rotate-overlay__title { font-family: 'Bangers', Impact, sans-serif; font-size: 2rem; letter-spacing: 1px; margin-top: 0.5rem; color: var(--color-orange); }
.rotate-overlay__sub { font-family: 'Orbitron', sans-serif; opacity: 0.8; margin-top: 0.25rem; }
@keyframes rotate-hint { 0%, 100% { transform: rotate(-12deg); } 50% { transform: rotate(12deg); } }

/* Only block play on phones held in portrait during an active match. Tablets
   (>767px) and the lobby (no .in-game) are never covered. */
@media (orientation: portrait) and (max-width: 767px) {
    body.is-mobile.in-game #rotate-overlay { display: flex; }
}

/* ---- Mobile fixes (round 2) ------------------------------------------- */
/* The cinematic widescreen letterbox bars are a desktop affectation; on a phone
   they just eat scarce vertical space. Hide them. */
body.is-mobile .letterbox-bar { display: none !important; }

/* In-game leaderboard starts minimised on mobile (tap the 🏆 button to open).
   The toggle flips .leaderboard-mobile-closed; this is the style that backs it. */
body.is-mobile #leaderboard.leaderboard-mobile-closed { display: none; }

/* Docked music player: on mobile the floating widget is relocated into
   Settings > AUDIO (see main.js). Neutralise its fixed-widget chrome so it sits
   inline in the settings card. */
.music-player--docked {
    position: static !important;
    width: 100% !important;
    max-width: none !important;
    left: auto !important;
    bottom: auto !important;
    transform: none !important;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    cursor: default;
    z-index: auto;
}
.music-player--docked::before { display: none; }
.music-player--docked .mp-titlebar { display: none; }   /* settings card has its own MUSIC header */
.music-player--docked .mp-vinyl { cursor: default; }
