:root {
  --sky: #cbe4f2; --sky-deep: #bcdcee; --sand: #f1e3b5; --sun: #ffc013;
  --ink: #0a0a0a; --paper: #f2f2f2; --accent: #b0298f;
  --step-small: clamp(0.8125rem, 0.79rem + 0.1vw, 0.875rem);
  --step-body: clamp(1.0625rem, 1rem + 0.25vw, 1.1875rem);
  --step-head: clamp(2rem, 1.3rem + 3.2vw, 4rem);
  --step-display: clamp(4rem, 8.3vw, 8rem);
  --step-mega: 28vw;
  --m: 16px;
  --ease: cubic-bezier(.16, 1, .3, 1);
}
/* The TV is read from a sofa: every step scales with the screen, nothing is set in fixed small sizes. */
.tv {
  --step-small: max(1.25vw, 13px); --step-body: max(1.7vw, 16px); --step-head: 4.2vw; --step-display: 8.3vw; --step-mega: min(17svh, 10vw);
  --m: 1.6vw;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font: 400 var(--step-body)/1.5 "Pilcrow Rounded", ui-rounded, system-ui, sans-serif; background: var(--sky); color: var(--ink); }
h1, h2, p, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
a { color: inherit; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.field { background: var(--bg); color: var(--fg); padding: var(--m); }
.sky { --bg: var(--sky); --fg: var(--ink); }
.sand { --bg: var(--sand); --fg: var(--ink); }
.sun { --bg: var(--sun); --fg: var(--ink); }
.night { --bg: var(--ink); --fg: var(--paper); }
.screen { min-height: 100svh; }

.display, .head, .mega { font-weight: 700; letter-spacing: -0.05em; line-height: 0.9; }
.display { font-size: var(--step-display); text-transform: lowercase; }
.head { font-size: var(--step-head); line-height: 1; text-transform: lowercase; }
.asis { text-transform: none; }
.mega { font-size: var(--step-mega); letter-spacing: -0.03em; }
.line { display: block; overflow: hidden; padding-bottom: .08em; }
.line > span { display: block; animation: unmask .9s var(--ease) both; }
.line + .line > span { animation-delay: .11s; }
h1:focus, h2:focus { outline: 0; }
b { font-weight: 700; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 56px; padding: 0 28px; border: 0; border-radius: 0; font: inherit; font-weight: 700; background: var(--fg); color: var(--bg); cursor: pointer; transition: transform .12s var(--ease); }
.btn.go { background: var(--accent); color: #fff; }
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(2px); }
:focus-visible { outline: 3px solid var(--fg, var(--ink)); outline-offset: 3px; }

label { display: block; font-weight: 500; }
input, select { display: block; width: 100%; height: 52px; margin-top: 4px; padding: 0 14px; border: 2px solid var(--ink); border-radius: 0; background: #fff; color: var(--ink); font: inherit; font-weight: 500; }
.clock { font-variant-numeric: tabular-nums; }
.clock.late { color: var(--accent); }
.answer.out { text-decoration: line-through; text-decoration-thickness: .08em; }
.why { color: var(--sun); font-size: var(--step-small); }
.answer.double { width: fit-content; margin: .08em 0 .12em; padding: .04em .18em; background: var(--sun); color: var(--ink); transform-origin: left center; }
.why.bonus { font-weight: 700; }
.error { font-weight: 700; color: var(--accent); }
.error:empty { display: none; }

/* ---------- TV ---------- */
.bar { display: flex; height: 3.4vw; min-height: 44px; font-weight: 500; }
.bar > * { display: flex; align-items: center; gap: .4em; padding: 0 var(--m); white-space: nowrap; }
.bar .mark { background: var(--ink); color: var(--paper); font-weight: 700; }
.bar .tab { background: var(--accent); color: #fff; }
.bar .where { margin-left: auto; }

#lobby { display: flex; flex-direction: column; height: 100svh; }
.mosaic { display: grid; grid-template: repeat(2, 1fr) / repeat(6, 1fr); flex: 1; min-height: 0; }
.tile { display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; min-width: 0; background: var(--t); color: var(--tc, var(--ink)); animation: drop .7s var(--ease) both; animation-delay: calc(var(--i) * 55ms); }
.tile .who { max-width: 100%; padding: 0 .4em; font-size: var(--step-body); font-weight: 700; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .who:empty { display: none; }
.tile.taken .mega { animation: drop .5s var(--ease) both; }
.tile.qr { grid-area: span 2 / span 2; background: #fff; padding: 1.2vw; }
.tile.qr img { width: 100%; height: 100%; object-fit: contain; }

.intro { display: grid; grid-template-columns: 42% 1fr; gap: 0; padding: 3vw var(--m); }
.intro .display { grid-column: 2; grid-row: 1; }
.intro .side { grid-column: 1; grid-row: 1; max-width: 26em; padding-right: 2em; animation: rise .7s var(--ease) .5s both; }
.intro .side p + p { margin-top: .8em; font-weight: 700; }

.write { display: grid; grid-template-columns: 42% 1fr; align-items: center; }
.write .mega { font-size: min(70svh, 34vw); animation: drop .5s var(--ease) both; }
.write .clock { font-size: 13vw; }
.names { display: flex; flex-wrap: wrap; gap: .5vw; margin-top: 2vw; font-size: 2.6vw; font-weight: 700; line-height: 1.3; }
.names li { padding: .2em .7em; background: var(--sky-deep); }
.names .done { background: var(--ink); color: var(--paper); }
.names .out { background: none; font-weight: 400; }

.reveal { display: flex; flex-direction: column; }
.reveal > p { margin-top: .6em; }
.entries { display: grid; grid-template-columns: 1fr 1fr; gap: 2.2vw 4vw; margin: auto 0; padding: 2vw 0; }
.entries li { min-width: 0; animation: rise .5s var(--ease) both; animation-delay: calc(var(--i) * 70ms); }
.entries .answer { display: block; font-size: var(--step-head); font-weight: 700; letter-spacing: -0.04em; line-height: 1; overflow-wrap: anywhere; }
.entries.few .answer { font-size: 6.4vw; }
.entries .none { opacity: .55; }
.entries li { position: relative; }
.entries .double { animation: pop .8s var(--ease) both; animation-delay: calc(var(--i) * 70ms + .3s); }
/* The fanfare: squares in the palette thrown out from a double answer. */
.bit { position: absolute; left: 12%; top: 55%; width: 1.3vw; height: 1.3vw; background: var(--c); pointer-events: none; animation: burst 1.3s var(--ease) both; animation-delay: calc(var(--i) * 70ms + .3s); }

.ranks { margin-top: 3vw; }
.ranks li { display: flex; align-items: baseline; gap: 1em; padding: .12em 0; font-size: min(8vw, calc(62svh / var(--rows))); font-weight: 700; letter-spacing: -0.04em; line-height: 1.15; animation: rise .5s var(--ease) both; animation-delay: calc(var(--i) * 70ms); }
.ranks .gain { margin-left: auto; font-size: var(--step-body); letter-spacing: 0; }
.ranks .total { min-width: 2ch; text-align: right; font-variant-numeric: tabular-nums; }
.scores > p { margin-top: 2vw; }

/* ---------- Phone ---------- */
.phone { display: flex; flex-direction: column; gap: 20px; }
.phone .head { animation: rise .5s var(--ease) both; }
.stack { display: grid; gap: 14px; max-width: 30rem; }
.stack .btn { width: 100%; margin-top: 6px; }
.phone .list li { padding: 6px 0; font-weight: 500; display: flex; justify-content: space-between; }
.end { margin-top: auto; }
.linkbtn { min-height: 44px; padding: 10px 0; border: 0; background: none; color: inherit; font: inherit; font-weight: 700; text-align: left; text-decoration: underline; text-underline-offset: 4px; cursor: pointer; }
.invite { overflow-wrap: anywhere; }
.invite:empty { display: none; }

.board { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; margin: calc(var(--m) * -1) calc(var(--m) * -1) 0; padding: 8px var(--m); background: var(--bg); }
.board .mega { font-size: 20vw; line-height: 1; }
.board .clock { font-size: 13vw; }
.sheet li + li { margin-top: 14px; }

.strikes li + li { margin-top: 8px; }
.strike { display: block; width: 100%; min-height: 64px; padding: 10px 14px; border: 0; border-radius: 0; background: #1c1c1c; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.strike .answer { display: block; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; overflow-wrap: anywhere; }
.strike .why { margin-left: .6em; }
.strike:active { transform: translateY(2px); }

@keyframes drop { from { opacity: 0; transform: scale(.86); } }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } }
@keyframes unmask { from { transform: translateY(105%); } }
@keyframes pop { 0% { transform: scale(.5); } 55% { transform: scale(1.18) rotate(-2deg); } 100% { transform: none; } }
@keyframes burst { from { opacity: 1; transform: none; } to { opacity: 0; transform: translate(var(--x), var(--y)) rotate(var(--r)); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
