
        /* ===== Snake — gold serpent on midnight grid (matches poster) ===== */
        body.game-page {
            --t-bg: #0a0806;
            --t-bg-grad: radial-gradient(ellipse at 50% 0%, #3a2200 0%, #0a0806 70%);
            --t-text: #fef3c7;
            --t-text-muted: #d4a017;
            --t-text-subtle: #a17008;
            --t-primary: #d97706;
            --t-primary-mid: #fbbf24;
            --t-primary-dark: #92400e;
            --t-glass-bg: rgba(217,119,6,0.08);
            --t-glass-border: rgba(251,191,36,0.35);
            --t-card-bg: rgba(217,119,6,0.06);
            --t-card-border: rgba(251,191,36,0.25);
            --t-btn-grad: linear-gradient(135deg, #fbbf24, #d97706 55%, #92400e);
        }

        /* ----- Settings bar (difficulty) ----- */
        .settings-bar {
            display: flex; flex-wrap: wrap; gap: 0.5rem;
            justify-content: center; margin: 0 auto 0.6rem; max-width: 720px;
        }
        .setting-group {
            display: flex; align-items: center; gap: 0.3rem;
            background: rgba(217,119,6,0.1);
            border: 1px solid rgba(251,191,36,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: #d4a017; 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: #fef3c7;
            transition: all 0.18s;
        }
        .setting-btn.active {
            background: linear-gradient(135deg, #fbbf24, #d97706 55%, #92400e);
            color: #fff; box-shadow: 0 2px 10px rgba(217,119,6,0.45);
        }
        .setting-btn:hover:not(.active):not(:disabled) {
            background: rgba(217,119,6,0.18);
        }
        .setting-btn:disabled { opacity: 0.4; cursor: not-allowed; }

        /* ----- Canvas container + overlays ----- */
        .game-container {
            position: relative;
            width: 100%;
            max-width: min(760px, 96vw);
            margin: 0 auto;
            border-radius: 18px; overflow: hidden;
            box-shadow: 0 20px 60px rgba(0,0,0,0.45),
                        0 0 0 1px rgba(251,191,36,0.35) inset,
                        0 0 40px rgba(217,119,6,0.18);
        }
        #canvas3d {
            display: block; border-radius: 18px;
            touch-action: none; cursor: pointer;
            background: linear-gradient(180deg, #0a0806 0%, #1a1206 60%, #1a1206 100%);
        }

        /* Top HUD bar: pause + score (overlay on canvas) */
        .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(8, 18, 14, 0.65);
            backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
            border: 1px solid rgba(251,191,36,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(254,243,199,0.7);
        }
        .hud-score-value {
            font-size: 1.5rem; font-weight: 800; color: #fff;
            text-shadow: 0 0 12px rgba(251,191,36,0.7);
        }
        .hud-best {
            margin-left: 8px; font-size: 0.7rem;
            color: rgba(253,230,138,0.95); letter-spacing: 0.08em;
        }
        .hud-pause-btn {
            pointer-events: auto;
            width: 44px; height: 44px; border-radius: 12px;
            background: rgba(8, 18, 14, 0.65);
            backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
            border: 1px solid rgba(251,191,36,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(217,119,6,0.35); transform: scale(1.05); }
        .hud-pause-btn[hidden] { display: none; }

        /* Mini stats row — sits BELOW the canvas so it never overlaps gameplay */
        .hud-stats {
            display: flex; justify-content: center; gap: 22px;
            font-family: 'Orbitron', monospace;
            background: rgba(10, 8, 6, 0.55);
            border-radius: 14px; padding: 8px 18px;
            border: 1px solid rgba(251,191,36,0.22);
            backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
            max-width: 460px; margin: 10px auto 0;
        }
        .hud-stat-cell { text-align: center; min-width: 58px; }
        .hud-stat-label {
            font-size: 0.52rem; letter-spacing: 0.18em; text-transform: uppercase;
            color: rgba(254,243,199,0.6);
        }
        .hud-stat-value {
            font-size: 1rem; font-weight: 800; color: #fff;
            text-shadow: 0 0 8px rgba(251,191,36,0.55);
        }
        @media (max-width: 600px), (pointer: coarse) {
            .hud-stats { gap: 14px; padding: 6px 12px; }
            .hud-stat-cell { min-width: 46px; }
            .hud-stat-value { font-size: 0.85rem; }
        }

        /* Power-up indicator (right side) */
        .hud-powerup {
            position: absolute; top: 70px; 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(8, 18, 14, 0.78);
            border: 1px solid rgba(252,214,99,0.5);
            border-radius: 20px;
            font-family: 'Orbitron', monospace; font-size: 0.7rem;
            color: #fde68a; font-weight: 700;
            box-shadow: 0 0 12px rgba(252,214,99,0.35);
            animation: powerupPulse 0.8s ease-in-out infinite;
        }
        .powerup-badge.lightning {
            border-color: rgba(96,165,250,0.6); color: #93c5fd;
            box-shadow: 0 0 12px rgba(96,165,250,0.4);
        }
        @keyframes powerupPulse {
            0%, 100% { transform: scale(1); }
            50% { transform: scale(1.05); }
        }

        /* 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(8,18,14,0.4), rgba(8,18,14,0.75));
            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(8, 18, 14, 0.78);
            border: 1px solid rgba(251,191,36,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.55);
        }
        .overlay-title {
            font-size: 1.4rem; font-weight: 900; letter-spacing: 0.04em;
            margin: 0 0 6px; color: #fbbf24;
            text-shadow: 0 0 18px rgba(251,191,36,0.6);
        }
        .overlay-sub {
            margin: 0 0 16px; color: rgba(254,243,199,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, #fbbf24, #d97706 55%, #92400e);
            color: #fff;
        }
        .overlay-btn-primary:hover {
            transform: translateY(-1px);
            box-shadow: 0 10px 22px rgba(217,119,6,0.45);
        }
        .overlay-btn-ghost {
            background: rgba(255,255,255,0.06);
            border: 1px solid rgba(251,191,36,0.3); 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 16px;
        }
        .stat-cell {
            padding: 10px 6px;
            background: rgba(217,119,6,0.06);
            border: 1px solid rgba(251,191,36,0.18);
            border-radius: 10px;
        }
        .stat-cell-label {
            font-size: 0.52rem; letter-spacing: 0.14em;
            color: rgba(254,243,199,0.55); margin-bottom: 4px;
        }
        .stat-cell-value {
            font-size: 1rem; font-weight: 800; color: #fbbf24;
        }

        /* Countdown */
        .countdown {
            font-size: 5rem; font-weight: 900; color: #fff;
            text-shadow: 0 0 24px rgba(251,191,36,0.65),
                         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 (idle pulse) */
        .start-cta {
            background: linear-gradient(135deg, #fbbf24, #d97706 55%, #92400e);
            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(217,119,6,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(217,119,6,0.5); }
            50% { transform: scale(1.06); box-shadow: 0 18px 44px rgba(217,119,6,0.75); }
        }
        .start-sub {
            display: block; margin-top: 14px;
            font-size: 0.85rem; color: rgba(254,243,199,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 descriptor inside start screen */
        .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(254,243,199,0.78);
            background: rgba(217,119,6,0.08);
            border: 1px solid rgba(251,191,36,0.22);
            padding: 10px 14px; border-radius: 12px;
        }

        /* Mobile D-pad */
        .mobile-controls {
            display: none;
            grid-template-areas:
                ". up ."
                "left . right"
                ". down .";
            gap: 8px;
            margin: 0.9rem auto 0;
            width: max-content;
        }
        .mobile-controls button {
            width: 60px; height: 60px;
            border: 1px solid rgba(251,191,36,0.3);
            border-radius: 50%;
            background: rgba(217,119,6,0.12);
            backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
            color: #fef3c7; font-size: 1.5rem; cursor: pointer;
            display: flex; align-items: center; justify-content: center;
            transition: box-shadow 0.2s, background 0.2s, transform 0.1s;
            box-shadow: 0 0 0 1px rgba(251,191,36,0.18), inset 0 1px 0 rgba(255,255,255,0.08);
        }
        .mobile-controls button:active {
            background: rgba(217,119,6,0.28);
            box-shadow: 0 0 22px rgba(217,119,6,0.5), 0 0 0 1px rgba(251,191,36,0.5);
            transform: scale(0.95);
        }
        .btn-up { grid-area: up; }
        .btn-down { grid-area: down; }
        .btn-left { grid-area: left; }
        .btn-right { grid-area: right; }
        @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(251,191,36,0.3);
            color: #fef3c7; 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(217,119,6,0.12); color: #fbbf24;
        }
        .help-panel, .history-panel {
            display: none; max-width: 460px;
            margin: 0.8rem auto 0; padding: 1rem 1.2rem;
            background: rgba(217,119,6,0.07);
            border: 1px solid rgba(251,191,36,0.22);
            border-radius: 14px; color: #fef3c7;
            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: #fbbf24;
        }
        .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: #fbbf24;
            text-align: center; margin-bottom: 8px;
        }
        .history-item {
            display: flex; justify-content: space-between; align-items: center;
            padding: 6px 12px;
            background: rgba(217,119,6,0.08);
            border-radius: 8px; font-size: 0.78rem; margin-bottom: 4px;
        }
        .history-score {
            font-family: 'Orbitron', monospace;
            font-weight: 700; color: #fbbf24;
        }
        .history-meta {
            color: rgba(254,243,199,0.65); font-size: 0.72rem;
        }
        .history-empty {
            text-align: center; color: rgba(254,243,199,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: #fbbf24;
            text-shadow: 0 0 14px rgba(251,191,36,0.8),
                         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: #fbbf24 !important;
            -webkit-text-fill-color: #fbbf24 !important;
            background: none !important;
        }

        /* ============================================================
           DESKTOP BOARD + SIDE RAIL (2026-06-03)
           The 1:1 board grows to fill the viewport height; the rail
           consumes the horizontal space with setup/stats/recent games.
           Overlays are CONFINED to the board (position:absolute) so the
           rail stays clickable — previously the full-screen 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). backdrop-filter is
           dropped so that `position:fixed` overlays (mobile) aren't trapped to
           the container — the blur is invisible behind the opaque canvas. */
        .game-container {
            width: fit-content; max-width: 100%; margin: 0;
            backdrop-filter: none; -webkit-backdrop-filter: none;
        }

        .game-rail {
            width: 340px; flex-shrink: 0;
            display: flex; flex-direction: column; gap: 14px;
        }
        .rail-card {
            background: rgba(217,119,6,0.07);
            border: 1px solid rgba(251,191,36,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: #d4a017; margin-bottom: 10px;
        }
        /* Settings stack 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; }
        /* Stats fill the rail row */
        .game-rail .hud-stats {
            margin: 0; max-width: none; width: 100%;
            background: none; border: none; padding: 0; gap: 8px;
        }
        .game-rail .hud-stat-cell { flex: 1; min-width: 0; }
        /* 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 end screen launch a new run at a
           different difficulty without hunting for the panel below. */
        .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: overlays go full-screen (no rail beside the board to
               preserve), so the end / start screens get 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;
            }
            /* The "Game Setup" rail card is redundant on mobile — the start &
               game-over overlays now carry the full setup (difficulty + walls +
               speed). Hiding it removes the duplicate block that pushed the
               page into a long scroll below the board. */
            .game-rail .rail-card-setup { display: none; }
        }
