:root {
  color-scheme: light dark;

  --bg: light-dark(#f6f2ff, #150f2b);
  --surface: light-dark(#ffffff, #221a42);
  --surface-2: light-dark(#efe8ff, #2e2457);
  --ink: light-dark(#24184a, #f5f0ff);
  --ink-soft: light-dark(#675d88, #b6abd9);
  --line: light-dark(#e4dafb, #3d3270);

  --grape: light-dark(#7b3ff2, #a98bff);
  --grape-deep: light-dark(#5a22c9, #6f4fe0);
  --pink: light-dark(#ff4f8b, #ff77a6);
  --sun: light-dark(#ffc63a, #ffd466);
  --mint: light-dark(#14b98f, #4fe0c4);
  --sky: light-dark(#2f9bff, #6cc0ff);
  --orange: light-dark(#ff8a3d, #ffa766);
  --on-accent: #fff;
  --ok: light-dark(#0f9d74, #4fe0c4);
  --bad: light-dark(#e23d6d, #ff7a9c);
  --warn: light-dark(#b86a00, #ffc83d);

  /* The four answers, always in this order: A pink, B blue, C yellow, D green. */
  --a0: #ff4f8b; --a1: #2f8fff; --a2: #ffb81f; --a3: #12b886;
  --a0-deep: #c92a63; --a1-deep: #1a63c4; --a2-deep: #c98500; --a3-deep: #0b8763;

  --radius: 28px;
  --shadow: 0 18px 50px -18px light-dark(rgb(90 50 160 / .35), rgb(0 0 0 / .6));
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
  --bounce: cubic-bezier(.34, 1.56, .64, 1);

  accent-color: var(--grape);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { min-block-size: 100%; }
body {
  margin: 0;
  font: 500 1rem/1.5 var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

h1, h2, h3, p { margin: 0; }
h1:focus, h2:focus { outline: none; }
button, input, textarea { font: inherit; color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.visually-hidden {
  position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.spacer { flex: 1; }

:focus-visible { outline: 3px solid var(--grape); outline-offset: 3px; }

/* ── Background ── */
.blobs { position: fixed; inset: 0; overflow: hidden; z-index: -2; pointer-events: none; }
.blobs i { position: absolute; border-radius: 50%; filter: blur(70px); opacity: light-dark(.5, .25); }
.blobs i:nth-child(1) { inline-size: 42vmax; block-size: 42vmax; background: var(--pink); inset: -14vmax auto auto -10vmax; }
.blobs i:nth-child(2) { inline-size: 36vmax; block-size: 36vmax; background: var(--sun); inset: -12vmax -10vmax auto auto; }
.blobs i:nth-child(3) { inline-size: 40vmax; block-size: 40vmax; background: var(--sky); inset: auto auto -18vmax -8vmax; }
.blobs i:nth-child(4) { inline-size: 34vmax; block-size: 34vmax; background: var(--grape); inset: auto -12vmax -14vmax auto; }

.floaters { position: fixed; inset: 0; overflow: hidden; z-index: -1; pointer-events: none; }
.floaters span {
  position: absolute; font-weight: 900; font-size: clamp(2rem, 6vw, 4.5rem); line-height: 1;
  color: var(--grape); opacity: light-dark(.12, .16);
}
.floaters span:nth-child(1) { inset: 12% auto auto 6%; rotate: -14deg; color: var(--pink); }
.floaters span:nth-child(2) { inset: 22% 8% auto auto; rotate: 12deg; color: var(--sun); opacity: .35; }
.floaters span:nth-child(3) { inset: auto auto 18% 12%; rotate: 8deg; color: var(--sky); }
.floaters span:nth-child(4) { inset: auto 14% 10% auto; rotate: -8deg; }
.floaters span:nth-child(5) { inset: 55% auto auto 45%; color: var(--mint); }
.floaters span:nth-child(6) { inset: 6% auto auto 52%; rotate: 20deg; color: var(--orange); }
/* The big screen and the phones are busy enough already. */
body:has(#stage:not([hidden]), #play:not([hidden])) .floaters { display: none; }

@media (prefers-reduced-motion: no-preference) {
  .blobs i { animation: drift 22s ease-in-out infinite alternate; }
  .blobs i:nth-child(2n) { animation-duration: 28s; animation-direction: alternate-reverse; }
  @keyframes drift { to { transform: translate(6vmax, 4vmax) scale(1.12); } }
  .floaters span { animation: bob 7s ease-in-out infinite alternate; }
  .floaters span:nth-child(2n) { animation-duration: 9s; animation-delay: -3s; }
  .floaters span:nth-child(3n) { animation-duration: 11s; animation-delay: -5s; }
  @keyframes bob { to { translate: 0 -24px; rotate: 10deg; } }
}

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .55em;
  min-block-size: 44px; padding: .6em 1.25em;
  border: 2px solid var(--line); border-radius: 999px;
  background: var(--surface); font-weight: 800; cursor: pointer; text-decoration: none;
  transition: transform .12s, box-shadow .12s, background-color .15s, filter .15s;
}
.btn svg { inline-size: 1.3em; block-size: 1.3em; flex: none; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(2px); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.primary {
  border: 0; color: var(--on-accent);
  background: linear-gradient(135deg, var(--pink), var(--grape));
  box-shadow: 0 5px 0 var(--grape-deep), 0 14px 24px -10px var(--grape);
}
.btn.primary:hover { filter: brightness(1.07); }
.btn.primary:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--grape-deep); }
.btn.primary[disabled] { box-shadow: none; transform: none; filter: saturate(.4); }
.btn.sunny {
  border: 0; color: #3a2600;
  background: linear-gradient(135deg, #ffd84d, #ff9f3d);
  box-shadow: 0 5px 0 #d97a12, 0 14px 24px -10px #ff9f3d;
}
.btn.sunny:active { transform: translateY(4px); box-shadow: 0 1px 0 #d97a12; }
.btn.big { inline-size: 100%; font-size: 1.2rem; min-block-size: 60px; }
.btn.small { min-block-size: 40px; padding: .35em 1em; font-size: .95rem; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.primary.danger { background: linear-gradient(135deg, var(--pink), var(--bad)); box-shadow: 0 5px 0 #a3143f; }
.danger-text { color: var(--bad); }
.btn.busy { cursor: progress; }
@media (prefers-reduced-motion: no-preference) {
  .btn.busy span[aria-hidden] { display: inline-block; animation: spin 1s linear infinite; }
}
@keyframes spin { to { rotate: 360deg; } }

.icon-btn {
  display: grid; place-items: center; inline-size: 46px; block-size: 46px; flex: none;
  border: 2px solid var(--line); border-radius: 50%; background: var(--surface); cursor: pointer;
  transition: transform .15s var(--bounce), background-color .15s;
}
.icon-btn svg { inline-size: 22px; block-size: 22px; grid-area: 1 / 1; }
.icon-btn:hover { background: var(--surface-2); transform: scale(1.08); }
.icon-btn.small { inline-size: 40px; block-size: 40px; font-size: 1.05rem; }
.icon-btn .off, .icon-btn[aria-pressed="false"] .on { display: none; }
.icon-btn[aria-pressed="false"] .off { display: block; }

/* ── Pages ── */
.page { min-block-size: 100dvh; max-inline-size: 1120px; margin-inline: auto; padding: 20px clamp(16px, 4vw, 40px) 40px; }
.page.narrow { max-inline-size: 720px; }

.topbar { display: flex; align-items: center; justify-content: space-between; margin-block-end: clamp(16px, 4vh, 44px); }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 900; font-size: 1.7rem; letter-spacing: -.02em; color: inherit; text-decoration: none; }
.logo { inline-size: 42px; block-size: 42px; overflow: visible; }
.logo-a { fill: var(--grape); stroke: none; }
.logo-q { stroke: #fff; stroke-width: 3.2; }
.logo-dot { fill: #fff; stroke: none; }
.logo-star { fill: var(--sun); stroke: none; transform-origin: 33.5px 7px; }
@media (prefers-reduced-motion: no-preference) {
  .logo-star { animation: twinkle 2.4s ease-in-out infinite; }
  @keyframes twinkle { 50% { scale: .6; rotate: 45deg; } }
}
.brand-wrap { display: grid; justify-items: start; }
/* Lines up under the app name, past the logo. */
.credit { margin-block-start: -4px; padding-inline-start: 52px; font-size: .85rem; font-weight: 600; color: var(--ink-soft); }
.credit a { color: var(--grape); font-weight: 800; text-decoration: none; }
.credit a:hover { text-decoration: underline; }

.bar { display: flex; align-items: center; gap: 14px; margin-block-end: 22px; }
.bar h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); font-weight: 900; letter-spacing: -.02em; }

/* ── Home ── */
.hero { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: clamp(24px, 4vw, 56px); align-items: center; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; } }

.stickers { display: flex; gap: 10px; margin-block-end: 18px; font-size: 2rem; }
.stickers span {
  display: grid; place-items: center; inline-size: 58px; block-size: 58px; border-radius: 18px;
  background: var(--surface); box-shadow: var(--shadow); border: 2px solid var(--line);
}
.stickers span:nth-child(odd) { rotate: -6deg; }
.stickers span:nth-child(even) { rotate: 5deg; }
@media (prefers-reduced-motion: no-preference) {
  .stickers span { animation: hop 2.8s var(--bounce) infinite; }
  .stickers span:nth-child(2) { animation-delay: .2s; }
  .stickers span:nth-child(3) { animation-delay: .4s; }
  .stickers span:nth-child(4) { animation-delay: .6s; }
  @keyframes hop { 0%, 60%, 100% { translate: 0 0; } 70% { translate: 0 -12px; } }
}

h1 { font-size: clamp(2.2rem, 5.4vw, 3.8rem); line-height: 1.02; font-weight: 900; letter-spacing: -.03em; text-wrap: balance; }
#home-title {
  background: linear-gradient(100deg, var(--grape), var(--pink) 55%, var(--orange));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.sub { margin-block-start: 16px; font-size: 1.15rem; color: var(--ink-soft); max-inline-size: 34em; text-wrap: pretty; }

.start-cards { display: grid; gap: 20px; }
.card {
  background: var(--surface); border-radius: var(--radius); padding: clamp(20px, 3vw, 30px);
  box-shadow: var(--shadow); border: 2px solid var(--line);
  display: grid; gap: 18px;
}
.card h2 { font-size: 1.45rem; font-weight: 900; letter-spacing: -.01em; }
.join-card { rotate: -1deg; }
.host-card { rotate: .8deg; background: linear-gradient(160deg, var(--surface), light-dark(#fff4dc, #2d2440)); }
@media (prefers-reduced-motion: no-preference) {
  .join-card, .host-card { transition: rotate .3s var(--bounce); }
  .join-card:hover, .host-card:hover { rotate: 0deg; }
}
.code-input { font: 800 1.6rem/1 ui-monospace, "SF Mono", monospace; letter-spacing: .12em; text-align: center; text-transform: lowercase; }

/* ── Forms ── */
.field { display: grid; gap: 8px; border: 0; padding: 0; margin: 0; min-inline-size: 0; }
.field > span, .field > legend { font-weight: 800; padding: 0; }
.field > legend { margin-block-end: 8px; }

input[type="text"], input[type="password"], textarea {
  inline-size: 100%; min-block-size: 50px; padding: .55em 1em;
  border: 2px solid var(--line); border-radius: 16px; background: var(--bg);
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; line-height: 1.4; }
input::placeholder, textarea::placeholder { color: var(--ink-soft); opacity: .8; }
input[type="text"]:focus-visible, input[type="password"]:focus-visible, textarea:focus-visible {
  outline: none; border-color: var(--grape); box-shadow: 0 0 0 4px light-dark(rgb(123 63 242 / .15), rgb(169 139 255 / .25));
}
input[type="range"] { inline-size: 100%; accent-color: var(--pink); }
output { font-weight: 900; color: var(--pink); }

.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chips label {
  position: relative; display: inline-flex; align-items: center; gap: .5em; min-block-size: 46px; padding: .4em 1.1em;
  border: 2px solid var(--line); border-radius: 999px; font-weight: 800; cursor: pointer;
  background: var(--bg); transition: transform .15s var(--bounce), background-color .15s;
}
.chips label:hover { transform: translateY(-2px); }
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chips label:has(:checked) { background: var(--grape); border-color: var(--grape); color: var(--on-accent); }
.chips label:has(:focus-visible) { outline: 3px solid var(--grape); outline-offset: 3px; }
.chips .flag { font-size: 1.3em; line-height: 1; }

.topic-ideas { display: flex; flex-wrap: wrap; gap: 8px; margin-block-start: -6px; }
.idea {
  padding: .3em .9em; border-radius: 999px; border: 0; cursor: pointer; font-weight: 700; font-size: .9rem;
  background: var(--surface-2); color: var(--ink); transition: transform .15s var(--bounce);
}
.idea:nth-child(4n+1) { background: light-dark(#ffe1ec, #4a1f38); }
.idea:nth-child(4n+2) { background: light-dark(#dcefff, #1d3352); }
.idea:nth-child(4n+3) { background: light-dark(#fff1c9, #463a17); }
.idea:nth-child(4n+4) { background: light-dark(#d6f6ec, #17423a); }
.idea:hover { transform: translateY(-2px) rotate(-2deg); }

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface-2); }
.segmented label { position: relative; display: grid; }
.segmented input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.segmented span { display: grid; place-items: center; min-block-size: 2.6rem; padding: 0 .4rem; border-radius: 999px; font-weight: 800; font-size: .95rem; color: var(--ink-soft); transition: background-color .15s; }
.segmented input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgb(0 0 0 / .15); }
.segmented input:focus-visible + span { outline: 3px solid var(--grape); outline-offset: 1px; }

.switch-row { display: flex; align-items: center; gap: 12px; min-block-size: 44px; font-weight: 800; cursor: pointer; }
.switch-row input { inline-size: 22px; block-size: 22px; flex: none; }
.switch-row > span { display: grid; }
.switch-row small { font-weight: 600; }

.pill-status {
  display: inline-flex; align-items: center; gap: .6em; justify-self: start;
  min-block-size: 40px; padding: .3em 1em; border-radius: 999px; cursor: pointer;
  border: 2px dashed var(--line); background: transparent; font-weight: 700; color: var(--ink-soft); text-align: start;
}
.pill-status:hover { background: var(--surface-2); }
.dot { inline-size: 10px; block-size: 10px; border-radius: 50%; background: var(--warn); flex: none; }
.pill-status[data-ready="true"] { border-style: solid; color: var(--ink); }
.pill-status[data-ready="true"] .dot { background: var(--ok); }

.error { padding: .7em 1em; border-radius: 16px; background: light-dark(#ffe3ea, #4a1d2b); color: light-dark(#a3142f, #ffb3c0); font-weight: 700; }
.help { font-size: .9rem; color: var(--ink-soft); }
.help a { color: var(--grape); font-weight: 800; }

/* ── Player profile ── */
.code-chip { justify-self: start; padding: .3em 1em; border-radius: 999px; background: var(--surface-2); font-weight: 700; }
.code-chip strong { font-family: ui-monospace, monospace; letter-spacing: .08em; color: var(--grape); }
.avatars { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 8px; }
.avatars label {
  position: relative; display: grid; place-items: center; aspect-ratio: 1; border-radius: 18px; cursor: pointer;
  font-size: 2rem; background: var(--bg); border: 2px solid var(--line);
  transition: transform .2s var(--bounce), background-color .15s;
}
.avatars input { position: absolute; opacity: 0; pointer-events: none; }
.avatars label:hover { transform: scale(1.1) rotate(-6deg); }
.avatars label:has(:checked) { background: var(--sun); border-color: var(--orange); transform: scale(1.12); box-shadow: 0 8px 18px -8px var(--orange); }
.avatars label:has(:focus-visible) { outline: 3px solid var(--grape); outline-offset: 2px; }

/* ── Library ── */
.library-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-block-end: 24px; }
.file-btn { position: relative; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-btn:has(:focus-visible) { outline: 3px solid var(--grape); outline-offset: 3px; }
.quiz-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 20px; }
.quiz-card {
  --tint: var(--grape);
  position: relative; display: grid; gap: 6px; align-content: start; padding: 20px 20px 16px;
  border-radius: var(--radius); background: var(--surface); border: 2px solid var(--line); box-shadow: var(--shadow);
  overflow: hidden; view-transition-class: card;
  transition: transform .2s var(--bounce);
}
.quiz-card::before { content: ""; position: absolute; inset: 0 0 auto; block-size: 76px; background: linear-gradient(120deg, var(--tint), color-mix(in oklab, var(--tint) 55%, var(--sun))); opacity: .9; }
.quiz-card:hover { transform: translateY(-4px) rotate(-.5deg); }
.tint-0 { --tint: var(--grape); } .tint-1 { --tint: var(--pink); } .tint-2 { --tint: var(--sky); }
.tint-3 { --tint: var(--mint); } .tint-4 { --tint: var(--orange); } .tint-5 { --tint: #c04bdb; }
.quiz-emoji {
  position: relative; display: grid; place-items: center; inline-size: 72px; block-size: 72px; margin-block: 10px 6px;
  border-radius: 22px; background: var(--surface); font-size: 2.6rem; box-shadow: 0 8px 18px -10px rgb(0 0 0 / .4); rotate: -4deg;
}
.quiz-card h2 { position: relative; font-size: 1.25rem; font-weight: 900; line-height: 1.2; }
.card-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-block-start: 10px; }
.card-actions .btn { margin-inline-end: auto; }
.card-actions .spacer { display: none; }
.card-actions .icon-btn.small { inline-size: 36px; block-size: 36px; font-size: .95rem; border-width: 0; background: var(--surface-2); }
.flag-badge { justify-self: start; padding: .15em .7em; border-radius: 999px; background: light-dark(#fff1c9, #463a17); color: var(--warn); font-weight: 800; font-size: .85rem; }
.empty { padding: 40px; text-align: center; color: var(--ink-soft); font-weight: 700; }
::view-transition-group(.card) { animation-duration: .35s; animation-timing-function: var(--bounce); }

/* ── Create: the thinking animation ── */
.thinking { display: grid; place-items: center; gap: 22px; padding: 70px 20px; text-align: center; font-weight: 800; font-size: 1.2rem; }
.thinking-orbit { position: relative; inline-size: 120px; block-size: 120px; border-radius: 50%; background: radial-gradient(circle, light-dark(#fff, #2e2457) 40%, transparent 41%), conic-gradient(var(--pink), var(--sun), var(--mint), var(--sky), var(--grape), var(--pink)); }
.thinking-orbit span { position: absolute; inset: 50% auto auto 50%; inline-size: 40px; block-size: 40px; margin: -20px; display: grid; place-items: center; border-radius: 50%; background: var(--surface); font-weight: 900; font-size: 1.3rem; box-shadow: var(--shadow); }
.thinking-orbit span:nth-child(1) { color: var(--pink); translate: 0 -64px; }
.thinking-orbit span:nth-child(2) { color: var(--sky); translate: 55px 32px; }
.thinking-orbit span:nth-child(3) { color: var(--orange); translate: -55px 32px; }
@media (prefers-reduced-motion: no-preference) {
  .thinking-orbit { animation: spin 3s linear infinite; }
  .thinking-orbit span { animation: spin 3s linear infinite reverse; }
  .thinking p { animation: breathe 1.6s ease-in-out infinite alternate; }
  @keyframes breathe { from { opacity: .55; } }
}

/* ── Editor ── */
.editor { display: grid; gap: 18px; }
.editor-head { grid-template-columns: 96px 1fr; align-items: end; }
.emoji-field input { text-align: center; font-size: 1.8rem; padding-inline: .2em; }
.flag-note { padding: .8em 1.1em; border-radius: 18px; font-weight: 700; background: light-dark(#fff1c9, #463a17); }
.flag-note[data-ok="true"] { background: light-dark(#d6f6ec, #17423a); }
.questions { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.q-card { gap: 12px; padding: 18px; view-transition-class: card; }
.q-card[data-flag="true"] { border-color: var(--sun); box-shadow: 0 0 0 4px light-dark(rgb(255 198 58 / .3), rgb(255 212 102 / .2)), var(--shadow); }
.q-card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.q-index { display: grid; place-items: center; inline-size: 34px; block-size: 34px; border-radius: 50%; background: var(--grape); color: #fff; font-weight: 900; }
.answers { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 8px; border: 0; padding: 0; margin: 0; }
.answers legend { margin-block-end: 6px; }
.answer-row { display: flex; align-items: center; gap: 8px; }
.right-pick { position: relative; flex: none; cursor: pointer; }
.right-pick input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.right-pick span {
  display: grid; place-items: center; inline-size: 44px; block-size: 44px; border-radius: 14px;
  font-weight: 900; color: #fff; background: var(--c); opacity: .45; transition: opacity .15s, transform .2s var(--bounce);
}
.right-pick input:checked + span { opacity: 1; transform: scale(1.08); box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--c); }
.right-pick input:checked + span::after { content: "✓"; position: absolute; inset: -6px -6px auto auto; display: grid; place-items: center; inline-size: 20px; block-size: 20px; border-radius: 50%; background: var(--ok); font-size: .75rem; }
.right-pick input:focus-visible + span { outline: 3px solid var(--grape); outline-offset: 4px; }
.answer-row.c0 { --c: var(--a0); } .answer-row.c1 { --c: var(--a1); } .answer-row.c2 { --c: var(--a2); } .answer-row.c3 { --c: var(--a3); }
.answer-row:has(:checked) .a-input { border-color: var(--ok); }
.editor-foot {
  position: sticky; inset-block-end: 12px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  padding: 10px; border-radius: 999px; background: color-mix(in oklab, var(--surface) 88%, transparent); border: 2px solid var(--line);
  box-shadow: var(--shadow); backdrop-filter: blur(10px);
}
@media (max-width: 560px) { .editor-foot { border-radius: 24px; } .editor-foot .spacer { display: none; } .editor-foot .btn { flex: 1; } }

/* ── Setup ── */
.setup-quiz { display: flex; align-items: center; gap: 16px; }
.big-emoji { display: grid; place-items: center; inline-size: 72px; block-size: 72px; border-radius: 22px; background: var(--surface-2); font-size: 2.5rem; rotate: -4deg; flex: none; }
.mode-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .mode-pick { grid-template-columns: 1fr; } }
.mode-pick label { position: relative; cursor: pointer; }
.mode-pick input { position: absolute; opacity: 0; }
.mode-pick label > span { display: grid; gap: 4px; block-size: 100%; padding: 14px 16px; border-radius: 20px; border: 2px solid var(--line); background: var(--bg); transition: border-color .15s, transform .2s var(--bounce); }
.mode-pick small { color: var(--ink-soft); font-weight: 600; font-size: .88rem; }
.mode-pick input:checked + span { border-color: var(--grape); background: light-dark(#f1eaff, #2e2457); transform: scale(1.02); }
.mode-pick input:focus-visible + span { outline: 3px solid var(--grape); outline-offset: 3px; }
.chips#seconds label { min-inline-size: 64px; justify-content: center; }

/* ── The big screen ── */
.stage { min-block-size: 100dvh; display: grid; grid-template-rows: auto 1fr; padding: 14px clamp(14px, 3vw, 36px) 24px; }
.stage-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-block-end: 12px; }
.stage-quiz { display: flex; align-items: center; gap: 8px; font-weight: 900; font-size: 1.15rem; }
.stage-quiz span:first-child { font-size: 1.6rem; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: .4em; padding: .3em .9em; border-radius: 999px; background: var(--surface); border: 2px solid var(--line); font-weight: 800; font-size: .95rem; }
.chip strong { font-family: ui-monospace, monospace; letter-spacing: .08em; color: var(--grape); }
.phase { min-block-size: 0; }

/* Lobby */
.lobby { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "join qr" "players players" "go go"; gap: 24px 32px; align-content: start; max-inline-size: 1200px; inline-size: 100%; margin-inline: auto; }
.lobby-join { grid-area: join; align-self: center; display: grid; gap: 4px; }
.lobby-how, .lobby-code-label { font-weight: 800; font-size: clamp(1.1rem, 2.2vw, 1.5rem); color: var(--ink-soft); }
.lobby-url { font-weight: 900; font-size: clamp(1.6rem, 4vw, 3rem); letter-spacing: -.02em; overflow-wrap: anywhere; }
.lobby-code {
  justify-self: start; margin-block: 6px 12px; padding: .1em .5em; border-radius: 22px;
  font: 900 clamp(3rem, 9vw, 7rem)/1.1 ui-monospace, "SF Mono", monospace; letter-spacing: .08em;
  color: #fff; background: linear-gradient(120deg, var(--grape), var(--pink)); box-shadow: 0 8px 0 var(--grape-deep), var(--shadow);
  rotate: -1.5deg;
}
.lobby-code.small { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 4px 0 0; box-shadow: 0 5px 0 var(--grape-deep); }
.copy-row { position: relative; display: flex; align-items: center; gap: 10px; }
.tip { font-weight: 800; color: var(--ok); opacity: 0; transition: opacity .2s; }
.tip.show { opacity: 1; }
.qr { grid-area: qr; inline-size: clamp(180px, 24vw, 300px); aspect-ratio: 1; padding: 10px; border-radius: 26px; background: #fff; box-shadow: var(--shadow); rotate: 2deg; }
.qr svg { display: block; inline-size: 100%; block-size: 100%; }
.qr.small { inline-size: 130px; padding: 6px; border-radius: 18px; }
.lobby-players { grid-area: players; display: grid; gap: 14px; padding: 22px; border-radius: var(--radius); background: color-mix(in oklab, var(--surface) 80%, transparent); border: 2px solid var(--line); }
.lobby-players h2 { display: flex; align-items: center; gap: 10px; font-size: 1.4rem; font-weight: 900; }
.count-badge { display: grid; place-items: center; min-inline-size: 38px; block-size: 38px; padding-inline: 8px; border-radius: 999px; background: var(--pink); color: #fff; }
.player-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.player-chip {
  display: inline-flex; align-items: center; gap: .45em; padding: .35em 1em .35em .45em; border-radius: 999px; cursor: pointer;
  border: 0; font-weight: 900; font-size: clamp(1rem, 1.8vw, 1.3rem); color: #fff; background: var(--c, var(--grape));
  box-shadow: 0 4px 0 color-mix(in oklab, var(--c, var(--grape)) 70%, #000);
  transition: transform .2s var(--bounce), opacity .2s;
}
.player-chips li:nth-child(6n+1) .player-chip { --c: var(--a0); }
.player-chips li:nth-child(6n+2) .player-chip { --c: var(--a1); }
.player-chips li:nth-child(6n+3) .player-chip { --c: var(--grape); }
.player-chips li:nth-child(6n+4) .player-chip { --c: var(--a3); }
.player-chips li:nth-child(6n+5) .player-chip { --c: #ff7a2f; }
.player-chips li:nth-child(6n+6) .player-chip { --c: #c04bdb; }
.player-chip .avatar { display: grid; place-items: center; inline-size: 1.9em; block-size: 1.9em; border-radius: 50%; background: #fff; font-size: 1.1em; }
.player-chip:hover { transform: scale(1.06) rotate(-2deg); text-decoration: line-through; }
@media (prefers-reduced-motion: no-preference) {
  .player-chip { animation: pop-in .5s var(--bounce) both; }
}
@keyframes pop-in { from { scale: .2; opacity: 0; rotate: -20deg; } }
.lobby-go { grid-area: go; justify-self: center; inline-size: min(100%, 420px); }
@media (max-width: 760px) {
  .lobby { grid-template-columns: 1fr; grid-template-areas: "join" "qr" "players" "go"; }
  .qr { justify-self: center; }
}

.waiting { display: flex; align-items: center; gap: 10px; color: var(--ink-soft); font-weight: 700; }
.pulse { inline-size: 12px; block-size: 12px; border-radius: 50%; background: var(--pink); flex: none; }
@media (prefers-reduced-motion: no-preference) {
  .pulse { animation: pulse 1.4s ease-out infinite; }
  @keyframes pulse { from { box-shadow: 0 0 0 0 var(--pink); } to { box-shadow: 0 0 0 14px transparent; } }
}

/* 3, 2, 1 */
.countdown { display: grid; place-content: center; justify-items: center; gap: 10px; min-block-size: 70dvh; text-align: center; }
.count-title { font-weight: 900; font-size: clamp(1.3rem, 3vw, 2.2rem); }
.count-num {
  display: grid; place-items: center; inline-size: clamp(160px, 30vw, 280px); aspect-ratio: 1; border-radius: 50%;
  font-weight: 900; font-size: clamp(5rem, 14vw, 10rem); line-height: 1; color: #fff;
  background: conic-gradient(from 20deg, var(--pink), var(--sun), var(--mint), var(--sky), var(--grape), var(--pink));
  box-shadow: inset 0 0 0 14px rgb(255 255 255 / .25), var(--shadow);
  text-shadow: 0 4px 0 rgb(0 0 0 / .2);
}
@media (prefers-reduced-motion: no-preference) {
  .count-num { animation: count-pop .6s var(--bounce); }
  .count-num.pop { animation: count-pop .6s var(--bounce); }
  @keyframes count-pop { from { scale: .3; rotate: -90deg; } }
}

/* Question */
.question { display: grid; grid-template-rows: auto auto 1fr auto; gap: clamp(12px, 2.4vh, 26px); max-inline-size: 1300px; inline-size: 100%; margin-inline: auto; }
.q-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; }
.q-num { justify-self: start; padding: .3em 1em; border-radius: 999px; background: var(--surface); border: 2px solid var(--line); font-weight: 900; }
.q-answered { justify-self: end; font-weight: 800; color: var(--ink-soft); font-size: 1.1rem; }
.q-answered strong { font-size: 1.8rem; color: var(--ink); }
.timer { position: relative; display: grid; place-items: center; inline-size: clamp(76px, 9vw, 110px); aspect-ratio: 1; }
.timer svg { position: absolute; inset: 0; rotate: -90deg; }
.timer circle { stroke-width: 10; fill: none; }
.timer-track { stroke: var(--surface-2); fill: var(--surface) !important; }
.timer-fill { stroke: var(--grape); stroke-dasharray: 100; stroke-dashoffset: 0; animation: drain linear forwards; }
#h-question[data-state="reveal"] .timer-fill { animation-play-state: paused; stroke: var(--ok); stroke-dashoffset: 0; animation: none; }
.timer span { position: relative; font-weight: 900; font-size: clamp(1.8rem, 3.6vw, 2.6rem); }
.timer.hurry .timer-fill { stroke: var(--pink); }
@media (prefers-reduced-motion: no-preference) {
  .timer.hurry span { animation: throb .5s ease-in-out infinite alternate; }
  @keyframes throb { to { scale: 1.2; color: var(--pink); } }
}
@keyframes drain { to { stroke-dashoffset: 100; } }
.q-text {
  text-align: center; font-weight: 900; font-size: clamp(1.6rem, 3.8vw, 3.2rem); line-height: 1.15; letter-spacing: -.02em; text-wrap: balance;
  padding: clamp(14px, 3vh, 30px) clamp(14px, 3vw, 40px); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); border: 2px solid var(--line);
}

.tiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: clamp(10px, 1.6vw, 18px); }
.tile {
  --c: var(--a0); --deep: var(--a0-deep);
  position: relative; display: flex; align-items: center; gap: 14px; min-block-size: 84px; padding: 14px 18px;
  border: 0; border-radius: 24px; color: #fff; background: var(--c); text-align: start;
  font-weight: 900; font-size: clamp(1.1rem, 2.2vw, 1.8rem); line-height: 1.2;
  box-shadow: 0 6px 0 var(--deep); overflow: hidden;
  transition: opacity .3s, filter .3s, transform .3s var(--bounce);
}
.tile.c1 { --c: var(--a1); --deep: var(--a1-deep); }
.tile.c2 { --c: var(--a2); --deep: var(--a2-deep); color: #3a2600; }
.tile.c3 { --c: var(--a3); --deep: var(--a3-deep); }
.letter { display: grid; place-items: center; flex: none; inline-size: 1.9em; block-size: 1.9em; border-radius: 14px; background: rgb(255 255 255 / .28); font-size: .9em; }
.tile .text { flex: 1; position: relative; overflow-wrap: anywhere; }
@media (prefers-reduced-motion: no-preference) {
  .tiles > .tile { animation: tile-in .45s var(--bounce) both; animation-delay: calc(var(--sibling-index, 1) * 90ms); }
  @supports (animation-delay: calc(sibling-index() * 0.1s)) {
    .tiles > .tile { animation-delay: calc(sibling-index() * 90ms); }
  }
  @keyframes tile-in { from { opacity: 0; translate: 0 30px; scale: .9; } }
}
.big-tiles .tile { min-block-size: clamp(90px, 15vh, 170px); }

/* Reveal: the right answer glows, the rest fade, and bars show how people voted. */
.votes { display: none; position: absolute; inset: auto 0 0 0; block-size: 100%; pointer-events: none; }
.votes i { position: absolute; inset: auto auto 0 0; block-size: 100%; inline-size: calc(var(--share, 0) * 100%); background: rgb(255 255 255 / .2); transition: inline-size .9s cubic-bezier(.2, .8, .2, 1); }
.votes b { position: absolute; inset: 50% 18px auto auto; translate: 0 -50%; font-size: 1.3em; }
#h-question[data-state="reveal"] .votes { display: block; }
#h-question[data-state="reveal"] .tile .text { padding-inline-end: 2.5em; }
.tile[data-result="wrong"] { opacity: .35; filter: saturate(.4); transform: scale(.97); }
.tile[data-result="right"] { transform: scale(1.03); box-shadow: 0 6px 0 var(--deep), 0 0 0 6px var(--surface), 0 0 0 11px var(--ok), 0 20px 40px -10px var(--ok); }
.tile[data-result="right"]::after { content: "✓"; position: absolute; inset: 10px 12px auto auto; display: grid; place-items: center; inline-size: 34px; block-size: 34px; border-radius: 50%; background: #fff; color: var(--ok); font-size: 1.2rem; }
@media (prefers-reduced-motion: no-preference) {
  .tile[data-result="right"] { animation: wiggle .7s var(--bounce); }
  @keyframes wiggle { 30% { rotate: -2deg; } 60% { rotate: 2deg; } }
}

.q-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.q-actions .btn { font-size: 1.15rem; min-block-size: 54px; padding-inline: 1.6em; }

/* Leaderboard */
.board, .final, .dash { display: grid; gap: 22px; align-content: start; max-inline-size: 900px; inline-size: 100%; margin-inline: auto; }
.board-title { text-align: center; font-weight: 900; font-size: clamp(2rem, 5vw, 3.4rem); letter-spacing: -.02em; }
.ranking { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.rank-row {
  display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-radius: 22px;
  background: var(--surface); border: 2px solid var(--line); box-shadow: var(--shadow);
  font-weight: 900; font-size: clamp(1.1rem, 2.2vw, 1.6rem); view-transition-class: rank;
}
.rank-row:nth-child(1) { background: linear-gradient(120deg, #ffe07a, #ffb83d); color: #3a2600; border-color: transparent; }
.rank-row:nth-child(2) { background: linear-gradient(120deg, light-dark(#eef0f6, #4a4f66), light-dark(#cdd3e3, #353a50)); border-color: transparent; }
.rank-row:nth-child(3) { background: linear-gradient(120deg, light-dark(#ffd7b8, #6b3d22), light-dark(#f2a679, #4f2c17)); border-color: transparent; }
.rank-row[data-connected="false"] { opacity: .55; }
.place { display: grid; place-items: center; inline-size: 2em; block-size: 2em; border-radius: 50%; background: rgb(0 0 0 / .08); flex: none; font-size: .8em; }
.rank-row .avatar { font-size: 1.4em; }
.rank-row .name { flex: 1; min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plus { color: var(--ok); font-size: .8em; }
.rank-row:nth-child(-n+3) .plus { color: inherit; opacity: .75; }
.fire { font-size: .8em; }
.pts { font-variant-numeric: tabular-nums; }
.ranking.compact .rank-row { font-size: 1.05rem; padding: 8px 14px; box-shadow: none; background: var(--surface); color: inherit; border-color: var(--line); }
::view-transition-group(.rank) { animation-duration: .8s; animation-timing-function: cubic-bezier(.5, 0, .2, 1.3); }
@media (prefers-reduced-motion: no-preference) {
  .rank-row .plus { animation: float-up 1s var(--bounce) both .4s; }
  @keyframes float-up { from { opacity: 0; translate: 0 12px; } }
}

/* Podium */
.podium { list-style: none; margin: 20px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); align-items: end; gap: 12px; }
.step { display: grid; justify-items: center; gap: 6px; text-align: center; font-weight: 900; }
.step .avatar { font-size: clamp(2.6rem, 6vw, 4.5rem); }
.step .name { font-size: clamp(1rem, 2.2vw, 1.6rem); max-inline-size: 100%; overflow-wrap: anywhere; }
.step .pts { color: var(--ink-soft); }
.step .block { display: grid; place-items: start center; inline-size: 100%; padding-block-start: 14px; border-radius: 20px 20px 0 0; color: #fff; font-size: clamp(1.6rem, 4vw, 2.8rem); text-shadow: 0 3px 0 rgb(0 0 0 / .2); }
.step.s1 .block { block-size: clamp(150px, 26vh, 240px); background: linear-gradient(#ffd84d, #ff9f3d); }
.step.s2 .block { block-size: clamp(110px, 19vh, 175px); background: linear-gradient(var(--a1), var(--grape)); }
.step.s3 .block { block-size: clamp(80px, 13vh, 125px); background: linear-gradient(var(--a0), #c04bdb); }
.step.s1 .avatar::before { content: "👑"; display: block; font-size: .5em; }
@media (prefers-reduced-motion: no-preference) {
  .step .block { animation: rise 1s var(--bounce) both; transform-origin: bottom; }
  .step .avatar, .step .name, .step .pts { animation: drop-in .6s var(--bounce) both; }
  .step.s3 .block { animation-delay: .2s; } .step.s3 :is(.avatar, .name, .pts) { animation-delay: .9s; }
  .step.s2 .block { animation-delay: .6s; } .step.s2 :is(.avatar, .name, .pts) { animation-delay: 1.3s; }
  .step.s1 .block { animation-delay: 1s; } .step.s1 :is(.avatar, .name, .pts) { animation-delay: 1.8s; }
  @keyframes rise { from { scale: 1 0; } }
  @keyframes drop-in { from { opacity: 0; translate: 0 -40px; } }
}

/* At their own pace */
.dash-join { display: flex; align-items: center; gap: 20px; justify-content: center; flex-wrap: wrap; }
.dash-list .rank-row { flex-wrap: wrap; }
.progress { position: relative; flex-basis: 100%; block-size: 10px; border-radius: 999px; background: rgb(0 0 0 / .08); overflow: visible; }
.progress i { position: absolute; inset: 0 auto 0 0; inline-size: calc(var(--done) * 100%); border-radius: inherit; background: linear-gradient(90deg, var(--pink), var(--grape)); transition: inline-size .6s var(--bounce); }
.progress .flag { position: absolute; inset: -14px -6px auto auto; font-size: 1.2rem; }

/* ── A player's phone ── */
.play { min-block-size: 100dvh; display: grid; grid-template-rows: auto 1fr; padding: max(10px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom)); max-inline-size: 640px; margin-inline: auto; }
.play-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-block-end: 10px; }
.me { display: flex; align-items: center; gap: 8px; font-weight: 900; min-inline-size: 0; }
.me span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-avatar { display: grid; place-items: center; inline-size: 42px; block-size: 42px; border-radius: 50%; background: var(--sun); font-size: 1.5rem; flex: none; }
.score-chip { font-variant-numeric: tabular-nums; }
.play .phase:not(.p-question) { display: grid; place-content: center; justify-items: center; gap: 14px; text-align: center; padding-block: 20px; }
.play h2 { font-weight: 900; font-size: clamp(1.8rem, 7vw, 2.6rem); letter-spacing: -.02em; text-wrap: balance; }
.hop { font-size: 6rem; line-height: 1; }
.p-quiz { font-weight: 800; font-size: 1.2rem; }
.spin-emoji { font-size: 5rem; line-height: 1; }
@media (prefers-reduced-motion: no-preference) {
  .hop { animation: hop2 1.2s var(--bounce) infinite; }
  @keyframes hop2 { 0%, 100% { translate: 0 0; } 40% { translate: 0 -26px; rotate: -8deg; } 60% { translate: 0 0; rotate: 6deg; } }
  .spin-emoji { animation: wobble 1.4s ease-in-out infinite; }
  @keyframes wobble { 25% { rotate: -14deg; } 75% { rotate: 14deg; } }
}

.p-question { display: grid; grid-template-rows: auto auto 1fr; gap: 12px; }
.p-q-top { display: grid; gap: 8px; }
.p-q-top .q-num { justify-self: start; font-size: .95rem; }
.bar-timer { block-size: 12px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar-timer i { display: block; block-size: 100%; inline-size: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--mint), var(--sun), var(--pink)); background-size: 300% 100%; transform-origin: left; animation: shrink linear forwards; }
@keyframes shrink { to { scale: 0 1; background-position: 100% 0; } }
.p-question .q-text { font-size: clamp(1.2rem, 5vw, 1.7rem); padding: 16px; }
.answer-buttons { grid-template-columns: 1fr 1fr; grid-auto-rows: 1fr; min-block-size: min(52dvh, 440px); }
.answer-buttons .tile { cursor: pointer; flex-direction: column; justify-content: center; text-align: center; gap: 8px; font-size: clamp(1rem, 4.4vw, 1.35rem); min-block-size: 110px; }
.answer-buttons .tile .text { flex: none; }
.answer-buttons .tile:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--deep); }
.answer-buttons .tile[data-picked] { transform: scale(1.04); box-shadow: 0 0 0 4px var(--surface), 0 0 0 8px var(--c); }
.answer-buttons .tile[data-dim] { opacity: .3; }
.answer-buttons .tile:disabled { cursor: default; }

.result-icon {
  display: grid; place-items: center; inline-size: 130px; block-size: 130px; border-radius: 50%;
  font-size: 4.5rem; font-weight: 900; color: #fff; background: var(--bad); box-shadow: 0 10px 0 #a3143f, var(--shadow);
}
.p-result[data-result="right"] .result-icon { background: var(--ok); box-shadow: 0 10px 0 #08664b, var(--shadow); }
.p-result { border-radius: var(--radius); }
.p-result[data-result="right"] { background: radial-gradient(circle at 50% 30%, light-dark(rgb(20 185 143 / .22), rgb(79 224 196 / .16)), transparent 70%); }
.p-result[data-result="wrong"] { background: radial-gradient(circle at 50% 30%, light-dark(rgb(226 61 109 / .18), rgb(255 122 156 / .14)), transparent 70%); }
.gain { font-weight: 900; font-size: 2.6rem; color: var(--ok); }
.streak { font-weight: 900; font-size: 1.2rem; padding: .25em 1em; border-radius: 999px; background: light-dark(#fff1c9, #463a17); color: var(--orange); }
.right-answer { font-weight: 800; padding: .5em 1em; border-radius: 16px; background: var(--surface); border: 2px solid var(--line); }
.rank-line { font-weight: 800; color: var(--ink-soft); font-size: 1.1rem; }
@media (prefers-reduced-motion: no-preference) {
  .result-icon { animation: stamp .55s var(--bounce); }
  .p-result[data-result="wrong"] .result-icon { animation: shake .5s ease-in-out; }
  .gain { animation: gain-pop .7s var(--bounce) .15s both; }
  @keyframes stamp { from { scale: 2.2; opacity: 0; rotate: -30deg; } }
  @keyframes shake { 20%, 60% { translate: -10px 0; } 40%, 80% { translate: 10px 0; } }
  @keyframes gain-pop { from { scale: .2; opacity: 0; } }
}

.rank-big {
  display: grid; place-items: center; min-inline-size: 150px; padding: 18px 26px; border-radius: 40px;
  font-weight: 900; font-size: 4.5rem; line-height: 1; color: #fff;
  background: linear-gradient(135deg, var(--sky), var(--grape)); box-shadow: 0 10px 0 var(--grape-deep), var(--shadow);
}
.medal { font-size: 7rem; line-height: 1; }
@media (prefers-reduced-motion: no-preference) {
  .medal, .rank-big { animation: medal-in 1s var(--bounce); }
  @keyframes medal-in { from { scale: 0; rotate: 200deg; } }
}
.final-score { font-weight: 800; font-size: 1.15rem; }
.mini-podium { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; inline-size: min(100%, 360px); }
.mini-podium li { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 16px; background: var(--surface); border: 2px solid var(--line); font-weight: 800; }
.mini-podium .name { flex: 1; text-align: start; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.play .btn.big { inline-size: min(100%, 360px); }

/* ── Dialogs ── */
.sheet {
  inline-size: min(500px, calc(100vw - 24px)); max-block-size: calc(100dvh - 24px); padding: 26px; border: 2px solid var(--line);
  border-radius: var(--radius); background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
.sheet[open] { display: grid; gap: 14px; }
.sheet h2 { font-size: 1.5rem; font-weight: 900; }
dialog:modal { overscroll-behavior: contain; }
dialog::backdrop { background: rgb(30 18 60 / .45); backdrop-filter: blur(4px); overflow: hidden; overscroll-behavior: contain; }
@media (prefers-reduced-motion: no-preference) {
  .sheet { transition: opacity .2s, scale .25s var(--bounce), display .25s, overlay .25s; transition-behavior: allow-discrete; }
  .sheet:not([open]) { opacity: 0; scale: .92; }
  @starting-style { .sheet[open] { opacity: 0; scale: .92; } }
}
.key-row { display: flex; gap: 8px; align-items: center; }
.key-row input { flex: 1; min-inline-size: 0; font-family: ui-monospace, monospace; font-size: .95rem; }
.forget { display: grid; gap: 2px; justify-items: start; padding-block-start: 10px; border-block-start: 2px solid var(--line); }
.forget .btn { margin-inline-start: -1em; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ── Toast and confetti ── */
.toast {
  position: fixed; inset: auto 0 32px; margin-inline: auto; inline-size: fit-content; max-inline-size: calc(100vw - 32px);
  padding: .6em 1.2em; border-radius: 999px; background: var(--ink); color: var(--bg); font-weight: 800;
  box-shadow: var(--shadow); opacity: 0; translate: 0 10px; transition: opacity .2s, translate .2s; pointer-events: none; z-index: 10;
}
.toast.show { opacity: 1; translate: 0 0; }
@media (prefers-reduced-motion: reduce) { .toast { transition: opacity .2s; translate: none; } }
.confetti { position: fixed; inset: 0; inline-size: 100vw; block-size: 100vh; pointer-events: none; z-index: 20; }

/* Copyright notice at the foot of the page. */
.copyright { margin: 0; padding: 1.5rem 1rem calc(1.5rem + env(safe-area-inset-bottom, 0px)); text-align: center; font-size: 0.8rem; color: var(--ink-soft); }
/* Only on the start screen: during a game the main view fills the window. */
body:has(#home[hidden]) .copyright { display: none; }

/* Back to the list of all of Marc's apps, on its own line under the credit. */
.apps-link { display: block; inline-size: fit-content; margin-block-start: 0.15rem; white-space: nowrap; }
.apps-link svg { display: inline; inline-size: 1.05em; block-size: 1.05em; margin-inline-end: 0.25em; vertical-align: -0.18em; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ── Screen changes ── */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .28s; }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* Appearance: the setting writes <meta name="color-scheme">; map it back so light-dark() follows it. */
:root:has(> head > meta[name="color-scheme"][content="light"]) { color-scheme: light; }
:root:has(> head > meta[name="color-scheme"][content="dark"]) { color-scheme: dark; }
