/* Themes are [data-theme] blocks of CSS variables, set by theme.js before
   first paint. Same look as clock.apphub.casa (world-clock).
   VT323 (SIL OFL, see fonts/OFL-VT323.txt) for the hacker theme, self-hosted
   so it works offline. Its glyphs run small; size-adjust scales them up. */
@font-face {
    font-family: "VT323";
    font-display: swap;
    size-adjust: 135%;
    src: url(/fonts/vt323-latin-ext.woff2) format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: "VT323";
    font-display: swap;
    size-adjust: 135%;
    src: url(/fonts/vt323-latin.woff2) format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root, [data-theme="dark"] {
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    /* Text on --accent and the team colours (dark text: the fills are light). */
    --on-accent: #0a0e1a;
    --on-team: #0a0e1a;
    --bg: #0a0e1a;
    --bg-glow-1: rgba(99, 102, 241, 0.18);
    --bg-glow-2: rgba(20, 184, 166, 0.12);
    --card: rgba(255, 255, 255, 0.045);
    --card-strong: rgba(255, 255, 255, 0.07);
    --border: rgba(255, 255, 255, 0.08);
    --text: #e9edf7;
    --muted: #8b93a7;
    --faint: #5c6479;
    --accent: #8b9dff;
    --accent-soft: rgba(139, 157, 255, 0.16);
    --danger: #ff7a8a;

    --team-0: #4c8dff;
    --team-0-bg: rgba(76, 141, 255, 0.16);
    --team-1: #ff8a3d;
    --team-1-bg: rgba(255, 138, 61, 0.16);
    --up: #34d399;
    --down: #ff7a8a;
    --gold: #fbbf24;
    --silver: #cbd5e1;
    --bronze: #d97706;

    --radius: 20px;
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 20px 40px -24px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
}

[data-theme="light"] {
    --bg: #f3f5fa;
    --bg-glow-1: rgba(99, 102, 241, 0.14);
    --bg-glow-2: rgba(20, 184, 166, 0.1);
    --card: rgba(255, 255, 255, 0.75);
    --card-strong: #fff;
    --border: rgba(15, 23, 42, 0.08);
    --text: #111827;
    --muted: #5b6477;
    --faint: #9aa2b4;
    --accent: #4f5fe0;
    --accent-soft: rgba(79, 95, 224, 0.1);
    --on-accent: #fff;
    --on-team: #fff;
    --danger: #d83a52;

    --team-0: #1d63e0;
    --team-0-bg: rgba(29, 99, 224, 0.1);
    --team-1: #b45309;
    --team-1-bg: rgba(217, 98, 15, 0.1);
    --up: #059669;
    --down: #d83a52;
    --gold: #b7791f;
    --silver: #64748b;
    --bronze: #9a5b13;

    --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 12px 32px -16px rgba(15, 23, 42, 0.18);
    color-scheme: light;
}

[data-theme="hacker"] {
    --font: "VT323", ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    --bg: #000;
    --bg-glow-1: rgba(0, 255, 65, 0.07);
    --bg-glow-2: transparent;
    --card: rgba(0, 20, 6, 0.6);
    --card-strong: #001a07;
    --border: rgba(0, 255, 65, 0.28);
    --text: #33ff66;
    --muted: #1fae48;
    --faint: #137a31;
    --accent: #00ff41;
    --accent-soft: rgba(0, 255, 65, 0.14);
    --on-accent: #000;
    --on-team: #000;
    --danger: #ff4d4d;

    --team-0: #00e5ff;
    --team-0-bg: rgba(0, 229, 255, 0.12);
    --team-1: #ffb000;
    --team-1-bg: rgba(255, 176, 0, 0.12);
    --up: #00ff41;
    --down: #ff4d4d;
    --gold: #9dff00;
    --silver: #33ff66;
    --bronze: #1fae48;

    --radius: 2px;
    --shadow: 0 0 18px -6px rgba(0, 255, 65, 0.35);
    color-scheme: dark;
}
/* VT323 has one weight; faux bold smears its pixels. */
[data-theme="hacker"] body { text-shadow: 0 0 6px rgba(0, 255, 65, 0.45); font-synthesis: none; }
/* CRT scan lines over everything, with a brief flicker every few seconds. */
[data-theme="hacker"] body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 100;
    background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.15) 0 1px, transparent 1px 3px);
    animation: crt-flicker 4s infinite;
}
@keyframes crt-flicker {
    0%, 95%, 97%, 100% { opacity: 1; }
    96% { opacity: 0.8; }
    98% { opacity: 0.85; }
}
[data-theme="hacker"] .brand::before { content: "$ "; color: var(--accent); }
[data-theme="hacker"] .brand-dot { display: none; }
[data-theme="hacker"] .brand::after {
    content: "";
    width: 0.6em;
    height: 1.1em;
    background: var(--accent);
    animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
[data-theme="hacker"] .switch span::after { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
[data-theme="hacker"] .switch input:checked + span::after { background: #000; }
[data-theme="hacker"] :is(h1, h2, h3, strong, .btn, th, .rating, .stat-value, .code) { font-weight: 400; letter-spacing: 0; }
[data-theme="hacker"] h2::before { content: "> "; color: var(--faint); }
[data-theme="hacker"] .qr { filter: none; }
/* Square corners: terminal windows, not bubbles. */
[data-theme="hacker"] :is(.card, .icon-btn, .btn, .segmented, .segmented button, .input, .chip, .pchip, .toast, .switch span,
    .sheet, .round, .win-btn, .fab, .list-link, .invite-qr, .code, .team-box, .stat, .chip-main, .chip-x) { border-radius: 2px; }
[data-theme="hacker"] .switch span::after { border-radius: 1px; }

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    color: var(--text);
    background:
        radial-gradient(60rem 40rem at 10% -10%, var(--bg-glow-1), transparent 60%),
        radial-gradient(50rem 36rem at 100% 0%, var(--bg-glow-2), transparent 60%),
        var(--bg);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 1rem; display: flex; align-items: center; gap: 6px; }
h3 { font-size: 0.85rem; color: var(--muted); margin: 16px 0 6px; }
a { color: inherit; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.center { text-align: center; }
.faded { opacity: .5; }
[hidden] { display: none !important; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.pad { padding: clamp(16px, 2.4vw, 24px); display: grid; gap: 14px; align-content: start; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 6px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--card-strong);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 500;
    white-space: nowrap;
    vertical-align: middle;
}

/* ---------- Top bar ---------- */

.topbar {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    max-width: 1200px;
    margin: 0 auto;
    padding: max(16px, env(safe-area-inset-top)) clamp(16px, 4vw, 40px) 8px;
}
.topbar .title { font-size: 1.15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: flex; gap: 8px; }

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    color: var(--muted);
    font-weight: 500;
    text-decoration: none;
}
.brand-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--team-0), var(--team-1));
    box-shadow: 0 0 12px var(--accent);
}

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--muted);
    cursor: pointer;
    transition: color .15s, background .15s, transform .15s;
    text-decoration: none;
    flex: none;
}
.icon-btn:hover { color: var(--text); background: var(--card-strong); }
.icon-btn:active { transform: scale(0.96); }
.icon-btn.small { width: 32px; height: 32px; border-radius: 10px; }
.icon-btn.small svg { width: 16px; height: 16px; }
.icon-btn.danger:hover { color: var(--danger); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 8px 18px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: var(--accent);
    color: var(--on-accent);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: transform .1s, opacity .15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: .4; cursor: default; transform: none; }
.btn.ghost { background: var(--card-strong); border-color: var(--border); color: var(--text); font-weight: 500; }
.btn.small { min-height: 32px; padding: 4px 12px; font-size: 0.85rem; border-radius: 10px; gap: 6px; }
.btn.small svg { width: 16px; height: 16px; }
.btn.danger { color: var(--danger); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.input {
    width: 100%;
    min-width: 0;
    min-height: 42px;
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--card-strong);
    color: var(--text);
    font: inherit;
    font-size: max(16px, 1rem); /* iOS zooms on smaller inputs */
}
.input:disabled { opacity: .7; }
.code-input { text-transform: uppercase; letter-spacing: .1em; font-variant-numeric: tabular-nums; }

.row { display: flex; align-items: center; gap: 8px; }
.wrap-row { flex-wrap: wrap; }
.stack { display: grid; gap: 12px; }
.field { display: grid; gap: 6px; font-size: 0.85rem; color: var(--muted); }
.field .input { color: var(--text); }
.spacer { flex: 1; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- Layout ---------- */

.wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px clamp(12px, 4vw, 40px) calc(110px + env(safe-area-inset-bottom));
    display: grid;
    gap: clamp(12px, 2vw, 20px);
    align-items: start;
}
.wrap > * { min-width: 0; }
.wrap.narrow { max-width: 680px; }
.side-col { display: grid; gap: clamp(12px, 2vw, 20px); min-width: 0; }

@media (min-width: 900px) {
    .game-grid { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
}

.hero { padding: 12px 4px 4px; display: grid; gap: 8px; }
.hero h1 { font-size: clamp(1.6rem, 5vw, 2.2rem); }
.hero p { color: var(--muted); line-height: 1.5; }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); display: grid; gap: 16px; justify-items: center; }
.empty-small { padding: 8px 0; }

/* Dim the old page only if loading the next one takes a moment. */
#app.loading { opacity: .55; transition: opacity .2s .25s; }

/* ---------- Lists ---------- */

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.list-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--card-strong);
    border: 1px solid var(--border);
    text-decoration: none;
}
.list-link > span { display: inline-flex; align-items: center; gap: 4px; overflow: hidden; text-overflow: ellipsis; }
.list-link > svg { transform: rotate(180deg); color: var(--faint); width: 16px; height: 16px; }
.list-link:hover { border-color: var(--accent); }
.list-link.big { padding: 14px 16px; font-size: 1.05rem; font-weight: 600; }
.list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: 0; }

/* ---------- Players ---------- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.pchip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--card-strong);
    color: var(--text);
    font: inherit;
    cursor: pointer;
    user-select: none;
    transition: background .12s, border-color .12s;
}
.pchip.static { cursor: default; min-height: 32px; padding: 4px 12px; }
.pchip.sel { border-color: var(--accent); background: var(--accent-soft); }
.pchip.team-0 { border-color: var(--team-0); background: var(--team-0-bg); }
.pchip.team-1 { border-color: var(--team-1); background: var(--team-1-bg); }
.chip-team { font-size: 0.72rem; font-weight: 600; }
.team-0 .chip-team { color: var(--team-0); }
.team-1 .chip-team { color: var(--team-1); }

.team-legend { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; }
.tl { font-weight: 600; }
.tl-0 { color: var(--team-0); }
.tl-1 { color: var(--team-1); }

/* ---------- Leaderboard ---------- */

.board { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.board th {
    padding: 6px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    text-align: left;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.board td { padding: 10px 8px; border-top: 1px solid var(--border); }
.board .num { text-align: right; white-space: nowrap; }
.board .name { width: 100%; }
.board .sub { display: block; font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.board tr.clickable { cursor: pointer; }
.board tr.clickable:hover td { background: var(--card-strong); }
.fresh { margin-top: 14px; }
.fresh h3 { margin: 0 0 4px; }
.board-wrap.big { font-size: clamp(1rem, 1.6vw, 1.6rem); }
.board-wrap.big .board td { padding: 0.55em 0.5em; }
.board-wrap.big .board .rating { font-size: 1.25em; }
.board-wrap.big .board .sub { font-size: 0.7em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.board .name a { text-decoration: none; font-weight: 500; }
.board .name a:hover { text-decoration: underline; }
.board .rank { color: var(--muted); width: 2.5em; }
.board .rating { font-weight: 700; font-size: 1.05rem; }
.board tr.me td { background: var(--accent-soft); }
.board tr.me td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.board tr.provisional .rating, .board tr.provisional .name a { color: var(--muted); }
.board tr.top1 .rank { color: var(--gold); font-weight: 700; }
.board tr.top2 .rank { color: var(--silver); font-weight: 700; }
.board tr.top3 .rank { color: var(--bronze); font-weight: 700; }
.board.compact td { padding: 6px 8px; }
.board-card { overflow-x: auto; }

.delta { font-size: 0.85rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.delta.small { font-size: 0.72rem; font-weight: 500; }


/* ---------- Rounds ---------- */

.rounds { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rounds .day { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 10px 2px 2px; }
.round {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--card-strong);
    color: var(--text);
    font: inherit;
    text-align: left;
}
button.round { cursor: pointer; }
button.round:hover { border-color: var(--accent); }
.side { display: flex; flex-direction: column; gap: 2px; min-width: 0; color: var(--muted); }
.side.won { color: var(--text); }
.side.won .pname { font-weight: 700; }
.win-mark { display: inline-flex; align-items: center; gap: 4px; font-size: 0.7rem; font-weight: 700; color: var(--gold);
    text-transform: uppercase; letter-spacing: .05em; }
.win-mark svg { width: 13px; height: 13px; }
.side-0 { border-left: 3px solid var(--team-0); padding-left: 8px; }
.side-1 { border-right: 3px solid var(--team-1); padding-right: 8px; align-items: flex-end; text-align: right; }
.who { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.side-1 .who { flex-direction: row-reverse; }
.pname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mid { display: grid; justify-items: center; gap: 2px; }
.score { font-weight: 700; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.when { font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
.tour { display: inline-flex; align-items: center; gap: 3px; font-size: 0.7rem; color: var(--gold); max-width: 9em; overflow: hidden; white-space: nowrap; }
.tour svg { width: 12px; height: 12px; }

/* ---------- Floating "new round" ---------- */

.fab {
    position: fixed;
    z-index: 10;
    left: 50%;
    bottom: max(20px, env(safe-area-inset-bottom));
    translate: -50% 0;
    min-height: 56px;
    padding: 12px 28px;
    border-radius: 999px;
    font-size: 1.05rem;
    box-shadow: 0 10px 30px -8px var(--accent);
}
@media (min-width: 900px) {
    .fab { left: auto; right: max(40px, calc((100vw - 1200px) / 2 + 40px)); translate: none; }
}

/* ---------- Sheets (dialogs) ---------- */

.sheet {
    width: min(560px, 100%);
    max-height: min(92vh, 900px);
    margin: auto auto 0;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    background: var(--bg);
    color: var(--text);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, .4);
}
.sheet { overflow-y: auto; }
.sheet::backdrop { background: rgba(0, 0, 0, .5); }
@media (min-width: 640px) {
    .sheet { margin: auto; border-radius: var(--radius); }
}
.sheet-body {
    display: grid;
    gap: 14px;
    padding: 20px 20px max(20px, env(safe-area-inset-bottom));
    background: var(--card);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.tools { gap: 6px; }

.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.team-box {
    display: grid;
    gap: 8px;
    align-content: start;
    min-height: 100%;
    padding: 10px;
    border-radius: 14px;
    border: 2px solid var(--border);
}
.team-box-0 { border-color: var(--team-0); background: var(--team-0-bg); }
.team-box-1 { border-color: var(--team-1); background: var(--team-1-bg); }
.team-box-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.team-box-0 strong { color: var(--team-0); }
.team-box-1 strong { color: var(--team-1); }
.odds { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.team-box .pchip { padding: 0; gap: 0; background: var(--card-strong); }
.chip-main { border: 0; background: none; color: inherit; font: inherit; padding: 8px 4px 8px 12px; min-height: 40px; cursor: pointer; border-radius: 999px 0 0 999px; }
.chip-x { border: 0; background: none; color: var(--muted); padding: 0 10px 0 6px; min-height: 40px; cursor: pointer; display: grid; place-items: center; border-radius: 0 999px 999px 0; }
.chip-x svg { width: 14px; height: 14px; }
.chip-x:hover { color: var(--danger); }
.bench { display: grid; gap: 8px; }
.bench h3 { margin: 0; }
.more { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.more summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; }
.more[open] { display: grid; gap: 10px; }
.sheet-footer {
    position: sticky;
    bottom: calc(-1 * max(20px, env(safe-area-inset-bottom)));
    display: grid;
    gap: 8px;
    margin: 0 -20px calc(-1 * max(20px, env(safe-area-inset-bottom)));
    padding: 12px 20px max(16px, env(safe-area-inset-bottom));
    background: var(--bg);
    border-top: 1px solid var(--border);
}
.winners { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.win-btn {
    min-height: 56px;
    border-radius: 14px;
    border: 2px solid var(--border);
    background: var(--card-strong);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.win-0 { border-color: var(--team-0); }
.win-1 { border-color: var(--team-1); }
.win-btn:disabled { opacity: .45; cursor: default; }
.win-0.on { background: var(--team-0); color: var(--on-team); }
.win-1.on { background: var(--team-1); color: var(--on-team); }
.round-sheet .win-btn:not(.on):not(:disabled):hover { background: var(--card); }
.score-row { justify-content: flex-end; }
.score-row .muted { margin-right: auto; }
.score-input { width: 4.5em; text-align: center; }

/* ---------- Invite / QR ---------- */

.invite { grid-template-columns: 1fr auto; align-items: center; }
.invite-text { display: grid; gap: 12px; }
.code {
    font-size: clamp(1.6rem, 6vw, 2.2rem);
    font-weight: 700;
    letter-spacing: .08em;
    font-variant-numeric: tabular-nums;
}
.invite-qr { display: block; width: 128px; border-radius: 12px; overflow: hidden; }
.qr { display: block; width: 100%; height: auto; stroke: none; shape-rendering: crispEdges; }
@media (max-width: 460px) {
    .invite { grid-template-columns: 1fr; }
    .invite-qr { width: 160px; }
}

.poster {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px;
    display: grid;
    justify-items: center;
    gap: 16px;
    text-align: center;
}
.poster h1 { font-size: clamp(2rem, 8vw, 3.5rem); }
.poster-games { font-size: 1.3rem; color: var(--muted); }
.poster-steps { margin: 0; padding-left: 1.4em; text-align: left; font-size: 1.2rem; line-height: 1.6; }
.poster .qr { width: min(420px, 80vw); border-radius: 12px; }
.poster-code { font-size: clamp(2rem, 9vw, 3.5rem); font-weight: 700; letter-spacing: .1em; }
.poster-url { color: var(--muted); font-size: 1.1rem; }

@media print {
    body { background: #fff !important; color: #000 !important; text-shadow: none !important; }
    body::after, .topbar { display: none !important; }
    .poster { max-width: none; padding-top: 6vh; }
    .poster-games, .poster-url { color: #333 !important; }
    .poster .qr { width: min(60vw, 120mm); }
}

/* ---------- Player page ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.stat { display: grid; gap: 2px; padding: 10px 12px; border-radius: 12px; background: var(--card-strong); border: 1px solid var(--border); min-width: 0; }
.stat-label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-sub { font-size: 0.75rem; color: var(--muted); }
.chart { width: 100%; height: 120px; display: block; }
.chart polyline { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .area { fill: var(--accent-soft); stroke: none; }
.h2h { display: grid; gap: 4px 20px; }
@media (min-width: 640px) { .h2h { grid-template-columns: 1fr 1fr; } }

/* ---------- Settings ---------- */

.segmented {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px;
    border-radius: 12px;
    background: var(--card-strong);
    border: 1px solid var(--border);
}
.segmented button {
    padding: 8px 14px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    cursor: pointer;
}
.segmented button.on { background: var(--accent); color: var(--on-accent); font-weight: 600; }

.setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.setting p { margin-top: 2px; }
.stack-setting { flex-direction: column; align-items: stretch; }
.stack-setting .segmented { display: flex; }
.stack-setting .segmented button { flex: 1 1 auto; }

.switch { position: relative; display: inline-block; width: 46px; height: 28px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch input:disabled { cursor: default; }
.switch span {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: var(--card-strong);
    border: 1px solid var(--border);
    transition: background .15s;
}
.switch span::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--muted);
    transition: transform .15s, background .15s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); background: #fff; }
.switch input:disabled + span { opacity: .5; }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.danger-zone h2 { color: var(--danger); }

/* ---------- Toast ---------- */

.toast {
    position: fixed;
    z-index: 200;
    left: 50%;
    bottom: calc(max(20px, env(safe-area-inset-bottom)) + 70px);
    translate: -50% 0;
    display: flex;
    align-items: center;
    gap: 14px;
    max-width: calc(100vw - 32px);
    padding: 12px 16px;
    border-radius: 14px;
    background: var(--text);
    color: var(--bg);
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
    animation: toast-in .2s ease-out;
}
.toast button { border: 0; background: none; color: var(--accent); font: inherit; font-weight: 700; cursor: pointer; padding: 0; }
[data-theme="dark"] .toast button { color: #3442b8; }
[data-theme="light"] .toast button { color: #a5b4fc; }
[data-theme="hacker"] .toast { background: #000; color: var(--text); border: 1px solid var(--accent); }
@keyframes toast-in { from { opacity: 0; translate: -50% 10px; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Misc ---------- */

.main-col { display: grid; gap: clamp(12px, 2vw, 20px); min-width: 0; align-content: start; }
.prose { display: grid; gap: 10px; line-height: 1.5; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.9rem; }
.nudge { grid-template-columns: 1fr auto; align-items: center; border-color: var(--accent); }
.device { display: grid; gap: 2px; }
h2 .icon-btn { margin-left: 2px; }
h2 > svg { width: 18px; height: 18px; }

/* Dashboard: wall screens. */
.wrap.tv { max-width: 1600px; padding-bottom: 32px; }
.tv-grid { display: grid; gap: clamp(12px, 2vw, 24px); align-items: start; }
@media (min-width: 900px) { .tv-grid { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); } }
.game-select { width: auto; min-height: 40px; }
