/* Flux v3 — "Neon Arcade Glow"
   Token-driven rebuild. Selector inventory is 1:1 with v2 (game.js and friends
   query these classes/ids); legacy custom-property names are kept because JS
   writes them inline (var(--pN-color) etc). Design doctrine: DESIGN.md. */

/* ===== FONTS (self-hosted, PWA-safe) ===== */

@font-face {
    font-family: 'Unbounded';
    src: url('../assets/fonts/unbounded-var-latin.woff2') format('woff2');
    font-weight: 200 900;
    font-display: swap;
}
@font-face {
    font-family: 'Archivo';
    src: url('../assets/fonts/archivo-var-latin.woff2') format('woff2');
    font-weight: 100 900;
    font-display: swap;
}

/* ===== TOKENS ===== */

:root {
    /* chrome (oklch, violet-blue undertone) */
    --bg-color: oklch(0.145 0.014 290);
    --board-bg: oklch(0.19 0.016 290);
    --cell-bg: oklch(0.245 0.018 290);
    --surface: oklch(0.19 0.016 290);
    --surface-2: oklch(0.235 0.018 290);
    --edge: oklch(0.32 0.02 290);
    --ink: oklch(0.93 0.006 290);
    --ink-muted: oklch(0.74 0.012 290);
    --ink-faint: oklch(0.58 0.012 290);

    /* identity palette — never re-derive (JS writes these inline) */
    --p1-color: #00fff2;
    --p1-shadow: 0 0 15px rgba(0, 255, 242, 0.6);
    --p2-color: #ff0055;
    --p2-shadow: 0 0 15px rgba(255, 0, 85, 0.6);
    --p3-color: #bfff00;
    --p3-shadow: 0 0 15px rgba(191, 255, 0, 0.6);
    --p4-color: #ffaa00;
    --p4-shadow: 0 0 15px rgba(255, 170, 0, 0.6);

    --accent: var(--p1-color);
    --highlight: rgba(255, 255, 255, 0.2);
    --text-color: var(--ink);
    --preview-capture: rgba(255, 100, 100, 0.5);
    --preview-glow: rgba(255, 255, 100, 0.4);

    /* type */
    --font-display: 'Unbounded', system-ui, sans-serif;
    --font-ui: 'Archivo', 'Segoe UI', system-ui, sans-serif;

    /* motion */
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --t-fast: 140ms;
    --t-med: 240ms;

    /* z scale */
    --z-sticky: 10;
    --z-chat: 50;
    --z-backdrop: 90;
    --z-modal: 100;
    --z-toast: 120;

    --radius: 14px;
    --radius-sm: 8px;
}

/* ===== BASE ===== */

* { box-sizing: border-box; }

/* Scrollbars — same chrome as the panels, neon on hover. */
* {
    scrollbar-width: thin;                       /* Firefox */
    scrollbar-color: var(--edge) transparent;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--edge);
    border-radius: 8px;
    border: 3px solid transparent;               /* slim inset pill */
    background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
    background: oklch(0.55 0.09 195);            /* cyan undertone, on brand */
    border: 3px solid transparent;
    background-clip: content-box;
}

body {
    font-family: var(--font-ui);
    background-color: var(--bg-color);
    background-image:
        radial-gradient(1100px 600px at 85% -10%, oklch(0.20 0.05 200 / 0.35), transparent 60%),
        radial-gradient(900px 700px at -10% 110%, oklch(0.19 0.06 340 / 0.28), transparent 55%);
    background-attachment: fixed;
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    overflow-x: hidden;
    overflow-y: auto;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    padding: env(safe-area-inset-top) env(safe-area-inset-right)
             env(safe-area-inset-bottom) env(safe-area-inset-left);
}

h1 {
    margin: 6px 0;
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: 0.30em;
    text-indent: 0.30em; /* optically recenters tracked caps */
    text-transform: uppercase;
    font-size: 1.5rem;
    color: var(--ink);
    text-shadow: 0 0 18px oklch(0.85 0.16 195 / 0.35);
}

h2, h3, h4 { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.01em; text-wrap: balance; }

button {
    font-family: var(--font-ui);
    font-size: 0.95rem;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--edge);
    background: var(--surface-2);
    color: var(--ink);
    cursor: pointer;
    transition: transform var(--t-fast) var(--ease-out),
                border-color var(--t-fast) var(--ease-out),
                box-shadow var(--t-fast) var(--ease-out),
                background var(--t-fast) var(--ease-out);
}
button:hover { border-color: var(--accent); box-shadow: 0 0 0 1px oklch(0.85 0.16 195 / 0.35), 0 0 18px oklch(0.85 0.16 195 / 0.18); }
button:active { transform: translateY(1px) scale(0.99); }
button:focus-visible, .opt-btn:focus-visible, input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ===== SCREENS ===== */

.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 600px;
    animation: screenIn 320ms var(--ease-out);
}
.screen.active { display: flex; }

@keyframes screenIn {
    from { opacity: 0; transform: translateY(14px); filter: blur(4px); }
    to { opacity: 1; transform: translateY(0); filter: blur(0); }
}

/* ===== MENU COMPONENTS ===== */

.menu-card {
    background: color-mix(in oklab, var(--surface) 88%, transparent);
    padding: clamp(20px, 4vw, 34px);
    border-radius: var(--radius);
    box-shadow: 0 24px 60px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.04);
    text-align: center;
    width: 92%;
    max-width: 400px;
    border: 1px solid var(--edge);
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
}

.menu-btn {
    display: block;
    width: 100%;
    padding: 15px;
    margin: 9px 0;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid var(--edge);
    background: var(--surface-2);
    color: var(--ink);
}
.menu-btn:hover { transform: translateY(-1px); }

.setting-group { margin: 16px 0; text-align: left; }
.setting-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ink-muted);
    margin-bottom: 8px;
}
.option-row { display: flex; gap: 8px; }
.opt-btn {
    flex: 1;
    padding: 10px 6px;
    text-align: center;
    background: var(--surface-2);
    border: 1px solid var(--edge);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--ink-muted);
    transition: all var(--t-fast) var(--ease-out);
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.opt-btn:hover { color: var(--ink); border-color: var(--accent); }
.opt-btn.selected {
    color: #041413;
    background: var(--accent);
    border-color: var(--accent);
    font-weight: 700;
    box-shadow: 0 0 16px oklch(0.85 0.16 195 / 0.45);
}

/* ===== GAME HEADER ===== */

.game-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 450px;
    margin-bottom: 10px;
}

.scoreboard {
    display: flex;
    justify-content: center;
    gap: 10px;
    width: 100%;
    background: oklch(0.16 0.02 275);
    padding: 8px;
    border-radius: var(--radius);
    border: 1px solid oklch(0.45 0.1 260 / 0.55);
    box-shadow: 0 10px 30px rgba(0,0,0,0.45);
    flex-wrap: wrap;
}

/* player-colored score boxes, like the hero's Cyan-vs-Magenta strip */
#sb-p1 { color: var(--p1-color); }
#sb-p2 { color: var(--p2-color); }
#sb-p3 { color: var(--p3-color); }
#sb-p4 { color: var(--p4-color); }
.score-box.active-turn { text-shadow: 0 0 12px currentColor; }

.timer-bar {
    width: 100%;
    height: 6px;
    margin-top: 8px;
    border-radius: 3px;
    background: var(--surface-2);
    overflow: hidden;
    display: none;
}
.timer-fill {
    height: 100%;
    width: 100%;
    border-radius: 3px;
    transition: width 1s linear;
    box-shadow: 0 0 10px currentColor;
}

.score-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 10px;
    background: var(--surface-2);
    border: 1px solid transparent;
    min-width: 72px;
    justify-content: center;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    transition: border-color var(--t-med) var(--ease-out), box-shadow var(--t-med) var(--ease-out), transform var(--t-med) var(--ease-out);
}
.score-box.active-turn {
    border-color: currentColor;
    transform: translateY(-1px) scale(1.04);
    box-shadow: 0 0 22px -2px currentColor, inset 0 0 12px -6px currentColor;
}
#message {
    min-height: 1.3em;
    margin: 2px 0 8px;
    color: var(--ink-muted);
    font-weight: 600;
    letter-spacing: 0.02em;
}
.score-box.eliminated { opacity: 0.35; filter: saturate(0.2); }

.indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.ind-p1 { background: var(--p1-color); box-shadow: var(--p1-shadow); }
.ind-p2 { background: var(--p2-color); box-shadow: var(--p2-shadow); }
.ind-p3 { background: var(--p3-color); box-shadow: var(--p3-shadow); }
.ind-p4 { background: var(--p4-color); box-shadow: var(--p4-shadow); }

/* ===== BOARD ===== */

.board {
    display: grid;
    gap: 4px;
    background: oklch(0.12 0.015 275);
    padding: 8px;
    border-radius: 10px;
    width: min(87vw, calc(100dvh - 250px), 420px);
    height: min(87vw, calc(100dvh - 250px), 420px);
    position: relative;
}

.board-frame.flat { transform: none; }
.board-frame.flat { padding: 12px; }
.game-container .board-frame { margin-bottom: 4px; }

.cell {
    background: oklch(0.20 0.02 275);
    border-radius: 5px;
    cursor: pointer;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.03), inset 0 -2px 6px rgba(0,0,0,0.25);
    transition: box-shadow var(--t-fast) var(--ease-out);
}

/* Move targets speak in SHAPE + FILL, never color alone:
   ● filled circle = clone (piece stays), ◇ outlined diamond = jump. */
.cell.valid-move::after {
    content: '';
    position: absolute;
    animation: validPulse 1.6s var(--ease-out) infinite;
}
.cell.valid-clone::after {
    width: 34%;
    height: 34%;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 10px oklch(0.85 0.16 195 / 0.5);
    opacity: 0.85;
}
.cell.valid-jump::after {
    width: 38%;
    height: 38%;
    border: 2px solid var(--accent);
    border-radius: 3px;
    background: transparent;
    box-shadow: 0 0 10px oklch(0.85 0.16 195 / 0.4);
    opacity: 0.9;
}
@keyframes validPulse {
    0%, 100% { transform: scale(0.92) rotate(0deg); opacity: 0.55; }
    50% { transform: scale(1.08) rotate(0deg); opacity: 1; }
}
.cell.valid-jump::after { transform: rotate(45deg); }
@keyframes validPulseJump {
    0%, 100% { transform: scale(0.92) rotate(45deg); opacity: 0.55; }
    50% { transform: scale(1.08) rotate(45deg); opacity: 1; }
}
.cell.valid-jump::after { animation-name: validPulseJump; }
.cell.valid-move:hover::after { opacity: 1; }

.cell.will-capture::before {
    content: '';
    position: absolute;
    inset: 2px;
    border-radius: 5px;
    border: 2px solid var(--preview-capture);
    box-shadow: 0 0 12px var(--preview-capture);
    animation: captureWarn 1s ease-in-out infinite alternate;
}
@keyframes captureWarn { from { opacity: 0.5; } to { opacity: 1; } }

.cell.valid-move.hovered { box-shadow: inset 0 0 0 2px var(--preview-glow); }
/* Selected piece: strong double ring, unmistakable vs focus and targets. */
.cell.selected {
    box-shadow: inset 0 0 0 2px var(--accent), inset 0 0 0 5px oklch(0.3 0.05 195),
                0 0 18px oklch(0.85 0.16 195 / 0.5);
}

/* ===== PIECES ===== */

/* LED pucks — dark core, blazing rim. One piece style everywhere: hero demo,
   game board, tutorial, landing mini-boards. */
.piece {
    width: 82%;
    height: 82%;
    border-radius: 50%;
    position: relative;
    transition: transform var(--t-med) var(--ease-out);
}
.piece.p1 {
    background: radial-gradient(circle, #06272b 0%, #0a4a4d 38%, var(--p1-color) 66%, #ccfffc 80%, var(--p1-color) 100%);
    box-shadow: 0 0 12px rgba(0,255,242,0.75), 0 0 26px rgba(0,255,242,0.32);
}
.piece.p2 {
    background: radial-gradient(circle, #2b0614 0%, #58102b 38%, var(--p2-color) 66%, #ffc7d8 80%, var(--p2-color) 100%);
    box-shadow: 0 0 12px rgba(255,0,85,0.75), 0 0 26px rgba(255,0,85,0.32);
}
.piece.p3 {
    background: radial-gradient(circle, #1c2b06 0%, #3d5708 38%, var(--p3-color) 66%, #ecffc9 80%, var(--p3-color) 100%);
    box-shadow: 0 0 12px rgba(191,255,0,0.7), 0 0 26px rgba(191,255,0,0.3);
}
.piece.p4 {
    background: radial-gradient(circle, #2b1c06 0%, #5c3c08 38%, var(--p4-color) 66%, #ffe4b8 80%, var(--p4-color) 100%);
    box-shadow: 0 0 12px rgba(255,170,0,0.7), 0 0 26px rgba(255,170,0,0.3);
}

/* electric flash whenever a piece converts — game, demo, and tutorial alike */
.piece.convert::after {
    content: '';
    position: absolute;
    inset: -45%;
    border-radius: 50%;
    background: radial-gradient(circle,
        rgba(255,255,255,0.95) 0%, rgba(0,255,242,0.5) 30%,
        rgba(255,0,85,0.25) 55%, transparent 72%);
    animation: burstOut 520ms var(--ease-out) forwards;
    pointer-events: none;
    z-index: 2;
}

.piece.new { animation: pieceIn 380ms var(--ease-out); }
@keyframes pieceIn {
    0% { transform: scale(0); }
    70% { transform: scale(1.12); }
    100% { transform: scale(1); }
}
.piece.pop { animation: pieceIn 380ms var(--ease-out); }

.piece.convert { animation: convertFlip 520ms var(--ease-out); }
@keyframes convertFlip {
    0% { transform: scale(1) rotate(0deg); filter: brightness(1); }
    35% { transform: scale(1.28); filter: brightness(2.2) saturate(1.6); }
    100% { transform: scale(1); filter: brightness(1); }
}

/* ===== CONTROLS + MESSAGE ===== */

.controls { display: flex; gap: 10px; margin-top: 12px; }

#message {
    height: 22px;
    color: var(--ink-muted);
    font-size: 0.92rem;
    margin-top: 8px;
    text-align: center;
}

.game-container { display: flex; flex-direction: column; align-items: center; }

/* ===== TUTORIAL ===== */

.tutorial-step { color: var(--ink-muted); line-height: 1.65; max-width: 60ch; margin-inline: auto; }
.tutorial-highlight { color: var(--accent); font-weight: 700; }
#tut-board-container .cell { border-radius: 5px; }

/* ===== GAME OVER MODAL ===== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(6, 6, 10, 0.7);
    backdrop-filter: blur(3px);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t-med) var(--ease-out);
    z-index: var(--z-modal);
}
.modal-overlay.visible { opacity: 1; pointer-events: auto; }

.modal {
    background: var(--surface);
    border: 1px solid var(--edge);
    padding: 34px 42px;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: 0 30px 80px rgba(0,0,0,0.6);
    transform: scale(0.94);
    transition: transform var(--t-med) var(--ease-out);
}
.modal-overlay.visible .modal { transform: scale(1); }
.modal h2 { margin-top: 0; font-size: 1.7rem; }

/* ===== NAME / ACCOUNT MODALS ===== */

.name-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(6, 6, 10, 0.75);
    backdrop-filter: blur(3px);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t-med) var(--ease-out);
    z-index: var(--z-modal);
}
.name-modal-overlay.visible { opacity: 1; pointer-events: auto; }

/* Hidden dialogs must leave the tab order and the accessibility tree —
   opacity alone keeps their controls focusable. visibility flips after the
   fade-out so the close animation still shows. */
.name-modal-overlay, .modal-overlay {
    visibility: hidden;
    transition: opacity var(--t-med) var(--ease-out), visibility 0s linear var(--t-med);
}
.name-modal-overlay.visible, .modal-overlay.visible {
    visibility: visible;
    transition: opacity var(--t-med) var(--ease-out);
}

/* Keyboard play */
.cell:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    border-radius: 6px;
}

.name-modal {
    background: var(--surface);
    border: 1px solid var(--edge);
    border-radius: var(--radius);
    padding: 30px;
    width: 92%;
    max-width: 380px;
    text-align: center;
    box-shadow: 0 30px 80px rgba(0,0,0,0.6);
    transform: scale(0.94) translateY(8px);
    transition: transform var(--t-med) var(--ease-out);
}
.name-modal-overlay.visible .name-modal { transform: scale(1) translateY(0); }
.name-modal h2 { margin: 0 0 6px; font-size: 1.25rem; }
.name-modal p { color: var(--ink-muted); margin: 0 0 18px; font-size: 0.92rem; }

.name-input-wrapper { margin: 10px 0; }
.name-input-field {
    width: 100%;
    padding: 12px 14px;
    font-size: 1rem;
    font-family: var(--font-ui);
    background: var(--surface-2);
    border: 1px solid var(--edge);
    color: var(--ink);
    border-radius: var(--radius-sm);
    transition: border-color var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out);
}
.name-input-field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px oklch(0.85 0.16 195 / 0.18); }
.name-input-field::placeholder { color: var(--ink-faint); }

.char-counter { font-size: 0.75rem; color: var(--ink-faint); text-align: right; margin-top: 4px; }

.name-modal-btn {
    width: 100%;
    padding: 13px;
    margin-top: 12px;
    font-weight: 700;
    font-size: 1rem;
    background: var(--accent);
    color: #041413;
    border: none;
    border-radius: var(--radius-sm);
    box-shadow: 0 0 18px oklch(0.85 0.16 195 / 0.4);
}
.name-modal-btn:hover { transform: translateY(-1px); box-shadow: 0 0 26px oklch(0.85 0.16 195 / 0.55); }
.name-modal-btn:active { transform: translateY(0); }
.name-modal-btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

/* ===== CHAT ===== */

.chat-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 310px;
    height: 400px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--edge);
    display: none;
    flex-direction: column;
    box-shadow: 0 24px 60px rgba(0,0,0,0.6);
    z-index: var(--z-chat);
}
.chat-container.visible { display: flex; animation: chatIn 260ms var(--ease-out); }
@keyframes chatIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid var(--edge);
}
.chat-messages { flex: 1; overflow-y: auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; }
.chat-message { font-size: 0.88rem; line-height: 1.45; word-break: break-word; }
.chat-message .sender { font-weight: 700; margin-right: 4px; }
.chat-message.system { color: var(--ink-faint); font-style: italic; font-size: 0.8rem; text-align: center; }

.chat-input-container { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--edge); }
.chat-input {
    flex: 1;
    padding: 9px 12px;
    background: var(--surface-2);
    border: 1px solid var(--edge);
    border-radius: var(--radius-sm);
    color: var(--ink);
    font-family: var(--font-ui);
}
.chat-send-btn { background: var(--accent); color: #041413; border: none; font-weight: 700; }

/* ===== LOBBY / PLAYERS ===== */

.player-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface-2);
    border: 1px solid var(--edge);
    border-radius: 10px;
    padding: 10px 12px;
}
.kick-btn {
    background: transparent;
    border: 1px solid oklch(0.55 0.19 20);
    color: oklch(0.75 0.16 20);
    font-size: 0.78rem;
    padding: 5px 10px;
    min-height: 34px;
}
.kick-btn:hover { background: oklch(0.55 0.19 20 / 0.15); box-shadow: none; }

.player-name-input input {
    width: 100%;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--edge);
    border-radius: var(--radius-sm);
    color: var(--ink);
    font-family: var(--font-ui);
}
.player-name-input input:focus { outline: none; border-color: var(--accent); }

.admin-badge {
    background: oklch(0.4 0.09 290);
    color: var(--ink);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 3px 8px;
    border-radius: 20px;
}

.lobby-chat-panel { background: var(--surface-2); border: 1px solid var(--edge); border-radius: var(--radius); margin-top: 16px; overflow: hidden; }
.lobby-chat-header { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px 8px; text-align: left; }
.lobby-chat-header small { color: var(--ink-faint); font-size: 0.75rem; }
.lobby-chat-messages { max-height: 140px; overflow-y: auto; padding: 4px 14px; display: flex; flex-direction: column; gap: 5px; text-align: left; }
.lobby-chat-input { display: flex; gap: 8px; padding: 10px 12px 12px; }
.lobby-chat-input input {
    flex: 1;
    padding: 9px 12px;
    background: var(--bg-color);
    border: 1px solid var(--edge);
    border-radius: var(--radius-sm);
    color: var(--ink);
    font-family: var(--font-ui);
}
.lobby-chat-input input:focus { outline: none; border-color: var(--accent); }
.lobby-chat-input button { background: var(--accent); color: #041413; border: none; font-weight: 700; padding: 9px 14px; }
.lobby-chat-message { font-size: 0.85rem; line-height: 1.4; word-break: break-word; }
.lobby-chat-message .sender { font-weight: 700; margin-right: 4px; }
.lobby-chat-message.system { color: var(--ink-faint); font-style: italic; font-size: 0.78rem; }

/* ===== ADMIN TOOLS ===== */

.admin-tools-panel { background: var(--surface-2); border: 1px solid var(--edge); border-radius: var(--radius); margin-top: 14px; text-align: left; }
.admin-tools-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--edge); font-weight: 700; }
.admin-tools-content { padding: 12px 14px; }
.admin-tool-section { margin-bottom: 14px; }
.admin-tool-section:last-child { margin-bottom: 0; }
.admin-tool-section h4 { margin: 0 0 8px; font-size: 0.8rem; color: var(--ink-muted); font-family: var(--font-ui); font-weight: 600; }
.admin-tool-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    background: var(--surface);
    border: 1px solid var(--edge);
    padding: 10px 12px;
}
.admin-tool-btn:hover { border-color: var(--accent); }
.admin-tool-btn.danger { border-color: oklch(0.5 0.17 20); }
.admin-tool-btn.danger:hover { background: oklch(0.5 0.17 20 / 0.12); box-shadow: none; }
.admin-tool-btn span { font-size: 1.1rem; }
.admin-tool-btn strong { display: block; font-size: 0.9rem; }
.admin-tool-btn small { color: var(--ink-faint); font-size: 0.75rem; }
.admin-player-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--edge); }
.admin-player-item:last-child { border-bottom: none; }
.admin-kick-btn {
    background: transparent;
    border: 1px solid oklch(0.55 0.19 20);
    color: oklch(0.75 0.16 20);
    font-size: 0.75rem;
    padding: 4px 10px;
}
.admin-kick-btn:hover { background: oklch(0.55 0.19 20 / 0.15); box-shadow: none; }

/* ===== TOGGLES ===== */

.public-toggle .open-toggle { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.open-toggle input { position: absolute; opacity: 0; }
.open-toggle-track {
    width: 40px;
    height: 22px;
    border-radius: 20px;
    background: var(--surface-2);
    border: 1px solid var(--edge);
    position: relative;
    flex-shrink: 0;
    transition: background var(--t-fast) var(--ease-out);
}
.open-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--ink-muted);
    transition: transform var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out);
}
.open-toggle input:checked + .open-toggle-track { background: oklch(0.45 0.1 195); border-color: var(--accent); }
.open-toggle input:checked + .open-toggle-track .open-toggle-thumb { transform: translateX(18px); background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.open-toggle-text { font-size: 0.8rem; color: var(--ink-muted); text-align: left; line-height: 1.45; }

/* ===== OPEN GAMES ===== */

.open-games-panel { margin-top: 22px; text-align: left; }
.open-games-header { display: flex; justify-content: space-between; align-items: center; }
.open-games-subtitle { color: var(--ink-faint); font-size: 0.82rem; margin: 6px 0 12px; }
.open-games-empty {
    background: var(--surface-2);
    border: 1px dashed var(--edge);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
    color: var(--ink-faint);
    font-size: 0.85rem;
}
.open-games-list { display: flex; flex-direction: column; gap: 10px; }
.open-game-card {
    background: var(--surface-2);
    border: 1px solid var(--edge);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    transition: border-color var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out);
}
.open-game-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.open-game-title { font-weight: 700; margin-bottom: 6px; }
.open-game-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.open-game-badge {
    background: var(--bg-color);
    border: 1px solid var(--edge);
    border-radius: 20px;
    padding: 2px 9px;
    font-size: 0.72rem;
    color: var(--ink-muted);
}
.open-game-actions { display: flex; justify-content: space-between; align-items: center; }
.open-refresh-btn { background: transparent; border: 1px solid var(--edge); font-size: 0.8rem; padding: 6px 12px; }
.open-refresh-btn:hover { border-color: var(--accent); }
.open-game-join { background: var(--accent); color: #041413; border: none; font-weight: 700; padding: 8px 18px; min-height: 38px; }
.open-game-join:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== LEADERBOARD ===== */

#leaderboard-screen td { padding: 8px 6px; border-bottom: 1px solid var(--edge); }
#leaderboard-screen tr.lb-me td { color: var(--accent); font-weight: 700; }

input[type="range"] { accent-color: var(--accent); }

/* unread badge on the chat toggle */
#chat-toggle-btn { position: relative; }
#chat-toggle-btn[data-unread]::after {
    content: attr(data-unread);
    position: absolute;
    top: -7px;
    right: -7px;
    min-width: 19px;
    height: 19px;
    border-radius: 10px;
    background: var(--p2-color);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-shadow: 0 0 10px rgba(255, 0, 85, 0.6);
}

/* toast notifications */
.flux-toast {
    position: fixed;
    top: calc(16px + env(safe-area-inset-top));
    left: 50%;
    transform: translate(-50%, -16px);
    max-width: min(86vw, 420px);
    background: color-mix(in oklab, var(--surface) 90%, transparent);
    border: 1px solid var(--accent);
    border-radius: 30px;
    padding: 9px 18px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    pointer-events: none;
    transition: opacity 300ms var(--ease-out), transform 300ms var(--ease-out);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: var(--z-toast);
}
.flux-toast.in { opacity: 1; transform: translate(-50%, 0); }

/* ===== AGENTS ===== */

.agent-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: oklch(0.3 0.09 300 / 0.6);
    border: 1px solid oklch(0.55 0.15 300 / 0.7);
    color: oklch(0.85 0.1 300);
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    border-radius: 20px;
    padding: 2px 7px;
    vertical-align: middle;
    text-shadow: none;
}
.model-chip {
    display: inline-block;
    background: var(--bg-color);
    border: 1px solid var(--edge);
    border-radius: 20px;
    padding: 2px 8px;
    font-size: 0.7rem;
    color: var(--ink-muted);
    margin: 2px 2px 2px 0;
}
.mini-btn {
    background: transparent;
    border: 1px solid var(--edge);
    border-radius: 8px;
    font-size: 0.72rem;
    padding: 4px 8px;
    color: var(--ink-muted);
}
.mini-btn:hover { border-color: var(--accent); color: var(--ink); box-shadow: none; }
.mini-btn.danger { border-color: oklch(0.5 0.17 20); color: oklch(0.72 0.15 20); }
.card-sect { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--edge); }
.card-sect h4 { margin: 0 0 6px; font-size: 0.72rem; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.08em; font-family: var(--font-ui); }
.card-sect p { margin: 4px 0 0; font-size: 0.85rem; color: var(--ink-muted); line-height: 1.5; }

/* ===== AVATARS + PROFILE ===== */

.av {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--surface-2);
    border: 1px solid var(--edge);
    object-fit: cover;
    font-size: 1.05rem;
    vertical-align: middle;
    flex-shrink: 0;
    overflow: hidden;
}
.av-i { color: var(--accent); font-weight: 800; text-shadow: 0 0 8px oklch(0.85 0.16 195 / 0.5); }
.av-xs { width: 20px; height: 20px; font-size: 0.75rem; margin-right: 2px; }
.av-sm { width: 28px; height: 28px; font-size: 0.9rem; }
.av-xl {
    width: 88px;
    height: 88px;
    font-size: 2.6rem;
    border-width: 2px;
    box-shadow: 0 0 24px oklch(0.85 0.16 195 / 0.3);
}

.avatar-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}
.avatar-choice {
    font-size: 1.4rem;
    padding: 8px 0;
    background: var(--surface-2);
    border: 1px solid var(--edge);
    border-radius: 10px;
}
.avatar-choice:hover { border-color: var(--accent); }

.profile-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin: 14px 0;
}
.pstat {
    background: var(--surface-2);
    border: 1px solid var(--edge);
    border-radius: 10px;
    padding: 10px 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.pstat b { font-size: 1.15rem; color: var(--accent); font-variant-numeric: tabular-nums; }
.pstat span { font-size: 0.68rem; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.06em; }

.profile-section { margin: 16px 0; text-align: left; }
.profile-section h3 { font-size: 0.95rem; margin: 0 0 8px; }
.history-list { display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; }
.history-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    background: var(--surface-2);
    border: 1px solid var(--edge);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.85rem;
}
.h-delta { font-weight: 800; min-width: 44px; font-variant-numeric: tabular-nums; }
.h-delta.up { color: var(--p3-color); text-shadow: 0 0 8px rgba(191,255,0,0.4); }
.h-delta.down { color: var(--p2-color); text-shadow: 0 0 8px rgba(255,0,85,0.4); }
.h-main { flex: 1; color: var(--ink-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h-date { color: var(--ink-faint); font-size: 0.72rem; white-space: nowrap; }
.history-empty { color: var(--ink-faint); font-size: 0.85rem; padding: 10px; text-align: center; }

/* ===== SOUND TOGGLE ===== */

.sound-toggle {
    position: fixed;
    top: calc(14px + env(safe-area-inset-top));
    right: calc(14px + env(safe-area-inset-right));
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: color-mix(in oklab, var(--surface) 85%, transparent);
    border: 1px solid var(--edge);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.15rem;
    z-index: var(--z-sticky);
    transition: border-color var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out);
}
.sound-toggle:hover { border-color: var(--accent); box-shadow: 0 0 14px oklch(0.85 0.16 195 / 0.25); }
.sound-toggle.muted { opacity: 0.55; }

body.on-landing > h1 { display: none; }

/* ===== LANDING (v3) ===== */

#landing-screen { max-width: none; }

.lp-nav {
    width: 100%;
    max-width: 1100px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 20px;
}
.lp-nav-brand {
    font-family: var(--font-display);
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-size: 1.05rem;
    text-shadow: 0 0 14px oklch(0.85 0.16 195 / 0.4);
}
.ic {
    width: 1em;
    height: 1em;
    vertical-align: -0.14em;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.ic-fill { fill: currentColor; stroke: none; }

.lp-nav-links { display: flex; gap: 4px; }
.lp-nav-links button {
    background: transparent;
    border: none;
    color: var(--ink-muted);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 8px 12px;
}
.lp-nav-links button:hover { color: var(--ink); box-shadow: none; }
.lp-nav-right { display: flex; align-items: center; gap: 8px; }
.lp-nav-account {
    background: transparent;
    border: 1px solid var(--edge);
    border-radius: 30px;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 9px 14px;
    color: var(--ink-muted);
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.lp-nav-account:hover { color: var(--ink); border-color: var(--accent); }

.lp-nav-cta {
    border-radius: 30px;
    font-size: 0.82rem;
    font-weight: 700;
    padding: 9px 18px;
    border: 1px solid var(--accent);
    color: var(--accent);
    background: transparent;
}
.lp-nav-cta:hover { background: oklch(0.85 0.16 195 / 0.1); }

.hero {
    position: relative;
    min-height: calc(100dvh - 110px);
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: clamp(18px, 3.5vh, 34px);
    padding: 24px 18px;
    text-align: center;
}

.hero-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: clamp(22px, 4vw, 48px);
    align-items: center;
    width: 100%;
    max-width: 1040px;
}
.hero-copy { display: flex; flex-direction: column; align-items: center; gap: clamp(12px, 2.2vh, 20px); }
.hero-stage { display: flex; flex-direction: column; align-items: center; gap: 14px; animation: wordmarkIn 700ms var(--ease-out) 60ms both; }

@media (min-width: 880px) {
    .hero-grid { grid-template-columns: 1.05fr 1fr; }
    .hero-copy { align-items: flex-start; text-align: left; }
    .hero-copy .hero-tagline { text-align: left; }
}

.hero-wordmark {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(2.1rem, 8.6vw, 4.6rem);
    letter-spacing: 0.02em;
    text-transform: uppercase;
    margin: 0;
    line-height: 1;
    color: var(--ink);
    /* chromatic-aberration fringe: cyan ghost right, magenta ghost left */
    text-shadow:
        0.03em 0 0 rgba(0, 255, 242, 0.7),
        -0.03em 0 0 rgba(255, 0, 85, 0.7),
        0 0 28px rgba(255, 255, 255, 0.28),
        0 0 80px oklch(0.85 0.16 195 / 0.3);
    animation: wordmarkIn 700ms var(--ease-out) both,
               glitchTwitch 7s 2.2s infinite;
}
@keyframes glitchTwitch {
    0%, 93.4%, 96.2%, 100% { transform: none; }
    94% { transform: skewX(-7deg) translateX(-3px); }
    95% { transform: skewX(5deg) translateX(3px); }
}

.hero-tagline-loud {
    font-family: var(--font-display);
    font-weight: 500;
    font-style: italic;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: clamp(0.95rem, 2.6vw, 1.35rem);
    color: var(--p2-color);
    text-shadow: 0 0 16px rgba(255, 0, 85, 0.55);
    margin: 0;
    animation: wordmarkIn 700ms var(--ease-out) 80ms both;
}
@keyframes wordmarkIn {
    from { opacity: 0; transform: translateY(18px) scale(0.97); filter: blur(6px); }
    to { opacity: 1; transform: none; filter: blur(0); }
}

.hero-tagline {
    color: var(--ink-muted);
    font-size: clamp(1rem, 2.4vw, 1.2rem);
    max-width: 44ch;
    margin: 0;
    line-height: 1.6;
    animation: wordmarkIn 700ms var(--ease-out) 120ms both;
}

/* The framed, rim-lit, tilted stage from the mockup. The frame carries the
   perspective so the board's own layout stays flat inside it. */
.board-frame {
    position: relative;
    padding: 14px 14px 4px;
    background: oklch(0.16 0.02 275);
    border-radius: 18px;
    border: 1px solid oklch(0.45 0.1 260 / 0.55);
    transform: perspective(1200px) rotateX(26deg) rotateZ(-3deg);
    box-shadow:
        0 40px 90px rgba(0,0,0,0.65),
        inset 0 1px 0 rgba(255,255,255,0.05);
}
/* neon rim: a blurred conic ring glowing behind the frame */
.board-frame::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 20px;
    background: conic-gradient(from 210deg,
        rgba(0, 255, 242, 0.8), rgba(120, 80, 255, 0.6),
        rgba(255, 0, 85, 0.8), rgba(120, 80, 255, 0.6),
        rgba(0, 255, 242, 0.8));
    filter: blur(14px);
    opacity: 0.45;
    z-index: -1;
}

#demo-board {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 5px;
    width: min(74vw, 40dvh, 360px);
    height: min(74vw, 40dvh, 360px);
    background: oklch(0.12 0.015 275);
    padding: 8px;
    border-radius: 10px;
}
#demo-board .cell { cursor: default; }

@keyframes burstOut {
    0% { transform: scale(0.3); opacity: 1; }
    100% { transform: scale(1.5); opacity: 0; }
}

.ds-turn {
    position: absolute;
    top: -13px;
    right: 16px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
    background: oklch(0.16 0.02 275);
    border: 1px solid oklch(0.85 0.16 195 / 0.5);
    box-shadow: 0 0 12px oklch(0.85 0.16 195 / 0.3);
    border-radius: 20px;
    padding: 4px 12px;
    z-index: 1;
}

.demo-score {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 16px;
    padding: 10px 6px 8px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-size: 0.95rem;
}
.ds-side b { font-size: 1.3rem; margin: 0 2px; }
.ds-cyan { color: var(--p1-color); text-shadow: 0 0 12px rgba(0, 255, 242, 0.5); }
.ds-magenta { color: var(--p2-color); text-shadow: 0 0 12px rgba(255, 0, 85, 0.5); }
.ds-vs { font-family: var(--font-display); font-style: italic; font-size: 0.8rem; color: var(--ink-muted); }

/* 4-up neon feature row in the first fold, like the probe's bottom strip */
.hero-features {
    width: 100%;
    max-width: 1040px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 4px;
    background: color-mix(in oklab, var(--surface) 80%, transparent);
    border: 1px solid var(--edge);
    border-radius: var(--radius);
    padding: 14px;
    animation: wordmarkIn 700ms var(--ease-out) 280ms both;
}
.hf { display: grid; grid-template-columns: 30px 1fr; grid-template-rows: auto auto; column-gap: 12px; padding: 10px 12px; text-align: left; align-items: center; }
.hf svg { width: 24px; height: 24px; grid-row: 1 / 3; color: var(--hf); filter: drop-shadow(0 0 8px var(--hf)); }
.hf strong { font-size: 0.88rem; letter-spacing: 0.03em; }
.hf span { color: var(--ink-faint); font-size: 0.78rem; line-height: 1.45; }

.hero-ctas { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; animation: wordmarkIn 700ms var(--ease-out) 200ms both; }
.cta-primary {
    background: var(--accent);
    color: #041413;
    border: none;
    font-weight: 700;
    font-size: 1.05rem;
    padding: 15px 38px;
    border-radius: 40px;
    box-shadow: 0 0 26px oklch(0.85 0.16 195 / 0.5);
}
.cta-primary:hover { transform: translateY(-2px); box-shadow: 0 0 40px oklch(0.85 0.16 195 / 0.65); }
.cta-secondary {
    background: transparent;
    border: 1px solid var(--edge);
    font-size: 1.05rem;
    padding: 15px 30px;
    border-radius: 40px;
}

/* faint CRT scanlines over the first fold — texture, not gimmick */
.hero::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(0deg,
        rgba(255,255,255,0.016) 0 1px, transparent 1px 3px);
    pointer-events: none;
}

.hero-chips {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 14px 0 0;
    animation: wordmarkIn 700ms var(--ease-out) 240ms both;
}
.hero-chips span {
    color: var(--ink-muted);
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--edge);
    border-radius: 999px;
    padding: 5px 12px;
    background: oklch(0.19 0.016 290 / 0.7);
}

.hero-links {
    display: flex;
    gap: 18px;
    justify-content: center;
    flex-wrap: wrap;
    animation: wordmarkIn 700ms var(--ease-out) 240ms both;
}
.hero-links button {
    background: transparent;
    border: none;
    color: var(--ink-muted);
    font-size: 0.86rem;
    font-weight: 600;
    padding: 6px 10px;
}
.hero-links button:hover { color: var(--ink); box-shadow: none; }

@media (min-width: 880px) {
    .hero-copy .hero-links { justify-content: flex-start; }
}

.hero-scroll-hint {
    color: var(--ink-muted);
    font-size: 0.88rem;
    font-weight: 600;
    background: transparent;
    border: none;
    padding: 10px 16px;
    cursor: pointer;
    animation: hintFloat 2.4s ease-in-out infinite;
}
.hero-scroll-hint:hover { color: var(--accent); }
@keyframes hintFloat { 0%,100% { transform: translateY(0); opacity: 0.6; } 50% { transform: translateY(6px); opacity: 1; } }

.ds-live-label {
    position: absolute;
    top: -12px;
    left: 18px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-display);
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    color: var(--ink-muted);
    background: var(--surface);
    border: 1px solid var(--edge);
    border-radius: 999px;
    padding: 4px 10px;
}

.lp-section {
    width: 100%;
    max-width: 900px;
    padding: clamp(36px, 7.5vh, 74px) 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 26px;
}
.lp-section h2 { font-size: clamp(1.5rem, 4vw, 2.2rem); margin: 0; text-align: center; }
.lp-section > p { color: var(--ink-muted); max-width: 56ch; text-align: center; line-height: 1.65; margin: 0; }

.lp-moves { display: flex; gap: 22px; flex-wrap: wrap; justify-content: center; }
.lp-move {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: min(240px, 84vw);
}
.lp-move-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    width: 132px;
    height: 132px;
    background: var(--board-bg);
    padding: 6px;
    border-radius: 10px;
    border: 1px solid var(--edge);
}
.lp-move h3 { margin: 0; font-size: 1.05rem; }
.lp-move p { margin: 0; color: var(--ink-muted); font-size: 0.88rem; text-align: center; line-height: 1.55; }

.lp-features { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 560px; }
.lp-feature {
    display: flex;
    align-items: baseline;
    gap: 14px;
    padding: 16px 18px;
    background: color-mix(in oklab, var(--surface) 82%, transparent);
    border: 1px solid var(--edge);
    border-radius: var(--radius);
    text-align: left;
}
.lp-feature .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; transform: translateY(-1px); }
.lp-feature strong { display: block; margin-bottom: 3px; }
.lp-feature span { color: var(--ink-muted); font-size: 0.9rem; line-height: 1.5; }

/* End-of-game announcement */
.endfx {
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-modal) + 5);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.endfx-word {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(2.6rem, 11vw, 6rem);
    letter-spacing: 0.12em;
    animation: endWord 2.4s var(--ease-out) forwards;
}
.endfx-win .endfx-word { color: var(--p1-color); text-shadow: 0 0 34px oklch(0.85 0.16 195 / 0.9), 0 0 80px oklch(0.85 0.16 195 / 0.5); }
.endfx-lose .endfx-word { color: var(--p2-color); text-shadow: 0 0 30px oklch(0.6 0.24 10 / 0.8); }
.endfx-draw .endfx-word { color: var(--ink-muted); text-shadow: 0 0 24px rgba(255,255,255,0.35); }
@keyframes endWord {
    0% { opacity: 0; transform: scale(0.6); filter: blur(6px); }
    18% { opacity: 1; transform: scale(1.06); filter: blur(0); }
    30% { transform: scale(1); }
    78% { opacity: 1; }
    100% { opacity: 0; transform: scale(1.04); }
}
.endfx-p {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--c);
    box-shadow: 0 0 12px var(--c);
    opacity: 0;
    animation: endBurst 1.6s var(--ease-out) forwards;
}
@keyframes endBurst {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.3); }
}
@media (prefers-reduced-motion: reduce) {
    .endfx-word { animation: none; opacity: 1; }
    .endfx-p { display: none; }
}

/* In-game music menu: anchored above the controls row */
/* Must out-specify .lp-menu-panel (defined later in this file): with equal
   specificity its top/right values win and the popover stretches to fill
   the viewport — shipped that way in v4.10.3, caught in the v4.11.1 gate. */
.lp-menu-panel.music-menu {
    top: auto;
    bottom: 84px;
    right: auto;
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: min(92vw, 340px);
    max-height: min(70vh, 540px);
    overflow-y: auto;
}
.music-menu .mm-vols {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 214px;
    padding: 6px 12px 12px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--edge);
}
.music-menu .mm-vols label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.78rem;
    color: var(--ink-muted);
}
.music-menu .mm-vols span { width: 52px; flex-shrink: 0; }
.music-menu .mm-vols input[type="range"] { flex: 1; min-width: 0; }

/* Modal close ✕ + API docs modal */
.modal-x {
    position: absolute;
    top: 10px;
    right: 12px;
    background: transparent;
    border: none;
    color: var(--ink-faint);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 6px;
    line-height: 1;
}
.modal-x:hover { color: var(--ink); }
.name-modal { position: relative; }
.api-modal {
    max-width: min(860px, 94vw);
    width: 94vw;
    text-align: left;
    padding: 40px 18px 18px;
}
.api-modal iframe {
    width: 100%;
    height: min(72vh, 640px);
    border: 1px solid var(--edge);
    border-radius: var(--radius-sm);
    background: #0e0916;
}

/* Leaderboard podium + rows */
.lb-podium {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 10px;
    margin: 16px 0 6px;
}
.lb-pod {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    width: 118px;
    padding: 14px 8px 12px;
    background: var(--surface-2);
    border: 1px solid var(--edge);
    border-radius: var(--radius);
    font-size: 0.82rem;
}
.lb-pod[onclick] { cursor: pointer; }
.lb-pod[onclick]:hover { border-color: var(--accent); }
.lb-pod b { color: var(--ink); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-pod-1 {
    width: 132px;
    padding-top: 18px;
    padding-bottom: 20px;
    border-color: oklch(0.6 0.1 90 / 0.6);
    box-shadow: 0 0 24px -6px oklch(0.8 0.14 90 / 0.45);
}
.lb-pod-medal { font-size: 1.3rem; }
.lb-pod .av { width: 40px; height: 40px; }
.lb-pod-1 .av { width: 48px; height: 48px; }
.lb-pod-elo { font-weight: 800; color: var(--accent); font-size: 1.05rem; }
.lb-rows { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.lb-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--surface-2);
    border: 1px solid var(--edge);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
}
.lb-row.lb-me { border-color: var(--accent); }
.lb-rank { color: var(--ink-faint); width: 34px; }
.lb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-stats { color: var(--ink-muted); white-space: nowrap; font-size: 0.8rem; }
.lb-stats b { color: var(--ink); }

/* FluxDots Score tier chips */
.tier-chip {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--tier);
    border: 1px solid color-mix(in oklab, var(--tier) 55%, transparent);
    border-radius: 999px;
    padding: 1px 8px;
    vertical-align: 1px;
}
.tier-chip.provisional { opacity: 0.55; border-style: dashed; }

/* Bot Arena roster */
.arena-roster {
    display: flex;
    gap: 14px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 18px 0;
}
.arena-bot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 200px;
    padding: 18px 14px;
    background: var(--surface);
    border: 1px solid var(--edge);
    border-radius: var(--radius);
    color: var(--ink-muted);
    cursor: pointer;
    transition: border-color var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out);
}
.arena-bot:hover { border-color: var(--accent); transform: translateY(-2px); }
.arena-bot .arena-av { font-size: 1.8rem; }
.arena-bot b { color: var(--ink); font-size: 1.05rem; }
.arena-bot span:last-child { font-size: 0.78rem; line-height: 1.4; }
.arena-byo { max-width: 560px; }
.arena-byo a { color: var(--accent); }

.lp-section-tight { padding-top: clamp(20px, 4vh, 40px); }
.lp-footer { color: var(--ink-faint); font-size: 0.8rem; padding: 26px 20px 46px; text-align: center; }
.lp-footer a { color: var(--ink-muted); text-decoration: none; }
.lp-footer-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px 20px;
    margin-bottom: 12px;
}
.lp-footer-links button, .lp-footer-links a {
    background: transparent;
    border: none;
    color: var(--ink-muted);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 2px;
}
.lp-footer-links button:hover, .lp-footer-links a:hover { color: var(--accent); }

/* Scroll reveals: content is visible by default; fx.js opts elements in only
   when JS runs and motion is allowed, so nothing can ship hidden. */
.reveal-armed { opacity: 0; transform: translateY(22px); }
.reveal-in { opacity: 1; transform: translateY(0); transition: opacity 600ms var(--ease-out), transform 600ms var(--ease-out); }

/* ===== MOBILE ===== */

/* Compact phone menu */
.lp-nav-menu-btn {
    display: none;
    background: transparent;
    border: 1px solid var(--edge);
    border-radius: 30px;
    color: var(--ink);
    padding: 7px 11px;
    font-size: 1rem;
    cursor: pointer;
}
.lp-nav-menu-btn .av { width: 24px; height: 24px; font-size: 0.7rem; }
.lp-menu-panel {
    position: fixed;
    top: 56px;
    right: 12px;
    z-index: var(--z-modal);
    display: none;
    flex-direction: column;
    min-width: 210px;
    background: var(--surface);
    border: 1px solid var(--edge);
    border-radius: var(--radius);
    padding: 8px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.6);
}
.lp-menu-panel.visible { display: flex; }
.lp-menu-panel button {
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: none;
    color: var(--ink-muted);
    font-size: 0.92rem;
    font-weight: 600;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    text-align: left;
    cursor: pointer;
}
.lp-menu-panel button:hover { background: var(--surface-2); color: var(--ink); }

/* Desktop: Multiplayer is the emphasized header action; Install stays quiet */
.lp-nav-mp { border-color: var(--accent); box-shadow: 0 0 14px oklch(0.85 0.16 195 / 0.25); }
.lp-nav-install { color: var(--ink-muted); }

@media (max-width: 640px) {
    /* One-row header: brand + menu (everything else lives in the menu) */
    .lp-nav { padding-right: 76px; } /* clear the fixed sound toggle */
    .lp-nav-links { display: none; }
    .lp-nav-cta { display: none; }        /* Multiplayer lives in the hero CTAs */
    .lp-nav-account { display: none !important; }  /* account lives in the menu */
    .lp-nav-menu-btn { display: inline-flex; align-items: center; }
    .board-frame { transform: perspective(1100px) rotateX(16deg); }
}

@media (max-width: 480px) {
    h1 { font-size: 1.1rem; margin: 2px 0; }

    .menu-card { padding: 20px 16px; width: 94%; }
    .menu-btn { padding: 14px 12px; min-height: 48px; }
    .opt-btn { min-height: 44px; }
    .open-game-join, .chat-send-btn, .kick-btn { min-height: 40px; }

    /* Compact translucent sheet — the board stays visible above it */
    .chat-container {
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 36dvh;
        max-height: 320px;
        background: color-mix(in oklab, var(--surface) 72%, transparent);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border-radius: var(--radius) var(--radius) 0 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
        padding-bottom: env(safe-area-inset-bottom);
    }
    .chat-header { padding: 8px 14px; }

    /* While the chat sheet is open, the board steps down so every row stays
       tappable above the sheet. */
    .board { transition: width 250ms var(--ease-out), height 250ms var(--ease-out); }
    body.chat-open .board {
        width: min(62vw, calc(100dvh - 480px), 420px);
        height: min(62vw, calc(100dvh - 480px), 420px);
    }

    .scoreboard { gap: 6px; padding: 6px; }
    .score-box { min-width: 64px; }
}

@media (hover: none) {
    .cell.valid-move::after { opacity: 0.85; }
    button:hover { transform: none; }
}

/* ===== REDUCED MOTION ===== */

@media (prefers-reduced-motion: reduce) {
    .screen, .hero-wordmark, .hero-tagline, .hero-tagline-loud, .hero-ctas, .hero-stage, .hero-features { animation: none; }
    .burst { animation: none; opacity: 0; }
    .piece.new, .piece.pop { animation: none; }
    .piece.convert { animation: convertFade 300ms ease-out; }
    .piece.convert::after { animation: none; opacity: 0; }
    @keyframes convertFade { from { filter: brightness(1.8); } to { filter: brightness(1); } }
    .cell.valid-move::after { animation: none; opacity: 0.75; }
    .hero-scroll-hint { animation: none; }
    .reveal-armed { opacity: 1; transform: none; }
    * { transition-duration: 1ms !important; }
}

/* ===== DASHBOARD (profile) ===== */

#profile-screen.screen, #agent-profile-screen.screen { max-width: 960px; }

/* Agent page extras */
.ag-head-main { display: flex; align-items: center; gap: 14px; min-width: 0; flex: 1; }
.ag-live-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: transparent;
    border: 1px solid oklch(0.45 0.12 10 / 0.55);
    color: var(--p2-color);
    border-radius: 999px;
    padding: 7px 14px;
    font-family: var(--font-display);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    cursor: pointer;
}
.ag-live-btn:hover { background: oklch(0.3 0.08 10 / 0.3); }
.ag-rank-chip {
    color: var(--ink-muted);
    font-size: 0.78rem;
    border: 1px solid var(--edge);
    border-radius: 999px;
    padding: 3px 10px;
    background: var(--surface-2);
    white-space: nowrap;
}
.ag-greeting { color: var(--ink-muted); font-style: italic; margin: 12px 0 0; }

.dash {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 14px;
    text-align: left;
    margin: 12px 0 34px;
    padding: 0 12px;
}
.panel {
    background: var(--surface);
    border: 1px solid var(--edge);
    border-radius: var(--radius);
    padding: 16px 18px;
    min-width: 0;
}
.panel > h3 { margin: 0 0 12px; font-size: 1rem; }

.dash-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
@media (max-width: 560px) {
    /* the floating sound toggle owns the top-right corner on phones */
    .dash-head { flex-direction: column; align-items: flex-start; }
}
.dash-id { display: flex; align-items: center; gap: 14px; min-width: 0; }
.dash-id h2 { margin: 0; font-size: 1.3rem; overflow-wrap: anywhere; }
.dash-id #profile-email { color: var(--ink-faint); font-size: 0.8rem; }
.dash-avbtn { background: transparent; border: none; color: var(--ink-faint); font-size: 0.76rem; cursor: pointer; padding: 3px 0 0; }
.dash-avbtn:hover { color: var(--ink-muted); }

.dash-grid { display: grid; grid-template-columns: 1fr; gap: 14px; align-items: start; }
@media (min-width: 880px) { .dash-grid { grid-template-columns: 1fr 1fr; } }
.dash-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.dash-foot { display: flex; gap: 8px; }

.act-h {
    margin: 14px 0 6px;
    font-size: 0.72rem;
    color: var(--ink-faint);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.act-h:first-of-type { margin-top: 0; }

/* Elo sparkline + win-rate bar */
#elo-spark { margin-top: 14px; }
#elo-spark svg { display: block; width: 100%; height: 56px; }
.spark-cap, .winbar-cap { color: var(--ink-faint); font-size: 0.72rem; margin-top: 5px; }
.winbar {
    display: flex;
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    margin-top: 12px;
    background: var(--cell-bg);
}
.winbar .w { background: var(--p1-color); box-shadow: 0 0 8px rgba(0, 255, 242, 0.5); }
.winbar .l { background: var(--p2-color); }

/* Agents panel */
.agent-row {
    border: 1px solid var(--edge);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 8px;
    background: var(--surface-2);
}
.agent-row-main { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.agent-row-main:hover b { color: var(--accent); }
.agent-row-id { flex: 1; min-width: 0; }
.agent-status { color: var(--ink-faint); font-size: 0.72rem; margin-top: 2px; }
.status-dot {
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--p3-color);
    box-shadow: 0 0 6px var(--p3-color);
    vertical-align: 1px;
    margin-right: 3px;
}
.status-dot.off { background: var(--p2-color); box-shadow: 0 0 6px var(--p2-color); }
.agent-elo { text-align: right; font-size: 0.74rem; color: var(--ink-muted); white-space: nowrap; line-height: 1.35; }
.agent-elo b { color: var(--accent); font-size: 0.95rem; }
.agent-row-actions { display: flex; gap: 6px; margin-top: 9px; justify-content: flex-end; }
.agent-empty p { color: var(--ink-muted); font-size: 0.85rem; margin: 0 0 8px; line-height: 1.5; }
.agent-empty a { color: var(--accent); }

/* ===== SPECTATING + REPLAYS ===== */

.live-games-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 22px 0 8px;
    font-family: var(--font-display);
    font-size: 0.95rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.live-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--p2-color);
    box-shadow: 0 0 8px var(--p2-color);
    animation: livePulse 1.6s ease-in-out infinite;
}
@keyframes livePulse { 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

/* Setup disclosure */
.setup-disclosure {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin: 10px 0 4px;
    padding: 10px;
    background: transparent;
    border: 1px solid var(--edge);
    border-radius: var(--radius-sm);
    color: var(--ink-muted);
    font-weight: 600;
    cursor: pointer;
}
.setup-disclosure:hover { color: var(--ink); border-color: var(--accent); }
.setup-disclosure .chev { display: inline-block; transition: transform var(--t-fast) var(--ease-out); }
.setup-summary {
    color: var(--ink-faint);
    font-size: 0.74rem;
    font-weight: 500;
    border: 1px solid var(--edge);
    border-radius: 999px;
    padding: 2px 9px;
    background: var(--surface-2);
}
#setup-start {
    position: sticky;
    bottom: 10px;
    z-index: 2;
    box-shadow: 0 -12px 24px -12px rgba(0,0,0,0.8), 0 0 18px oklch(0.85 0.16 195 / 0.25);
}

/* Landing live-battles ticker */
.live-ticker {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 7px 18px;
    border-top: 1px solid var(--edge);
    border-bottom: 1px solid var(--edge);
    background: oklch(0.17 0.02 290 / 0.75);
    overflow: hidden;
}
.lt-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 0;
    font-family: var(--font-display);
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    color: var(--p2-color);
}
.lt-viewport {
    overflow: hidden;
    flex: 1;
    -webkit-mask-image: linear-gradient(90deg, transparent, black 5%, black 95%, transparent);
    mask-image: linear-gradient(90deg, transparent, black 5%, black 95%, transparent);
}
.lt-track {
    display: inline-flex;
    align-items: center;
    gap: 16px;
    white-space: nowrap;
    width: max-content;
    animation: ltScroll linear infinite;
}
.lt-track:hover { animation-play-state: paused; }
@keyframes ltScroll { to { transform: translateX(-50%); } }
.lt-item {
    background: transparent;
    border: none;
    color: var(--ink-muted);
    font-size: 0.82rem;
    cursor: pointer;
    padding: 0;
}
.lt-item b { color: var(--ink); font-weight: 600; }
.lt-item span { color: var(--ink-faint); font-size: 0.75rem; }
.lt-item:hover b { color: var(--accent); }
.lt-sep { color: var(--ink-faint); margin: 0 4px; }
@media (prefers-reduced-motion: reduce) {
    .lt-track { animation: none; }
    .lt-viewport { overflow-x: auto; mask-image: none; -webkit-mask-image: none; }
}

.watch-head {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.live-pill, .replay-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-display);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--edge);
    background: var(--surface-2);
}
.live-pill { color: var(--p2-color); border-color: oklch(0.45 0.12 10 / 0.55); }
.replay-pill { color: var(--accent); border-color: oklch(0.45 0.09 195 / 0.55); }
.watch-players { font-weight: 700; }
.watch-vs { color: var(--ink-faint); font-weight: 400; font-size: 0.8rem; }
.watch-status { color: var(--ink-muted); font-size: 0.82rem; margin: 6px 0 10px; min-height: 1.2em; }
.watch-frame { margin: 0 auto; max-width: 100%; }
/* The game board's viewport-based width can exceed the card on phones —
   inside watch/replay cards it must fit its container instead. */
.watch-frame .board {
    width: min(100%, 340px, calc(100dvh - 330px));
    height: auto;
    aspect-ratio: 1 / 1;
}
.watch-scores { display: flex; justify-content: center; gap: 16px; margin-top: 12px; font-size: 0.9rem; }
.watch-badge {
    font-size: 0.78rem;
    color: var(--ink-muted);
    border: 1px solid var(--edge);
    border-radius: 999px;
    padding: 3px 9px;
    background: var(--surface-2);
}
.pcol-1 { color: var(--p1-color); }
.pcol-2 { color: var(--p2-color); }
.pcol-3 { color: var(--p3-color); }
.pcol-4 { color: var(--p4-color); }
.replay-controls { display: flex; justify-content: center; gap: 8px; margin-top: 14px; }
.replay-controls .mini-btn { min-width: 44px; }

/* Panel entrance — enhance-only (visible without animation) */
.dash > *, .dash-col > .panel { animation: dashIn 360ms var(--ease-out) backwards; }
.dash-col > .panel:nth-child(2) { animation-delay: 60ms; }
.dash-grid .dash-col:last-child > .panel { animation-delay: 110ms; }
@keyframes dashIn { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) {
    .dash > *, .dash-col > .panel { animation: none; }
}
