/* Team Blending — one stylesheet for the app pages and the presenter stage.
   Tokens first; dark theme per viewer (ThemeToggle sets <html data-theme="dark">). */
:root {
    --bg: #f6f4f0;
    --surface: #ffffff;
    --surface-2: #f0ede7;
    --text: #1d1b19;
    --muted: #6a655d;
    --border: #e3ded4;
    --input-border: #d2ccc1;
    --accent: #4f46e5;
    --on-accent: #ffffff;
    --danger: #c62828;
    --good: #2e7d32;
    --good-bg: #e3f5e6;
    --notice: #fff4d6;
    --radius: 10px;
    --control-height: 2.6rem;
    --team-0: #f08a24;
    --team-1: #12a594;
    --team-2: #8b5cf6;
    --red: #ff3b5c;
    --green: #22c55e;
    --blue: #3b7bff;
    color-scheme: light;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
}

:root[data-theme="dark"] {
    --bg: #14161a;
    --surface: #1d2127;
    --surface-2: #252a31;
    --text: #ecebe7;
    --muted: #a39f97;
    --border: #333941;
    --input-border: #4a515a;
    --accent: #8b93ff;
    --on-accent: #12142a;
    --danger: #ff7a7a;
    --good: #7bd88f;
    --good-bg: #1f3525;
    --notice: #3a321f;
    color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:not([class]):hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; }
h1 { font-size: 1.8rem; margin: 0 0 1rem; }
h2 { font-size: 1.2rem; margin: 0 0 0.75rem; }
h3 { font-size: 1rem; margin: 0 0 0.5rem; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.hint { color: var(--muted); font-size: 0.9rem; }
.count { color: var(--muted); font-weight: normal; }
.error { color: var(--danger); }
.notice { background: var(--notice); padding: 0.6rem 0.8rem; border-radius: var(--radius); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }

/* Controls */
input, select, textarea {
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--input-border);
    border-radius: var(--radius);
    min-height: var(--control-height);
    padding: 0 0.7rem;
}
input[type="checkbox"] { min-height: 0; width: 1.1rem; height: 1.1rem; }
label { display: flex; flex-direction: column; gap: 0.3rem; font-weight: 500; }
label.check { flex-direction: row; align-items: center; gap: 0.5rem; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }

button, .button {
    font: inherit;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: var(--control-height);
    padding: 0 1.1rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    background: var(--accent);
    color: var(--on-accent);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
button:hover:not(:disabled), .button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.45; cursor: default; }
button.secondary, .button.secondary { background: var(--surface); color: var(--text); border-color: var(--input-border); }
button.danger { background: var(--danger); color: #fff; }
button.secondary.danger { background: var(--surface); color: var(--danger); border-color: currentColor; }
button.small, .button.small { min-height: 2.1rem; padding: 0 0.75rem; font-size: 0.9rem; }
button.large { min-height: 3.2rem; padding: 0 1.6rem; font-size: 1.1rem; }
.icon-button {
    min-height: 2rem; width: 2rem; padding: 0;
    background: var(--surface); color: var(--text); border-color: var(--input-border);
}
.icon-button.danger { color: var(--danger); background: var(--surface); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1.2rem; margin-bottom: 1rem; }
.chip { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 999px; background: var(--surface-2); font-size: 0.85rem; color: var(--muted); }
.chip.good { background: var(--good-bg); color: var(--good); }
.chip.info { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.3rem; }
.join-code { font-weight: 700; letter-spacing: 0.08em; }
.join-code.big { display: inline-block; font-size: 2.4rem; letter-spacing: 0.15em; }

/* Brand: three overlapping light dots */
.brand-dots { display: inline-flex; margin-right: 0.45rem; vertical-align: -0.1em; }
.brand-dots i { width: 0.8em; height: 0.8em; border-radius: 50%; mix-blend-mode: multiply; margin-right: -0.3em; }
:root[data-theme="dark"] .brand-dots i, .stage .brand-dots i { mix-blend-mode: screen; }
.brand-dots i:nth-child(1) { background: var(--red); }
.brand-dots i:nth-child(2) { background: var(--green); }
.brand-dots i:nth-child(3) { background: var(--blue); margin-right: 0; }

/* Teams: every element with team-N gets --team, used by swatches, borders and highlights. */
.team-0 { --team: var(--team-0); }
.team-1 { --team: var(--team-1); }
.team-2 { --team: var(--team-2); }
.team-swatch { display: inline-block; width: 0.8rem; height: 0.8rem; border-radius: 50%; background: var(--team, var(--muted)); flex: none; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
h1:focus { outline: none; }
.site-header-inner { max-width: 1100px; margin: 0 auto; padding: 0.6rem 1.5rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.site-path { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.site-brand { font-weight: 800; color: var(--text); font-size: 1.1rem; }
.crumb { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb-separator { color: var(--muted); }
.site-tools { display: flex; align-items: center; gap: 0.6rem; }
.theme-toggle { min-height: 2.1rem; width: 2.1rem; padding: 0; background: transparent; border-color: var(--border); color: var(--text); }
.theme-toggle .to-light, :root[data-theme="dark"] .theme-toggle .to-dark { display: none; }
:root[data-theme="dark"] .theme-toggle .to-light { display: inline; }
/* Language: a two-way switch with the current language filled in (as in Variants). */
.language-switcher {
    display: inline-flex; align-items: center; height: 2.1rem; padding: 0.2rem;
    border: 1px solid var(--input-border); border-radius: 999px; background: var(--surface);
    font-size: 0.8rem; font-weight: 700; letter-spacing: 0.04em;
}
.language-switcher .separator { display: none; }
.language-switcher a, .language-switcher .current { display: grid; place-items: center; height: 100%; padding: 0 0.7rem; border-radius: 999px; color: var(--muted); }
.language-switcher a:hover { color: var(--text); background: var(--surface-2); }
.language-switcher .current { background: var(--accent); color: var(--on-accent); }
.my-team { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 700; padding: 0.25rem 0.7rem; border-radius: 999px; border: 2px solid var(--team); }

/* Pages */
.page { max-width: 900px; margin: 0 auto; padding: 2rem 1.25rem 4rem; }
.home-headline { font-size: 2.4rem; margin-bottom: 0.5rem; }
.home-lead { font-size: 1.15rem; color: var(--muted); max-width: 42rem; }
.home-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0.75rem 1.5rem; padding: 0; margin: 1.5rem 0 0; list-style: none; counter-reset: home-step; }
.home-steps li { counter-increment: home-step; display: flex; gap: 0.6rem; align-items: flex-start; line-height: 1.45; }
.home-steps li::before {
    content: counter(home-step); flex: none; display: grid; place-items: center; width: 1.75rem; height: 1.75rem; border-radius: 50%;
    background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); font-weight: 700;
}
.home-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; margin-top: 2rem; }
.home-choice { display: flex; flex-direction: column; gap: 0.5rem; padding: 1.4rem 1.5rem 1.5rem; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.home-choice:hover { border-color: var(--accent); }
.home-choice-icon { font-size: 2rem; }
.home-choice-title { font-size: 1.25rem; font-weight: 700; }
.home-choice-text { color: var(--muted); flex: 1; }
.home-choice .button { align-self: flex-start; margin-top: 0.6rem; }

.host-forms { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.host-forms section, .join-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1.2rem; }
.host-forms form, .join-form { display: flex; flex-direction: column; gap: 0.8rem; }
.host-forms form button, .join-button { align-self: flex-start; }
.join-page { max-width: 640px; }
.join-form .row { flex-wrap: nowrap; }
.code-input { flex: 1; min-width: 0; font-size: 1.4rem; letter-spacing: 0.15em; text-align: center; }
.join-form .row button { min-width: 7rem; }
.join-room { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin: 0; }
.game-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.game-list li { display: flex; justify-content: space-between; padding: 0.6rem 0.8rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }

.room-hero { display: flex; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; align-items: center; }
.room-status { display: flex; flex-direction: column; align-items: flex-start; gap: 0.6rem; }
.room-queue, .room-history, .playlist { list-style: none; padding: 0; margin: 0 0 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.queued-game, .room-history li, .playlist-entry {
    display: flex; align-items: center; gap: 0.8rem; padding: 0.7rem 0.9rem;
    background: var(--surface-2); border-radius: var(--radius);
}
.playlist-entry { flex-wrap: wrap; align-items: flex-end; }
.queue-number { width: 1.8rem; height: 1.8rem; border-radius: 50%; display: grid; place-items: center; background: var(--surface); font-weight: 700; flex: none; }
.queue-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.queue-title { font-weight: 600; }
.queue-buttons { display: flex; gap: 0.3rem; margin-left: auto; }
.confirm-delete { display: inline-flex; gap: 0.3rem; }
.create-game input { flex: 1; min-width: 14rem; }
.delete-room { margin-top: 2rem; }

.segmented { display: inline-flex; border: 1px solid var(--input-border); border-radius: var(--radius); overflow: hidden; margin-bottom: 0.8rem; }
.segmented button { border-radius: 0; background: var(--surface); color: var(--text); border: 0; }
.segmented button.selected { background: var(--accent); color: var(--on-accent); }
.team-names { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.team-names label { flex-direction: row; align-items: center; gap: 0.5rem; }
.timers { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 0.8rem; }
.timers input { width: 7rem; }
.editor-fields[disabled] { opacity: 0.7; }

/* Game layout: status strip, main column, scoreboard on the side */
.game { max-width: 1100px; margin: 0 auto; padding: 1rem 1.25rem 3rem; display: grid; grid-template-columns: 1fr 300px; gap: 1.25rem; align-items: start; }
.game-status { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem; padding: 0.6rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.game-status .round { font-weight: 700; }
.game-status .phase { color: var(--muted); }
.level-chip { padding: 0.15rem 0.6rem; border-radius: 999px; background: var(--surface-2); font-size: 0.9rem; }
.countdown { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.3rem; }
.countdown.urgent { color: var(--danger); }
.paused { margin-left: auto; font-weight: 700; color: var(--muted); }
.host-controls { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.game-main { min-width: 0; display: flex; flex-direction: column; gap: 1rem; }
.game-side { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1rem; position: sticky; top: 1rem; }

/* Lobby */
.lobby-wait { text-align: center; padding: 1rem 0; }
.lobby-me { font-size: 1.3rem; font-weight: 700; margin: 0 0 0.3rem; }
.waiting { color: var(--muted); }
.waiting-dots i { display: inline-block; width: 0.35em; height: 0.35em; margin: 0 0.1em; border-radius: 50%; background: currentColor; animation: blink 1.2s infinite; }
.waiting-dots i:nth-child(2) { animation-delay: 0.2s; }
.waiting-dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.2; } 40% { opacity: 1; } }
.lobby-teams { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.8rem; }
.lobby-team { background: var(--surface); border: 1px solid var(--border); border-top: 5px solid var(--team); border-radius: 14px; padding: 0.9rem; display: flex; flex-direction: column; gap: 0.5rem; }
.lobby-team.mine { box-shadow: 0 0 0 2px var(--team); }
.lobby-team h3 { display: flex; align-items: center; gap: 0.5rem; margin: 0; }
.lobby-team h3 .count { margin-left: auto; font-size: 0.85rem; }
.lobby-team ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.3rem; flex: 1; }
.lobby-team li { display: flex; align-items: center; gap: 0.5rem; padding: 0.3rem 0; }
.lobby-team li.offline .member-name { opacity: 0.5; }
.member-tools { margin-left: auto; display: flex; gap: 0.25rem; }
.member-tools .icon-button { width: 1.8rem; min-height: 1.8rem; }
.lobby-tools h2 { margin: 0 auto 0 0; }
.invite { display: flex; justify-content: space-between; gap: 1.5rem; align-items: center; flex-wrap: wrap; }
.invite-url { word-break: break-all; }
.qr svg { width: 160px; height: 160px; background: #fff; border-radius: 10px; padding: 6px; display: block; }

/* Team board */
.team-board { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.team-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem 0.7rem; border-radius: var(--radius); background: var(--surface-2); border-left: 5px solid var(--team); }
.team-row.mine { box-shadow: inset 0 0 0 2px var(--team); }
.team-place { font-weight: 800; color: var(--muted); width: 1.2rem; text-align: center; }
.team-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.2rem; }
.team-members { display: flex; flex-wrap: wrap; gap: 0.15rem 0.6rem; font-size: 0.85rem; color: var(--muted); }
.member.me { color: var(--text); font-weight: 700; }
.member.offline { opacity: 0.5; text-decoration: line-through; }
.acted { color: var(--muted); }
.acted.done { color: var(--good); font-weight: 800; }
.team-score { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.team-delta { color: var(--good); font-weight: 800; animation: pop 0.6s ease-out; }
@keyframes pop { from { transform: scale(0.3); opacity: 0; } 60% { transform: scale(1.3); } to { transform: scale(1); opacity: 1; } }

/* Level intro and target */
.level-intro { text-align: center; padding: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.level-title { font-size: 1.6rem; font-weight: 800; margin: 0; }
.level-how { color: var(--muted); max-width: 36rem; margin: 0.5rem auto; }
.target { display: flex; flex-direction: column; align-items: center; margin: 0.6rem 0 0.2rem; }
.target-label { text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.8rem; color: var(--muted); }
.target-value { font-size: 3rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.get-ready { text-align: center; font-size: 1.4rem; font-weight: 700; animation: pulse 1s infinite alternate; }
@keyframes pulse { from { opacity: 0.5; } to { opacity: 1; } }

/* Stop the clock */
.stopclock { display: flex; flex-direction: column; align-items: center; gap: 1rem; padding: 1.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.stopclock-display { font-size: 5rem; font-weight: 900; font-variant-numeric: tabular-nums; margin: 0; min-width: 5ch; text-align: center; transition: color 0.2s; }
.stopclock-display.hidden-time { color: var(--muted); animation: pulse 0.6s infinite alternate; }
.stopclock-button { min-width: 12rem; min-height: 4.5rem; font-size: 1.6rem; border-radius: 999px; background: var(--good); color: #fff; }
.stopclock-button.running { background: var(--danger); }
.stopclock.done .stopclock-display { color: var(--good); }

/* Reveal */
.reveal { display: flex; flex-direction: column; gap: 0.8rem; }
.reveal-team { background: var(--surface); border: 1px solid var(--border); border-left: 6px solid var(--team); border-radius: 14px; padding: 0.9rem 1rem; animation: slide-in 0.5s ease-out; }
.reveal-team.closest { box-shadow: 0 0 0 3px var(--team); }
.reveal-team.mine .team-name::after { content: " ●"; color: var(--team); }
.reveal-team.sealed { display: grid; place-items: center; min-height: 4.5rem; border-left-color: var(--border); border-style: dashed; color: var(--muted); font-size: 2rem; font-weight: 800; animation: none; }
.reveal-team header { display: flex; align-items: center; gap: 0.5rem; }
.reveal-team .points { margin-left: auto; font-size: 1.4rem; font-weight: 900; color: var(--good); }
.closest-badge { font-size: 0.8rem; font-weight: 700; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--team); color: #fff; }
.accuracy { display: flex; align-items: center; gap: 0.8rem; margin: 0.6rem 0; }
.accuracy-bar { flex: 1; height: 0.8rem; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.accuracy-bar i { display: block; height: 100%; width: var(--value); background: var(--team); border-radius: 999px; animation: grow 1s ease-out both; animation-delay: var(--result-delay, 0s); }
.accuracy-value { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 4.5rem; text-align: right; }
.attempts { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.3rem 1rem; font-size: 0.95rem; }
.attempts li { display: flex; gap: 0.5rem; }
.attempt-name { flex: 1; }
.attempt-value { font-variant-numeric: tabular-nums; font-weight: 700; }
.attempt-accuracy { color: var(--muted); font-variant-numeric: tabular-nums; }
@keyframes slide-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes grow { from { width: 0; } }

/* Final */
.final { text-align: center; display: flex; flex-direction: column; gap: 0.8rem; }
.final-trophy { font-size: 4rem; margin: 0; animation: pop 0.8s ease-out; }
.final-title { font-size: 1.8rem; margin: 0; }
.final .team-board { text-align: left; }
details.more summary { cursor: pointer; font-weight: 600; }
details.more[open] summary { margin-bottom: 0.8rem; }
details.more .lobby-teams { margin-bottom: 1rem; }

/* Presenter stage: always dark, big type, for screen sharing */
.stage {
    --bg: #0f1115; --surface: #1a1e25; --surface-2: #232831; --text: #f3f2ee; --muted: #a09c94;
    --border: #2d333c; --good: #6ee08a; --accent: #8b93ff; --danger: #ff7a7a;
    color-scheme: dark;
    min-height: 100vh; background: radial-gradient(circle at 20% 0%, #1d2230, var(--bg) 60%); color: var(--text);
    display: flex; flex-direction: column;
}
.stage-message { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; padding: 2rem; text-align: center; }
.stage-brand { font-size: 1.4rem; font-weight: 800; }
.stage-message .stage-brand { font-size: 3rem; }
.stage-waiting { font-size: 1.4rem; color: var(--muted); }
.tv-form { display: flex; flex-direction: column; gap: 1.25rem; width: min(22rem, 90vw); margin: 0 auto; text-align: center; }
.tv-form h1 { margin: 0 0 0.5rem; font-size: 2.5rem; }
.tv-form label { font-size: 1.4rem; }
.tv-form input, .tv-form button { width: 100%; height: 4.25rem; }
.tv-form input { text-align: center; font-size: 2.5rem; letter-spacing: 0.15em; }
.tv-form button { font-size: 1.8rem; }
.stage-top { display: flex; align-items: center; gap: 1rem; padding: 0.8rem 1.5rem; }
.stage-top .game-status { flex: 1; font-size: 1.1rem; }
.stage-join { color: var(--muted); white-space: nowrap; }
.stage-join code { color: var(--text); font-weight: 800; letter-spacing: 0.1em; }
.stage-main { flex: 1; width: 100%; max-width: 1300px; margin: 0 auto; padding: 1rem 2rem 2rem; display: flex; flex-direction: column; gap: 1.5rem; justify-content: center; }
.stage-lobby { display: grid; grid-template-columns: minmax(260px, 1fr) 2fr; gap: 2rem; align-items: center; }
.stage-invite { text-align: center; }
.stage-lead { font-size: 1.4rem; margin: 0; color: var(--muted); }
.stage-url { font-size: 1.6rem; font-weight: 700; margin: 0.3rem 0; word-break: break-all; }
.stage-code { font-size: 5rem; font-weight: 900; letter-spacing: 0.15em; margin: 0; }
.stage-invite .qr { display: flex; justify-content: center; margin-top: 1rem; }
.stage-invite .qr svg { width: 220px; height: 220px; }
.stage .lobby-team { font-size: 1.15rem; }
.level-intro.large { padding: 2.5rem; }
.level-intro.large .level-title { font-size: 3rem; }
.level-intro.large .level-how { font-size: 1.4rem; max-width: 50rem; }
.level-intro.large .target-value { font-size: 7rem; }
.stage-progress { display: flex; justify-content: center; gap: 1rem; flex-wrap: wrap; }
.progress-team { display: flex; align-items: center; gap: 0.6rem; font-size: 1.4rem; padding: 0.8rem 1.4rem; border-radius: 14px; background: var(--surface); border-bottom: 5px solid var(--team); }
.stage-heading { font-size: 2.4rem; text-align: center; margin: 0; }
.reveal.large { font-size: 1.25rem; }
.reveal.large .reveal-team { padding: 1.2rem 1.5rem; }
.reveal.large .points { font-size: 2.2rem; }
.reveal.large .accuracy-bar { height: 1.2rem; }
.reveal.large .accuracy-value { font-size: 1.6rem; }
.team-board.large { font-size: 1.3rem; max-width: 900px; width: 100%; margin: 0 auto; }
.team-board.large .team-row { padding: 1rem 1.2rem; }
.team-board.large .team-score { font-size: 2.4rem; }
.final.large .final-title { font-size: 3.2rem; }
.final.large .final-trophy { font-size: 6rem; }

@media (max-width: 860px) {
    .game { grid-template-columns: 1fr; }
    .game-side { position: static; }
    .stage-lobby { grid-template-columns: 1fr; }
    .stage-top { flex-wrap: wrap; }
}

/* Color levels: swatches */
.swatch { margin: 0; display: inline-flex; flex-direction: column; align-items: center; gap: 0.4rem; }
.swatch-color {
    --size: 5rem;
    width: var(--size); height: var(--size); border-radius: 50%;
    background: var(--swatch); display: grid; place-items: center; font-size: 2rem; font-weight: 800; color: var(--muted);
    box-shadow: 0 0 0 4px var(--surface), 0 0 0 5px var(--border), 0 0 40px color-mix(in srgb, var(--swatch) 55%, transparent);
    transition: background 0.4s;
}
.swatch figcaption { font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.swatch.medium .swatch-color { --size: 6.5rem; }
.swatch.large .swatch-color { --size: 9rem; }
.swatch.huge .swatch-color { --size: 15rem; }
.swatch.live .swatch-color { transition: background 0.15s; }
.swatch.pour-in .swatch-color { animation: pour-in 1.2s ease-out; }
@keyframes pour-in { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0 0 0 0); } }
.swatch-pair { display: flex; justify-content: center; gap: 2.5rem; flex-wrap: wrap; margin: 1rem 0; }
.secret-target { font-size: 1.3rem; font-weight: 700; margin: 0.8rem 0 0.2rem; }
.level-intro.large .secret-target { font-size: 2.2rem; }
.rule-reminder { display: inline-block; margin: 0.4rem 0; padding: 0.3rem 0.9rem; border-radius: 999px; background: var(--danger); color: #fff; font-weight: 800; }
.level-intro.large .rule-reminder { font-size: 1.6rem; }
.my-role { font-weight: 700; margin: 0.8rem 0 0; }
.role-banner { font-size: 1.2rem; font-weight: 800; text-align: center; margin: 0 0 0.5rem; }
.describer, .mixer { display: flex; flex-direction: column; align-items: center; gap: 0.8rem; text-align: center; }
.done-note { font-size: 1.3rem; font-weight: 800; color: var(--good); margin: 0; }
.done-button { min-width: 10rem; }

/* Pouring: glowing liquid light in beakers */
.pour { display: flex; justify-content: center; align-items: flex-end; gap: 2rem; flex-wrap: wrap; padding: 0.5rem 0; }
.pour-hint { flex-basis: 100%; text-align: center; margin: 0; }
.beaker-wrap { display: flex; flex-direction: column; align-items: center; gap: 0.6rem; --flow: 0.3; }
.beaker {
    position: relative; width: 7rem; height: 11rem;
    border: 3px solid color-mix(in srgb, var(--text) 35%, transparent); border-top: 0;
    border-radius: 0 0 1.6rem 1.6rem; overflow: visible;
    background: linear-gradient(90deg, transparent 70%, color-mix(in srgb, var(--text) 6%, transparent));
}
.beaker::before { content: ""; position: absolute; top: -3px; left: -8px; right: -8px; height: 3px; background: color-mix(in srgb, var(--text) 35%, transparent); border-radius: 3px; }
.liquid {
    position: absolute; left: 0; right: 0; bottom: 0; height: 0;
    border-radius: 0 0 1.4rem 1.4rem; overflow: hidden;
    background: linear-gradient(180deg, color-mix(in srgb, var(--liquid) 85%, #fff), var(--liquid));
    box-shadow: 0 0 24px color-mix(in srgb, var(--liquid) 70%, transparent), inset 0 0 18px color-mix(in srgb, #fff 30%, transparent);
    transition: height 0.08s linear;
}
.surface {
    position: absolute; top: -6px; left: -10%; width: 120%; height: 12px; border-radius: 50%;
    background: color-mix(in srgb, var(--liquid) 60%, #fff); opacity: 0.8;
}
.pouring .surface { animation: slosh 0.5s ease-in-out infinite alternate; }
@keyframes slosh { from { transform: translateX(-4%) rotate(-2deg); } to { transform: translateX(4%) rotate(2deg); } }
.stream {
    position: absolute; left: 50%; top: -3.5rem; bottom: 0; width: calc(4px + 10px * var(--flow)); transform: translateX(-50%);
    background: linear-gradient(180deg, transparent, var(--liquid) 25%, var(--liquid));
    border-radius: 6px; opacity: 0; box-shadow: 0 0 16px var(--liquid); transition: opacity 0.12s, width 0.2s;
}
.pouring .stream { opacity: 0.95; animation: stream-wobble 0.18s linear infinite alternate; }
@keyframes stream-wobble { from { margin-left: -1px; } to { margin-left: 1px; } }
.splash { position: absolute; left: 50%; bottom: 0; width: 3rem; height: 1rem; transform: translateX(-50%); opacity: 0; }
.pouring .splash { opacity: 1; background: radial-gradient(circle, color-mix(in srgb, var(--liquid) 80%, #fff) 0 20%, transparent 21%) 0 0 / 0.7rem 0.7rem; animation: fizz 0.3s steps(3) infinite; }
@keyframes fizz { to { background-position: 0.7rem -0.5rem; } }
.spilling .beaker { animation: shake 0.15s linear infinite; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(3px); } }
.full .beaker-amount { color: var(--danger); }
.beaker-label { font-weight: 700; }
.beaker-amount { color: var(--muted); font-variant-numeric: tabular-nums; margin-left: 0.3rem; }
.pour-button {
    min-width: 7rem; min-height: 3.2rem; border-radius: 999px; touch-action: none; user-select: none;
    background: var(--liquid); color: #111; box-shadow: 0 0 18px color-mix(in srgb, var(--liquid) 55%, transparent);
}
.channel-blue .pour-button { color: #fff; }
.pouring .pour-button { transform: scale(0.96); filter: brightness(1.15); }
.pour-button kbd { font: inherit; font-size: 0.75rem; padding: 0 0.35rem; border: 1px solid currentColor; border-radius: 4px; opacity: 0.7; }

/* Color reveal */
.color-reveal { display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; }
.versus { font-size: 1.5rem; color: var(--muted); }
.contributions { list-style: none; padding: 0; margin: 0 0 0 auto; display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.95rem; }
.contributions li { display: flex; align-items: center; gap: 0.4rem; }
.drop { display: inline-flex; align-items: center; justify-content: center; min-width: 2.6rem; padding: 0.05rem 0.4rem; border-radius: 999px; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 0.85rem; }
.drop.channel-red { background: #ff3b5c; color: #111; }
.drop.channel-green { background: #22e06b; color: #111; }
.drop.channel-blue { background: #3b7bff; color: #fff; }
.drop.channel-white { background: #eee; color: #111; border: 1px solid var(--border); }
.reveal.large .swatch.medium .swatch-color { --size: 8rem; }

/* Cutting levels */
.cut-canvas {
    --cut-shape: #7c6cf6; --cut-a: rgba(255, 176, 32, 0.6); --cut-b: rgba(20, 184, 166, 0.55); --cut-frame: rgba(128, 128, 128, 0.55);
    display: block; width: min(100%, 460px); aspect-ratio: 1; touch-action: none;
    background: var(--surface-2); border-radius: 14px;
}
.cut-canvas.medium { width: min(100%, 300px); margin: 0.5rem auto 0; }
.cut-canvas.small { width: 200px; flex: none; }
.cut-canvas.large { width: min(100%, 52vh); margin: 0.5rem auto 0; }
.stage .cut-canvas { --cut-shape: #9d90ff; }
.cut-play { display: flex; flex-direction: column; align-items: center; gap: 0.8rem; text-align: center; }
.cut-play .cut-canvas { cursor: crosshair; }
.cut-target { font-size: 1.6rem; font-weight: 900; margin: 0; }
.level-intro.large .cut-target { font-size: 3rem; }
.cutter-status { list-style: none; display: flex; gap: 1rem; padding: 0; margin: 0; font-weight: 600; }
.cut-reveal { display: flex; gap: 1.2rem; align-items: flex-start; flex-wrap: wrap; }
.cut-reveal .cut-target { font-size: 1.1rem; margin-bottom: 0.4rem; }
.cut-reveal .attempts { grid-template-columns: 1fr; }
.reveal.large .cut-canvas.small { width: 260px; }

/* Chameleon */
.chameleon, .challenge { display: flex; flex-direction: column; align-items: center; gap: 0.8rem; text-align: center; }
.chameleon-canvas { display: block; width: 100%; max-width: min(760px, calc((100vh - 360px) * 1.6)); border-radius: 12px; box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15); }
.chameleon-canvas.seek { cursor: crosshair; }
.seek-status { display: flex; gap: 1.5rem; font-weight: 800; font-size: 1.1rem; }
.clicks-left.urgent { color: var(--danger); }
.light-sliders { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; justify-content: center; }
.swatch.small .swatch-color { --size: 3rem; }
.light-slider { flex-direction: row; align-items: center; gap: 0.5rem; }
.light-slider input { min-height: 0; width: 9rem; padding: 0; }
.light-slider.channel-red input { accent-color: #ff3b5c; }
.light-slider.channel-green input { accent-color: #22c55e; }
.light-slider.channel-blue input { accent-color: #3b7bff; }
.chameleon-reveal { display: flex; flex-direction: column; gap: 0.6rem; }
.chameleon-reveal .chameleon-canvas { max-width: 520px; }
.chameleon-reveal .attempts { grid-template-columns: 1fr; }

/* Team challenge */
.color-pick { flex-direction: row; align-items: center; gap: 0.6rem; }
.color-pick input[type="color"] { width: 4rem; height: 3rem; padding: 0.2rem; }
.percent-pick { align-items: center; }
.percent-pick input { width: 16rem; min-height: 0; padding: 0; }
.draw-canvas { cursor: crosshair; }
.made-by { margin: 0 0 0.4rem; color: var(--muted); font-size: 0.95rem; }
.maker-bonus { color: var(--good); }

/* Sabotage: the controls, the banner on the target team, the effects, the presenter feed and the reveal replay. */
.sabotage-banner {
    margin: 0 0 0.8rem; padding: 0.7rem 1rem; border-radius: var(--radius); font-weight: 700; text-align: center;
    background: color-mix(in srgb, var(--team, var(--danger)) 18%, var(--surface)); border: 2px solid var(--team, var(--danger));
    animation: sabotage-pop 0.4s ease-out;
}
.sabotage-panel { margin: 0 0 0.8rem; padding: 0.5rem 0.9rem; border: 1px dashed var(--input-border); border-radius: var(--radius); background: var(--surface); }
.sabotage-panel summary { cursor: pointer; font-weight: 700; }
.sabotage-kind { margin-top: 0.6rem; }
.sabotage-kind p { margin: 0 0 0.35rem; }
.sabotage-target .team-swatch { margin-right: 0.35rem; }
.sabotage-feed { list-style: none; padding: 0; margin: 1rem auto 0; display: flex; flex-direction: column; align-items: center; gap: 0.4rem; }
.sabotage-feed li, .catch-up {
    padding: 0.35rem 0.9rem; border-radius: 999px; font-weight: 700;
    background: color-mix(in srgb, var(--team, var(--accent)) 16%, var(--surface)); animation: sabotage-pop 0.4s ease-out;
}
.catch-up { display: block; width: fit-content; margin: 0 auto 1rem; }
.sabotage-replay { margin: 0.4rem 0; font-size: 0.9rem; font-weight: 600; color: var(--team, var(--muted)); }
.team-tokens { font-size: 0.95rem; white-space: nowrap; }

.swatch.fogged .swatch-color { filter: blur(14px) grayscale(0.9) brightness(1.15); transition: filter 0.3s; }
.seek-frame { width: 100%; display: flex; justify-content: center; }
.seek-frame.fogged canvas { filter: blur(9px) saturate(0.6); transition: filter 0.3s; }
.cut-frame { width: 100%; }
.cut-frame .cut-canvas { margin-inline: auto; }
.cut-frame.wobbling canvas { animation: wobble 0.7s ease-in-out infinite; }
.hidden-target { letter-spacing: 0.1em; color: var(--muted); }

@keyframes sabotage-pop { from { transform: scale(0.85); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes wobble {
    0%, 100% { transform: none; }
    20% { transform: rotate(-7deg) translateX(-10px) skewX(4deg); }
    45% { transform: rotate(6deg) translateY(8px) skewY(-3deg); }
    70% { transform: rotate(-4deg) translateX(12px) scale(1.04); }
}
@media (prefers-reduced-motion: reduce) {
    .cut-frame.wobbling canvas { animation: none; filter: blur(4px); }
}

/* How to play: sections, the points table and small looping demos. */
.howto { max-width: 960px; }
.howto-section { margin: 2rem 0; }
.howto-phases { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.6rem; counter-reset: phase; }
.howto-phases li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.7rem 0.9rem; display: flex; flex-direction: column; gap: 0.2rem; counter-increment: phase; }
.howto-phases li strong::before { content: counter(phase) ". "; color: var(--muted); }
.howto-points { border-collapse: collapse; min-width: min(100%, 360px); }
.howto-points th, .howto-points td { text-align: left; padding: 0.4rem 1rem 0.4rem 0; border-bottom: 1px solid var(--border); }
.howto-points td:last-child, .howto-points th:last-child { text-align: right; font-weight: 800; }
.howto-points .closest td { color: var(--accent); }
.howto-family { margin: 1.4rem 0 0.2rem; }
.howto-levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; margin-top: 0.8rem; }
.howto-level { margin: 0; }
.howto-level h4 { margin: 0.6rem 0 0.3rem; font-size: 1.05rem; }
.howto-level p { margin: 0; font-size: 0.92rem; }
.demo-box { height: 120px; display: grid; place-items: center; background: var(--surface-2); border-radius: var(--radius); overflow: hidden; }
.demo { display: flex; align-items: center; justify-content: center; gap: 0.7rem; }
.demo-arrow, .bubble { font-size: 1.5rem; color: var(--muted); }
.mini-swatch { width: 54px; height: 54px; border-radius: 50%; background: #e8a33c; box-shadow: 0 0 0 3px var(--surface); }

.demo-clock .dial { position: relative; width: 70px; height: 70px; border-radius: 50%; border: 4px solid var(--text); animation: dial-hide 4s infinite; }
.demo-clock .hand { position: absolute; left: calc(50% - 2px); bottom: 50%; width: 4px; height: 42%; background: var(--red); border-radius: 2px; transform-origin: bottom center; animation: spin 4s linear infinite; }
.demo-time { font-size: 1.6rem; font-weight: 900; animation: time-pop 4s infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes dial-hide { 0%, 25% { opacity: 1; } 35%, 85% { opacity: 0.12; } 100% { opacity: 1; } }
@keyframes time-pop { 0%, 75% { opacity: 0; transform: scale(0.6); } 85%, 100% { opacity: 1; transform: none; } }

.demo-pour .beaker { position: relative; width: 22px; height: 70px; border: 2px solid var(--muted); border-top: none; border-radius: 0 0 6px 6px; overflow: hidden; }
.demo-pour .beaker i { position: absolute; left: 0; right: 0; bottom: 0; height: 0; animation: fill 4s ease-in infinite; }
.demo-pour .r i { background: var(--red); --to: 90%; }
.demo-pour .g i { background: var(--green); --to: 60%; animation-delay: 0.3s; }
.demo-pour .b i { background: var(--blue); --to: 20%; animation-delay: 0.6s; }
.demo-pour .flask { width: 60px; height: 60px; border-radius: 50%; animation: mix 4s ease-in infinite; }
@keyframes fill { 0% { height: 0; } 60%, 100% { height: var(--to); } }
@keyframes mix { 0% { background: #2a2a2a; } 30% { background: #8a3b2c; } 60%, 100% { background: #e8a33c; } }

.demo-describe .mixing { animation: describe 4s ease-in-out infinite; }
@keyframes describe { 0% { background: #8a8a8a; } 35% { background: #6f9bd8; } 65%, 100% { background: #e8a33c; } }

.demo-cut { width: 100px; height: 100px; }
.demo-cut .frame { fill: none; stroke: var(--border); stroke-width: 1.5; stroke-dasharray: 4 3; }
.demo-cut .blob { fill: #7c6cf6; opacity: 0.85; }
.demo-cut .cutline { stroke: var(--text); stroke-width: 3; stroke-linecap: round; transform-box: view-box; transform-origin: 50px 50px; animation: sweep 3s ease-in-out infinite alternate; }
.demo-cut.blind .blob { animation: blink 3s ease-in-out infinite; }
.demo-cut.wobbly .blob { transform-box: view-box; transform-origin: 50px 50px; animation: wobble 0.8s ease-in-out infinite; }
.demo-percent { font-size: 1.5rem; font-weight: 900; }
@keyframes sweep { from { transform: rotate(-25deg) translateY(-6px); } to { transform: rotate(18deg) translateY(8px); } }
@keyframes blink { 0%, 30% { opacity: 0; } 60%, 100% { opacity: 0.85; } }

.demo-chameleon { position: relative; width: 170px; height: 100px; border-radius: 10px;
    background: radial-gradient(circle at 20% 30%, #6b8e5a 0 18%, transparent 19%), radial-gradient(circle at 70% 60%, #a3b86c 0 22%, transparent 23%),
        radial-gradient(circle at 45% 80%, #3e5c3a 0 15%, transparent 16%), linear-gradient(135deg, #8aa66a, #556f43); }
.demo-chameleon .hidden-blob { position: absolute; left: 62%; top: 42%; width: 22px; height: 22px; border-radius: 50%; background: #9db368; animation: found 4s infinite; }
.demo-chameleon .seeker { position: absolute; font-size: 1.4rem; animation: seek 4s ease-in-out infinite; }
@keyframes seek { 0% { left: 10%; top: 10%; } 40% { left: 40%; top: 55%; } 70%, 100% { left: 60%; top: 30%; } }
@keyframes found { 0%, 70% { box-shadow: none; } 80%, 100% { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--good); } }

.demo-challenge .team-dot { width: 34px; height: 34px; border-radius: 50%; background: var(--team); }
.demo-challenge .gift { font-size: 1.6rem; animation: hand-over 3s ease-in-out infinite; }
@keyframes hand-over { 0% { transform: translateX(-34px) scale(0.7); opacity: 0; } 30%, 70% { transform: none; opacity: 1; } 100% { transform: translateX(34px) scale(0.7); opacity: 0; } }

.demo-drip { flex-direction: column; gap: 0.2rem; }
.demo-drip .drop { width: 12px; height: 12px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--blue); animation: drop 3s ease-in infinite; }
.demo-drip .mini-swatch { animation: dripped 3s infinite; }
@keyframes drop { 0% { opacity: 0; translate: 0 -20px; } 20% { opacity: 1; } 50%, 100% { opacity: 0; translate: 0 30px; } }
@keyframes dripped { 0%, 45% { background: #e8a33c; } 60%, 100% { background: #d5a07a; } }
.demo-fog .mini-swatch { width: 70px; height: 70px; animation: fog 3s ease-in-out infinite; }
@keyframes fog { 0%, 20%, 100% { filter: none; } 40%, 80% { filter: blur(10px) grayscale(0.9) brightness(1.15); } }
.demo-hide { position: relative; width: 110px; height: 50px; font-size: 2rem; font-weight: 900; }
.demo-hide span { position: absolute; inset: 0; display: grid; place-items: center; }
.demo-hide .shown { animation: hide-a 3s infinite; }
.demo-hide .hidden { color: var(--muted); animation: hide-b 3s infinite; }
@keyframes hide-a { 0%, 30%, 90%, 100% { opacity: 1; } 40%, 80% { opacity: 0; } }
@keyframes hide-b { 0%, 30%, 90%, 100% { opacity: 0; } 40%, 80% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
    .howto *, .howto *::before { animation: none !important; }
    .demo-pour .beaker i { height: var(--to); }
    .demo-pour .flask, .demo-describe .mixing { background: #e8a33c; }
    .demo-time { opacity: 1; }
}

/* Reveal: the flask fills color by color (base first), each one slowly blending in; its drops light up meanwhile. */
.swatch.mixing .swatch-color {
    --swatch: var(--final); position: relative; background: #111;
    animation: glow-in 0.8s ease-out both; animation-delay: calc(var(--steps) * var(--step) + 0.8s);
}
.mix-layer { position: absolute; inset: 0; border-radius: inherit; background: var(--swatch); animation: mix-in var(--step) ease-in-out both; animation-delay: calc(var(--i) * var(--step) + 0.8s); }
.mix-layer:first-child { animation-name: mix-first; }
.drop.mix-drop { opacity: 0.3; animation: drop-in var(--step) ease-in-out both; animation-delay: calc(var(--i) * var(--step) + 0.8s); }
@keyframes mix-in { from { opacity: 0; } }
@keyframes mix-first { from { opacity: 0; transform: scale(0.2); } }
@keyframes drop-in { from { opacity: 0.3; transform: scale(0.8); } 25% { opacity: 1; transform: scale(1.3); } 50%, to { opacity: 1; transform: none; } }
@keyframes glow-in { from { box-shadow: 0 0 0 4px var(--surface), 0 0 0 5px var(--border); } }

/* Reveal: Stop the clock — the target bar, then each player's bar running in time and stopping. */
.clock-reveal { display: grid; grid-template-columns: minmax(5rem, auto) 1fr auto auto; gap: 0.45rem 0.75rem; align-items: center; margin-top: 0.4rem; font-size: 0.95rem; }
.clock-row { display: contents; }
.clock-row.target .attempt-value, .clock-row .hint { grid-column: span 2; }
.clock-row.target .attempt-name { font-weight: 700; }
.clock-track { position: relative; height: 0.9rem; background: var(--surface-2); border-radius: 999px; }
.clock-track i { display: block; height: 100%; width: var(--value); border-radius: 999px; background: var(--team); }
.clock-row.target .clock-track i { background: repeating-linear-gradient(-45deg, var(--muted) 0 6px, color-mix(in srgb, var(--muted) 55%, transparent) 6px 12px); }
.clock-track::after { content: ""; position: absolute; left: var(--target); top: -0.3rem; bottom: -0.3rem; width: 2px; margin-left: -1px; background: var(--text); border-radius: 1px; }
.clock-run { animation: grow var(--duration) linear both; animation-delay: 0.8s; }
.clock-stop { animation: pop 0.4s ease-out both; animation-delay: calc(var(--duration) + 0.8s); }
.reveal.large .clock-reveal { font-size: 1.1rem; }
.reveal.large .clock-track { height: 1.2rem; }

/* Reveal: a team's result waits for its level animation (--result-delay, set per card). */
.reveal-team .points, .reveal-team .closest-badge, .reveal-team .accuracy, .cut-reveal .attempt-value, .cut-reveal .attempt-accuracy {
    animation: pop 0.45s ease-out both; animation-delay: var(--result-delay, 0s);
}
.reveal-team.closest { animation: slide-in 0.5s ease-out, closest-in 0.5s ease-out both; animation-delay: 0s, var(--result-delay, 0s); }
@keyframes closest-in { from { box-shadow: 0 0 0 0 var(--team); } }

@media (prefers-reduced-motion: reduce) {
    .reveal-team .points, .reveal-team .closest-badge, .reveal-team .accuracy, .cut-reveal .attempt-value, .cut-reveal .attempt-accuracy,
    .reveal-team.closest, .accuracy-bar i { animation-delay: 0s; }
    .mix-layer, .drop.mix-drop, .swatch.mixing .swatch-color, .clock-run, .clock-stop { animation: none; }
    .drop.mix-drop { opacity: 1; }
}
