
        /* ===== Asteroids — vector neon arcade theme ===== */
        body.game-page {
            --t-bg: #050817;
            --t-bg-grad: radial-gradient(ellipse at 50% 0%, #0d1530 0%, #050817 70%);
            --t-text: #e8ecff;
            --t-text-muted: #9aa3d4;
            --t-text-subtle: #6a72a8;
            --t-primary: #00eaff;
            --t-primary-mid: #7b5cff;
            --t-primary-dark: #4338ca;
            --t-glass-bg: rgba(123,92,255,0.08);
            --t-glass-border: rgba(0,234,255,0.35);
            --t-card-bg: rgba(123,92,255,0.06);
            --t-card-border: rgba(0,234,255,0.25);
            --t-btn-grad: linear-gradient(135deg, #00eaff, #7b5cff 55%, #4338ca);
        }

        /* ----- Settings bar (difficulty) ----- */
        .settings-bar {
            display: flex; flex-wrap: wrap; gap: 0.5rem;
            justify-content: center; margin-bottom: 0.6rem; max-width: 460px;
        }
        .setting-group {
            display: flex; align-items: center; gap: 0.3rem;
            background: rgba(123,92,255,0.1);
            border: 1px solid rgba(0,234,255,0.3);
            border-radius: 30px; padding: 0.25rem 0.4rem;
            backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
        }
        .setting-label {
            font-family: 'Orbitron', monospace; font-size: 0.5rem;
            text-transform: uppercase; letter-spacing: 0.08em;
            color: #9aa3d4; padding-left: 0.4rem;
        }
        .setting-btn {
            padding: 0.3rem 0.7rem; border: none; border-radius: 20px;
            font-family: inherit; font-size: 0.7rem; font-weight: 600;
            cursor: pointer; background: transparent; color: #e8ecff;
            transition: all 0.18s;
        }
        .setting-btn.active {
            background: linear-gradient(135deg, #00eaff, #7b5cff 55%, #4338ca);
            color: #fff; box-shadow: 0 2px 12px rgba(0,234,255,0.45);
        }
        .setting-btn:hover:not(.active):not(:disabled) {
            background: rgba(0,234,255,0.18);
        }
        .setting-btn:disabled { opacity: 0.4; cursor: not-allowed; }

        /* ----- Canvas container + overlays ----- */
        .game-container {
            position: relative;
            width: 100%;
            max-width: min(900px, 96vw);
            margin: 0 auto;
            border-radius: 18px; overflow: hidden;
            box-shadow: 0 20px 60px rgba(0,0,0,0.55),
                        0 0 0 1px rgba(0,234,255,0.35) inset,
                        0 0 40px rgba(123,92,255,0.22);
        }
        #canvas3d {
            display: block; border-radius: 18px;
            touch-action: none; cursor: pointer;
            background: radial-gradient(ellipse at 50% 35%, #0a1235 0%, #050817 65%, #03050f 100%);
        }

        /* Top HUD bar: pause + score */
        .game-hud { position: absolute; inset: 0; pointer-events: none; }
        .hud-top {
            position: absolute; top: 10px; left: 10px; right: 10px;
            display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
        }
        .hud-score-box {
            background: rgba(5, 8, 23, 0.7);
            backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
            border: 1px solid rgba(0,234,255,0.3);
            color: #fff; border-radius: 16px; padding: 8px 16px;
            font-family: 'Orbitron', monospace;
            display: flex; align-items: baseline; gap: 6px;
        }
        .hud-score-label {
            font-size: 0.6rem; letter-spacing: 0.18em;
            text-transform: uppercase; color: rgba(232,236,255,0.7);
        }
        .hud-score-value {
            font-size: 1.5rem; font-weight: 800; color: #fff;
            text-shadow: 0 0 12px rgba(0,234,255,0.8);
        }
        .hud-best {
            margin-left: 8px; font-size: 0.7rem;
            color: rgba(167,139,250,0.95); letter-spacing: 0.08em;
        }
        .hud-pause-btn {
            pointer-events: auto;
            width: 44px; height: 44px; border-radius: 12px;
            background: rgba(5, 8, 23, 0.7);
            backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
            border: 1px solid rgba(0,234,255,0.3);
            color: #fff; font-size: 1.1rem; cursor: pointer;
            display: flex; align-items: center; justify-content: center;
            transition: transform 0.15s, background 0.15s;
        }
        .hud-pause-btn:hover { background: rgba(123,92,255,0.35); transform: scale(1.05); }
        .hud-pause-btn[hidden] { display: none; }

        /* Mini stats row (bottom) */
        .hud-stats {
            position: absolute; bottom: 12px; left: 12px; right: 12px;
            display: flex; justify-content: center; gap: 14px;
            font-family: 'Orbitron', monospace;
            background: rgba(5, 8, 23, 0.55);
            border-radius: 12px; padding: 6px 12px;
            border: 1px solid rgba(0,234,255,0.2);
            backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
        }
        .hud-stat-cell { text-align: center; min-width: 50px; }
        .hud-stat-label {
            font-size: 0.5rem; letter-spacing: 0.16em; text-transform: uppercase;
            color: rgba(232,236,255,0.55);
        }
        .hud-stat-value {
            font-size: 0.85rem; font-weight: 700; color: #fff;
            text-shadow: 0 0 8px rgba(0,234,255,0.5);
        }
        .hud-stat-value.hyper-disabled { color: #6a72a8; text-shadow: none; }

        /* Lives row (top center) */
        .hud-lives {
            position: absolute; top: 64px; left: 0; right: 0;
            display: flex; gap: 6px; justify-content: center;
            pointer-events: none;
        }
        .life-icon {
            width: 20px; height: 22px;
            filter: drop-shadow(0 0 5px rgba(0,234,255,0.65));
        }
        .life-icon path { fill: none; stroke: #00eaff; stroke-width: 1.6; stroke-linejoin: round; }

        /* Power-up indicator (right side) */
        .hud-powerup {
            position: absolute; top: 92px; right: 12px;
            display: flex; flex-direction: column; gap: 6px;
            pointer-events: none;
        }
        .powerup-badge {
            display: flex; align-items: center; gap: 6px;
            padding: 6px 10px;
            background: rgba(5, 8, 23, 0.82);
            border: 1px solid rgba(0,234,255,0.5);
            border-radius: 20px;
            font-family: 'Orbitron', monospace; font-size: 0.7rem;
            color: #00eaff; font-weight: 700;
            box-shadow: 0 0 12px rgba(0,234,255,0.35);
            animation: powerupPulse 0.8s ease-in-out infinite;
        }
        .powerup-badge.shield   { border-color: rgba(0,234,255,0.6); color: #67e8f9; box-shadow: 0 0 12px rgba(0,234,255,0.45); }
        .powerup-badge.rapid    { border-color: rgba(252,211,77,0.6); color: #fde68a; box-shadow: 0 0 12px rgba(252,211,77,0.45); }
        .powerup-badge.spread   { border-color: rgba(244,114,182,0.6); color: #fbcfe8; box-shadow: 0 0 12px rgba(244,114,182,0.45); }
        @keyframes powerupPulse {
            0%, 100% { transform: scale(1); }
            50% { transform: scale(1.05); }
        }

        /* Hyperspace + Fire buttons (mobile / desktop) */
        .action-bar {
            position: absolute; left: 12px; right: 12px; bottom: 50px;
            display: flex; justify-content: space-between; pointer-events: none;
        }
        .action-btn {
            pointer-events: auto;
            min-width: 76px;
            padding: 9px 16px;
            border-radius: 99px;
            font-family: 'Orbitron', monospace;
            font-size: 0.68rem; font-weight: 800;
            letter-spacing: 0.12em; text-transform: uppercase;
            background: rgba(5, 8, 23, 0.78);
            border: 1px solid rgba(0,234,255,0.45);
            color: #00eaff;
            box-shadow: 0 0 14px rgba(0,234,255,0.3);
            cursor: pointer;
            transition: transform 0.1s, background 0.15s;
        }
        .action-btn:hover:not(:disabled) {
            background: rgba(123,92,255,0.25);
            transform: scale(1.04);
        }
        .action-btn:active:not(:disabled) {
            transform: scale(0.96);
        }
        .action-btn:disabled {
            opacity: 0.32;
            cursor: not-allowed;
            box-shadow: none;
        }
        .action-btn.fire {
            color: #fde68a;
            border-color: rgba(252,211,77,0.55);
            box-shadow: 0 0 14px rgba(252,211,77,0.3);
        }
        .action-btn.fire:hover:not(:disabled) { background: rgba(252,211,77,0.18); }

        /* Start / pause / gameover overlays */
        .overlay {
            position: fixed; inset: 0; z-index: 10000;
            display: none; align-items: center; justify-content: center;
            background: linear-gradient(180deg, rgba(5,8,23,0.4), rgba(5,8,23,0.8));
            text-align: center; color: #fff;
            font-family: 'Orbitron', monospace; padding: 24px;
            backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
        }
        .overlay.active { display: flex; }
        .overlay-box {
            background: rgba(5, 8, 23, 0.82);
            border: 1px solid rgba(0,234,255,0.3);
            border-radius: 22px;
            padding: 26px 28px 24px;
            min-width: 260px; max-width: 380px;
            box-shadow: 0 20px 60px rgba(0,0,0,0.65),
                        0 0 40px rgba(123,92,255,0.18);
        }
        .overlay-title {
            font-size: 1.4rem; font-weight: 900; letter-spacing: 0.04em;
            margin: 0 0 6px;
            color: #00eaff;
            text-shadow: 0 0 18px rgba(0,234,255,0.7);
        }
        .overlay-sub {
            margin: 0 0 16px; color: rgba(232,236,255,0.82);
            font-family: -apple-system, sans-serif;
            font-size: 0.9rem; line-height: 1.5;
        }
        .overlay-btn-row {
            display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
        }
        .overlay-btn {
            padding: 11px 20px; border-radius: 99px;
            border: 0; cursor: pointer;
            font-family: 'Orbitron', monospace;
            font-size: 0.76rem; font-weight: 800;
            letter-spacing: 0.1em; text-transform: uppercase;
            transition: transform 0.15s, box-shadow 0.15s;
            text-decoration: none;
            display: inline-flex; align-items: center; justify-content: center;
            gap: 6px;
        }
        .overlay-btn-primary {
            background: linear-gradient(135deg, #00eaff, #7b5cff 55%, #4338ca);
            color: #fff;
        }
        .overlay-btn-primary:hover {
            transform: translateY(-1px);
            box-shadow: 0 10px 22px rgba(0,234,255,0.45);
        }
        .overlay-btn-ghost {
            background: rgba(255,255,255,0.06);
            border: 1px solid rgba(0,234,255,0.35); color: #fff;
        }
        .overlay-btn-ghost:hover { background: rgba(255,255,255,0.12); }

        /* Game-over stats grid */
        .stats-grid {
            display: grid; grid-template-columns: repeat(3, 1fr);
            gap: 8px; margin: 12px 0 12px;
        }
        .stats-grid.two-col { grid-template-columns: repeat(2, 1fr); margin-top: -2px; }
        .stat-cell {
            padding: 10px 6px;
            background: rgba(123,92,255,0.08);
            border: 1px solid rgba(0,234,255,0.2);
            border-radius: 10px;
        }
        .stat-cell-label {
            font-size: 0.52rem; letter-spacing: 0.14em;
            color: rgba(232,236,255,0.55); margin-bottom: 4px;
        }
        .stat-cell-value {
            font-size: 1rem; font-weight: 800; color: #00eaff;
            text-shadow: 0 0 10px rgba(0,234,255,0.5);
        }

        /* Countdown */
        .countdown {
            font-size: 5rem; font-weight: 900; color: #fff;
            text-shadow: 0 0 24px rgba(0,234,255,0.75),
                         0 4px 20px rgba(0,0,0,0.5);
            animation: countdownPulse 1s ease-out;
        }
        @keyframes countdownPulse {
            0% { transform: scale(0.6); opacity: 0; }
            40% { transform: scale(1.2); opacity: 1; }
            100% { transform: scale(1); opacity: 0.95; }
        }

        /* Start CTA */
        .start-cta {
            background: linear-gradient(135deg, #00eaff, #7b5cff 55%, #4338ca);
            color: #fff;
            padding: 16px 38px; border-radius: 99px;
            font-family: 'Orbitron', monospace;
            font-weight: 800; font-size: 1.05rem;
            letter-spacing: 0.16em; text-transform: uppercase;
            box-shadow: 0 14px 36px rgba(0,234,255,0.5);
            animation: startPulse 1.6s ease-in-out infinite;
            cursor: pointer; border: none;
        }
        @keyframes startPulse {
            0%, 100% { transform: scale(1); box-shadow: 0 14px 36px rgba(0,234,255,0.5); }
            50% { transform: scale(1.06); box-shadow: 0 18px 44px rgba(0,234,255,0.75); }
        }
        .start-sub {
            display: block; margin-top: 14px;
            font-size: 0.85rem; color: rgba(232,236,255,0.9);
            font-weight: 500; letter-spacing: 0.06em;
            font-family: -apple-system, sans-serif;
            text-shadow: 0 2px 8px rgba(0,0,0,0.5);
        }

        /* Difficulty preview */
        .diff-preview {
            margin: 12px auto 4px; max-width: 320px;
            font-family: -apple-system, sans-serif;
            font-size: 0.78rem; line-height: 1.5;
            color: rgba(232,236,255,0.82);
            background: rgba(123,92,255,0.1);
            border: 1px solid rgba(0,234,255,0.22);
            padding: 10px 14px; border-radius: 12px;
        }

        /* Mobile thumbstick + buttons */
        .mobile-controls {
            display: none;
            grid-template-areas:
                ". up ."
                "left thrust right";
            gap: 8px;
            margin: 0.9rem auto 0;
            width: max-content;
        }
        .mobile-controls button {
            width: 60px; height: 60px;
            border: 1px solid rgba(0,234,255,0.35);
            border-radius: 50%;
            background: rgba(123,92,255,0.14);
            backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
            color: #e8ecff; font-size: 1.5rem; cursor: pointer;
            display: flex; align-items: center; justify-content: center;
            transition: box-shadow 0.18s, background 0.18s, transform 0.1s;
            box-shadow: 0 0 0 1px rgba(0,234,255,0.18), inset 0 1px 0 rgba(255,255,255,0.08);
            user-select: none; -webkit-user-select: none;
        }
        .mobile-controls button:active {
            background: rgba(0,234,255,0.28);
            box-shadow: 0 0 22px rgba(0,234,255,0.55), 0 0 0 1px rgba(0,234,255,0.55);
            transform: scale(0.95);
        }
        .btn-left  { grid-area: left; }
        .btn-right { grid-area: right; }
        .btn-thrust { grid-area: thrust; }
        .btn-up    { grid-area: up; color: #fde68a; }
        @media (max-width: 600px), (pointer: coarse) {
            .mobile-controls { display: grid; }
        }

        /* Help + history panels */
        .help-toggle, .history-toggle {
            display: block; margin: 0.7rem auto 0;
            padding: 0.4rem 1.1rem; background: none;
            border: 1px solid rgba(0,234,255,0.3);
            color: #e8ecff; border-radius: 20px;
            font-family: 'Orbitron', monospace;
            font-size: 0.66rem; cursor: pointer;
            letter-spacing: 0.12em; text-transform: uppercase;
        }
        .help-toggle:hover, .history-toggle:hover {
            background: rgba(0,234,255,0.12); color: #00eaff;
        }
        .help-panel, .history-panel {
            display: none; max-width: 460px;
            margin: 0.8rem auto 0; padding: 1rem 1.2rem;
            background: rgba(123,92,255,0.07);
            border: 1px solid rgba(0,234,255,0.22);
            border-radius: 14px; color: #e8ecff;
            font-family: -apple-system, sans-serif;
            font-size: 0.86rem; line-height: 1.55;
        }
        .help-panel.active, .history-panel.active { display: block; }
        .help-panel h3 {
            margin: 8px 0 6px;
            font-family: 'Orbitron', monospace;
            font-size: 0.85rem; color: #00eaff;
        }
        .help-panel h3:first-child { margin-top: 0; }
        .help-panel ul { margin: 0 0 10px; padding-left: 20px; }
        .help-panel li { margin: 3px 0; }
        .history-title {
            font-family: 'Orbitron', monospace;
            font-size: 0.66rem; text-transform: uppercase;
            letter-spacing: 0.1em; color: #00eaff;
            text-align: center; margin-bottom: 8px;
        }
        .history-item {
            display: flex; justify-content: space-between; align-items: center;
            padding: 6px 12px;
            background: rgba(123,92,255,0.1);
            border-radius: 8px; font-size: 0.78rem; margin-bottom: 4px;
        }
        .history-score {
            font-family: 'Orbitron', monospace;
            font-weight: 700; color: #00eaff;
        }
        .history-meta {
            color: rgba(232,236,255,0.65); font-size: 0.72rem;
        }
        .history-empty {
            text-align: center; color: rgba(232,236,255,0.5);
            font-size: 0.84rem; padding: 12px;
        }

        /* Score pop +N */
        .score-pop {
            position: absolute;
            font-family: 'Orbitron', monospace;
            font-weight: 900; font-size: 1.4rem;
            color: #00eaff;
            text-shadow: 0 0 14px rgba(0,234,255,0.85),
                         0 2px 12px rgba(0,0,0,0.5);
            pointer-events: none;
            animation: scorePop 0.9s ease-out forwards;
            z-index: 5;
        }
        @keyframes scorePop {
            0% { opacity: 0; transform: scale(0.6) translateY(0); }
            20% { opacity: 1; transform: scale(1.4) translateY(-10px); }
            100% { opacity: 0; transform: scale(0.9) translateY(-50px); }
        }

        /* Pause icons */
        .pause-icon::before { content: '⏸'; }
        .play-icon::before { content: '▶'; }

        body.game-page .game-name,
        body.game-page .score-value {
            color: #00eaff !important;
            -webkit-text-fill-color: #00eaff !important;
            background: none !important;
        }

        /* ============================================================
           DESKTOP LAYOUT — board fills the viewport HEIGHT, the side
           RAIL consumes the leftover horizontal space (was: tiny board
           floating in a sea of black with controls stacked below).
           Overlays are CONFINED to the board (position:absolute) so the
           rail stays clickable — previously the full-screen `fixed`
           start & game-over overlays buried the difficulty selectors,
           so you could never start a new game at a different difficulty.
           ============================================================ */
        .game-layout {
            display: flex; gap: 22px; align-items: flex-start;
            justify-content: center; width: 100%;
            max-width: 1400px; margin: 0 auto; padding: 0 18px;
        }
        .game-main {
            position: relative; display: flex; flex-direction: column;
            align-items: center; min-width: 0; max-width: 100%;
        }
        /* Board hugs the canvas (no empty strip beside it). */
        .game-container {
            width: fit-content; max-width: 100%; margin: 0;
        }

        .game-rail {
            width: 340px; flex-shrink: 0;
            display: flex; flex-direction: column; gap: 14px;
        }
        .rail-card {
            background: rgba(123,92,255,0.07);
            border: 1px solid rgba(0,234,255,0.22);
            border-radius: 16px; padding: 14px 16px;
            backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
        }
        .rail-card-title {
            font-family: 'Orbitron', monospace; font-size: 0.6rem;
            text-transform: uppercase; letter-spacing: 0.14em;
            color: #00eaff; margin-bottom: 10px;
        }
        /* Settings + difficulty preview stretch full-width in the rail */
        .game-rail .settings-bar {
            flex-direction: column; align-items: stretch;
            gap: 10px; margin: 0; max-width: none;
        }
        .game-rail .setting-group { justify-content: space-between; }
        .game-rail .diff-preview { margin: 10px 0 0; max-width: none; }
        /* Recent games + help live open in the rail */
        .game-rail .history-toggle, .game-rail .help-toggle {
            display: block; width: 100%; margin: 0; text-align: left;
        }
        .game-rail .history-panel, .game-rail .help-panel {
            max-width: none; margin: 10px 0 0; background: none;
            border: none; padding: 0;
        }

        /* Overlays: confine to the board (was full-screen `fixed`). The
           container is position:relative + overflow:hidden, so the overlay
           clips to the rounded board and scrolls internally if needed. */
        .overlay {
            position: absolute;
            z-index: 20;
            overflow-y: auto;
            border-radius: 18px;
        }
        .overlay .overlay-box { margin: auto; }

        /* In-overlay difficulty re-pick — MOBILE only (desktop uses the
           always-visible rail). Lets the start + end screens launch a new
           run at a different difficulty without hunting for a panel. */
        .overlay-settings { display: none; }

        @media (max-width: 899px) {
            .game-layout { flex-direction: column; align-items: center; gap: 14px; padding: 0 12px; }
            .game-rail { width: 100%; max-width: 480px; }
            .game-rail .settings-bar { flex-direction: row; flex-wrap: wrap; justify-content: center; }
            .game-rail .setting-group { justify-content: center; }
            /* Mobile: no rail beside the board to preserve, so overlays go
               full-screen and own the whole viewport. */
            .overlay { position: fixed; border-radius: 0; }
            .overlay-settings {
                display: flex; flex-wrap: wrap; gap: 8px;
                justify-content: center; margin: 4px 0 14px;
            }
        }
