
        /* ===== Settings / difficulty bar ===== */
        .settings-bar {
            display: flex; flex-wrap: wrap; gap: 0.5rem;
            justify-content: center; margin-bottom: 0.8rem;
            max-width: 720px; padding: 0 0.5rem;
        }
        .setting-group {
            display: flex; align-items: center; gap: 0.3rem;
            background: var(--t-card-bg);
            border: 1px solid var(--t-card-border);
            border-radius: 30px;
            padding: 0.3rem 0.45rem;
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 4px 14px rgba(0,0,0,0.18);
        }
        .setting-label {
            font-family: 'Orbitron', monospace;
            font-size: 0.5rem; text-transform: uppercase;
            letter-spacing: 0.08em; color: var(--t-text-muted);
            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: var(--t-text); transition: all 0.18s;
        }
        .setting-btn.active {
            background: var(--t-btn-grad); color: #fff;
            box-shadow: 0 2px 8px rgba(0,0,0,0.25);
        }
        .setting-btn:hover:not(.active):not(:disabled) { background: rgba(255,255,255,0.08); }
        .setting-btn:disabled { opacity: 0.4; cursor: not-allowed; }

        /* ===== Stats row ===== */
        .stats-row {
            display: flex; gap: 0.6rem;
            justify-content: center; margin-bottom: 0.8rem;
            flex-wrap: wrap;
        }
        .stat {
            text-align: center; padding: 0.4rem 0.9rem;
            background: var(--t-card-bg);
            border: 1px solid var(--t-card-border);
            border-radius: 12px;
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            min-width: 78px;
        }
        .stat-label {
            font-family: 'Orbitron', monospace;
            font-size: 0.52rem; text-transform: uppercase;
            letter-spacing: 0.12em; color: var(--t-text-muted);
        }
        .stat-value {
            font-family: 'Orbitron', monospace;
            font-size: 1rem; font-weight: 700;
            color: var(--t-text); margin-top: 0.15rem;
        }

        /* ===== Game container ===== */
        .game-container {
            position: relative;
            padding: 1.2rem;
            max-width: 900px;
            width: 100%;
        }
        .game-container.shake { animation: gShake 0.5s; }
        @keyframes gShake {
            0%, 100% { transform: translateX(0); }
            20% { transform: translateX(-7px) rotate(-0.4deg); }
            40% { transform: translateX(7px) rotate(0.4deg); }
            60% { transform: translateX(-5px) rotate(-0.3deg); }
            80% { transform: translateX(5px) rotate(0.3deg); }
        }

        /* ===== Action bar ===== */
        .action-bar {
            display: flex; gap: 0.5rem; flex-wrap: wrap;
            justify-content: center; margin-bottom: 0.8rem;
        }
        .action-btn {
            display: inline-flex; align-items: center; gap: 0.3rem;
            padding: 0.45rem 0.9rem;
            border: 1px solid var(--t-card-border);
            border-radius: 30px;
            background: var(--t-card-bg);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            font-family: inherit; font-size: 0.75rem; font-weight: 500;
            color: var(--t-text); cursor: pointer; transition: all 0.2s;
        }
        .action-btn:hover { transform: translateY(-1px); background: rgba(255,255,255,0.08); }
        .action-btn.primary {
            background: var(--t-btn-grad); color: #fff;
            border-color: transparent;
            box-shadow: 0 4px 14px rgba(0,0,0,0.3);
        }
        .action-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

        /* ===== Phase banner ===== */
        .phase-banner {
            text-align: center;
            font-family: 'Orbitron', monospace;
            font-size: 0.78rem; letter-spacing: 0.18em;
            text-transform: uppercase;
            color: var(--t-primary);
            margin-bottom: 0.6rem;
            min-height: 1.2rem;
        }
        .phase-sub {
            text-align: center;
            font-size: 0.78rem;
            color: var(--t-text-muted);
            margin-bottom: 0.8rem;
            min-height: 1rem;
        }

        /* ===== Twin grids layout ===== */
        .boards-wrap {
            display: flex; gap: 1.2rem; flex-wrap: wrap;
            justify-content: center; align-items: flex-start;
        }
        .board-col {
            display: flex; flex-direction: column; align-items: center;
            min-width: 0;
        }
        .board-title {
            font-family: 'Orbitron', monospace;
            font-size: 0.7rem; letter-spacing: 0.16em;
            text-transform: uppercase;
            color: var(--t-text-muted);
            margin-bottom: 0.45rem;
        }
        .board-title .target-name { color: var(--t-primary); }
        .board-title .fleet-name { color: #2d8a4e; }

        /* ===== Grid ===== */
        .bs-board {
            --cell-size: 30px;
            display: inline-block;
            padding: 6px 6px 6px 6px;
            background: linear-gradient(135deg, #062035 0%, #051527 70%);
            border: 1px solid rgba(56, 132, 200, 0.35);
            border-radius: 12px;
            box-shadow:
                inset 0 4px 12px rgba(0,0,0,0.55),
                0 12px 32px rgba(0,0,0,0.4);
            position: relative;
            user-select: none;
            touch-action: manipulation;
        }
        .bs-grid {
            display: grid;
            grid-template-columns: 16px repeat(10, var(--cell-size));
            grid-template-rows: 16px repeat(10, var(--cell-size));
            gap: 2px;
            position: relative;
        }
        .bs-label {
            display: flex; align-items: center; justify-content: center;
            font-family: 'Orbitron', monospace;
            font-size: 0.58rem;
            color: rgba(180, 220, 255, 0.7);
            font-weight: 700;
        }
        .bs-corner { background: transparent; }
        .bs-cell {
            width: var(--cell-size);
            height: var(--cell-size);
            background:
                linear-gradient(135deg, rgba(14,90,140,0.42), rgba(8,60,100,0.55)),
                #0a4368;
            border-radius: 3px;
            position: relative;
            cursor: pointer;
            overflow: hidden;
            transition: filter 0.15s, transform 0.1s;
            box-shadow:
                inset 0 1px 0 rgba(150, 210, 255, 0.18),
                inset 0 -1px 0 rgba(0,0,0,0.32);
        }
        /* Subtle wave animation */
        .bs-cell::before {
            content: '';
            position: absolute;
            inset: 0;
            background:
                radial-gradient(ellipse at 30% 30%, rgba(125, 211, 252, 0.22), transparent 60%),
                radial-gradient(ellipse at 70% 70%, rgba(56, 189, 248, 0.18), transparent 55%);
            opacity: 0.6;
            animation: waveShift 6s ease-in-out infinite;
            pointer-events: none;
        }
        @keyframes waveShift {
            0%, 100% { transform: translate(0, 0); opacity: 0.55; }
            50% { transform: translate(2px, -1px); opacity: 0.8; }
        }

        /* Fleet grid (your ships visible) */
        .bs-board.fleet .bs-cell { cursor: default; }
        .bs-board.target .bs-cell:hover:not(.struck) {
            filter: brightness(1.25) saturate(1.1);
            box-shadow:
                inset 0 0 0 2px rgba(252, 211, 77, 0.85),
                inset 0 1px 0 rgba(150, 210, 255, 0.2);
        }
        .bs-board.target .bs-cell:active:not(.struck) { transform: scale(0.95); }
        .bs-board.target .bs-cell.struck { cursor: not-allowed; }

        .bs-board.placement .bs-cell { cursor: pointer; }
        .bs-board.placement .bs-cell.preview-ok {
            background:
                linear-gradient(135deg, rgba(45, 138, 78, 0.65), rgba(20, 80, 40, 0.7)),
                #0a4368;
            box-shadow: inset 0 0 0 2px rgba(74, 222, 128, 0.85);
        }
        .bs-board.placement .bs-cell.preview-bad {
            background:
                linear-gradient(135deg, rgba(220, 38, 38, 0.6), rgba(127, 29, 29, 0.7)),
                #0a4368;
            box-shadow: inset 0 0 0 2px rgba(248, 113, 113, 0.85);
        }

        /* ===== Ship overlay (drawn cohesive) =====
           Positioned at top:24px/left:24px = board padding (6) + label row (16) + gap (2)
           to align with the first cell's top-left corner. drawShips() then offsets
           pieces by (cellSize+gap)*r and (cellSize+gap)*c.
           pointer-events: none on the layer; placed ship pieces accept clicks
           individually during the placement phase only. */
        .bs-ship-layer {
            position: absolute;
            top: 24px; left: 24px;
            pointer-events: none;
            z-index: 2;
        }
        .ship-piece {
            position: absolute;
            border-radius: 6px;
            background: linear-gradient(180deg, #6b7280 0%, #4b5563 45%, #1f2937 100%);
            border: 1px solid #111827;
            box-shadow:
                inset 0 2px 0 rgba(255,255,255,0.16),
                inset 0 -2px 4px rgba(0,0,0,0.45),
                0 3px 10px rgba(0,0,0,0.5);
            display: flex; align-items: center; justify-content: center;
            transition: filter 0.25s, box-shadow 0.4s, transform 0.18s;
        }
        /* Re-enable pointer events on ship pieces only while in placement phase.
           This way right-click on a ship rotates it, and the placement preview
           still works on cells underneath when no ship is rendered there. */
        .bs-board.placement .ship-piece {
            pointer-events: auto;
            cursor: grab;
        }
        .bs-board.placement .ship-piece:hover {
            filter: brightness(1.15);
        }
        .ship-piece.sunk {
            filter: brightness(0.55) saturate(1.2);
            background: linear-gradient(180deg, #7f1d1d 0%, #450a0a 100%);
            box-shadow:
                0 0 18px rgba(248, 113, 113, 0.85),
                0 0 36px rgba(220, 38, 38, 0.55),
                inset 0 -2px 4px rgba(0,0,0,0.6);
            animation: sunkPulse 1.2s ease-out;
        }
        @keyframes sunkPulse {
            0% { filter: brightness(1.5) saturate(2); }
            70% { filter: brightness(0.8) saturate(1.3); }
            100% { filter: brightness(0.55) saturate(1.2); }
        }
        .ship-piece.dragging { opacity: 0.7; }

        /* Decorative ship details */
        .ship-piece.bow::after {
            content: '';
            position: absolute;
            inset: 0;
            background: linear-gradient(90deg, transparent 0%, transparent 60%, rgba(0,0,0,0.3) 100%);
            border-radius: 6px;
        }
        .ship-piece.bow.horizontal::before {
            content: ''; position: absolute;
            right: -4px; top: 50%; transform: translateY(-50%);
            width: 10px; height: 60%;
            background: inherit;
            border-radius: 0 50% 50% 0;
            box-shadow: inherit;
            z-index: -1;
        }
        .ship-piece.bow.vertical::before {
            content: ''; position: absolute;
            bottom: -4px; left: 50%; transform: translateX(-50%);
            width: 60%; height: 10px;
            background: inherit;
            border-radius: 0 0 50% 50%;
            box-shadow: inherit;
            z-index: -1;
        }
        .ship-piece.stern.horizontal::before {
            content: ''; position: absolute;
            left: -4px; top: 50%; transform: translateY(-50%);
            width: 6px; height: 70%;
            background: inherit;
            border-radius: 50% 0 0 50%;
            box-shadow: inherit;
            z-index: -1;
        }
        .ship-piece.stern.vertical::before {
            content: ''; position: absolute;
            top: -4px; left: 50%; transform: translateX(-50%);
            width: 70%; height: 6px;
            background: inherit;
            border-radius: 50% 50% 0 0;
            box-shadow: inherit;
            z-index: -1;
        }
        .ship-icon {
            font-family: 'Orbitron', monospace;
            font-size: 0.55rem;
            font-weight: 800;
            color: rgba(255,255,255,0.35);
            letter-spacing: 0.05em;
        }

        /* On target grid - hide ships unless hit */
        .bs-board.target .ship-piece { display: none; }
        .bs-board.target .ship-piece.revealed { display: flex; }

        /* ===== Strike markers ===== */
        .bs-cell.miss {
            background:
                radial-gradient(circle at center, rgba(255,255,255,0.85) 0%, rgba(255,255,255,0.35) 40%, transparent 65%),
                linear-gradient(135deg, rgba(14,90,140,0.42), rgba(8,60,100,0.55)),
                #0a4368;
        }
        .bs-cell.miss::after {
            content: '';
            position: absolute;
            inset: 25%;
            border-radius: 50%;
            border: 2px solid rgba(255,255,255,0.95);
            box-shadow:
                0 0 8px rgba(255,255,255,0.5),
                inset 0 0 6px rgba(125,211,252,0.6);
            animation: missPing 0.6s ease-out;
        }
        @keyframes missPing {
            0% { transform: scale(0); opacity: 0; border-width: 6px; }
            50% { transform: scale(1.4); opacity: 1; }
            100% { transform: scale(1); opacity: 1; border-width: 2px; }
        }

        .bs-cell.hit {
            background:
                radial-gradient(circle at center, #fbbf24 0%, #f59e0b 30%, #b91c1c 60%, #450a0a 90%);
            z-index: 1;
        }
        .bs-cell.hit::after {
            content: '✸';
            position: absolute;
            inset: 0;
            display: flex; align-items: center; justify-content: center;
            color: #fff;
            font-size: 1rem;
            font-weight: 900;
            text-shadow:
                0 0 8px #fbbf24,
                0 0 16px #f59e0b,
                0 0 24px #dc2626;
            animation: hitFlash 0.7s ease-out;
        }
        @keyframes hitFlash {
            0% { transform: scale(0) rotate(0); opacity: 0; }
            40% { transform: scale(2) rotate(180deg); opacity: 1; }
            100% { transform: scale(1) rotate(360deg); opacity: 1; }
        }
        .bs-cell.hit::before {
            content: '';
            position: absolute;
            inset: -30%;
            background: radial-gradient(circle, rgba(251,191,36,0.6) 0%, rgba(220,38,38,0.4) 30%, transparent 65%);
            animation: hitGlow 0.9s ease-out forwards;
            pointer-events: none;
            border-radius: 50%;
        }
        @keyframes hitGlow {
            0% { transform: scale(0); opacity: 1; }
            100% { transform: scale(1.5); opacity: 0; }
        }

        /* Smoke trail on hit (multiple particles via JS) */
        .smoke {
            position: absolute;
            width: 14px; height: 14px;
            border-radius: 50%;
            background: radial-gradient(circle, rgba(75,85,99,0.85), rgba(31,41,55,0.4) 60%, transparent 100%);
            pointer-events: none;
            animation: smokeRise 1.2s ease-out forwards;
            z-index: 4;
        }
        @keyframes smokeRise {
            0% { transform: translateY(0) scale(0.4); opacity: 0.95; }
            100% { transform: translateY(-30px) scale(2.2); opacity: 0; }
        }

        /* Splash particles for misses */
        .splash {
            position: absolute;
            width: 4px; height: 4px;
            background: rgba(255,255,255,0.95);
            border-radius: 50%;
            pointer-events: none;
            box-shadow: 0 0 4px rgba(255,255,255,0.7);
            z-index: 4;
        }

        /* ===== Fleet panel (placement phase) ===== */
        .fleet-panel {
            background: var(--t-card-bg);
            border: 1px solid var(--t-card-border);
            border-radius: 14px;
            padding: 0.9rem 1rem;
            min-width: 200px;
            max-width: 240px;
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
        }
        .fleet-title {
            font-family: 'Orbitron', monospace;
            font-size: 0.7rem; letter-spacing: 0.14em;
            text-transform: uppercase;
            color: var(--t-primary);
            margin-bottom: 0.6rem;
            text-align: center;
        }
        .fleet-list { display: flex; flex-direction: column; gap: 0.5rem; }
        .fleet-item {
            display: flex; align-items: center; gap: 0.6rem;
            padding: 0.5rem 0.6rem;
            background: rgba(255,255,255,0.04);
            border: 1px solid var(--t-card-border);
            border-radius: 10px;
            cursor: grab;
            transition: all 0.18s;
            position: relative;
        }
        .fleet-item:not(.placed):hover {
            background: rgba(255,255,255,0.08);
            transform: translateX(2px);
        }
        .fleet-item.selected {
            border-color: var(--t-primary);
            box-shadow: 0 0 14px rgba(212, 160, 23, 0.45);
            background: rgba(212, 160, 23, 0.08);
        }
        .fleet-item.placed {
            opacity: 0.42;
            cursor: not-allowed;
            text-decoration: line-through;
            text-decoration-color: rgba(74, 222, 128, 0.6);
        }
        .fleet-item.placed::after {
            content: '✓';
            position: absolute;
            right: 0.6rem;
            color: #4ade80;
            font-weight: 800;
            font-size: 0.9rem;
        }
        .fleet-icon-row {
            display: flex; gap: 1px;
        }
        .fleet-icon-cell {
            width: 9px; height: 9px;
            background: linear-gradient(180deg, #6b7280, #1f2937);
            border-radius: 2px;
            border: 1px solid #111827;
        }
        .fleet-info {
            display: flex; flex-direction: column;
            font-size: 0.8rem;
        }
        .fleet-name {
            font-family: 'Orbitron', monospace;
            font-weight: 700;
            font-size: 0.7rem;
            color: var(--t-text);
        }
        .fleet-size {
            font-size: 0.62rem;
            color: var(--t-text-muted);
            letter-spacing: 0.06em;
            text-transform: uppercase;
        }
        .placement-actions {
            display: flex; flex-direction: column; gap: 0.4rem;
            margin-top: 0.8rem;
        }
        .placement-actions button {
            padding: 0.5rem 0.8rem;
            border: 1px solid var(--t-card-border);
            background: var(--t-card-bg);
            color: var(--t-text);
            border-radius: 10px;
            cursor: pointer;
            font-family: 'Orbitron', monospace;
            font-size: 0.65rem;
            letter-spacing: 0.12em;
            text-transform: uppercase;
            font-weight: 700;
            transition: all 0.18s;
        }
        .placement-actions button:hover { background: rgba(255,255,255,0.08); transform: translateY(-1px); }
        .placement-actions button.primary {
            background: var(--t-btn-grad); color: #fff; border-color: transparent;
        }
        .placement-actions button:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

        /* Rotate hint */
        .rotate-hint {
            font-size: 0.6rem;
            color: var(--t-text-muted);
            text-align: center;
            margin-top: 0.4rem;
            line-height: 1.4;
        }
        .rotate-hint kbd {
            background: rgba(255,255,255,0.1);
            border: 1px solid var(--t-card-border);
            border-radius: 4px;
            padding: 0 4px;
            font-family: monospace;
        }

        /* ===== Pause/Start/Game over overlays ===== */
        .overlay {
            position: fixed;
            inset: 0;
            display: none;
            align-items: center;
            justify-content: center;
            background: rgba(7, 5, 10, 0.78);
            text-align: center;
            color: #fff;
            font-family: 'Orbitron', monospace;
            padding: 24px;
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            z-index: 50;
        }
        .overlay.active { display: flex; }
        .overlay-box {
            background: rgba(13, 10, 20, 0.7);
            border: 1px solid var(--t-card-border);
            border-radius: 22px;
            padding: 32px 30px 28px;
            min-width: 280px;
            max-width: 420px;
            box-shadow: 0 24px 60px rgba(0,0,0,0.5);
        }
        .overlay-title {
            font-size: 1.6rem;
            font-weight: 900;
            letter-spacing: 0.04em;
            margin: 0 0 6px;
            color: var(--t-primary);
            text-shadow: 0 2px 12px rgba(0,0,0,0.4);
        }
        .overlay-sub {
            margin: 0 0 18px;
            color: rgba(255,255,255,0.78);
            font-family: -apple-system, sans-serif;
            font-size: 0.92rem;
            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.78rem;
            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: var(--t-btn-grad);
            color: #1a1207;
        }
        .overlay-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(212,160,23,0.4); }
        .overlay-btn-ghost {
            background: rgba(255,255,255,0.08);
            border: 1px solid rgba(255,255,255,0.25);
            color: #fff;
        }
        .overlay-btn-ghost:hover { background: rgba(255,255,255,0.15); }

        /* Game-over stats */
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 8px;
            margin: 12px 0 18px;
        }
        .stat-cell {
            padding: 10px 6px;
            background: rgba(255,255,255,0.06);
            border: 1px solid rgba(255,255,255,0.12);
            border-radius: 10px;
        }
        .stat-cell-label {
            font-size: 0.55rem;
            letter-spacing: 0.14em;
            color: rgba(255,255,255,0.55);
            margin-bottom: 4px;
        }
        .stat-cell-value {
            font-size: 1.1rem;
            font-weight: 800;
            color: var(--t-primary);
        }

        /* Help + history toggles */
        .help-toggle, .history-toggle {
            display: block; margin: 0.7rem auto 0; padding: 0.4rem 1.1rem;
            background: none; border: 1px solid var(--t-card-border);
            color: var(--t-text-muted); 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(255,255,255,0.06); color: var(--t-primary); }
        .help-panel, .history-panel {
            display: none; max-width: 620px; margin: 0.8rem auto 0;
            padding: 1rem 1.2rem;
            background: var(--t-card-bg);
            border: 1px solid var(--t-card-border);
            border-radius: 14px;
            color: var(--t-text);
            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: 0 0 6px;
            font-family: 'Orbitron', monospace;
            font-size: 0.82rem;
            color: var(--t-primary);
            letter-spacing: 0.08em;
            text-transform: uppercase;
        }
        .help-panel h3:not(:first-child) { margin-top: 12px; }
        .help-panel ul { margin: 0 0 6px; padding-left: 20px; color: var(--t-text-muted); }
        .help-panel li { margin: 3px 0; }
        .help-panel strong { color: var(--t-text); }
        .history-title {
            font-family: 'Orbitron', monospace; font-size: 0.66rem;
            text-transform: uppercase; letter-spacing: 0.1em;
            color: var(--t-primary); text-align: center; margin-bottom: 8px;
        }
        .history-item {
            display: flex; justify-content: space-between; align-items: center;
            padding: 6px 12px;
            background: rgba(255,255,255,0.04);
            border-radius: 8px; font-size: 0.78rem;
            margin-bottom: 4px;
        }
        .history-score {
            font-family: 'Orbitron', monospace;
            font-weight: 700;
            color: var(--t-primary);
        }
        .history-meta { color: var(--t-text-muted); font-size: 0.72rem; }
        .history-empty {
            text-align: center;
            color: var(--t-text-muted);
            font-size: 0.84rem;
            padding: 12px;
        }
        .history-result-win { color: #4ade80; font-weight: 700; }
        .history-result-loss { color: #f87171; font-weight: 700; }

        /* ============================================================
           DESKTOP-FILL LAYOUT — board(s) grow to use the viewport, the
           leftover horizontal space becomes a side rail (settings / stats /
           history / help). Mirrors the shared .game-layout pattern used
           across the 18 HT games, themed to battleship's ocean palette.
           ============================================================ */
        .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%;
        }
        /* Container hugs its content; drop backdrop-filter so the mobile
           position:fixed overlays aren't trapped to it. (The shake transform
           lives on #gameContainer, so overlays are siblings of it under
           .game-main, never descendants.) */
        .game-container {
            backdrop-filter: none; -webkit-backdrop-filter: none;
            width: fit-content; max-width: 100%; margin: 0 auto;
        }

        .game-rail {
            width: 340px; flex-shrink: 0;
            display: flex; flex-direction: column; gap: 14px;
        }
        .rail-card {
            background: var(--t-card-bg);
            border: 1px solid var(--t-card-border);
            border-radius: 16px; padding: 14px 16px;
            backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
        }
        .rail-card-title {
            font-family: 'Orbitron', monospace; font-size: 0.6rem;
            text-transform: uppercase; letter-spacing: 0.14em;
            color: var(--t-primary); margin-bottom: 10px;
        }
        /* Settings + stats fill the rail width (strip the centered-bar maxes) */
        .game-rail .settings-bar {
            flex-direction: column; align-items: stretch;
            gap: 10px; margin: 0; max-width: none; padding: 0;
        }
        .game-rail .setting-group { justify-content: space-between; flex-wrap: wrap; }
        .game-rail .stats-row {
            margin: 0; max-width: none; width: 100%;
            gap: 8px; justify-content: stretch;
        }
        .game-rail .stat { flex: 1; min-width: 0; }
        /* History + help open inline 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 .game-main (position:relative, no filter/
           transform) so the rail stays clickable behind them on desktop.
           They clip to the rounded board area and scroll internally. */
        .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 battle at a
           different difficulty without hunting for the panel beside the board. */
        .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: 520px; }
            .game-rail .settings-bar { flex-direction: row; flex-wrap: wrap; justify-content: center; }
            .game-rail .setting-group { justify-content: center; }
            .game-rail .stats-row { flex-wrap: wrap; }
            /* Mobile: overlays go full-screen (no rail beside the board to
               preserve), so start / end 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;
            }
        }

        /* Mobile tweaks */
        @media (max-width: 720px) {
            .bs-board { --cell-size: 26px; }
            .boards-wrap { gap: 0.6rem; }
            .fleet-panel { max-width: 100%; width: 100%; }
            .stat { min-width: 64px; padding: 0.35rem 0.7rem; }
            .stat-value { font-size: 0.85rem; }
            .ship-icon { display: none; }
        }
        @media (max-width: 480px) {
            .bs-board { --cell-size: 22px; }
            .bs-grid { grid-template-columns: 14px repeat(10, var(--cell-size)); grid-template-rows: 14px repeat(10, var(--cell-size)); }
            .bs-ship-layer { top: 22px; left: 22px; } /* 6 padding + 14 label + 2 gap */
            .bs-label { font-size: 0.5rem; }
            .stat { min-width: 54px; padding: 0.3rem 0.55rem; }
            .stat-label { font-size: 0.46rem; }
            .stat-value { font-size: 0.78rem; }
            .action-btn { padding: 0.4rem 0.7rem; font-size: 0.7rem; }
            .fleet-panel { padding: 0.7rem 0.8rem; }
        }

        /* Audio toggle inherits .audio-toggle from games.css */
