/* Base layout and design variables. No external resources (school network filter). */

@font-face {
    font-family: "Andika";
    src: url("/assets/fonts/Andika-Regular.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Andika";
    src: url("/assets/fonts/Andika-Bold.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    /* Okabe-Ito palette, colour-blind-safe */
    --okabe-orange: #E69F00;
    --okabe-sky-blue: #56B4E9;
    --okabe-green: #009E73;
    --okabe-yellow: #F0E442;
    --okabe-blue: #0072B2;
    --okabe-vermillion: #D55E00;
    --okabe-purple: #CC79A7;

    /* Answer colours, each colour always paired with the same shape.
       Contrast is checked in phase 4. */
    --answer-1: var(--okabe-vermillion);   /* triangle */
    --answer-1-text: #FFFFFF;
    --answer-2: var(--okabe-blue);         /* circle */
    --answer-2-text: #FFFFFF;
    --answer-3: var(--okabe-orange);       /* square */
    --answer-3-text: #1A1A2E;
    --answer-4: var(--okabe-green);        /* star */
    --answer-4-text: #FFFFFF;

    /* Surfaces and text */
    --color-background: #2B2A6B;
    --color-background-accent: #3D3B8E;
    --color-surface: #FFFFFF;
    --color-text: #1A1A2E;
    --color-text-muted: #55557A;
    --color-text-on-dark: #FFFFFF;
    --color-primary: var(--okabe-blue);
    --color-primary-text: #FFFFFF;
    --color-ok: var(--okabe-green);
    --color-warning: var(--okabe-orange);
    --color-error: var(--okabe-vermillion);
    /* Error text on white cards: vermillion itself is too light for small text (3.9:1); this is 6.6:1. */
    --color-error-text: #A33A00;

    /* Font and sizes relative to the screen width, readable on the projector */
    --font-family: "Andika", "Segoe UI", system-ui, sans-serif;
    --font-size-small: clamp(0.8rem, 1vw, 1rem);
    --font-size-normal: clamp(1.1rem, 1.8vw, 1.6rem);
    --font-size-large: clamp(1.6rem, 3.5vw, 3rem);
    --font-size-huge: clamp(2.5rem, 7vw, 6rem);

    --space-small: 0.5rem;
    --space-normal: 1rem;
    --space-large: 2rem;
    --radius: 1rem;
    --shadow: 0 0.4rem 1.2rem rgb(0 0 0 / 0.25);
}

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

html, body {
    height: 100%;
    margin: 0;
}

body {
    display: flex;
    flex-direction: column;
    font-family: var(--font-family);
    font-size: var(--font-size-normal);
    line-height: 1.4;
    color: var(--color-text-on-dark);
    background: radial-gradient(circle at top, var(--color-background-accent), var(--color-background));
}

/* ── Layout ───────────────────────────────────────────────────────── */

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-normal);
    padding: var(--space-small) var(--space-normal);
    background: rgb(0 0 0 / 0.2);
}

.top-bar h1 {
    margin: 0;
    font-size: var(--font-size-normal);
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-large);
    padding: var(--space-large) var(--space-normal);
    text-align: center;
}

.title {
    margin: 0;
    font-size: var(--font-size-huge);
    font-weight: 700;
    text-shadow: var(--shadow);
}

.card {
    display: flex;
    flex-direction: column;
    gap: var(--space-normal);
    width: min(32rem, 100%);
    padding: var(--space-large);
    border-radius: var(--radius);
    color: var(--color-text);
    background: var(--color-surface);
    box-shadow: var(--shadow);
}

.card label {
    font-weight: 700;
}

/* ── Controls ─────────────────────────────────────────────────────── */

input {
    width: 100%;
    padding: var(--space-small) var(--space-normal);
    font: inherit;
    color: var(--color-text);
    border: 0.2rem solid var(--color-text-muted);
    border-radius: calc(var(--radius) / 2);
}

input:focus-visible, button:focus-visible {
    outline: 0.25rem solid var(--okabe-yellow);
    outline-offset: 0.15rem;
}

.code-input {
    font-size: var(--font-size-huge);
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.3em;
    text-indent: 0.3em;   /* balances the spacing after the last digit */
}

.button {
    padding: var(--space-small) var(--space-large);
    font: inherit;
    font-weight: 700;
    color: var(--color-primary-text);
    background: var(--color-primary);
    border: none;
    border-radius: calc(var(--radius) / 2);
    cursor: pointer;
}

.button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.button-small {
    padding: 0.2rem var(--space-normal);
    font-size: var(--font-size-small);
}

.message {
    min-height: 1.4em;
    margin: 0;
    color: var(--color-text-muted);
}

.message.error {
    color: var(--color-error-text);
    font-weight: 700;
}

/* ── Status footer (connection state and transport for debugging) ─── */

.status-footer {
    display: flex;
    justify-content: center;
    gap: var(--space-normal);
    padding: 0.25rem var(--space-normal);
    font-size: var(--font-size-small);
    opacity: 0.75;
}

/* Shape plus colour, so the state is readable without colour vision */
.status-footer [data-state="connected"]::before {
    content: "● ";
    color: var(--color-ok);
}

.status-footer [data-state="connecting"]::before,
.status-footer [data-state="reconnecting"]::before {
    content: "◐ ";
    color: var(--color-warning);
}

.status-footer [data-state="offline"]::before {
    content: "✕ ";
    color: var(--color-error);
}

/* ── Screens and views ────────────────────────────────────────────── */

[hidden] {
    display: none !important;
}

.screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-large);
    width: 100%;
}

/* ── Host control bar ─────────────────────────────────────────────── */

.controls {
    display: flex;
    align-items: center;
    gap: var(--space-normal);
    font-size: var(--font-size-small);
    flex-wrap: wrap;
    row-gap: var(--space-small);
}

.player-panel {
    position: relative;
}

.player-panel summary {
    cursor: pointer;
}

.player-list {
    position: absolute;
    z-index: 10;
    top: 100%;
    left: 0;
    min-width: 20rem;
    max-height: 70vh;
    overflow-y: auto;
    margin: var(--space-small) 0 0;
    padding: var(--space-small);
    list-style: none;
    color: var(--color-text);
    background: var(--color-surface);
    border-radius: calc(var(--radius) / 2);
    box-shadow: var(--shadow);
}

.player-list:empty::before {
    content: "No players yet.";
    color: var(--color-text-muted);
}

.player-list li {
    display: flex;
    align-items: center;
    gap: var(--space-small);
    padding: 0.2rem 0;
}

.player-list-name {
    flex: 1;
}

/* Shape plus colour: ● online, ○ offline */
.online-state[data-online="true"] {
    color: var(--color-ok);
}

.online-state[data-online="false"] {
    color: var(--color-text-muted);
}

.button-danger {
    background: var(--color-error);
}

.button-secondary {
    color: var(--color-primary);
    background: transparent;
    border: 0.15rem solid var(--color-primary);
}

/* ── Waiting room ─────────────────────────────────────────────────── */

.waiting-room {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-normal);
}

.join-hint {
    margin: 0;
    font-size: var(--font-size-large);
}

.game-code {
    margin: 0;
    padding: var(--space-small) var(--space-large);
    font-size: var(--font-size-huge);
    font-weight: 700;
    letter-spacing: 0.2em;
    color: var(--color-text);
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.join-count {
    margin: 0;
    font-size: var(--font-size-normal);
    opacity: 0.85;
}

.name-cloud {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-small);
    max-width: 90vw;
    margin: 0;
    padding: 0;
    list-style: none;
}

.name-cloud li {
    padding: 0.2rem var(--space-normal);
    font-size: var(--font-size-large);
    font-weight: 700;
    color: var(--color-text);
    background: var(--color-surface);
    border-radius: 999px;
}

.name-cloud li.new {
    /* A bouncy pop and a short yellow glow, so a new name is seen from the back of the room. */
    animation: join-pop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1), join-glow 1.4s ease-out;
}

/* Bot mode (development only): a small dark tag after the name. */
.bot-badge {
    display: inline-block;
    margin-left: 0.4em;
    padding: 0.05em 0.4em;
    font-size: 0.6em;
    font-weight: 700;
    letter-spacing: 0.05em;
    vertical-align: middle;
    color: var(--color-text-on-dark);
    background: var(--color-text-muted);
    border-radius: 0.3em;
}

.own-name {
    margin: 0;
    font-size: var(--font-size-huge);
    font-weight: 700;
    text-shadow: var(--shadow);
}

@keyframes pop-in {
    from {
        transform: scale(0.5);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .name-cloud li.new {
        animation: none;
    }
}

.button-stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-small);
}

/* ── Round start, end, notice ─────────────────────────────────────── */

.round-start {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-normal);
    text-align: center;
}

.round-title {
    margin: 0;
    font-size: var(--font-size-huge);
    text-shadow: var(--shadow);
}

.team-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-normal);
    margin: 0;
    padding: 0;
    list-style: none;
}

.team-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-small);
    max-width: 22rem;
    padding: var(--space-normal);
    color: var(--color-text);
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.team-members {
    margin: 0;
    font-size: var(--font-size-normal);
}

/* Team colour plus shape (colour-blind safe). Text colours as for the answer colours. */
.team-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-small);
    padding: 0.1rem var(--space-normal);
    font-weight: 700;
    border-radius: 999px;
}

.team-badge[data-color="vermillion"] {
    color: var(--answer-1-text);
    background: var(--okabe-vermillion);
}

.team-badge[data-color="blue"] {
    color: var(--answer-2-text);
    background: var(--okabe-blue);
}

.team-badge[data-color="orange"] {
    color: var(--answer-3-text);
    background: var(--okabe-orange);
}

.team-badge[data-color="green"] {
    color: var(--answer-4-text);
    background: var(--okabe-green);
}

/* ── Host flow controls ───────────────────────────────────────────── */

.phase-label {
    min-width: 8rem;
    opacity: 0.85;
}

/* ── Version banner (wwwroot/js/core/version.js) ───────────────────── */

.version-banner {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--space-normal);
    padding: 0.5rem var(--space-normal);
    background: var(--okabe-yellow);
    color: var(--color-text);
    font-weight: 700;
}

.version-banner::before {
    content: "⚠";
}

/* ── Timer (wwwroot/js/core/timer.js) ─────────────────────────────── */

/* Fixed in the top right corner, large enough for the back of the room. A ring shows the time left
   (--timer-fraction from 1 to 0), the number counts down. Urgent: the last 5 seconds. */
.timer {
    position: fixed;
    top: 4rem;
    right: var(--space-normal);
    z-index: 50;
    display: grid;
    place-items: center;
    width: clamp(4rem, 9vw, 8rem);
    aspect-ratio: 1;
    border-radius: 50%;
    color: var(--color-text);
    background:
        radial-gradient(circle, var(--color-surface) 62%, transparent 63%),
        conic-gradient(var(--okabe-sky-blue) calc(var(--timer-fraction, 1) * 360deg), rgb(255 255 255 / 0.25) 0);
    box-shadow: var(--shadow);
}

.timer[hidden] {
    display: none;
}

.timer-seconds {
    font-size: var(--font-size-large);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.timer[data-urgent="true"] {
    background:
        radial-gradient(circle, var(--color-surface) 62%, transparent 63%),
        conic-gradient(var(--okabe-vermillion) calc(var(--timer-fraction, 1) * 360deg), rgb(255 255 255 / 0.25) 0);
}

/* Paused (noise meter): a pause sign instead of the colour ring. */
.timer[data-paused="true"]::after {
    content: "❚❚";
    position: absolute;
    bottom: -0.2rem;
    font-size: var(--font-size-small);
    color: var(--color-text-on-dark);
}

/* ── Answer counter in the host bar ───────────────────────────────── */

.answer-count {
    padding: 0.1rem var(--space-small);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--color-text);
    background: var(--color-surface);
    border-radius: 999px;
}

.answer-count[hidden] {
    display: none;
}

/* ── Game choice on the host create screen ────────────────────────── */

.game-select {
    padding: var(--space-small);
    font: inherit;
    border: 0.15rem solid var(--color-primary);
    border-radius: var(--radius);
}

.waiting-title {
    margin: 0;
    font-size: var(--font-size-large);
}

.game-problems {
    width: min(48rem, 100%);
    text-align: left;
}

.game-problems h2 {
    margin: 0;
    color: var(--color-error);
}

.game-problems ul {
    margin: var(--space-small) 0 0;
    padding-left: var(--space-large);
    font-family: ui-monospace, Consolas, monospace;
    font-size: var(--font-size-small);
}

.game-problem summary {
    font-weight: 700;
    cursor: pointer;
}

/* ── Demo mode (wwwroot/js/plugins/gamemodes/demo.js) ──────────────── */

.demo-button {
    min-width: 60vw;
    padding: var(--space-large);
    font-size: var(--font-size-huge);
}

/* ── Questions and reveal (wwwroot/js/core/question.js, question type modules) ── */

/* Views fill the height below the bar, so the question screens can use the vertical space. Other views
   (waiting room, round start) stay centred. */
.view {
    flex: 1;
    justify-content: center;
}

.question {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-normal);
    width: min(80rem, 100%);
    min-height: 0;
    text-align: center;
}

.question-number {
    margin: 0;
    font-size: var(--font-size-normal);
    opacity: 0.85;
}

.question-text {
    margin: 0;
    font-size: var(--font-size-large);
    line-height: 1.2;
    text-shadow: var(--shadow);
}

.question-image {
    max-width: min(40rem, 90vw);
    max-height: 35vh;
    min-height: 0;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.question-hint {
    margin: 0;
    font-size: var(--font-size-normal);
    opacity: 0.85;
}

/* Read step: only the question, large, and a bar that empties with the reading time
   (--timer-fraction from timer.js; the countdown ring is hidden). */
.question-read {
    gap: var(--space-large);
}

.read-text {
    font-size: clamp(2rem, 5.5vw, 5.5rem);
}

.read-title {
    margin: 0;
    font-size: var(--font-size-huge);
    font-weight: 700;
    line-height: 1.2;
    text-shadow: var(--shadow);
}

.read-progress {
    width: min(40rem, 80%);
    height: 1rem;
    overflow: hidden;
    border-radius: 999px;
    background: rgb(255 255 255 / 0.2);
}

.read-progress-fill {
    height: 100%;
    background: var(--okabe-yellow);
    transform-origin: left;
    transform: scaleX(var(--timer-fraction, 1));
    transition: transform 0.2s linear;
}

/* Every answer has its colour (--tile) and text colour (--tile-text), always paired with its shape. */
[data-answer="1"] {
    --tile: var(--answer-1);
    --tile-text: var(--answer-1-text);
}

[data-answer="2"] {
    --tile: var(--answer-2);
    --tile-text: var(--answer-2-text);
}

[data-answer="3"] {
    --tile: var(--answer-3);
    --tile-text: var(--answer-3-text);
}

[data-answer="4"] {
    --tile: var(--answer-4);
    --tile-text: var(--answer-4-text);
}

/* The answers: colour plus shape plus text. Two columns (three for three laptop buttons); all tiles of a
   grid have the same size. */
.answer-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: 1fr;
    gap: var(--space-normal);
    width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
}

.answer-grid.answer-single {
    grid-template-columns: minmax(0, 1fr);
    width: min(30rem, 100%);
}

@media (max-width: 40rem) {
    .answer-grid:not(.answer-buttons) {
        grid-template-columns: minmax(0, 1fr);
    }
}

.answer {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-normal);
    min-height: 4.5rem;
    padding: var(--space-normal) var(--space-large);
    font: inherit;
    font-size: var(--font-size-large);
    font-weight: 700;
    line-height: 1.2;
    text-align: left;
    color: var(--tile-text);
    background: var(--tile);
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.shape {
    flex: none;
    width: 1.4em;
    height: 1.4em;
    fill: currentColor;
}

.answer-text {
    flex: 1;
    overflow-wrap: anywhere;
}

/* Only colour and shape (laptop default): a big shape in the middle. */
.answer.shape-only {
    justify-content: center;
}

.answer.shape-only .shape {
    width: clamp(3rem, 11vw, 8rem);
    height: auto;
    aspect-ratio: 1;
}

.answer-single .answer.shape-only .shape {
    width: 4rem;
}

/* Projector while answering: the tiles fill the lower part of the screen. */
.question-answering .answer-grid {
    flex: 1 1 auto;
    max-height: 50vh;
    margin-top: auto;
}

/* Laptop: big buttons, easy to hit, filling the screen below the question. */
.question-answering .answer-buttons {
    flex: 1 1 auto;
    min-height: min(50vh, 24rem);
    max-height: none;
    margin-top: 0;
}

.answer-buttons[data-count="3"] {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.answer-button {
    cursor: pointer;
}

.answer-button:disabled {
    cursor: default;
    opacity: 0.45;
}

/* The own choice: an inner white line, so the size never changes. */
.answer-button:disabled.is-chosen,
.answer.is-chosen {
    opacity: 1;
    box-shadow: inset 0 0 0 0.35rem var(--color-text-on-dark), var(--shadow);
}

/* ── Reveal ───────────────────────────────────────────────────────── */

.reveal {
    justify-content: flex-start;
}

.reveal-tiles .answer {
    min-height: 3.5rem;
    padding: var(--space-small) 4rem var(--space-small) var(--space-normal);
    font-size: clamp(1.1rem, 2.2vw, 2rem);
}

/* The right answer: inner outline and ✓ (same size and place as every other tile). */
.answer.is-correct {
    box-shadow: inset 0 0 0 0.35rem var(--color-text-on-dark), var(--shadow);
}

/* Wrong answers: the tile dims, the text stays white and readable. A thin inner line in the full colour
   keeps the colours apart (dimmed vermillion and orange would both look brown). */
.answer.is-wrong,
.bar.is-wrong .bar-fill {
    color: var(--color-text-on-dark);
    background: color-mix(in srgb, var(--tile) 30%, #1E1D4D);
    box-shadow: inset 0 0 0 0.2rem var(--tile);
}

.answer-mark {
    position: absolute;
    top: 50%;
    right: var(--space-normal);
    display: grid;
    place-items: center;
    width: 1.6em;
    height: 1.6em;
    margin-top: -0.8em;
    font-weight: 700;
    color: var(--color-ok);
    background: var(--color-surface);
    border-radius: 50%;
}

/* The answer distribution: one vertical bar per answer, the number on top, its shape below. */
.bar-chart {
    flex: 1 1 12rem;
    display: flex;
    justify-content: center;
    gap: clamp(1rem, 5vw, 5rem);
    width: 100%;
    min-height: 9rem;
    max-height: 46vh;
    margin: 0;
    padding: 0;
    list-style: none;
}

.bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: clamp(4rem, 10vw, 10rem);
}

.bar-track {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: stretch;
    width: 100%;
    min-height: 0;
}

.bar-count {
    font-size: var(--font-size-large);
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.bar-fill {
    height: calc(var(--share, 0) * (100% - 4rem));
    min-height: 0.4rem;
    background: var(--tile);
    border-radius: 0.5rem 0.5rem 0 0;
    transform-origin: bottom;
}

.bar-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    padding: 0.3rem;
    color: var(--tile-text);
    background: var(--tile);
    border-radius: 0 0 0.5rem 0.5rem;
}

.bar-label .shape {
    width: clamp(1.4rem, 2.5vw, 2.2rem);
    height: auto;
    aspect-ratio: 1;
}

.bar-mark {
    display: grid;
    place-items: center;
    width: 1.6em;
    height: 1.6em;
    font-weight: 700;
    color: var(--color-ok);
    background: var(--color-surface);
    border-radius: 50%;
}

/* The sentence of the reveal: clearly highlighted, but never larger than the question. */
.reveal-sentence {
    margin: 0;
    padding: var(--space-small) var(--space-large);
    font-size: clamp(1.2rem, 2.6vw, 2.4rem);
    font-weight: 700;
    line-height: 1.25;
    color: var(--color-text);
    background: var(--color-surface);
    border-left: 0.6rem solid var(--okabe-yellow);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.reveal-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--space-small) var(--space-large);
}

.reveal-fastest {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--space-small);
    margin: 0;
}

.reveal-fastest-label {
    font-weight: 700;
}

.reveal-fastest-name {
    padding: 0.1rem 0.8rem;
    font-weight: 700;
    background: rgb(255 255 255 / 0.15);
    border-radius: 999px;
}

.reveal-summary {
    margin: 0;
    opacity: 0.85;
}

/* Laptop result: mark plus words, the colour only supports them. */
.laptop-reveal {
    justify-content: center;
}

.result {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-small);
    padding: var(--space-normal) var(--space-large);
    border-radius: var(--radius);
    background: rgb(0 0 0 / 0.2);
}

.result-mark-wrap {
    position: relative;
    display: grid;
    place-items: center;
}

.result-mark {
    display: grid;
    place-items: center;
    width: 1.6em;
    height: 1.6em;
    font-size: clamp(2rem, 4.5vw, 4rem);
    border-radius: 50%;
    color: var(--color-text-on-dark);
    background: var(--color-text-muted);
}

.result[data-verdict="correct"] .result-mark {
    background: var(--color-ok);
}

.result[data-verdict="wrong"] .result-mark,
.result[data-verdict="late"] .result-mark {
    background: var(--color-error);
}

/* Sparkles around a right answer: only visible while they fly (live); the end state hides them. */
.sparkles {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.sparkle {
    position: absolute;
    top: 50%;
    left: 50%;
    font-size: var(--font-size-large);
    color: var(--okabe-yellow);
    opacity: 0;
}

.result-title {
    margin: 0;
    font-size: clamp(2.2rem, 5.5vw, 5rem);
    line-height: 1.1;
    font-weight: 700;
    text-shadow: var(--shadow);
}

.result-points {
    margin: 0;
    font-size: var(--font-size-large);
    font-weight: 700;
}

.score {
    margin: 0;
    font-size: var(--font-size-large);
}

/* ── Word marks at the reveal ("LIE", "TRUE"): a badge instead of the round ✓ ── */

.answer-mark.is-word {
    width: auto;
    height: auto;
    margin-top: 0;
    padding: 0.1em 0.6em;
    font-size: 0.8em;
    letter-spacing: 0.05em;
    border-radius: 999px;
    /* "translate", not "transform", so the pop-in animation (a transform) keeps it centred. */
    translate: 0 -50%;
}

.answer.is-correct .answer-mark.is-word {
    color: var(--color-text-on-dark);
    background: var(--color-error);
}

.answer.is-wrong .answer-mark.is-word {
    color: var(--color-text);
    background: rgb(255 255 255 / 0.85);
}

/* ── truthlie: the statements are sentences, so one per row ───────── */

.answer-grid.statement-list {
    grid-template-columns: minmax(0, 1fr);
}

.question-answering .answer-grid.statement-list {
    max-height: 55vh;
}

.reveal-tiles.statement-list .answer {
    padding-right: 7.5rem;
}

/* ── blurphoto: the photo sharpens with the answer timer ──────────── */

/* The box clips the photo, so the blur never spills over the question text; while blurred the photo is a bit
   larger than its box, so its edges do not fade into the background. */
.blur-photo {
    /* Defaults; blurphoto.js sets them per question (startBlur, sharpAt from sharpAtSeconds, floor from startBlur). */
    --blur-max: 2vmin;
    --sharp-at: 0.25;
    --blur-floor: 0.4;
    --photo-height: 42vh;
    flex: 0 1 auto;
    align-self: center;
    max-width: 100%;
    min-height: 0;
    overflow: hidden;
    line-height: 0;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.blur-photo img {
    display: block;
    max-width: 100%;
    max-height: var(--photo-height);
}

/* Read step: the start blur, independent of the reading time. */
.blur-photo.is-read img {
    filter: blur(var(--blur-max));
    transform: scale(1.15);
}

/* Answering: from the start blur (all the time left) to sharp (--sharp-at of the time left); without a timer value
   the start blur. p = progress 0 → 1. A linear radius looks like "nothing happens, then suddenly sharp", because the
   eye judges blur roughly on log(radius + knee): big radii look alike and below the knee it already looks sharp. So
   the radius moves evenly on that scale: r = max × (floor^p − floor) / (1 − floor), floor = knee / (max + knee),
   which is exactly max at p = 0 and 0 at p = 1 (chosen from screenshot strips, see docs/decisions/question-types.md).
   p is warped by g(p) = p − 0.25 / 2π × sin(2πp): the middle changes 25% faster, both ends 25% slower, the start, the
   middle radius and the end stay the same. Browsers without pow() or sin() fall back to the linear radius. */
.blur-photo.is-sharpening img {
    --progress: clamp(0, (1 - var(--timer-fraction, 1)) / (1 - var(--sharp-at)), 1);
    filter: blur(calc((1 - var(--progress)) * var(--blur-max)));
    transform: scale(1.15);
    transition: filter 0.2s linear;
}

@supports (width: calc(pow(2, 2) * sin(1) * 1px)) {
    .blur-photo.is-sharpening img {
        --eased: calc(var(--progress) - 0.0397887 * sin(var(--progress) * 6.2831853));
        filter: blur(calc((pow(var(--blur-floor), var(--eased)) - var(--blur-floor)) / (1 - var(--blur-floor))
            * var(--blur-max)));
    }
}

.question-read.blurphoto .read-text {
    font-size: clamp(1.8rem, 4vw, 4rem);
}

.question-answering.blurphoto .answer-grid {
    flex: 0 1 auto;
    max-height: 30vh;
    margin-top: 0;
}

.question-answering.blurphoto .answer {
    min-height: 3.5rem;
    padding: var(--space-small) var(--space-normal);
    font-size: clamp(1.1rem, 2.2vw, 2rem);
}

/* Reveal: the sharp photo next to the bar chart. */
/* A fixed height (the photo is sized to it), so the row never shrinks below the photo on a small projector. */
.blurphoto-row {
    --row-height: calc(30vh - 2rem);
    flex: none;
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: var(--space-large);
    width: 100%;
    height: var(--row-height);
}

.blurphoto-row .blur-photo {
    --photo-height: var(--row-height);
    max-width: 45%;
}

.blurphoto-row .bar-chart {
    flex: 1 1 0;
    max-height: none;
}

/* ── estimate: number field, "? cm" and the number line ───────────── */

.estimate-blank {
    margin: auto 0;
    padding: var(--space-normal) var(--space-large);
    font-size: var(--font-size-huge);
    font-weight: 700;
    color: var(--color-text);
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.estimate-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--space-normal);
    margin: auto 0;
}

.estimate-field {
    display: flex;
    align-items: center;
    gap: var(--space-small);
    padding-right: var(--space-normal);
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.estimate-input {
    width: 9ch;
    padding: var(--space-small) var(--space-normal);
    font-size: var(--font-size-huge);
    font-weight: 700;
    text-align: right;
    border: none;
    background: transparent;
}

.estimate-unit {
    font-size: var(--font-size-large);
    font-weight: 700;
    color: var(--color-text);
}

.estimate-send {
    padding: var(--space-normal) var(--space-large);
    font-size: var(--font-size-large);
}

.estimate-message {
    flex-basis: 100%;
}

.estimate-own {
    margin: 0;
    padding: var(--space-small) var(--space-large);
    font-size: var(--font-size-huge);
    font-weight: 700;
    color: var(--color-text);
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: inset 0 0 0 0.35rem var(--okabe-yellow), var(--shadow);
}

.estimate-compare {
    display: grid;
    gap: var(--space-small);
    font-size: var(--font-size-large);
}

.estimate-compare-row {
    display: flex;
    justify-content: space-between;
    gap: var(--space-large);
}

.estimate-compare-row.is-answer strong {
    color: var(--okabe-yellow);
}

/* The number line: dots pile up above the axis (--stack), the band of answer ± tolerance behind them, the
   answer as a yellow line with its value on top. */
.number-line {
    /* About one spot wide (30 spots along the line, see numberLine in estimate.js). */
    --dot: clamp(1.2rem, 2.1vw, 2.2rem);
    flex: 1 1 14rem;
    display: flex;
    flex-direction: column;
    width: min(70rem, 92%);
    min-height: 12rem;
    max-height: 46vh;
}

/* Room above the plot for the answer's flag. */
.nl-plot {
    position: relative;
    flex: 1;
    min-height: 0;
    margin-top: calc(var(--font-size-large) * 1.3 + 1rem);
}

/* Above the band and the answer line. */
.nl-dots {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.nl-dot {
    position: absolute;
    left: var(--x);
    bottom: calc(0.3rem + var(--stack) * min(var(--dot) * 1.05, (100% - var(--dot) - 0.3rem) / var(--stacks)));
    display: grid;
    place-items: center;
    width: var(--dot);
    height: var(--dot);
    margin-left: calc(var(--dot) / -2);
    font-size: calc(var(--dot) * 0.9);
    line-height: 1;
    border-radius: 50%;
}

/* Close: filled; far away: hollow; exactly right: a star. Shape and fill, not colour alone. */
.nl-dot.is-close {
    background: var(--color-surface);
    box-shadow: 0 0 0 0.12rem var(--color-background);
}

.nl-dot.is-far {
    border: 0.22rem solid rgb(255 255 255 / 0.75);
}

/* Exactly right: a yellow badge with a dark star, drawn over the answer line. */
.nl-dot.is-exact {
    color: var(--color-text);
    background: var(--okabe-yellow);
    box-shadow: 0 0 0 0.15rem var(--color-text);
    font-size: calc(var(--dot) * 0.7);
}

.nl-dot.is-outside {
    border-style: dashed;
}

.nl-band {
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--from);
    width: calc(var(--to) - var(--from));
    background: rgb(0 158 115 / 0.35);
    border-left: 0.2rem dashed var(--okabe-green);
    border-right: 0.2rem dashed var(--okabe-green);
}

/* At the left edge of the band, away from the answer line in the middle. */
.nl-band-label {
    position: absolute;
    top: 0.2rem;
    left: 0.5rem;
    font-size: var(--font-size-small);
    font-weight: 700;
    opacity: 0.9;
}

.nl-answer {
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--x);
    width: 0.35rem;
    margin-left: -0.175rem;
    background: var(--okabe-yellow);
}

.nl-answer-label {
    position: absolute;
    bottom: 100%;
    left: 50%;
    padding: 0.1rem 0.8rem;
    font-size: var(--font-size-large);
    font-weight: 700;
    white-space: nowrap;
    color: var(--color-text);
    background: var(--okabe-yellow);
    border-radius: var(--radius);
    transform: translate(-50%, -0.3rem);
}

.nl-axis {
    height: 0.4rem;
    background: var(--color-surface);
    border-radius: 999px;
}

.nl-ends {
    display: flex;
    justify-content: space-between;
    font-size: var(--font-size-normal);
    opacity: 0.85;
}

/* ── Animations (only for live changes, see isLive in question.js) ── */

@keyframes fade-in {
    from {
        opacity: 0;
    }
}

@keyframes grow-up {
    from {
        transform: scaleY(0);
    }
}

@keyframes slide-in {
    from {
        opacity: 0;
        transform: translateY(1.5rem);
    }
}

@keyframes tile-undim {
    from {
        color: var(--tile-text);
        background-color: var(--tile);
    }
}

@keyframes tile-highlight {
    from {
        box-shadow: inset 0 0 0 0 var(--color-text-on-dark), var(--shadow);
    }
}

@keyframes happy-pop {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    60% {
        transform: scale(1.15);
        opacity: 1;
    }
    100% {
        transform: scale(1);
    }
}

@keyframes gentle-in {
    from {
        opacity: 0;
        transform: translateY(0.6rem);
    }
}

@keyframes sparkle {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) rotate(var(--angle)) translateY(0) scale(0.5);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) rotate(var(--angle)) translateY(-5rem) scale(1.1);
    }
}

@keyframes timer-pulse {
    50% {
        transform: scale(1.1);
    }
}

/* Read step: the question pops in. */
.is-live .read-text,
.is-live .read-title {
    animation: pop-in 0.4s ease-out both;
}

/* Answers appear one after another when the reading time is over. */
.is-live.question-answering .answer {
    animation: pop-in 0.35s ease-out both;
    animation-delay: calc(0.1s + var(--i, 0) * 0.12s);
}

.is-live.question-answering .question-image {
    animation: fade-in 0.4s ease-out both;
}

/* Reveal sequence: the bars grow one after another, then the right answer gets its ✓ and the others dim,
   then the sentence slides in, then the fastest players. */
.reveal.is-live {
    --step: 0.4s;
    --t-mark: calc(var(--bars, 4) * var(--step) + 0.4s);
    --t-sentence: calc(var(--t-mark) + 0.8s);
    --t-footer: calc(var(--t-sentence) + 0.7s);
}

.reveal.is-live .bar-fill {
    animation: grow-up 0.6s ease-out calc(var(--i, 0) * var(--step)) both;
}

.reveal.is-live .bar.is-wrong .bar-fill {
    animation: grow-up 0.6s ease-out calc(var(--i, 0) * var(--step)) both, tile-undim 0.5s ease-out var(--t-mark) backwards;
}

.reveal.is-live .bar-count {
    animation: fade-in 0.3s ease-out calc(var(--i, 0) * var(--step) + 0.3s) both;
}

.reveal.is-live .bar-mark,
.reveal.is-live .answer-mark {
    animation: pop-in 0.4s ease-out var(--t-mark) both;
}

.reveal.is-live .answer.is-wrong {
    animation: tile-undim 0.5s ease-out var(--t-mark) backwards;
}

.reveal.is-live .answer.is-correct {
    animation: tile-highlight 0.4s ease-out var(--t-mark) backwards;
}

.reveal.is-live .reveal-sentence {
    animation: slide-in 0.5s ease-out var(--t-sentence) both;
}

.reveal.is-live .reveal-footer {
    animation: fade-in 0.4s ease-out var(--t-footer) both;
}

/* blurphoto: the photo clears up at the start of the reveal. */
@keyframes unblur {
    from {
        filter: blur(1.5vmin);
    }
}

.reveal.is-live .blur-photo img {
    animation: unblur 0.8s ease-out both;
}

/* estimate: the dots drop in one after another, then the band and the answer appear. */
.reveal.is-live .nl-dot {
    animation: pop-in 0.35s ease-out calc(var(--i, 0) * var(--dot-delay, 0.05s)) both;
}

.reveal.is-live .nl-band,
.reveal.is-live .nl-answer {
    animation: fade-in 0.5s ease-out var(--t-mark) both;
}

/* Laptop result: a short happy pop with sparkles when right, a gentle fade otherwise. */
.laptop-reveal.is-live .result[data-verdict="correct"] .result-mark {
    animation: happy-pop 0.6s ease-out both;
}

.laptop-reveal.is-live .sparkle {
    animation: sparkle 0.9s ease-out 0.2s both;
}

.laptop-reveal.is-live .result:not([data-verdict="correct"]) .result-mark {
    animation: gentle-in 0.6s ease-out both;
}

.laptop-reveal.is-live .result-title {
    animation: fade-in 0.4s ease-out 0.2s both;
}

.laptop-reveal.is-live .result-points {
    animation: pop-in 0.4s ease-out 0.5s both;
}

/* ── Leaderboard (projector: top 5; laptop: own place) ────────────── */

.leaderboard {
    --row-gap: clamp(0.4rem, 1vh, 0.8rem);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-normal);
    width: min(100%, 60rem);
    margin: 0 auto;
}

.lb-list {
    display: flex;
    flex-direction: column;
    gap: var(--row-gap);
    width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
}

.lb-row {
    position: relative;
    display: grid;
    grid-template-columns: 2.2em 1fr auto 4.5em;
    align-items: center;
    gap: var(--space-normal);
    padding: var(--space-small) var(--space-large);
    font-size: var(--font-size-large);
    font-weight: 700;
    color: var(--color-text);
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.lb-row[data-rank="1"] {
    background: var(--okabe-yellow);
}

.lb-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.8em;
    height: 1.8em;
    border-radius: 50%;
    color: var(--color-primary-text);
    background: var(--color-primary);
}

.lb-name {
    text-align: left;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.lb-gained {
    font-size: var(--font-size-normal);
    color: var(--color-ok);
}

.lb-row[data-rank="1"] .lb-gained {
    color: var(--color-text);
}

.lb-points {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.laptop-leaderboard,
.podium-result,
.podium-wait {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-small);
    text-align: center;
}

.lb-own-rank {
    margin: 0;
    font-size: var(--font-size-huge);
    font-weight: 700;
    line-height: 1;
    text-shadow: var(--shadow);
}

.lb-change {
    margin: 0;
    padding: 0.2em 0.8em;
    font-size: var(--font-size-normal);
    font-weight: 700;
    border-radius: var(--radius);
    color: var(--color-text);
    background: var(--color-surface);
}

.lb-change[data-direction="up"] {
    color: var(--color-primary-text);
    background: var(--color-ok);
}

.lb-own-gained {
    margin: 0;
    font-size: var(--font-size-normal);
    font-weight: 700;
}

/* ── Podium ───────────────────────────────────────────────────────── */

.podium {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-normal);
    width: 100%;
}

.podium-stage {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: var(--space-normal);
    width: min(100%, 70rem);
}

.podium-place {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    align-items: stretch;
    min-width: 0;
}

.podium-winner {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: var(--space-small);
    text-align: center;
}

.podium-crown {
    font-size: var(--font-size-huge);
    line-height: 1;
    color: var(--okabe-yellow);
    text-shadow: var(--shadow);
}

.podium-name {
    max-width: 100%;
    overflow: hidden;
    font-size: var(--font-size-large);
    font-weight: 700;
    white-space: nowrap;
    text-overflow: ellipsis;
    text-shadow: var(--shadow);
}

.podium-points {
    font-size: var(--font-size-normal);
}

.podium-block {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: var(--space-normal);
    border-radius: var(--radius) var(--radius) 0 0;
    box-shadow: var(--shadow);
    transform-origin: bottom;
}

.podium-place[data-place="1"] .podium-block {
    height: 34vh;
    background: var(--okabe-yellow);
}

.podium-place[data-place="2"] .podium-block {
    height: 24vh;
    background: var(--okabe-sky-blue);
}

.podium-place[data-place="3"] .podium-block {
    height: 16vh;
    background: var(--okabe-orange);
}

.podium-rank {
    font-size: var(--font-size-huge);
    font-weight: 700;
    color: var(--color-text);
}

/* Laptop: "Look at the board!" and the own place lie on top of each other; only the own place stays. */
.laptop-podium {
    display: grid;
}

.laptop-podium > * {
    grid-area: 1 / 1;
}

.podium-wait {
    visibility: hidden;
}

/* Live leaderboard: the rows wait at their old places, then move to the new ones. */
@keyframes row-move {
    from {
        transform: translateY(calc(var(--shift, 0) * (100% + var(--row-gap))));
    }
}

.leaderboard.is-live .lb-row {
    animation: row-move 1s ease-in-out 0.6s backwards;
}

.leaderboard.is-live .lb-row.is-new {
    animation: row-move 1s ease-in-out 0.6s backwards, fade-in 0.6s ease-out 0.6s backwards;
}

.leaderboard.is-live .lb-gained {
    animation: pop-in 0.4s ease-out 0.2s both;
}

.laptop-leaderboard.is-live .lb-own-rank {
    animation: happy-pop 0.6s ease-out both;
}

.laptop-leaderboard.is-live .lb-change,
.laptop-leaderboard.is-live .lb-own-gained {
    animation: pop-in 0.4s ease-out 0.4s both;
}

/* Live podium: 3rd, then 2nd, then 1st; the laptops show the own place when the winner stands. */
.podium.is-live {
    --t-third: 0.6s;
    --t-second: 2.2s;
    --t-first: 4s;
}

.podium.is-live .podium-place[data-place="3"] .podium-block {
    animation: grow-up 0.6s ease-out var(--t-third) both;
}

.podium.is-live .podium-place[data-place="3"] .podium-winner {
    animation: pop-in 0.5s ease-out calc(var(--t-third) + 0.5s) both;
}

.podium.is-live .podium-place[data-place="2"] .podium-block {
    animation: grow-up 0.6s ease-out var(--t-second) both;
}

.podium.is-live .podium-place[data-place="2"] .podium-winner {
    animation: pop-in 0.5s ease-out calc(var(--t-second) + 0.5s) both;
}

.podium.is-live .podium-place[data-place="1"] .podium-block {
    animation: grow-up 0.8s ease-out var(--t-first) both;
}

.podium.is-live .podium-place[data-place="1"] .podium-winner {
    animation: happy-pop 0.7s ease-out calc(var(--t-first) + 0.7s) both;
}

@keyframes wait-then-hide {
    from,
    95% {
        visibility: visible;
        opacity: 1;
    }
    to {
        visibility: hidden;
        opacity: 0;
    }
}

.laptop-podium.is-live .podium-wait {
    animation: wait-then-hide 4.9s linear both;
}

.laptop-podium.is-live .podium-result {
    animation: pop-in 0.5s ease-out 4.9s both;
}

/* The timer ring pulses in the last 5 seconds. */
.timer[data-urgent="true"]:not([data-paused="true"]) {
    animation: timer-pulse 1s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
    .is-live,
    .is-live *,
    .timer {
        animation: none !important;
    }

    .read-progress-fill,
    .blur-photo.is-sharpening img {
        transition: none;
    }
}

/* ── Phase 4 styling: host bar ────────────────────────────────────── */

/* The host bar is clicked on a laptop next to the projector: bigger targets, and it wraps instead of overflowing. */
.host-bar {
    flex-wrap: wrap;
    row-gap: var(--space-small);
}

.host-bar .controls {
    flex: 1;
    gap: 0.6rem;
    font-size: 0.95rem;
}

.host-bar .button-small {
    min-height: 2.4rem;
    padding: 0.2rem 0.6rem;
    font-size: 0.95rem;
}

/* Sound and music: icon buttons (the title says what they do). Off: crossed out and dim. */
.host-bar .icon-button {
    min-width: 2.6rem;
    padding: 0.2rem 0.5rem;
    font-size: 1.2rem;
    line-height: 1;
}

.host-bar .icon-button[data-off="true"] {
    opacity: 0.6;
    text-decoration: line-through;
}

/* On a laptop-sized projector the bar needs the room for its buttons: the page title goes. */
@media (max-width: 100rem) {
    .host-bar h1 {
        display: none;
    }
}

.host-bar .player-panel summary {
    padding: 0.5rem 0.25rem;
}

/* Secondary buttons on the dark bar: outlined in white (blue on dark purple would be hard to read). */
.top-bar .button-secondary {
    color: var(--color-text-on-dark);
    background: transparent;
    border: 0.15rem solid rgb(255 255 255 / 0.7);
}

.top-bar .button-secondary:hover:not(:disabled),
.top-bar .button-secondary[aria-pressed="true"]:hover:not(:disabled) {
    background: rgb(255 255 255 / 0.12);
}

/* The main action ("Start", "Next"): larger and in its own colour, the one button to find at a glance. */
.button-flow {
    min-height: 3rem;
    padding: 0.4rem 1.6rem;
    font-size: clamp(1.1rem, 1.6vw, 1.4rem);
    color: #1A1A2E;
    background: var(--okabe-yellow);
    box-shadow: 0 0.2rem 0 rgb(0 0 0 / 0.35);
}

.button-flow:hover:not(:disabled) {
    filter: brightness(1.06);
}

.button-flow:active:not(:disabled) {
    transform: translateY(0.1rem);
    box-shadow: 0 0.1rem 0 rgb(0 0 0 / 0.35);
}

/* Pushes "Lock lobby" and "New lobby" to the far end, away from "Start". */
.controls-gap {
    flex: 1;
    min-width: var(--space-normal);
}

.host-tools {
    display: contents;
}

/* ── Behind the scenes (host tool "effects") ──────────────────────── */

.tools-panel {
    position: relative;
}

.tools-panel summary {
    display: inline-flex;
    align-items: center;
    list-style: none;
}

.tools-panel summary::-webkit-details-marker {
    display: none;
}

.tools-panel[open] summary {
    background: rgb(255 255 255 / 0.18);
}

.tools-popup {
    position: absolute;
    z-index: 10;
    top: 100%;
    left: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-small);
    min-width: 18rem;
    margin-top: var(--space-small);
    padding: var(--space-normal);
    font-size: 1rem;
    color: var(--color-text);
    background: var(--color-surface);
    border-radius: calc(var(--radius) / 2);
    box-shadow: var(--shadow);
}

.tools-heading {
    margin: 0;
    font-weight: 700;
}

.swatches {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-small);
}

.swatch {
    min-height: 2.5rem;
    padding: 0.3rem 0.8rem;
    font: inherit;
    font-weight: 700;
    color: var(--color-text-on-dark);
    background: var(--swatch);
    border: 0.2rem solid transparent;
    border-radius: 999px;
    cursor: pointer;
}

/* The colour everyone sees now: a ring and a check mark (not colour alone). */
.swatch[aria-pressed="true"] {
    border-color: var(--color-text);
}

.swatch[aria-pressed="true"]::before {
    content: "✓ ";
}

.swatch[data-theme="night"] { --swatch: #3D3B8E; }
.swatch[data-theme="ocean"] { --swatch: #13618F; }
.swatch[data-theme="forest"] { --swatch: #1D6B48; }
.swatch[data-theme="sunset"] { --swatch: #A0441C; }
.swatch[data-theme="berry"] { --swatch: #8A2A6E; }

/* The colours for everyone. White text stays readable on all of them (at least 7:1 on the darker colour). */
:root[data-theme="ocean"] {
    --color-background: #0B3D5C;
    --color-background-accent: #13618F;
}

:root[data-theme="forest"] {
    --color-background: #12452F;
    --color-background-accent: #1D6B48;
}

:root[data-theme="sunset"] {
    --color-background: #6B2412;
    --color-background-accent: #A0441C;
}

:root[data-theme="berry"] {
    --color-background: #5A1748;
    --color-background-accent: #8A2A6E;
}

/* Over every view, never in the way of a click. */
.overlay {
    position: fixed;
    z-index: 50;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.confetti-piece {
    position: absolute;
    top: -4vh;
    left: var(--x);
    width: 0.9rem;
    height: 0.9rem;
    background: var(--color);
    opacity: 0;
    animation: confetti-fall var(--fall) cubic-bezier(0.3, 0.1, 0.7, 1) var(--delay) forwards;
}

.confetti-piece[data-shape="circle"] {
    border-radius: 50%;
}

.confetti-piece[data-shape="strip"] {
    width: 0.45rem;
    height: 1.4rem;
}

.confetti-still {
    display: none;
}

@keyframes confetti-fall {
    from {
        opacity: 1;
        transform: translate(0, 0) rotate(0deg);
    }
    to {
        opacity: 1;
        transform: translate(var(--drift), 110vh) rotate(var(--spin));
    }
}

/* Without motion: no falling pieces, only a party emoji that fades in and out. */
@media (prefers-reduced-motion: reduce) {
    .confetti-piece {
        display: none;
    }

    .confetti-still {
        display: block;
        position: absolute;
        top: 50%;
        left: 50%;
        font-size: 20vmin;
        transform: translate(-50%, -50%);
        animation: fade-in-out 2.5s ease-in-out forwards;
    }
}

@keyframes fade-in-out {
    0% {
        opacity: 0;
    }
    15%, 70% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

/* ── Waiting room for up to 40 players ────────────────────────────── */

/* Smaller name pills as the class fills up (data-size from waitingRoom.js), so nothing overflows. */
.name-cloud[data-size="medium"] li {
    padding: 0.15rem 0.8rem;
    font-size: clamp(1.2rem, 2.4vw, 2.2rem);
}

.name-cloud[data-size="small"] {
    gap: 0.35rem;
    max-width: 96vw;
}

.name-cloud[data-size="small"] li {
    padding: 0.1rem 0.6rem;
    font-size: clamp(0.9rem, 1.4vw, 1.4rem);
}

/* The projector needs its height for the views: less padding below the host bar. */
.host-bar ~ main {
    padding-top: var(--space-normal);
    padding-bottom: var(--space-normal);
}

/* With a full class everything moves closer, and the code shrinks a little; it stays the largest thing on the screen. */
.waiting-room:has(.name-cloud[data-size="small"]) {
    gap: 0.6rem;
}

.waiting-room:has(.name-cloud[data-size="small"]) .waiting-title {
    font-size: clamp(1.4rem, 2.8vw, 2.6rem);
}

.waiting-room:has(.name-cloud[data-size="small"]) .game-code {
    font-size: clamp(2rem, 5vw, 4.5rem);
}

.waiting-room:has(.name-cloud[data-size="small"]) .join-hint {
    font-size: clamp(1.3rem, 2.6vw, 2.4rem);
}

@keyframes join-pop {
    0% {
        transform: scale(0.3) rotate(-8deg);
        opacity: 0;
    }
    60% {
        transform: scale(1.15) rotate(3deg);
        opacity: 1;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

@keyframes join-glow {
    from {
        box-shadow: 0 0 0 0 rgb(240 228 66 / 0.9);
    }
    to {
        box-shadow: 0 0 0 1rem rgb(240 228 66 / 0);
    }
}

/* "Log out" only on the game choice: in a lobby the bar needs the room, and nobody logs out mid-lesson. */
.host-bar:has(#lobby-controls:not([hidden])) .logout-form {
    display: none;
}
