/* ──────────────────────────────────────────────────────────────────────────
   Clarity — minimal high-contrast theme with editorial display type.
   Coexists with alt-theme.css; theme picker in footer toggles between them.
   Variable names match alt-theme.css so shared CSS (admin.css, etc.) works.
   ────────────────────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&family=Newsreader:opsz,wght@6..72,400;6..72,500;6..72,600;6..72,700&display=swap');

:root {
    /* ── Surfaces ──────────────────────────────────────────────────────── */
    --background:       #0b0d10;
    --surface:          #14171c;
    --card-bg:          #1a1e24;
    --input-bg:         #11141a;
    --border:           #262b33;
    --border-strong:    #353c47;
    --shadow:           0 1px 0 rgba(255,255,255,0.03), 0 12px 32px rgba(0,0,0,0.5);

    /* ── Text ──────────────────────────────────────────────────────────── */
    --text:             #e7ebf0;
    --text-main:        var(--text);
    --text-primary:     var(--text);
    --text-secondary:   #9aa3ae;
    --muted:            #6b7380;

    /* ── Accents ──────────────────────────────────────────────────────── */
    /* Burnt amber — warm, editorial, pairs with Fraunces serif. */
    --accent:           #d97706;
    --accent-hover:     #ea8a1a;
    --accent-dim:       #92520a;
    --accent-soft:      rgba(217, 119, 6, 0.14);
    --accent-glow:      0 0 0 1px rgba(217, 119, 6, 0.4);
    --on-accent:        #1c0f00;  /* readable text on amber background */

    /* Semantic colours (named to match alt-theme.css contract). */
    --accent-blue:      #4aa8ff;       /* secondary info accent */
    --accent-blue-dim:  #2e6fb3;
    --accent-green:     #34d399;       /* correct / success */
    --accent-gold:      #f5c842;       /* ranked / medal */
    --accent-orange:    #f59e0b;       /* warn / timer mid */
    --accent-red:       #ef4444;       /* incorrect / danger strong */
    --success:          var(--accent-green);
    --warn:             var(--accent-orange);
    --danger:           #ef4444;
    --error:            #fca5a5;

    /* ── Spacing scale (compact) ──────────────────────────────────────── */
    --s-1: 0.25rem;
    --s-2: 0.5rem;
    --s-3: 0.75rem;
    --s-4: 1rem;
    --s-5: 1.5rem;
    --s-6: 2rem;
    --s-8: 3rem;

    /* ── Radii ────────────────────────────────────────────────────────── */
    --r-sm: 4px;
    --r-md: 8px;
    --r-lg: 12px;
    --r-xl: 16px;
    --r-full: 9999px;

    /* ── Typography ───────────────────────────────────────────────────── */
    --font-sans:     'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-display:  'Fraunces', 'Inter', Georgia, serif;     /* page titles, Game Over, headings */
    --font-question: 'Newsreader', 'Source Serif Pro', Georgia, serif;  /* the question itself */
    --font-mono:     ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* ── Reset / base ──────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--background);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.5;
    font-feature-settings: "cv11", "ss01";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.15s ease;
}
a:hover { color: var(--accent-hover); }

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 600;
    line-height: 1.2;
    margin: 0 0 var(--s-3);
    color: var(--text);
    letter-spacing: -0.01em;
}
h1 { font-size: 1.875rem; font-variation-settings: "opsz" 96; }
h2 { font-size: 1.5rem;   font-variation-settings: "opsz" 72; }
h3 { font-size: 1.25rem;  font-variation-settings: "opsz" 48; }

p { margin: 0 0 var(--s-3); }

/* Tabular numerals — use for scores, timers, percentages. */
.tnum, .final-stat-value, .final-leaderboard, .timer-val, .player-card-name {
    font-variant-numeric: tabular-nums;
}

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

button { cursor: pointer; }

/* ── Layout: header / footer / main ───────────────────────────────────── */

.main-nav {
    display: flex;
    align-items: center;
    gap: var(--s-4);
    padding: var(--s-3) var(--s-5);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 30;
}
.logo {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text);
    letter-spacing: -0.02em;
    font-variation-settings: "opsz" 96;
    margin-right: var(--s-4);
}
.logo:hover { color: var(--text); }
.nav-game-title {
    font-family: var(--font-display);
    font-style: italic;
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-right: auto;
}
.nav-toggle {
    display: none;
    background: transparent;
    border: 0;
    padding: var(--s-2);
    margin-left: auto;
}
.nav-toggle-bar {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-secondary);
    margin: 4px 0;
    border-radius: 2px;
    transition: background 0.15s;
}
.nav-toggle:hover .nav-toggle-bar { background: var(--text); }
.nav-links {
    display: flex;
    gap: var(--s-1);
    align-items: center;
    flex-wrap: wrap;
    margin-left: auto;
}
.nav-link {
    color: var(--text-secondary);
    padding: var(--s-2) var(--s-3);
    border-radius: var(--r-md);
    font-weight: 500;
    font-size: 0.875rem;
    transition: color 0.15s, background 0.15s;
}
.nav-link:hover     { color: var(--text); background: var(--accent-soft); }
.nav-link--active   { color: var(--accent); background: var(--accent-soft); }
.nav-admin-link     { color: var(--accent-gold); }
.nav-admin-link:hover { color: var(--accent-gold); background: rgba(245, 200, 66, 0.12); }

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: var(--s-5) var(--s-4);
}
/* Presenter view is meant for projector/TV — break it out of the 1100 px
   container so the sidebar latches to the left edge and the layout spans full width. */
.container:has(.presenter-wrap) {
    max-width: none;
    padding: 0;
    margin: 0;
}

@media (max-width: 768px) {
    .nav-toggle { display: block; }
    .nav-links {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        margin-top: var(--s-3);
        margin-left: 0;
    }
    body.nav-open .nav-links { display: flex; }
    .nav-link { padding: var(--s-3); }
}

/* ── Quick Start (lobby landing) ──────────────────────────────────────── */
.qs-section { margin-bottom: var(--s-5); }
.qs-label {
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.75rem;
    color: var(--muted);
    margin-bottom: var(--s-3);
}
.qs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--s-3);
}
.qs-card {
    display: flex;
    flex-direction: column;
    gap: var(--s-1);
    padding: var(--s-4);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    color: var(--text);
    transition: border-color 0.15s, transform 0.05s, background 0.15s;
}
.qs-card:hover {
    border-color: var(--accent);
    background: var(--surface);
    color: var(--text);
}
.qs-card:active { transform: translateY(1px); }
.qs-card--ranked { border-color: rgba(245, 200, 66, 0.4); }
.qs-card--ranked:hover { border-color: var(--accent-gold); }
.qs-icon { font-size: 1.5rem; }
.qs-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text);
}
.qs-desc {
    font-size: 0.8rem;
    color: var(--muted);
}

/* ── Lobby controls (create / search / filters) ──────────────────────── */
.lobby-create-form { margin-bottom: var(--s-4); }
.lobby-create-btn {
    background: var(--accent);
    color: var(--on-accent);
    border: 0;
    padding: var(--s-3) var(--s-5);
    border-radius: var(--r-md);
    font-weight: 600;
    font-size: 0.95rem;
    transition: background 0.15s;
}
.lobby-create-btn:hover { background: var(--accent-hover); }

/* Lobby controls — search prominent on top (own row), filters and ELO chip
   smaller and quieter on a second row. Reduces the wall-of-pills feel. */
.lobby-controls {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
    align-items: center;
    margin-bottom: var(--s-4);
}
.lobby-search {
    flex: 1 0 100%;          /* forces a line break before filters */
    padding: var(--s-3);
    font-size: 0.95rem;
}
.lobby-filter-group {
    display: inline-flex;
    gap: 0;
    padding: 2px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
}
.lobby-filter-btn {
    background: transparent;
    border: 0;
    color: var(--muted);
    padding: 4px var(--s-3);
    font-size: 0.78rem;
    font-weight: 500;
    border-radius: var(--r-sm);
    transition: background 0.15s, color 0.15s;
}
.lobby-filter-btn:hover { color: var(--text); }
.lobby-filter-btn--active {
    background: var(--accent);
    color: var(--on-accent);
}
.lobby-elo-badge {
    margin-left: auto;
    padding: 4px var(--s-3);
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: var(--r-full);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ── Games table ──────────────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; }
.games-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
}
.games-table th,
.games-table td {
    padding: var(--s-3) var(--s-4);
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.games-table th {
    background: var(--surface);
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.72rem;
    font-weight: 600;
}
.games-table tr:last-child td { border-bottom: 0; }
.lobby-game-row {
    cursor: pointer;
    transition: background 0.1s;
}
.lobby-game-row:hover { background: var(--surface); }
.lobby-no-games-msg {
    text-align: center;
    padding: var(--s-6) !important;
    color: var(--muted);
    font-style: italic;
}

/* ── Status / mode / ranked badges ────────────────────────────────────── */
.lobby-status-open,
.lobby-status-playing,
.mode-badge,
.ranked-badge {
    display: inline-block;
    padding: 2px var(--s-2);
    border-radius: var(--r-full);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.4;
}
.lobby-status-open {
    background: rgba(52, 211, 153, 0.12);
    color: var(--accent-green);
}
.lobby-status-playing {
    background: rgba(245, 158, 11, 0.12);
    color: var(--accent-orange);
}
.mode-badge--movies {
    background: rgba(74, 168, 255, 0.12);
    color: var(--accent-blue);
    margin-right: var(--s-1);
}
.mode-badge--geo {
    background: rgba(52, 211, 153, 0.12);
    color: var(--accent-green);
    margin-right: var(--s-1);
}
.ranked-badge--active {
    background: rgba(245, 200, 66, 0.12);
    color: var(--accent-gold);
}
.ranked-badge--inactive {
    background: var(--input-bg);
    color: var(--muted);
}
.gameset-random {
    color: var(--muted);
    font-style: italic;
}

/* ── Game info modal ──────────────────────────────────────────────────── */
.game-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: var(--s-4);
}
.game-modal-overlay.is-open { display: flex; }
.game-modal {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: var(--s-6);
    max-width: 480px;
    width: 100%;
    box-shadow: var(--shadow);
    position: relative;
}
.game-modal-close {
    position: absolute;
    top: var(--s-3);
    right: var(--s-3);
    background: transparent;
    border: 0;
    color: var(--text-secondary);
    font-size: 1.5rem;
    line-height: 1;
    padding: var(--s-1) var(--s-2);
    border-radius: var(--r-md);
    transition: background 0.15s, color 0.15s;
}
.game-modal-close:hover { background: var(--surface); color: var(--text); }
.game-modal-title {
    font-family: var(--font-display);
    font-size: 1.4rem;
    margin: 0 0 var(--s-4);
    padding-right: var(--s-5);
}
.game-modal-info {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: var(--s-2) var(--s-4);
    margin-bottom: var(--s-5);
    font-size: 0.9rem;
}
.modal-label {
    color: var(--muted);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}
.game-modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
}
.game-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--s-2) var(--s-4);
    background: var(--accent);
    color: var(--on-accent);
    border: 0;
    border-radius: var(--r-md);
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s;
}
.game-action-btn:hover { background: var(--accent-hover); color: var(--on-accent); }
.game-action-btn--secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
}
.game-action-btn--secondary:hover { background: var(--card-bg); color: var(--text); }
.delete-btn { background: var(--danger); }
.delete-btn:hover { background: #f87171; }
.modal-delete-row { display: flex; gap: var(--s-2); align-items: center; }
.modal-delete-confirm-row { background: var(--input-bg); padding: var(--s-2); border-radius: var(--r-md); }
.modal-delete-prompt { color: var(--text-secondary); font-size: 0.85rem; }

.footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-4);
    padding: var(--s-3) var(--s-5);
    color: var(--muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}
.footer-theme-picker { display: flex; align-items: center; gap: var(--s-2); }
.footer-theme-label  { text-transform: uppercase; letter-spacing: 0.06em; }
.footer-theme-select {
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--r-sm);
    padding: 2px var(--s-2);
    font-size: 0.8rem;
}
.footer-version {
    margin-left: var(--s-2);
    opacity: 0.5;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
}

/* ── Buttons ──────────────────────────────────────────────────────────── */

.btn,
button.btn,
.game-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    padding: var(--s-3) var(--s-5);
    background: var(--accent);
    color: var(--on-accent);
    border: 1px solid transparent;
    border-radius: var(--r-md);
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1;
    text-decoration: none;
    transition: background 0.15s, transform 0.05s, box-shadow 0.15s;
}
.btn:hover, button.btn:hover, .game-action-btn:hover {
    background: var(--accent-hover);
    color: var(--on-accent);
}
.btn:active { transform: translateY(1px); }
.btn--secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-strong);
}
.btn--secondary:hover {
    background: var(--card-bg);
    color: var(--text);
}
.btn--danger {
    background: var(--danger);
}
.btn--danger:hover {
    background: #f87171;
}

/* ── Inputs ───────────────────────────────────────────────────────────── */

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], select, textarea {
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--s-2) var(--s-3);
    transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ── Cards & surfaces ─────────────────────────────────────────────────── */

.card, .panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--s-5);
}

/* ── Player game page (lobby + gameplay) ──────────────────────────────── */

.game-main-panel {
    margin-bottom: var(--s-4);
}
.game-chat-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--s-4);
    margin-top: var(--s-4);
}
@media (max-width: 768px) {
    .game-chat-panel { grid-template-columns: 1fr; }
}

/* Player sidebar */
#player-list-chat {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--s-4);
    height: 360px;
    overflow-y: auto;
}
.player-list-hd {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    margin-bottom: var(--s-3);
}
.player-list-hd-title {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.72rem;
    color: var(--muted);
    font-weight: 600;
}
.player-list-hd-count {
    background: var(--accent);
    color: var(--on-accent);
    border-radius: var(--r-full);
    padding: 1px var(--s-2);
    font-size: 0.7rem;
    font-weight: 700;
}
.player-cards {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
}
.player-card {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-2) var(--s-3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
}
.player-card-av {
    width: 32px;
    height: 32px;
    border-radius: var(--r-full);
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
    overflow: hidden;
}
.player-card-av img,
.player-card-av svg {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.player-card-info { flex: 1; min-width: 0; }
.player-card-name {
    font-weight: 500;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: var(--s-2);
    flex-wrap: wrap;
}
.player-tag {
    display: inline-block;
    padding: 1px var(--s-2);
    border-radius: var(--r-full);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1.4;
}
.player-tag--me {
    background: var(--accent-soft);
    color: var(--accent);
}
.player-tag--host {
    background: rgba(245, 200, 66, 0.14);
    color: var(--accent-gold);
}
.player-card-sub {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 2px;
}
.player-card-sub--ready  { color: var(--accent-green); }
.player-card-sub--unready { color: var(--muted); }
.player-card-sub--disc    { color: var(--accent-orange); font-style: italic; }
.player-card-sub--elo     { color: var(--text-secondary); font-variant-numeric: tabular-nums; }

.player-card-score {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    padding-left: var(--s-2);
}
.player-card-score--gold   { color: var(--accent-gold); }
.player-card-score--silver { color: #c0c4cc; }
.player-card-score--bronze { color: #c98044; }

.player-card-kick {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    width: 26px;
    height: 26px;
    border-radius: var(--r-full);
    padding: 0;
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.player-card-kick:hover {
    color: var(--danger);
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.08);
}
/* Armed state — first click of a two-click confirm. */
.player-card-kick--armed {
    color: var(--danger);
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.18);
    animation: arm-pulse 1.2s ease-in-out infinite;
}

/* Generic two-click armed state for destructive buttons (delete game,
   delete question, etc). Reuses the existing arm-pulse keyframe. */
.btn-armed {
    background: var(--danger) !important;
    color: white !important;
    border-color: var(--danger) !important;
    animation: arm-pulse 1.2s ease-in-out infinite;
}

.player-list-hd--spectators { margin-top: var(--s-3); }

/* Hide the bare "Status: LOBBY" text — the lobby card and gameplay panel
   already make the current phase obvious, so this is redundant noise. */
#game-status { display: none !important; }

/* Chat */
.game-chat-wrap {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--s-4);
    display: flex;
    flex-direction: column;
    height: 360px;
    transition: height 0.2s ease;
}

/* Collapsible chat toggle (injected by game-client.js). Hidden on desktop
   so the chat just shows as a normal panel; visible/sticky on mobile. */
.chat-toggle {
    display: none;
    align-items: center;
    gap: var(--s-2);
    width: 100%;
    background: transparent;
    border: 0;
    color: var(--text);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    padding: 0 0 var(--s-3);
    text-align: left;
}
.chat-toggle-label { flex: 1; }
.chat-toggle-chevron {
    color: var(--muted);
    font-size: 0.75rem;
    transition: transform 0.15s;
}
.chat-collapsed .chat-toggle-chevron {
    transform: rotate(-90deg);
}
.chat-unread {
    background: var(--accent);
    color: var(--on-accent);
    border-radius: var(--r-full);
    padding: 1px var(--s-2);
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 1.4em;
    text-align: center;
}

/* Mobile: show the toggle, collapse the chat by default, hide message/form
   when collapsed so the panel shrinks to a single row. */
@media (max-width: 768px) {
    .chat-toggle { display: flex; }
    .game-chat-wrap.chat-collapsed {
        height: auto;
        padding: var(--s-3) var(--s-4);
    }
    .game-chat-wrap.chat-collapsed > :not(.chat-toggle) {
        display: none;
    }
    .game-chat-wrap.chat-collapsed .chat-toggle {
        padding-bottom: 0;
    }
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    margin-bottom: var(--s-3);
    padding: var(--s-2) 0;
    font-size: 0.875rem;
    min-height: 160px;
    display: flex;
    flex-direction: column;
    gap: var(--s-1);
}
.chat-msg {
    padding: var(--s-2) var(--s-3);
    border-radius: var(--r-md);
    border-left: 2px solid transparent;
    background: var(--surface);
    min-width: 0;
}
.chat-msg--mine {
    background: var(--accent-soft);
    border-left-color: var(--accent);
}
.chat-meta {
    display: flex;
    align-items: baseline;
    gap: var(--s-2);
    margin-bottom: 2px;
}
.chat-from {
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--text);
}
.chat-msg--mine .chat-from { color: var(--accent); }
.chat-ts {
    color: var(--muted);
    font-size: 0.68rem;
    font-variant-numeric: tabular-nums;
}
.chat-body {
    font-size: 0.88rem;
    line-height: 1.4;
    color: var(--text);
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.chat-form {
    display: flex;
    gap: var(--s-2);
}
.chat-input-group { flex: 1; }
.chat-input {
    width: 100%;
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--s-2) var(--s-3);
}
.chat-send-btn {
    background: var(--accent);
    color: var(--on-accent);
    border: 0;
    padding: var(--s-2) var(--s-4);
    border-radius: var(--r-md);
    font-weight: 600;
}
.chat-send-btn:hover { background: var(--accent-hover); }
.game-id-info {
    margin-top: var(--s-3);
    color: var(--muted);
    font-size: 0.72rem;
    font-family: var(--font-mono);
    word-break: break-all;
}

/* ── Lobby phase (owner settings panel + share panel) ─────────────────── */

#lobby-actions { margin-bottom: var(--s-4); }

.lobby-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--s-4) var(--s-5);
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
}
.lobby-title-wrap {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    margin-bottom: var(--s-1);
}
.lobby-title-input {
    flex: 1;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font-display);
    font-size: 1.3rem;
    padding: var(--s-2) 0;
    font-weight: 600;
}
.lobby-title-input:focus {
    outline: none;
    border-bottom-color: var(--accent);
    box-shadow: none;
}

/* Section label sits inline-left of its controls when there's room. */
.lobby-section-label {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.68rem;
    color: var(--muted);
    font-weight: 600;
    margin: 0;
}

/* Mode grid (Regular / Presenter / Solo) — compact horizontal pills. */
.lobby-mode-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
}
.lobby-mode-btn {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: var(--s-2);
    padding: var(--s-2) var(--s-3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: var(--text);
    text-align: left;
    cursor: pointer;
    flex: 1 1 130px;
    min-width: 0;
    transition: border-color 0.15s, background 0.15s;
}
.lobby-mode-btn:hover { border-color: var(--accent-dim); }
.lobby-mode-btn--active {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.lmb-icon  { font-size: 1rem; flex-shrink: 0; }
.lmb-label { font-weight: 600; font-size: 0.88rem; }
.lmb-desc  { display: none; }  /* Tooltips/hover-only; saves vertical space. */

/* Question-type pill grid (Standard / Movies / Geography, decades, etc.) */
.lobby-qtype-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
}
.lobby-qtype-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: var(--s-2) var(--s-3);
    border-radius: var(--r-md);
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 500;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.lobby-qtype-btn:hover { color: var(--text); border-color: var(--accent-dim); }
.lobby-qtype-btn--active {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-soft);
}

/* Fields (questions / timer / max-players row, etc.) */
.lobby-fields {
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
}
.lobby-fields-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-3);
    align-items: flex-end;
}
.lobby-field {
    display: flex;
    flex-direction: column;
    gap: var(--s-1);
    flex: 1 1 140px;
    min-width: 0;
}
.lobby-field--full { flex: 1 1 100%; }
.lobby-field-label {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.65rem;
    color: var(--muted);
}
.lobby-field-input, .lobby-field-select {
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--s-2) var(--s-3);
    height: 36px;
}
.lobby-field-select--sm { font-size: 0.85rem; }

/* Pause-between-questions toggle. Sits in the prefs row next to scoring. */
.lobby-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0 var(--s-3);
    height: 36px;
    border-radius: var(--r-md);
    font-size: 0.85rem;
    cursor: pointer;
}
.lobby-toggle-label input { accent-color: var(--accent); margin: 0; }
.lobby-toggle-label input:disabled { opacity: 0.5; }
.lobby-toggle-text { color: var(--text-secondary); }
.lobby-toggle-label input:checked + .lobby-toggle-text { color: var(--accent); }

/* Visibility (public/private) toggle — aligns to the row baseline as a 36px chip. */
.lobby-vis-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0 var(--s-3);
    height: 36px;
    border-radius: var(--r-md);
    font-size: 0.85rem;
    cursor: pointer;
    flex: 0 0 auto;
    align-self: flex-end;
}
.lobby-vis-btn--private { border-color: var(--accent-orange); color: var(--accent-orange); }
.lobby-vis-btn--public  { color: var(--text-secondary); }

/* Mode badge (small chip) */
.lobby-mode-badge {
    display: inline-block;
    padding: 2px var(--s-2);
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: var(--r-full);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
}

/* Action buttons row (Start / Ready / Open presenter / Leave) */
.lobby-actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
}
.lobby-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--s-2) var(--s-5);
    background: var(--accent);
    color: var(--on-accent);
    border: 0;
    border-radius: var(--r-md);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}
.lobby-action-btn:hover { background: var(--accent-hover); color: var(--on-accent); }
.lobby-action-btn--start, .lobby-action-btn--ready {
    background: var(--accent-green);
    color: #062b1d;
}
.lobby-action-btn--start:hover, .lobby-action-btn--ready:hover { background: #4ade80; color: #062b1d; }
.lobby-action-btn--unready { background: var(--accent-orange); color: #2a1a06; }
.lobby-action-btn--secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
}
.lobby-action-btn--secondary:hover { background: var(--card-bg); color: var(--text); }
.lobby-action-btn--host {
    background: var(--accent-gold);
    color: #2a1f06;
}
.lobby-action-btn--host:hover { background: #fbd24a; color: #2a1f06; }

/* Share panel (QR + URL) */
.lobby-share-panel {
    margin-top: var(--s-3);
    padding: var(--s-4);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--s-3);
}
.lobby-share-title {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.75rem;
    color: var(--muted);
    margin: 0;
}
.lobby-share-link-row {
    display: flex;
    width: 100%;
    max-width: 480px;
    gap: var(--s-2);
}
.lobby-share-link-input {
    flex: 1;
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--accent);
    border-radius: var(--r-md);
    padding: var(--s-2);
    font-size: 0.8rem;
    font-family: var(--font-mono);
}
.lobby-share-copy-btn {
    background: var(--accent);
    color: var(--on-accent);
    border: 0;
    padding: var(--s-2) var(--s-4);
    border-radius: var(--r-md);
    font-weight: 600;
}
.lobby-share-qr {
    width: 180px;
    height: 180px;
    border-radius: var(--r-md);
    background: white;
    padding: var(--s-2);
}

/* Lobby summary (non-owner read-only view of settings) */
.lobby-summary {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: var(--s-2) var(--s-4);
    font-size: 0.9rem;
}
.lobby-summary-row { display: contents; }
.lobby-spectator-banner {
    background: var(--accent-soft);
    color: var(--accent);
    padding: var(--s-3);
    border-radius: var(--r-md);
    text-align: center;
    font-weight: 500;
    margin-bottom: var(--s-3);
}

.decade-badge {
    display: inline-block;
    margin-left: var(--s-1);
    padding: 0 var(--s-1);
    font-size: 0.65rem;
    color: var(--muted);
    background: var(--input-bg);
    border-radius: var(--r-full);
}

/* ── Gameplay panel: QUESTION phase ──────────────────────────────────── */

#gameplay-panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--s-5);
    display: flex;
    flex-direction: column;
    gap: var(--s-4);
    /* Pin a sensible min-height so the panel doesn't pop when transitioning
       from QUESTION → RESULTS. Components shift less, panel size stays put. */
    min-height: 540px;
    contain: layout;
}
#gameplay-panel h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    margin: 0;
    font-variation-settings: "opsz" 72;
    color: var(--text);
}

.game-timer,
.game-result-status {
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--s-2) var(--s-3);
    text-align: center;
    font-weight: 600;
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.game-timer {
    color: var(--accent-green);
}
.game-timer.timer-warn {
    color: var(--accent-orange);
    border-color: var(--accent-orange);
}
.game-timer.timer-danger {
    color: var(--danger);
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.08);
}

/* Result status banner — slots into the timer's old spot so the question text
   stays put. Pulses briefly on appearance for loud right/wrong feedback. */
.game-result-status--correct {
    color: var(--accent-green);
    border-color: var(--accent-green);
    background: rgba(52, 211, 153, 0.10);
    animation: result-correct-pulse 0.9s ease-out 2;
}
.game-result-status--wrong {
    color: var(--danger);
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.10);
    animation: result-wrong-pulse 0.9s ease-out 2;
}
.game-result-status--partial {
    color: var(--accent-orange);
    border-color: var(--accent-orange);
    background: rgba(245, 158, 11, 0.10);
}
.game-result-status--skipped {
    color: var(--muted);
    font-style: italic;
    font-weight: 500;
}

.question-media-img {
    max-width: 100%;
    max-height: 360px;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    align-self: center;
}
/* Mobile: clamp the image so it doesn't push the answer buttons off-screen. */
@media (max-width: 768px) {
    .question-media-img { max-height: 30vh; }
}
.question-media-img--result { opacity: 0.85; }
.question-media-audio-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--s-3);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--s-2);
}
.question-media-audio { width: 100%; }
.question-audio-note { color: var(--muted); font-size: 0.85rem; }

/* Question text rendered by JS — give it some weight, calmer serif than Fraunces. */
#gameplay-panel p {
    font-family: var(--font-question);
    font-size: 1.3rem;
    font-weight: 500;
    color: var(--text);
    margin: 0;
    line-height: 1.4;
    font-variation-settings: "opsz" 32;
}

.answer-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--s-2);
}
@media (max-width: 540px) {
    .answer-buttons { grid-template-columns: 1fr; }
}
.answer-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: var(--s-3) var(--s-4);
    border-radius: var(--r-md);
    font-size: 0.95rem;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.05s;
}
.answer-btn:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.answer-btn:active { transform: translateY(1px); }
.answer-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Armed: first click in confirm-required modes (Equal-points / Solo).
   Second click on the same option submits. */
.answer-btn.armed,
.answer-btn.submitted {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--on-accent);
    box-shadow: 0 0 0 3px var(--accent-soft), 0 0 16px rgba(217, 119, 6, 0.4);
}
.answer-btn.armed {
    animation: arm-pulse 1.4s ease-in-out infinite;
}
.answer-btn.armed::after {
    content: ' — click again to confirm';
    font-size: 0.7em;
    font-weight: 500;
    opacity: 0.85;
    margin-left: var(--s-1);
}
@keyframes arm-pulse {
    0%, 100% { box-shadow: 0 0 0 3px var(--accent-soft), 0 0 16px rgba(217, 119, 6, 0.4); }
    50%      { box-shadow: 0 0 0 5px var(--accent-soft), 0 0 24px rgba(217, 119, 6, 0.55); }
}
/* Keyboard focus highlight (used by arrow-key navigation). */
.answer-btn.kb-focus {
    border-color: var(--accent);
    background: var(--accent-soft);
}

/* Movie year input */
.movie-meta {
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
}
.movie-year-wrap {
    display: flex;
    gap: var(--s-2);
    align-items: stretch;
    justify-content: center;
}
.movie-year-input {
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--s-3) var(--s-4);
    font-size: 1.5rem;
    font-family: var(--font-display);
    text-align: center;
    width: 8em;
    font-variant-numeric: tabular-nums;
}

/* Presenter-mode hint shown to remote players in place of the question text/media,
   so they look at the projector and just tap an answer on their phone. */
.watch-screen-hint {
    text-align: center;
    color: var(--text-secondary);
    font-size: 1rem;
    margin: 0;
    padding: var(--s-3);
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--r-md);
    font-style: italic;
}

/* Status messages */
.host-watching-msg, .waiting-msg {
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--s-3);
    font-style: italic;
    text-align: center;
}
.error-msg {
    background: rgba(239, 68, 68, 0.08);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--r-md);
    padding: var(--s-3);
}

/* ── Gameplay panel: RESULTS phase ───────────────────────────────────── */

.result-question-text {
    font-family: var(--font-question);
    font-size: 1.3rem;
    font-weight: 500;
    color: var(--text);
    margin: 0;
    line-height: 1.4;
    font-variation-settings: "opsz" 32;
}
.result-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    cursor: default;
    pointer-events: none;
}
.result-option--correct {
    border-color: var(--accent-green);
    background: rgba(52, 211, 153, 0.12);
    color: var(--text);
    animation: result-correct-pulse 1s ease-out 2;
}
.result-option--wrong {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.12);
    color: var(--text);
    animation: result-wrong-pulse 1s ease-out 2;
}
@keyframes result-correct-pulse {
    0%   { box-shadow: 0 0 0 0   rgba(52, 211, 153, 0.7);   transform: scale(1); }
    40%  { box-shadow: 0 0 0 12px rgba(52, 211, 153, 0); transform: scale(1.015); }
    100% { box-shadow: 0 0 0 0   rgba(52, 211, 153, 0); transform: scale(1); }
}
@keyframes result-wrong-pulse {
    0%   { box-shadow: 0 0 0 0   rgba(239, 68, 68, 0.65); transform: scale(1); }
    40%  { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); transform: scale(1.01); }
    100% { box-shadow: 0 0 0 0   rgba(239, 68, 68, 0); transform: scale(1); }
}
.result-players {
    list-style: none;
    padding: 0;
    margin: var(--s-3) 0 0;
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
}
.result-players li {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-full);
    padding: var(--s-1) var(--s-3);
    font-size: 0.85rem;
}
.result-countdown {
    text-align: center;
    color: var(--muted);
    font-style: italic;
    margin: var(--s-3) 0 0;
}

/* ── Gameplay panel: ENDED phase (player view) ───────────────────────── */

.final-subtitle {
    text-align: center;
    color: var(--muted);
    font-size: 0.95rem;
    margin: 0 0 var(--s-3);
}
.final-badges {
    display: flex;
    justify-content: center;
    gap: var(--s-2);
    margin-bottom: var(--s-4);
}
.final-stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--s-2);
    margin-bottom: var(--s-5);
}
.final-stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--s-1);
    padding: var(--s-3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
}
.final-stat-label {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.7rem;
    color: var(--muted);
}
.final-stat-value {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.4rem;
    color: var(--accent);
    font-variation-settings: "opsz" 72;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
@media (max-width: 480px) {
    .final-stat-cards { grid-template-columns: 1fr; }
    .final-stat-card { flex-direction: row; justify-content: space-between; align-items: baseline; }
}

.final-leaderboard-heading {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.75rem;
    color: var(--muted);
    margin: var(--s-3) 0 var(--s-3);
    font-weight: 600;
}
.final-leaderboard {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.final-leaderboard th,
.final-leaderboard td {
    padding: var(--s-2) var(--s-3);
    border-bottom: 1px solid var(--border);
    text-align: left;
}
.final-leaderboard th {
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.7rem;
    font-weight: 600;
}
.final-leaderboard tr:last-child td { border-bottom: 0; }
.final-row-me td { color: var(--accent); font-weight: 600; }
.final-rank { font-size: 1.1em; }
.player-elo { font-variant-numeric: tabular-nums; }
.player-elo-delta { font-weight: 600; font-variant-numeric: tabular-nums; }
.elo-delta--up   { color: var(--accent-green); }
.elo-delta--down { color: var(--danger); }
.final-nav {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
    margin-top: var(--s-5);
}
.game-action-btn--rematch { background: var(--accent-gold); color: #2a1f06; }
.game-action-btn--rematch:hover { background: #fbd24a; color: #2a1f06; }

/* Connection lost */
.connection-lost-wrap {
    text-align: center;
    padding: var(--s-6) var(--s-4);
}
.connection-lost-msg {
    color: var(--danger);
    font-size: 1.1rem;
    margin-bottom: var(--s-3);
}

/* ── Presenter view ───────────────────────────────────────────────────── */

.presenter-wrap {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: 100vh;
    background: var(--background);
    color: var(--text);
}
/* During LOBBY, keep the sidebar visible so the presenter shows who's joined,
   but hide the redundant mini-QR — the big one in the main area is the call to action. */
.presenter-wrap--lobby .presenter-join-box--sidebar { display: none; }

.presenter-sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: var(--s-4);
    display: flex;
    flex-direction: column;
    gap: var(--s-4);
    overflow-y: auto;
}

.presenter-join-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--s-2);
}
.presenter-join-label {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.7rem;
    color: var(--muted);
    margin: 0;
}
.presenter-qr {
    width: 200px;
    height: 200px;
    border-radius: var(--r-md);
    background: white;
    padding: 4px;
}
.presenter-join-url {
    font-size: 0.7rem;
    color: var(--accent);
    word-break: break-all;
    text-align: center;
    margin: 0;
    font-family: var(--font-mono);
}

.presenter-players-box { flex: 1; }
.presenter-players-hd {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin: 0 0 var(--s-3);
}
.presenter-player-count {
    background: var(--accent);
    color: var(--on-accent);
    border-radius: var(--r-full);
    padding: 1px var(--s-2);
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 1.4em;
    text-align: center;
}
.presenter-player-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--s-1);
}
.presenter-player-empty {
    color: var(--muted);
    font-size: 0.85rem;
    font-style: italic;
}
.presenter-player-item {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    padding: var(--s-2) var(--s-3);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    font-size: 0.875rem;
    transition: opacity 0.2s;
}
.presenter-player-item.presenter-player--disc { opacity: 0.4; }
.presenter-player-rank   { min-width: 1.6em; text-align: center; }
.presenter-player-name   { flex: 1; font-weight: 500; }
.presenter-player-score  { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.presenter-player-status {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px var(--s-2);
    border-radius: var(--r-full);
}
.presenter-player-ready   { background: rgba(52, 211, 153, 0.14); color: var(--accent-green); }
.presenter-player-unready { background: var(--input-bg); color: var(--muted); }

.presenter-main {
    padding: var(--s-6) var(--s-8);
    display: grid;            /* all states overlap in a single grid cell */
    overflow: hidden;
    align-items: start;
    min-height: 0;            /* lets the grid child contract instead of overflow */
}
/* Presenter is a single-screen / projector experience — no scrolling allowed.
   Suppress any inherited body scroll when the presenter wrap is on the page. */
body:has(.presenter-wrap) {
    overflow: hidden;
    height: 100vh;
}
.presenter-state {
    grid-area: 1 / 1;         /* every state shares the same cell */
    display: flex;
    flex-direction: column;
    gap: var(--s-5);
    opacity: 1;
    transition: opacity 0.5s ease;
    width: 100%;
}
/* Cross-fade: hidden state is visually gone but still occupies the grid cell,
   so the question text + options never disappear/reappear during transitions. */
.presenter-state--hidden {
    opacity: 0;
    pointer-events: none;
}

/* ── Presenter LOBBY state ─────────────────────────────────────────── */
.presenter-wrap--lobby .presenter-main {
    align-items: center;
    justify-content: center;
}
.presenter-game-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    letter-spacing: -0.02em;
    text-align: center;
    margin-bottom: var(--s-6);
    font-variation-settings: "opsz" 144;
}
.presenter-lobby-qr-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--s-3);
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: var(--s-6);
    border-radius: var(--r-xl);
}
.presenter-lobby-qr {
    width: clamp(320px, 45vw, 560px);
    height: clamp(320px, 45vw, 560px);
    background: white;
    padding: var(--s-3);
    border-radius: var(--r-md);
}
.presenter-lobby-scan-label {
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.8rem;
    color: var(--muted);
    margin: 0;
}
.presenter-lobby-url {
    font-family: var(--font-mono);
    color: var(--accent);
    font-size: 1rem;
    word-break: break-all;
    text-align: center;
    margin: 0;
}
.presenter-copy-btn {
    background: var(--accent);
    color: var(--on-accent);
    border: 0;
    padding: var(--s-2) var(--s-4);
    border-radius: var(--r-md);
    font-weight: 600;
}
.presenter-waiting-msg {
    margin-top: var(--s-5);
    color: var(--muted);
    font-style: italic;
}

/* ── Presenter QUESTION / RESULTS shared meta + body ───────────────── */
.presenter-q-meta {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: var(--s-4);
    padding-bottom: var(--s-3);
    border-bottom: 1px solid var(--border);
    min-height: 56px;          /* keeps the row a constant height in Q and R */
}
.presenter-q-num {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.75rem;
    color: var(--muted);
    font-variation-settings: "opsz" 96;
    font-variant-numeric: tabular-nums;
}
.presenter-q-type { display: none; }
.presenter-timer-bar-wrap {
    height: 14px;
    background: var(--input-bg);
    border-radius: var(--r-full);
    overflow: hidden;
    border: 1px solid var(--border);
}
.presenter-timer-bar {
    height: 100%;
    background: var(--accent-green);
    transition: width 1s linear, background 0.3s;
}
.presenter-timer-val {
    min-width: 4em;
    text-align: right;
    font-weight: 600;
    font-size: 1.25rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
}

/* "Answer revealed: X" banner — takes the timer's slot in the RESULTS meta row.
   Pulses briefly green to draw the eye. */
.presenter-result-banner {
    background: rgba(52, 211, 153, 0.12);
    border: 1px solid var(--accent-green);
    color: var(--accent-green);
    border-radius: var(--r-full);
    padding: 6px var(--s-4);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.25rem;
    text-align: center;
    animation: result-correct-pulse 0.9s ease-out 2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.presenter-q-media {
    display: flex;
    justify-content: center;
    min-height: 0;
}
.presenter-q-media:empty { min-height: 0; }
.presenter-media-img {
    max-width: 75%;
    max-height: 36vh;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
}
.presenter-audio-note {
    color: var(--muted);
    font-style: italic;
}

.presenter-q-text {
    font-family: var(--font-question);
    font-weight: 500;
    font-size: clamp(2.5rem, 4.5vw, 4rem);
    line-height: 1.15;
    letter-spacing: -0.005em;
    text-align: center;
    color: var(--text);
    margin: 0 auto;
    font-variation-settings: "opsz" 60;
    max-width: 1400px;
}

.presenter-options,
.presenter-results-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--s-4);
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}
.presenter-option {
    display: flex;
    align-items: center;
    gap: var(--s-4);
    padding: var(--s-5) var(--s-6);
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: var(--r-lg);
    font-size: clamp(1.4rem, 1.9vw, 2rem);
    transition: border-color 0.15s, background 0.15s;
    min-height: 90px;
}
.presenter-opt-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.2em;
    height: 2.2em;
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: var(--r-md);
    font-family: var(--font-display);
    font-weight: 700;
    flex-shrink: 0;
    font-size: 0.95em;
}
.presenter-opt-text { flex: 1; }

/* Presenter — mode-specific prompts shown in QUESTION phase when there are
   no MCQ options (movie_year, geography). */
.presenter-mode-prompt {
    text-align: center;
    padding: var(--s-6) var(--s-4);
    background: var(--card-bg);
    border: 2px dashed var(--border-strong);
    border-radius: var(--r-lg);
    color: var(--text);
    font-size: clamp(1.4rem, 1.9vw, 2rem);
}
/* Presenter — mode-specific RESULTS rendering (movie_year, geography). */
.presenter-mode-results {
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
}
.presenter-mode-correct {
    text-align: center;
    padding: var(--s-4) var(--s-5);
    background: rgba(52, 211, 153, 0.12);
    border: 2px solid var(--accent-green);
    border-radius: var(--r-lg);
    color: var(--accent-green);
    font-weight: 600;
    font-size: clamp(1.4rem, 1.9vw, 2rem);
}
.presenter-mode-guesses {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--s-2);
}
.presenter-mode-guesses li {
    display: flex;
    justify-content: space-between;
    gap: var(--s-3);
    padding: var(--s-2) var(--s-4);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    font-size: 1.1rem;
}
.presenter-mode-name  { font-weight: 600; }
.presenter-mode-guess { color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* ── Presenter RESULTS state ──────────────────────────────────────── */
.presenter-result-opt {
    display: flex;
    align-items: center;
    gap: var(--s-4);
    padding: var(--s-5) var(--s-6);
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: var(--r-lg);
    position: relative;
    overflow: hidden;
    min-height: 90px;
    font-size: clamp(1.4rem, 1.9vw, 2rem);
}
.presenter-result-opt--correct {
    border-color: var(--accent-green);
    background: rgba(52, 211, 153, 0.10);
    animation: result-correct-pulse 0.9s ease-out 2;
}
.presenter-result-opt--wrong { opacity: 0.55; }
/* Bar sits at the bottom edge of the card, doesn't take grid space, so the
   result card and the question card render at the same height. */
.presenter-result-bar-wrap {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 4px;
    background: var(--input-bg);
    overflow: hidden;
}
.presenter-result-bar {
    height: 100%;
    background: var(--accent);
    transition: width 0.7s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.presenter-result-opt--correct .presenter-result-bar { background: var(--accent-green); }
.presenter-result-count {
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 600;
}

.presenter-advance-btn {
    display: block;
    margin: var(--s-6) auto 0;
    padding: var(--s-3) var(--s-6);
    background: var(--accent);
    color: var(--on-accent);
    border: 0;
    border-radius: var(--r-md);
    font-weight: 600;
    font-size: 1rem;
    transition: background 0.15s;
}
.presenter-advance-btn:hover { background: var(--accent-hover); }
.presenter-advance-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Presenter ENDED state ────────────────────────────────────────── */
.presenter-ended-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.5rem, 6vw, 5rem);
    text-align: center;
    margin-bottom: var(--s-6);
    background: linear-gradient(135deg, var(--accent), var(--accent-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-variation-settings: "opsz" 144;
    letter-spacing: -0.02em;
}
.presenter-final-list {
    list-style: none;
    padding: 0;
    margin: 0 auto var(--s-6);
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
    max-width: 640px;
    width: 100%;
}
.presenter-final-item {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--s-3) var(--s-4);
    font-size: 1.1rem;
}
.presenter-final-item:first-child {
    border-color: var(--accent-gold);
    background: rgba(245, 200, 66, 0.06);
}
.presenter-final-item:nth-child(2) { border-color: var(--text-secondary); }
.presenter-final-item:nth-child(3) { border-color: #a06b3d; }
.presenter-final-medal { font-size: 1.4rem; min-width: 1.6em; text-align: center; }
.presenter-final-name  { flex: 1; font-weight: 600; }
.presenter-final-score { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }

.presenter-ended-stats {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-3);
    justify-content: center;
    margin: 0 auto var(--s-5);
    max-width: 1100px;
}
.presenter-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--s-1);
    padding: var(--s-3) var(--s-5);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    min-width: 10rem;
}
.presenter-stat-label {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.7rem;
    color: var(--muted);
}
.presenter-stat-value {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.25rem;
    font-variation-settings: "opsz" 72;
    font-variant-numeric: tabular-nums;
}

.presenter-ended-chart {
    max-width: 1100px;
    margin: 0 auto;
}
.presenter-chart-title {
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: var(--s-3);
}
.presenter-chart-bars {
    display: flex;
    align-items: stretch;
    gap: var(--s-1);
    height: 240px;
    padding: var(--s-2) var(--s-2) 0;
    border-bottom: 1px solid var(--border);
}
.presenter-chart-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--s-1);
    min-width: 0;
}
.presenter-chart-bar-wrap {
    flex: 1;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.presenter-chart-bar {
    width: 70%;
    background: var(--accent);
    border-radius: var(--r-sm) var(--r-sm) 0 0;
    min-height: 2px;
}
.presenter-chart-count {
    font-size: 0.85rem;
    color: var(--text);
    font-weight: 600;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.presenter-chart-label {
    font-size: 0.75rem;
    color: var(--muted);
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.presenter-chart-col { cursor: default; }
.presenter-chart-col:hover .presenter-chart-bar {
    filter: brightness(1.25);
}
.presenter-ended-chart { position: relative; }
.presenter-chart-tooltip {
    position: absolute;
    z-index: 50;
    max-width: 480px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    padding: var(--s-3) var(--s-4);
    box-shadow: var(--shadow);
    pointer-events: none;
    transition: opacity 0.12s;
}
.presenter-chart-tooltip[hidden] { display: none; }
.presenter-chart-tt-label {
    font-size: 0.78rem;
    color: var(--accent);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}
.presenter-chart-tt-text {
    font-family: var(--font-question);
    font-size: 1rem;
    line-height: 1.35;
    color: var(--text);
}
.presenter-chart-col { cursor: pointer; }

/* Question breakdown modal — click a bar to open. */
.presenter-q-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--s-5);
}
.presenter-q-modal.is-open { display: flex; }
.presenter-q-modal-content {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: var(--s-6);
    max-width: 760px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
    position: relative;
}
.presenter-q-modal-close {
    position: absolute;
    top: var(--s-3);
    right: var(--s-3);
    background: transparent;
    border: 0;
    color: var(--text-secondary);
    font-size: 1.75rem;
    line-height: 1;
    padding: var(--s-1) var(--s-2);
    cursor: pointer;
    border-radius: var(--r-md);
}
.presenter-q-modal-close:hover { background: var(--surface); color: var(--text); }
.presenter-q-modal-eyebrow {
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: var(--s-2);
}
.presenter-q-modal-q {
    font-family: var(--font-question);
    font-size: clamp(1.4rem, 2.5vw, 2rem);
    font-weight: 500;
    line-height: 1.25;
    margin: 0 0 var(--s-5);
}
.presenter-q-modal-options {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
}
.presenter-q-modal-opt {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow: hidden;
    font-size: 1.05rem;
}
.presenter-q-modal-opt--correct {
    border-color: var(--accent-green);
    background: rgba(52, 211, 153, 0.08);
}
.presenter-q-modal-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2em;
    height: 2em;
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: var(--r-md);
    font-family: var(--font-display);
    font-weight: 700;
}
.presenter-q-modal-opt--correct .presenter-q-modal-letter {
    background: rgba(52, 211, 153, 0.18);
    color: var(--accent-green);
}
.presenter-q-modal-text { z-index: 1; }
.presenter-q-modal-tally {
    z-index: 1;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--text-secondary);
}
.presenter-q-modal-tally span { color: var(--muted); font-weight: 400; }
.presenter-q-modal-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: var(--accent-soft);
    z-index: 0;
}
.presenter-q-modal-opt--correct .presenter-q-modal-bar {
    background: rgba(52, 211, 153, 0.14);
}

/* ── Responsive: phone presenter (e.g. presenter QR projected from a phone) */
@media (max-width: 720px) {
    .presenter-wrap {
        grid-template-columns: 1fr;
        height: auto;
    }
    .presenter-sidebar {
        border-right: 0;
        border-bottom: 1px solid var(--border);
        flex-direction: row;
        gap: var(--s-3);
        align-items: stretch;
    }
    .presenter-join-box { flex: 0 0 auto; }
    .presenter-qr { width: 120px; height: 120px; }
    .presenter-main { padding: var(--s-4); }
    .presenter-options { grid-template-columns: 1fr; }
    .presenter-results-grid { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════════════════════════════
   AUTH PAGES (login, register, forgot/reset password, verify email)
   ══════════════════════════════════════════════════════════════════════════ */

.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 200px);
    padding: var(--s-5) var(--s-4);
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: var(--s-6);
    box-shadow: var(--shadow);
}
.auth-title {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 600;
    text-align: center;
    margin: 0 0 var(--s-5);
    letter-spacing: -0.01em;
    font-variation-settings: "opsz" 96;
}
.auth-form {
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
}
.auth-field {
    display: flex;
    flex-direction: column;
    gap: var(--s-1);
}
.auth-field label {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.7rem;
    color: var(--muted);
    font-weight: 600;
}
.auth-field input {
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--s-3);
    font-size: 0.95rem;
}
.auth-submit {
    margin-top: var(--s-2);
    background: var(--accent);
    color: var(--on-accent);
    border: 0;
    border-radius: var(--r-md);
    padding: var(--s-3) var(--s-5);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.15s;
}
.auth-submit:hover { background: var(--accent-hover); }
.auth-submit--secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
}
.auth-submit--secondary:hover { background: var(--card-bg); color: var(--text); }
.auth-error {
    background: rgba(239, 68, 68, 0.08);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--r-md);
    padding: var(--s-3);
    font-size: 0.9rem;
    text-align: center;
}
.auth-success {
    background: rgba(52, 211, 153, 0.08);
    color: var(--accent-green);
    border: 1px solid rgba(52, 211, 153, 0.3);
    border-radius: var(--r-md);
    padding: var(--s-3);
    font-size: 0.9rem;
    text-align: center;
}
.auth-hint, .auth-footer {
    font-size: 0.85rem;
    color: var(--muted);
    text-align: center;
    margin-top: var(--s-3);
}
.auth-footer a { color: var(--accent); }
.auth-verify-banner {
    background: rgba(245, 158, 11, 0.08);
    color: var(--accent-orange);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: var(--r-md);
    padding: var(--s-3);
    font-size: 0.85rem;
    margin-bottom: var(--s-3);
}

/* ══════════════════════════════════════════════════════════════════════════
   LANDING PAGE (lp-*)
   ══════════════════════════════════════════════════════════════════════════ */

.lp-wrap {
    max-width: 720px;
    margin: 0 auto;
    padding: var(--s-6) var(--s-4);
    display: flex;
    flex-direction: column;
    gap: var(--s-5);
    text-align: center;
}
.lp-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--s-3);
}
/* Hide the redundant single-letter "T" — the wordmark below is the real logo. */
.lp-logo-mark { display: none; }
.lp-title {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 5vw, 3.75rem);
    line-height: 1.05;
    letter-spacing: -0.02em;
    margin: 0;
    font-variation-settings: "opsz" 144;
}
.lp-tagline {
    color: var(--text-secondary);
    font-size: 1.05rem;
    margin: 0;
    max-width: 560px;
}
.lp-features {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--s-3);
}
@media (max-width: 540px) {
    .lp-features { grid-template-columns: 1fr; }
}
.lp-feature {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--s-2);
    padding: var(--s-4);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    text-align: left;
    transition: border-color 0.15s, transform 0.05s;
}
.lp-feature:hover { border-color: var(--accent-dim); }
.lp-feature-icon {
    font-size: 1.4rem;
    line-height: 1;
    width: 2.2rem;
    height: 2.2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    border-radius: var(--r-md);
    margin-bottom: var(--s-1);
}
.lp-feature strong {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text);
    letter-spacing: -0.01em;
}
.lp-feature span:not(.lp-feature-icon) {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.45;
}
.lp-stats { display: none; }

/* Email verification UI hidden until SMTP is wired up — the resend button
   currently POSTs successfully but no mail actually sends. */
#login-resend-wrap,
#register-resend-btn,
.auth-verify-banner { display: none !important; }
.lp-stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--s-2) var(--s-3);
    display: flex;
    align-items: baseline;
    gap: var(--s-2);
    min-width: 0;
}
.lp-stat-value {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}
.lp-stat-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    color: var(--muted);
    letter-spacing: 0.06em;
}
.lp-auth-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: var(--s-5);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    text-align: left;
}
.lp-auth-tabs {
    display: flex;
    gap: 2px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 2px;
    margin-bottom: var(--s-4);
}
.lp-auth-tab {
    flex: 1;
    background: transparent;
    border: 0;
    color: var(--text-secondary);
    padding: var(--s-2);
    border-radius: var(--r-sm);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
}
.lp-auth-tab--active {
    background: var(--accent);
    color: var(--on-accent);
}
.lp-auth-panel { display: none; flex-direction: column; gap: var(--s-3); }
.lp-auth-panel--active { display: flex; }
.lp-field { display: flex; flex-direction: column; gap: var(--s-1); }
.lp-field label {
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    color: var(--muted);
}
.lp-field input {
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--s-2) var(--s-3);
}
.lp-auth-submit {
    background: var(--accent);
    color: var(--on-accent);
    border: 0;
    border-radius: var(--r-md);
    padding: var(--s-3);
    font-weight: 600;
    cursor: pointer;
    margin-top: var(--s-2);
}
.lp-auth-submit:hover { background: var(--accent-hover); }
.lp-auth-meta { font-size: 0.85rem; color: var(--muted); text-align: center; margin-top: var(--s-3); }
.lp-auth-link, .lp-auth-link-btn { color: var(--accent); cursor: pointer; background: none; border: 0; padding: 0; }
.lp-auth-error {
    background: rgba(239, 68, 68, 0.08);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--r-md);
    padding: var(--s-2) var(--s-3);
    font-size: 0.85rem;
}
.lp-auth-success {
    background: rgba(52, 211, 153, 0.08);
    color: var(--accent-green);
    border: 1px solid rgba(52, 211, 153, 0.3);
    border-radius: var(--r-md);
    padding: var(--s-2) var(--s-3);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: var(--s-2);
}
.lp-auth-success-icon { font-size: 1rem; }
.lp-msg {
    padding: var(--s-2) var(--s-3);
    border-radius: var(--r-md);
    font-size: 0.85rem;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
.lp-msg--success    { background: rgba(52, 211, 153, 0.08); color: var(--accent-green); border-color: rgba(52, 211, 153, 0.3); }
.lp-msg--error,
.lp-msg--err        { background: rgba(239, 68, 68, 0.08); color: var(--danger); border-color: rgba(239, 68, 68, 0.3); }
.lp-msg--logged_out { background: var(--accent-soft); color: var(--accent); border-color: rgba(217, 119, 6, 0.3); }
.lp-guest-hint {
    margin-top: var(--s-3);
    text-align: center;
    font-size: 0.85rem;
    color: var(--muted);
}

/* ══════════════════════════════════════════════════════════════════════════
   PROFILE
   ══════════════════════════════════════════════════════════════════════════ */

.profile-page { display: flex; flex-direction: column; gap: var(--s-5); }
.profile-header {
    display: flex;
    gap: var(--s-4);
    align-items: center;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: var(--s-5);
}
.profile-avatar-wrap { position: relative; flex-shrink: 0; }
.profile-avatar {
    width: 96px;
    height: 96px;
    border-radius: var(--r-full);
    object-fit: cover;
    border: 2px solid var(--border);
    display: block;
}
.profile-avatar--placeholder {
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
}
.avatar-upload-form { position: absolute; bottom: 0; right: 0; }
.avatar-upload-input { display: none; }
.avatar-upload-label {
    background: var(--accent);
    color: var(--on-accent);
    border-radius: var(--r-full);
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    border: 2px solid var(--card-bg);
}
.profile-info { flex: 1; display: flex; flex-direction: column; gap: var(--s-1); }
.profile-username {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    font-variation-settings: "opsz" 72;
}
.profile-email { color: var(--text-secondary); font-size: 0.9rem; margin: 0; }
.profile-member-since { color: var(--muted); font-size: 0.8rem; margin: 0; }
.profile-section {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--s-5);
}
.profile-section-heading {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.78rem;
    color: var(--muted);
    margin: 0 0 var(--s-4);
    font-weight: 600;
}
.profile-form { display: flex; flex-direction: column; gap: var(--s-3); max-width: 480px; }
.profile-form-row { display: flex; flex-direction: column; gap: var(--s-1); }
.profile-form-row label {
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    color: var(--muted);
}
.profile-tz-select {
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--s-2) var(--s-3);
}
.profile-flash {
    padding: var(--s-2) var(--s-3);
    border-radius: var(--r-md);
    font-size: 0.85rem;
    text-align: center;
}
.profile-flash--ok { background: rgba(52, 211, 153, 0.08); color: var(--accent-green); }
.profile-flash--err { background: rgba(239, 68, 68, 0.08); color: var(--danger); }
.profile-stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: var(--s-3);
}
.profile-stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--s-3);
    display: flex;
    flex-direction: column;
    gap: var(--s-1);
}
.profile-stat-label {
    text-transform: uppercase;
    font-size: 0.68rem;
    letter-spacing: 0.06em;
    color: var(--muted);
}
.profile-stat-value {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}
.profile-history-link {
    display: inline-block;
    margin-top: var(--s-3);
    color: var(--accent);
    font-size: 0.9rem;
}
.stats-chart-wrap { margin-top: var(--s-3); }
.stats-chart-title {
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: var(--s-2);
}

/* ══════════════════════════════════════════════════════════════════════════
   HISTORY (list + detail)
   ══════════════════════════════════════════════════════════════════════════ */

/* .history-header, .history-count, .history-filters, .history-filter-group,
   .history-filter-label live in admin.css — single source. */
.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
}
.history-table th,
.history-table td {
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--border);
    text-align: left;
}
.history-table th {
    background: var(--surface);
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.72rem;
    font-weight: 600;
}
.history-table tr:last-child td { border-bottom: 0; }
.history-row { cursor: pointer; transition: background 0.1s; }
.history-row:hover { background: var(--surface); }
.history-row-link { color: var(--text); text-decoration: none; display: block; }
.history-row-link:hover { color: var(--text); }
/* .history-empty, .history-pagination, .history-page-btn family, .history-page-info
   live in admin.css — single source. */
.history-back-link {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: var(--s-3);
    display: inline-block;
}
.history-detail-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--s-3);
    flex-wrap: wrap;
    margin-bottom: var(--s-4);
}
.history-summary-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--s-5);
    margin-bottom: var(--s-5);
}
.history-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: var(--s-3);
}
.history-summary-label {
    text-transform: uppercase;
    font-size: 0.68rem;
    letter-spacing: 0.06em;
    color: var(--muted);
}
.history-section-heading {
    text-transform: uppercase;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    color: var(--muted);
    font-weight: 600;
    margin: var(--s-5) 0 var(--s-3);
}
.history-ranked-badge {
    display: inline-block;
    padding: 2px var(--s-2);
    background: rgba(245, 200, 66, 0.14);
    color: var(--accent-gold);
    border-radius: var(--r-full);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
}
.history-players-section { margin-bottom: var(--s-5); }
.history-players-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.history-players-table th,
.history-players-table td {
    padding: var(--s-2) var(--s-3);
    border-bottom: 1px solid var(--border);
    text-align: left;
}
.history-player-me td { color: var(--accent); font-weight: 600; }
.history-elo-cell { font-variant-numeric: tabular-nums; }
.history-questions { display: flex; flex-direction: column; gap: var(--s-3); }
.history-no-detail { color: var(--muted); font-style: italic; }
.history-you-badge {
    display: inline-block;
    margin-left: var(--s-2);
    padding: 1px var(--s-2);
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: var(--r-full);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
}
.history-player-answers {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-1);
    margin-top: var(--s-1);
}
.history-ans-correct { color: var(--accent-green); }
.history-ans-wrong { color: var(--danger); }
.history-ans-partial { color: var(--accent-orange); }
.history-ans-skipped { color: var(--muted); }
.history-answers-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.history-answers-table th,
.history-answers-table td {
    padding: var(--s-2);
    border-bottom: 1px solid var(--border);
    text-align: left;
}
.question-result-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left-width: 3px;
    border-radius: var(--r-md);
    padding: var(--s-3) var(--s-4);
}
.question-result-card--correct { border-left-color: var(--accent-green); }
.question-result-card--wrong   { border-left-color: var(--danger); }
.question-result-card--partial { border-left-color: var(--accent-orange); }
.question-result-card--skipped { border-left-color: var(--muted); }
.geo-result-entity { font-weight: 600; }
.geo-subtype-badge {
    display: inline-block;
    padding: 1px var(--s-2);
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: var(--r-full);
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-left: var(--s-1);
}
.mode-badge--standard {
    background: var(--accent-soft);
    color: var(--accent);
}
.mode-badge--geography {
    background: rgba(52, 211, 153, 0.12);
    color: var(--accent-green);
}

/* ══════════════════════════════════════════════════════════════════════════
   CUSTOM-GAME (list + editor)
   ══════════════════════════════════════════════════════════════════════════ */

.custom-list-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--s-3);
    margin-bottom: var(--s-4);
    flex-wrap: wrap;
}
.custom-edit-link { color: var(--accent); font-size: 0.85rem; }
.custom-vis-badge {
    display: inline-block;
    padding: 2px var(--s-2);
    border-radius: var(--r-full);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.custom-vis-badge--private   { background: var(--input-bg); color: var(--muted); }
.custom-vis-badge--shared    { background: var(--accent-soft); color: var(--accent); }
.custom-vis-badge--published { background: rgba(52, 211, 153, 0.12); color: var(--accent-green); }
.custom-tag-pill {
    display: inline-block;
    padding: 1px var(--s-2);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: var(--r-full);
    font-size: 0.7rem;
    margin: 2px;
}
.custom-tag-pill--auto { color: var(--muted); font-style: italic; }
.custom-hint { color: var(--muted); font-size: 0.85rem; }

/* Layout: questions sidebar on the left, main editor card on the right. */
.custom-game-wrap {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: var(--s-4);
    align-items: start;
}
@media (max-width: 860px) {
    .custom-game-wrap { grid-template-columns: 1fr; }
}

/* Sidebar: questions list. */
.custom-sidebar {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--s-4);
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
    position: sticky;
    top: calc(var(--s-4) + 60px);
    max-height: calc(100vh - 120px);
}
.custom-sidebar-hd {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-2);
}
.custom-sidebar-title {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.05rem;
}
.custom-q-list {
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    overflow-y: auto;
    min-height: 100px;
}
.custom-q-item {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    column-gap: var(--s-2);
    row-gap: var(--s-1);
    padding: var(--s-2) var(--s-3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.custom-q-item:hover { border-color: var(--accent-dim); }
.custom-q-item--active {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.custom-q-num {
    grid-row: 1;
    color: var(--muted);
    font-weight: 700;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}
.custom-q-body {
    grid-row: 1;
    display: flex;
    align-items: center;
    gap: var(--s-2);
    min-width: 0;
}
.custom-q-icon { flex-shrink: 0; font-size: 0.95rem; }
.custom-q-preview {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.88rem;
}
.custom-q-actions {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    gap: var(--s-3);
    justify-content: flex-end;
}
.custom-q-btn {
    background: transparent;
    border: 0;
    padding: 0;
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: color 0.15s;
}
.custom-q-btn:hover { color: var(--accent); }
.custom-q-btn--del:hover { color: var(--danger); }
.custom-empty-list {
    color: var(--muted);
    font-size: 0.85rem;
    font-style: italic;
    text-align: center;
    margin: 0;
    padding: var(--s-3);
}
.custom-q-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.6em;
    height: 1.4em;
    background: var(--accent-soft);
    color: var(--accent);
    padding: 0 var(--s-2);
    border-radius: var(--r-full);
    font-size: 0.72rem;
    font-weight: 700;
}

/* Main column: just a container for the cards inside (no styling itself). */
.custom-main {
    display: flex;
    flex-direction: column;
    gap: var(--s-4);
    min-width: 0;
}

/* Settings + editor cards. */
.custom-settings-card,
.custom-editor-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--s-5);
    display: flex;
    flex-direction: column;
    gap: var(--s-4);
}
.custom-settings-title-row {
    display: flex;
    align-items: center;
    gap: var(--s-2);
}
.custom-game-name {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 600;
    margin: 0;
    flex: 1;
    font-variation-settings: "opsz" 72;
    letter-spacing: -0.01em;
}
.custom-name-editor-row {
    display: flex;
    gap: var(--s-2);
    align-items: center;
}
.custom-name-input,
.custom-desc-input,
.custom-opt-input,
.custom-textarea {
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--s-2) var(--s-3);
    width: 100%;
    font-family: inherit;
}
.custom-textarea { resize: vertical; }

/* Setting rows: label on the left, control on the right by default;
   --col variant stacks (used for description + tags). */
.custom-settings-row {
    display: grid;
    grid-template-columns: 180px 1fr;
    align-items: center;
    gap: var(--s-3);
}
.custom-settings-row--col {
    grid-template-columns: 1fr;
}
.custom-settings-row > label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Visibility (and question-type) pill groups. */
.custom-vis-pills,
.custom-type-pills {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
}
.custom-vis-pill,
.custom-type-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: var(--s-2) var(--s-3);
    border-radius: var(--r-md);
    font-size: 0.88rem;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.custom-vis-pill input,
.custom-type-pill input { accent-color: var(--accent); }
.custom-vis-pill:has(input:checked),
.custom-type-pill:has(input:checked) {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

/* Tags input. */
.custom-tags-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--s-2) var(--s-3);
    min-height: 44px;
    align-items: center;
}
.custom-tag-input {
    flex: 1;
    min-width: 120px;
    background: transparent;
    border: 0;
    color: var(--text);
    padding: 2px 0;
    outline: none;
    font-family: inherit;
}
.custom-tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px var(--s-2);
    background: var(--accent-soft);
    border: 1px solid transparent;
    color: var(--accent);
    border-radius: var(--r-full);
    font-size: 0.78rem;
}
.custom-tag-pill--auto {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text-secondary);
    font-style: italic;
}
.custom-tag-remove {
    background: transparent;
    border: 0;
    color: inherit;
    padding: 0;
    margin-left: 2px;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    opacity: 0.6;
}
.custom-tag-remove:hover { opacity: 1; }
.custom-auto-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-1);
    margin-top: var(--s-2);
    align-items: center;
}

/* Sharing panel (Visibility = Shared). */
.custom-sharing-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--s-3);
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
}
.custom-sharing-hd {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.7rem;
    color: var(--muted);
    font-weight: 600;
}
.custom-share-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-1); }
.custom-share-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--s-1) var(--s-2);
    background: var(--card-bg);
    border-radius: var(--r-sm);
}
.custom-share-empty { color: var(--muted); font-style: italic; font-size: 0.85rem; }
.custom-share-remove {
    background: transparent;
    border: 0;
    color: var(--danger);
    cursor: pointer;
    font-size: 0.8rem;
}
.custom-share-add-row { display: flex; gap: var(--s-2); }
.custom-share-add-row input {
    flex: 1;
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--s-2) var(--s-3);
}
.custom-share-note { color: var(--muted); font-size: 0.8rem; margin: 0; }

/* Action button rows + danger variant for "Delete Game". */
.custom-settings-actions,
.custom-editor-actions {
    display: flex;
    gap: var(--s-2);
    flex-wrap: wrap;
    margin-top: var(--s-1);
}
.lobby-action-btn--small { padding: var(--s-1) var(--s-3); font-size: 0.85rem; }
.lobby-action-btn--danger {
    background: var(--danger);
    color: white;
}
.lobby-action-btn--danger:hover { background: #f87171; color: white; }
.custom-settings-note { font-size: 0.8rem; color: var(--muted); margin: 0; }

/* Question editor (inside main column, only visible when editing). */
.custom-editor-hd {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.custom-editor-hd h2 {
    font-family: var(--font-display);
    font-size: 1.3rem;
    margin: 0;
}
.custom-field-row { display: flex; flex-direction: column; gap: var(--s-1); margin-bottom: var(--s-3); }
.custom-field-label {
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    color: var(--muted);
}
.custom-options { display: flex; flex-direction: column; gap: var(--s-2); margin: var(--s-2) 0; }
.custom-option-row {
    display: flex;
    align-items: center;
    gap: var(--s-2);
}
.custom-opt-letter {
    background: var(--accent-soft);
    color: var(--accent);
    width: 1.8em;
    height: 1.8em;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
    font-family: var(--font-display);
}
.custom-correct-radio {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.custom-correct-radio input { accent-color: var(--accent); }
.custom-icon-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 30px;
    height: 30px;
    border-radius: var(--r-md);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.custom-icon-btn:hover { color: var(--text); border-color: var(--accent-dim); }
.custom-select {
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--s-2) var(--s-3);
}
.custom-file-input { display: none; }
.custom-file-label {
    display: inline-block;
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: var(--s-2) var(--s-3);
    border-radius: var(--r-md);
    font-size: 0.85rem;
    cursor: pointer;
}
.custom-file-label:hover { color: var(--text); }
.custom-media-preview {
    margin-top: var(--s-2);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--s-2);
}
.custom-preview-img {
    max-width: 280px;
    max-height: 200px;
    object-fit: contain;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: var(--input-bg);
    display: block;
}
.custom-preview-audio {
    width: 100%;
    max-width: 360px;
}
.custom-hint { color: var(--muted); font-size: 0.8rem; }
.custom-editor-error {
    background: rgba(239, 68, 68, 0.08);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--r-md);
    padding: var(--s-2) var(--s-3);
    font-size: 0.85rem;
}
.custom-loading { color: var(--muted); font-style: italic; text-align: center; padding: var(--s-4); }

.lobby-modal {
    position: fixed;
    inset: 0;
    background: transparent;
    border: 0;
    padding: var(--s-4);
    z-index: 100;
    color: var(--text);
    /* Native <dialog> hides itself when not open; only render when [open]. */
}
dialog.lobby-modal:not([open]) { display: none; }
dialog.lobby-modal[open] {
    display: flex;
    align-items: center;
    justify-content: center;
}
.lobby-modal::backdrop {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}
.lobby-modal-content {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: var(--s-5);
    max-width: 480px;
    width: 100%;
}
.lobby-modal-actions { display: flex; gap: var(--s-2); justify-content: flex-end; margin-top: var(--s-4); }

/* ══════════════════════════════════════════════════════════════════════════
   MATCHMAKING (1v1)
   ══════════════════════════════════════════════════════════════════════════ */

.mm-page {
    max-width: 480px;
    margin: 0 auto;
    padding: var(--s-6) var(--s-4);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--s-4);
    text-align: center;
}
.mm-panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: var(--s-5);
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
    align-items: center;
}
.mm-hidden { display: none !important; }
.mm-title {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 600;
    margin: 0;
    font-variation-settings: "opsz" 96;
}
.mm-subtitle { color: var(--text-secondary); font-size: 0.95rem; margin: 0; }
.mm-elo-card {
    display: flex;
    flex-direction: column;
    gap: var(--s-1);
    padding: var(--s-3) var(--s-5);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
}
.mm-elo-label {
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    color: var(--muted);
}
.mm-elo-value {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}
.mm-rules {
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    width: 100%;
    text-align: left;
}
.mm-rule {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    color: var(--text-secondary);
    font-size: 0.9rem;
}
.mm-rule-icon { font-size: 1.1rem; }
.mm-find-btn {
    background: var(--accent);
    color: var(--on-accent);
    border: 0;
    border-radius: var(--r-md);
    padding: var(--s-3) var(--s-6);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.15s;
}
.mm-find-btn:hover { background: var(--accent-hover); }
.mm-cancel-btn {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    padding: var(--s-2) var(--s-5);
    cursor: pointer;
    font-weight: 600;
}
.mm-cancel-btn:hover { background: var(--card-bg); }
.mm-spinner-wrap { display: flex; justify-content: center; }
.mm-spinner {
    width: 56px;
    height: 56px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: var(--r-full);
    animation: mm-spin 0.9s linear infinite;
}
@keyframes mm-spin { to { transform: rotate(360deg); } }
.mm-searching-text { color: var(--muted); }
.mm-queue-depth { color: var(--text-secondary); font-size: 0.85rem; }
.mm-matched-icon { font-size: 2rem; color: var(--accent-green); }
.mm-matched-text { color: var(--text); font-weight: 600; }

/* ══════════════════════════════════════════════════════════════════════════
   JOIN PAGE
   ══════════════════════════════════════════════════════════════════════════ */

.join-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--s-5);
    min-height: calc(100vh - 200px);
}
.join-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: var(--s-6);
    max-width: 440px;
    width: 100%;
    box-shadow: var(--shadow);
}
.join-logo {
    text-align: center;
    font-family: var(--font-display);
    font-size: 1.75rem;
    color: var(--accent);
    margin-bottom: var(--s-3);
}
.join-title {
    text-align: center;
    font-family: var(--font-display);
    font-size: 1.25rem;
    margin: 0 0 var(--s-2);
}
.join-host {
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    margin-bottom: var(--s-4);
}
.join-tabs {
    display: flex;
    gap: 2px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 2px;
    margin-bottom: var(--s-4);
}
.join-tab {
    flex: 1;
    background: transparent;
    border: 0;
    color: var(--text-secondary);
    padding: var(--s-2);
    border-radius: var(--r-sm);
    font-weight: 600;
    cursor: pointer;
}
.join-tab--active { background: var(--accent); color: var(--on-accent); }
.join-panel { display: flex; flex-direction: column; gap: var(--s-3); }
.join-panel--hidden { display: none; }
.join-form { display: flex; flex-direction: column; gap: var(--s-3); }
.join-label {
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    color: var(--muted);
}
.join-input {
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--s-3);
}
.join-btn {
    background: var(--accent);
    color: var(--on-accent);
    border: 0;
    border-radius: var(--r-md);
    padding: var(--s-3);
    font-weight: 600;
    cursor: pointer;
}
.join-btn:hover { background: var(--accent-hover); }
.join-hint { color: var(--muted); font-size: 0.8rem; text-align: center; }

/* ══════════════════════════════════════════════════════════════════════════
   ERROR PAGE
   ══════════════════════════════════════════════════════════════════════════ */

.error-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 200px);
    text-align: center;
    padding: var(--s-5);
    gap: var(--s-3);
}
.error-code {
    font-family: var(--font-display);
    font-size: clamp(4rem, 12vw, 8rem);
    color: var(--accent);
    margin: 0;
    font-weight: 700;
    line-height: 1;
    font-variation-settings: "opsz" 144;
}
.error-heading {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--text);
    margin: 0;
}
.error-message { color: var(--text-secondary); max-width: 480px; }
.error-actions {
    display: flex;
    gap: var(--s-2);
    margin-top: var(--s-3);
}
.btn-primary {
    background: var(--accent);
    color: var(--on-accent);
    border: 0;
    border-radius: var(--r-md);
    padding: var(--s-2) var(--s-4);
    text-decoration: none;
    font-weight: 600;
}
.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    padding: var(--s-2) var(--s-4);
    text-decoration: none;
    font-weight: 600;
}

/* ══════════════════════════════════════════════════════════════════════════
   ADMIN PANEL (admin-*, agd-*)
   ══════════════════════════════════════════════════════════════════════════ */

/* admin.css is the canonical source for .admin-* selectors and loads AFTER
   this file (via base.html head-extra), so any .admin-* rule here would be
   overridden. We keep only the small set that admin.css does not define. */
.admin-back-link { color: var(--text-secondary); font-size: 0.85rem; }
.admin-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--s-5);
    margin-bottom: var(--s-4);
}
.admin-card-title,
.admin-form-card-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    margin: 0 0 var(--s-3);
}
.admin-form-hint { color: var(--muted); font-size: 0.8rem; }
.admin-btn--sm { padding: 4px var(--s-2); font-size: 0.78rem; }
.admin-status-badge--LOBBY    { background: rgba(52, 211, 153, 0.12); color: var(--accent-green); }
.admin-status-badge--PLAYING  { background: rgba(245, 158, 11, 0.12); color: var(--accent-orange); }
.admin-status-badge--ENDED    { background: var(--input-bg); color: var(--muted); }
.admin-status-badge--ABANDONED{ background: rgba(239, 68, 68, 0.08); color: var(--danger); }

/* Admin-toggle (inline-styled in admin.html) — replace the hardcoded blue
   checked-state with the active theme's accent. */
.admin-toggle input:checked + .admin-toggle-slider {
    background: var(--accent) !important;
}

/* Admin: game-detail (agd-*) */
.agd-meta { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-bottom: var(--s-4); }
.agd-meta-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--s-2) var(--s-3);
    font-size: 0.85rem;
}
.agd-question-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--s-4);
    margin-bottom: var(--s-3);
}
.agd-question-header {
    display: flex;
    align-items: baseline;
    gap: var(--s-2);
    margin-bottom: var(--s-2);
}
.agd-question-num {
    color: var(--muted);
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    font-weight: 600;
}
.agd-question-text {
    font-family: var(--font-display);
    font-size: 1.1rem;
    margin: 0;
}
.agd-options { display: flex; flex-direction: column; gap: var(--s-1); margin: var(--s-2) 0; }
.agd-option {
    padding: var(--s-2) var(--s-3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    font-size: 0.9rem;
}
.agd-option--correct {
    border-color: var(--accent-green);
    background: rgba(52, 211, 153, 0.06);
}
.agd-answers-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin-top: var(--s-2);
}
.agd-answers-table th,
.agd-answers-table td {
    padding: var(--s-1) var(--s-2);
    border-bottom: 1px solid var(--border);
    text-align: left;
}
.agd-no-answer { color: var(--muted); }
.agd-no-answers { color: var(--muted); font-style: italic; }
.agd-guest-badge {
    display: inline-block;
    margin-left: var(--s-1);
    padding: 0 var(--s-1);
    background: var(--input-bg);
    color: var(--muted);
    border-radius: var(--r-full);
    font-size: 0.65rem;
}
.agd-chat-log {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--s-3);
    max-height: 320px;
    overflow-y: auto;
}
.agd-chat-msg { padding: var(--s-1) 0; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.agd-chat-msg:last-child { border-bottom: 0; }
.agd-chat-row { display: flex; gap: var(--s-2); }
.agd-chat-sender { font-weight: 600; color: var(--text); }
.agd-chat-time { color: var(--muted); font-size: 0.75rem; font-variant-numeric: tabular-nums; }

/* ══════════════════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ══════════════════════════════════════════════════════════════════════════ */
.toast-container {
    position: fixed;
    bottom: var(--s-4);
    right: var(--s-4);
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    z-index: 9999;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    min-width: 220px;
    max-width: 380px;
    padding: var(--s-3) var(--s-4);
    border-radius: var(--r-md);
    font-size: 0.9rem;
    line-height: 1.4;
    cursor: pointer;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    background: var(--card-bg);
    border: 1px solid var(--border-strong);
    color: var(--text);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.toast--visible { opacity: 1; transform: translateY(0); }
.toast--error   { border-color: var(--danger);       color: var(--danger); }
.toast--success { border-color: var(--accent-green); color: var(--accent-green); }
.toast--info    { border-color: var(--accent-blue);  color: var(--accent-blue); }

/* ── UIUtils.confirm() modal ───────────────────────────────────────────── */
.ui-confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: var(--s-3);
}
.ui-confirm-modal {
    background: var(--card-bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-lg);
    padding: var(--s-5);
    max-width: 460px;
    width: 100%;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
.ui-confirm-msg {
    margin: 0 0 var(--s-4);
    color: var(--text);
    font-size: 1rem;
    line-height: 1.45;
    white-space: pre-line;
}
.ui-confirm-btns {
    display: flex;
    justify-content: flex-end;
    gap: var(--s-2);
}
.ui-confirm-btn {
    padding: var(--s-2) var(--s-4);
    border-radius: var(--r-md);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
}
.ui-confirm-btn--cancel:hover { background: var(--card-bg); }
.ui-confirm-btn--confirm {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}
.ui-confirm-btn--confirm:hover { filter: brightness(1.08); }
.ui-confirm-btn--confirm:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

