/* Shared styles for every game.
   A game sets five things in its theme.css: --bg, --ink, --accent, --on-accent, --display.
   Motion uses transform and opacity only. Colors are solid. */

:root {
  --bg: #14110f;
  --ink: #f4efe6;
  --accent: #f0562a;
  --on-accent: #14110f;
  --display: 'Geist', system-ui, sans-serif;
  /* The one weight of the display font. Some display fonts have a single weight. */
  --dw: 800;
  --font: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
  /* Three neutrals derived from the two base colors. */
  --muted: color-mix(in oklab, var(--ink) 66%, var(--bg));
  --line: color-mix(in oklab, var(--ink) 15%, var(--bg));
  --raise: color-mix(in oklab, var(--ink) 8%, var(--bg));
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --gutter: 20px;
  --radius: 14px;
  --hit: 52px;
  --column: 27rem;
  --vvh: 100dvh;
}

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

html {
  -webkit-text-size-adjust: 100%;
  font-synthesis-weight: none;
  scrollbar-width: none;
  background: var(--bg);
}
html::-webkit-scrollbar { display: none; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

h1, h2, h3, p, ul, ol { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, input { font: inherit; color: inherit; }
button {
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }

/* ---------- Page frame ---------- */

.app {
  min-height: 100dvh;
  max-width: 34rem;
  margin: 0 auto;
  padding: 0 var(--gutter) env(safe-area-inset-bottom);
  display: flex;
  flex-direction: column;
}
.host { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.screen { flex: 1; display: flex; flex-direction: column; gap: 22px; padding: 4px 0 40px; }

.topbar {
  flex: none;
  height: 56px;
  padding-top: env(safe-area-inset-top);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar-left { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.topbar-home { font: var(--dw) 19px/1 var(--display); min-height: 44px; }
.topbar-label { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.topbar-right { display: flex; gap: 2px; margin-right: -10px; }

.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  transition: transform 0.2s var(--ease), background-color 0.2s var(--ease);
}
.icon-button:active { transform: scale(0.92); }

/* ---------- Buttons ---------- */

.button {
  min-height: var(--hit);
  padding: 0 20px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 600;
  font-size: 16px;
  text-decoration: none;
  transition: transform 0.2s var(--ease), background-color 0.2s var(--ease);
}
.button:active { transform: scale(0.98); }
.button-primary { background: var(--accent); color: var(--on-accent); }
.button-quiet { background: var(--raise); }
.button-danger { background: var(--ink); color: var(--bg); }
.button-big { width: 100%; min-height: 62px; padding: 0 22px; font-size: 19px; justify-content: space-between; }

@media (hover: hover) {
  .icon-button:hover, .button-quiet:hover, .list-row:hover { background: var(--line); }
}

/* ---------- The scene ---------- */

/* A game can set --scene-ratio in theme.css. It must match the view box of its scene (320 by 200 = 8 / 5). */
.scene-slot { flex: none; width: 100%; aspect-ratio: var(--scene-ratio, 8 / 3); }
.scene, .scene-svg { display: block; width: 100%; height: 100%; }
.scene-svg { overflow: visible; }
.scene-accent { fill: var(--accent); }
.scene-ink { fill: var(--ink); }
.scene-bg { fill: var(--bg); }
.scene-line { fill: var(--line); }
.scene-raise { fill: var(--raise); }
.scene-muted { fill: var(--muted); }
.scene-on-accent { fill: var(--on-accent); }
.scene-stroke-accent { fill: none; stroke: var(--accent); }
.scene-stroke-ink { fill: none; stroke: var(--ink); }
.scene-stroke-line { fill: none; stroke: var(--line); }
.scene-stroke-muted { fill: none; stroke: var(--muted); }
.scene-text { font-family: var(--display); font-weight: var(--dw); }

/* ---------- Home ---------- */

.screen-home { gap: 26px; }
.screen-home > * { animation: rise 0.55s var(--ease) both; }
.screen-home > :nth-child(2) { animation-delay: 50ms; }
.screen-home > :nth-child(3) { animation-delay: 100ms; }
.screen-home > :nth-child(4) { animation-delay: 150ms; }
.screen-home > :nth-child(5) { animation-delay: 200ms; }
.screen-home > :nth-child(n + 6) { animation-delay: 250ms; }

/* The name always fits on one line: the size comes from the width and the number of letters. */
.home-head { container-type: inline-size; }
.wordmark {
  font: var(--dw) 48px/1 var(--display);
  font-size: min(68px, calc(100cqw / (var(--chars, 10) * var(--char-width, 0.6))));
  white-space: nowrap;
}
.tagline { margin-top: 12px; max-width: 24ch; font-size: 20px; font-weight: 500; line-height: 1.25; }
.dayline { margin-top: 8px; color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; }

.rules { display: grid; gap: 9px; font-size: 17px; }
.rules li { display: grid; grid-template-columns: 8px 1fr; gap: 12px; align-items: baseline; }
.rules li::before { content: ''; width: 8px; height: 8px; border-radius: 2px; background: var(--accent); transform: translateY(-1px); }

.facts { display: flex; gap: 30px; }
.facts-wide { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px 12px; }
.fact { display: grid; gap: 4px; }
.fact-number { font: var(--dw) 30px/1 var(--display); font-variant-numeric: tabular-nums; }
.fact-label { color: var(--muted); font-size: 13px; }

.home-links { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.home-links .button { justify-content: flex-start; padding: 0 16px; }

.versus { padding: 14px 16px; border-radius: var(--radius); background: var(--raise); font-weight: 600; }
.fine { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.legal-links { display: flex; flex-wrap: wrap; column-gap: 20px; }
.text-link { justify-self: start; color: var(--ink); text-underline-offset: 3px; min-height: 32px; display: inline-flex; align-items: center; }
.empty { color: var(--muted); padding: 8px 0; }
.section-title { font: 700 15px/1.3 var(--font); }

/* ---------- Tier marks ---------- */

.glyph-row { display: flex; gap: 6px; }
.glyph {
  position: relative;
  flex: none;
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: var(--line);
  overflow: hidden;
}
.glyph-fill { position: absolute; inset: 0; background: var(--accent); transform: scaleY(0); transform-origin: bottom; }
.glyph-t1 .glyph-fill { transform: scaleY(0.2); }
.glyph-t2 .glyph-fill { transform: scaleY(0.4); }
.glyph-t3 .glyph-fill { transform: scaleY(0.6); }
.glyph-t4 .glyph-fill { transform: scaleY(0.8); }
.glyph-t5 .glyph-fill { transform: scaleY(1); }
.glyph-t5::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34%;
  height: 34%;
  background: var(--bg);
  transform: translate(-50%, -50%) rotate(45deg);
}
.glyph-miss { background: none; box-shadow: inset 0 0 0 2px var(--line); }
.glyph-miss::after { content: ''; position: absolute; left: 26%; right: 26%; top: calc(50% - 1px); height: 2px; background: var(--muted); }
.glyph-todo { background: var(--raise); }
.glyph-current { background: none; box-shadow: inset 0 0 0 2px var(--ink); }
.glyph-big { width: 30px; height: 30px; border-radius: 7px; }
.glyph-digit { position: absolute; inset: 0; display: none; place-items: center; font: 700 12px/1 var(--font); }

/* High contrast: the tier is a number, so it does not depend on color. */
[data-contrast='true'] .glyph { background: none; box-shadow: inset 0 0 0 2px var(--ink); }
[data-contrast='true'] .glyph-fill, [data-contrast='true'] .glyph-t5::after { display: none; }
[data-contrast='true'] .glyph-digit { display: grid; }
[data-contrast='true'] .glyph-todo { box-shadow: inset 0 0 0 2px var(--line); }

/* ---------- Play: the world fills the screen, the sheet floats over it ---------- */

.app[data-view='play'] {
  position: relative;
  height: var(--vvh);
  min-height: 0;
  max-width: none;
  padding: 0;
  overflow: hidden;
}
.app[data-view='play'] .topbar { position: relative; z-index: 2; padding-left: var(--gutter); padding-right: var(--gutter); }
/* The top bar sits over the world: its parts get a solid backing so they stay readable. */
.app[data-view='play'] .topbar-left { padding: 0 12px; border-radius: 12px; background: var(--bg); }
.app[data-view='play'] .topbar-right { margin-right: -4px; padding: 2px; border-radius: 14px; background: var(--bg); }
.screen-play { position: static; display: block; padding: 0; }
.screen-play > .scene-slot { position: absolute; inset: 0; z-index: 0; width: auto; aspect-ratio: auto; }

.play-sheet {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 40rem;
  margin: 0 auto;
  padding: 14px var(--gutter) max(12px, env(safe-area-inset-bottom));
  display: grid;
  gap: 11px;
  border-radius: 22px 22px 0 0;
  background: var(--bg);
  box-shadow: 0 -1px 0 var(--line);
}

.play-status { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.play-status .glyph { width: 18px; height: 18px; border-radius: 4px; }
.play-status .glyph-row { gap: 5px; }
.play-total { font: var(--dw) 20px/1 var(--display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.unit { font: 500 13px/1 var(--font); color: var(--muted); }

.timer { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; }
.timer-track { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.timer-fill { height: 100%; border-radius: 3px; background: var(--ink); transform-origin: left; }
.timer-seconds { min-width: 2ch; text-align: right; font: var(--dw) 20px/1 var(--display); font-variant-numeric: tabular-nums; }
.timer-warning .timer-fill { background: var(--accent); }
.timer-warning .timer-seconds { color: var(--accent); }

/* Two lines tall at least, so the sheet keeps its height from the count-in to the question. */
.stage { min-height: 54px; display: grid; align-content: start; }
.prompt { font: 600 22px/1.22 var(--font); text-wrap: balance; animation: rise 0.4s var(--ease) both; }
.countin { display: none; font: var(--dw) 54px/1 var(--display); color: var(--accent); font-variant-numeric: tabular-nums; }
/* The tier and the points share a row when they fit. A long tier name in a wide font pushes the points to the next row. */
.verdict { display: none; flex-wrap: wrap; align-items: center; gap: 4px 12px; }

[data-phase='ready'] .prompt, [data-phase='reveal'] .prompt { display: none; }
[data-phase='ready'] .countin { display: block; }
[data-phase='reveal'] .verdict { display: flex; animation: rise 0.45s var(--ease) both; }

.verdict-answer, .verdict-line { flex: 1 0 100%; }
.verdict-answer { color: var(--muted); font-size: 15px; font-weight: 500; }
.verdict-tier { display: flex; align-items: center; gap: 10px; font: var(--dw) 26px/1.05 var(--display); white-space: nowrap; }
.verdict-tier .glyph-big { width: 26px; height: 26px; border-radius: 6px; }
.verdict-units { margin-left: auto; font: var(--dw) 24px/1.05 var(--display); color: var(--accent); font-variant-numeric: tabular-nums; white-space: nowrap; }
.verdict-line { color: var(--muted); font-size: 14px; }
[data-status='miss'] .verdict-units, [data-status='timeout'] .verdict-units { color: var(--muted); }

.answer { display: grid; gap: 8px; }
/* The label is for screen readers. The question above the field says what to type. */
.answer-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.answer-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.answer-input {
  height: 54px;
  min-width: 0;
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--raise);
  font-size: 19px;
  font-weight: 500;
  outline: none;
  box-shadow: inset 0 0 0 2px transparent;
  transition: box-shadow 0.2s var(--ease);
}
.answer-input:focus { box-shadow: inset 0 0 0 2px var(--ink); }
.send {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--on-accent);
  transition: transform 0.2s var(--ease);
}
.send:active { transform: scale(0.93); }
/* A wrong or unknown answer: a note floats over the world, just above the sheet. The sheet keeps its height. */
.answer-note {
  position: absolute;
  left: var(--gutter);
  bottom: calc(100% + 10px);
  max-width: calc(100% - 2 * var(--gutter));
  padding: 9px 14px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  animation: rise 0.25s var(--ease) both;
}
.answer-note:empty { display: none; }
.next { display: none; width: 100%; min-height: 54px; font-size: 18px; }

[data-phase='reveal'] .next { display: inline-flex; }
[data-phase='reveal'] .timer { visibility: hidden; }
[data-phase='reveal'] .answer-note { display: none; }
/* The input stays in the page and keeps the focus, so the phone keyboard stays open. */
[data-phase='reveal'] .answer-row { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }

/* A short phone screen (the keyboard is open): the clock joins the score row and the type gets smaller,
   so the world keeps a band of about 180 pixels between the top bar and the sheet. */
@media (max-width: 959px) and (max-height: 620px) {
  .app[data-view='play'] .topbar { height: 48px; }
  .play-sheet {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: 'status timer' 'stage stage' 'answer answer';
    gap: 9px 14px;
    padding-top: 12px;
  }
  .play-status { grid-area: status; }
  .timer { grid-area: timer; gap: 8px; }
  .stage { grid-area: stage; min-height: 48px; }
  .answer { grid-area: answer; }
  .prompt { font-size: 20px; }
  .countin { font-size: 44px; }
  .answer-input, .send { height: 50px; }
  .send { width: 50px; }
  .next { min-height: 50px; }
  .verdict-tier { font-size: 22px; }
  .verdict-tier .glyph-big { width: 22px; height: 22px; }
  .verdict-units { font-size: 20px; }
  .verdict-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* ---------- Results ---------- */

.screen-results { gap: 28px; }
.result-head { display: grid; gap: 6px; animation: rise 0.5s var(--ease) both; }
.result-total { margin-top: 6px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 12px; }
.result-number { font: var(--dw) clamp(64px, 21vw, 108px)/0.92 var(--display); color: var(--accent); font-variant-numeric: tabular-nums; }
.result-of { font: 500 17px/1.2 var(--font); color: var(--muted); }
.result-title { margin-top: 10px; font: var(--dw) 30px/1.08 var(--display); }
.result-line { color: var(--muted); }
.result-head .glyph-row { margin-top: 16px; gap: 8px; }
.result-head .glyph { width: 34px; height: 34px; border-radius: 8px; }
.result-head .glyph-digit { font-size: 15px; }
.result-facts { margin-top: 10px; font-weight: 600; }

.field-curve { margin-top: 18px; display: grid; gap: 6px; }
.field-head { font-weight: 600; font-variant-numeric: tabular-nums; }
.field-svg { display: block; width: 100%; height: auto; overflow: visible; }
.field-area { fill: var(--line); }
.field-beat { fill: var(--accent); }
.field-edge { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; }
.field-base { stroke: var(--muted); stroke-width: 1; }
.field-mark { stroke: var(--ink); stroke-width: 2; }
.field-dot { fill: var(--ink); stroke: var(--bg); stroke-width: 2; }
.field-label {
  fill: var(--ink);
  stroke: var(--bg);
  stroke-width: 4px;
  stroke-linejoin: round;
  paint-order: stroke;
  font: 600 13px var(--font);
  font-variant-numeric: tabular-nums;
}
.field-end { fill: var(--muted); font: 500 11px var(--font); font-variant-numeric: tabular-nums; }

.result-actions { display: grid; gap: 10px; }
.action-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.action-row .button { min-height: 74px; padding: 12px 6px; flex-direction: column; gap: 6px; font-size: 13px; text-align: center; line-height: 1.2; }

.countdown { display: flex; align-items: baseline; gap: 10px; color: var(--muted); }
.countdown-digits { font: var(--dw) 26px/1 var(--display); color: var(--ink); font-variant-numeric: tabular-nums; }

.rounds { display: grid; gap: 2px; }
.round-summary {
  padding: 11px 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  list-style: none;
  cursor: pointer;
}
.round-summary::-webkit-details-marker { display: none; }
.round-text { display: grid; gap: 2px; min-width: 0; }
.round-prompt { color: var(--muted); font-size: 13px; }
.round-said { font-weight: 600; }
.round-units { font: var(--dw) 18px/1 var(--display); font-variant-numeric: tabular-nums; }
.round-answers { padding: 4px 0 18px 36px; display: grid; gap: 12px; }
.tier-name { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.tier-name .glyph { width: 14px; height: 14px; border-radius: 3px; }
.tier-name .glyph-digit { font-size: 9px; }
.tier-answers { margin-top: 4px; font-size: 14px; line-height: 1.65; }
.answer-item { display: inline-block; margin-right: 14px; }
.answer-share { color: var(--muted); font-variant-numeric: tabular-nums; }
.answer-mine { font-weight: 700; text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.answer-secret { color: var(--muted); }

/* ---------- Panels ---------- */

.sheet {
  width: min(100%, 30rem);
  max-width: 100%;
  max-height: min(88dvh, 46rem);
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 22px 22px 0 0;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  box-shadow: 0 -18px 60px rgb(8 8 8 / 0.35);
}
.sheet[open] { display: flex; flex-direction: column; animation: sheet-up 0.4s var(--ease); }
.sheet::backdrop, .palette::backdrop { background: rgb(8 8 8 / 0.58); }
.sheet-head { flex: none; padding: 14px 10px 4px 22px; display: flex; align-items: center; justify-content: space-between; }
.sheet-title { font: var(--dw) 22px/1.1 var(--display); }
.sheet-body { padding: 10px 22px calc(28px + env(safe-area-inset-bottom)); display: grid; gap: 18px; overflow-y: auto; scrollbar-width: none; }
.sheet-body::-webkit-scrollbar, .palette-list::-webkit-scrollbar { display: none; }

.list { display: grid; gap: 2px; margin: 0 -12px; }
.list-row {
  width: 100%;
  min-height: 54px;
  padding: 0 12px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  transition: background-color 0.15s var(--ease);
}
.list-row:active { background: var(--raise); }
.list-main { flex: 1; min-width: 0; font-weight: 500; }
.list-side { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
[aria-selected='true'] > .list-row { background: var(--raise); }

.ladder { display: grid; gap: 14px; }
.ladder-step { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 2px 12px; }
.ladder-name { font-weight: 600; }
.ladder-units { font: var(--dw) 15px/1 var(--display); font-variant-numeric: tabular-nums; }
.ladder-blurb { grid-column: 2 / -1; color: var(--muted); font-size: 13px; }

.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 9rem) minmax(0, 1fr) 3ch; align-items: center; gap: 12px; font-size: 14px; }
.bar-track { height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 5px; background: var(--accent); transform-origin: left; }
.bar-count { text-align: right; font-variant-numeric: tabular-nums; }

.switch { width: 100%; min-height: 52px; display: flex; align-items: center; justify-content: space-between; font-weight: 500; }
.switch-track { position: relative; width: 50px; height: 30px; border-radius: 15px; background: var(--line); transition: background-color 0.2s var(--ease); }
.switch-thumb { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--ink); transition: transform 0.3s var(--spring); }
.switch[aria-checked='true'] .switch-track { background: var(--accent); }
.switch[aria-checked='true'] .switch-thumb { transform: translateX(20px); background: var(--on-accent); }

.field { display: grid; gap: 8px; }
.field-label { font-size: 14px; font-weight: 600; }
.text-input { height: 52px; padding: 0 16px; border: 0; border-radius: var(--radius); background: var(--raise); font-size: 17px; outline: none; box-shadow: inset 0 0 0 2px transparent; }
.text-input:focus { box-shadow: inset 0 0 0 2px var(--ink); }
.segments, .brand-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.segment { min-height: 44px; padding: 0 16px; border-radius: 12px; background: var(--raise); font-weight: 600; }
.segment[aria-pressed='true'] { background: var(--ink); color: var(--bg); }
.swatch { width: 44px; height: 44px; border-radius: 12px; box-shadow: inset 0 0 0 2px var(--line); }

.palette {
  width: min(92vw, 32rem);
  margin: 12vh auto auto;
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  box-shadow: 0 30px 80px rgb(8 8 8 / 0.4);
}
.palette[open] { animation: rise 0.25s var(--ease); }
.palette-head { padding: 6px 18px; display: flex; align-items: center; gap: 12px; color: var(--muted); }
.palette-input { flex: 1; height: 52px; border: 0; outline: none; background: none; color: var(--ink); font-size: 17px; }
.palette-list { margin: 0; padding: 4px 8px 10px; max-height: 50vh; overflow-y: auto; scrollbar-width: none; }
.palette-list .empty { padding: 12px; }

.toast {
  position: fixed;
  inset: auto auto calc(24px + env(safe-area-inset-bottom)) 50%;
  margin: 0;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border: 0;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: transform 0.3s var(--ease), opacity 0.3s var(--ease);
  z-index: 10;
}
.toast-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Loading and errors ---------- */

.skeleton { padding-top: 76px; display: grid; gap: 16px; }
.skeleton i { display: block; height: 22px; border-radius: 8px; background: var(--raise); animation: breathe 1.1s ease-in-out infinite alternate; }
.skeleton i:first-child { height: 64px; width: 72%; }
.skeleton i:nth-child(2) { width: 54%; }
.skeleton i:nth-child(3) { height: 62px; margin-top: 12px; }
.crash { justify-content: center; gap: 16px; }

/* ---------- Motion ---------- */

@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes pop { from { opacity: 0; transform: scale(0.6); } }
@keyframes sheet-up { from { opacity: 0; transform: translateY(28px); } }
@keyframes breathe { to { opacity: 0.45; } }
@keyframes shake {
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}
.pop { animation: pop 0.5s var(--spring) both; transform-origin: left center; }
.shake { animation: shake 0.36s ease-in-out; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0s !important; transition-duration: 0.01ms !important; }
}

/* ---------- Wide screens: the game on the left, the scene on the right ---------- */

@media (min-width: 960px) {
  .app { max-width: 78rem; padding: 0 56px; }
  .topbar { height: 72px; }
  .screen { max-width: var(--column); padding-top: 3vh; }
  .screen > .scene-slot {
    position: fixed;
    top: 50%;
    right: max(56px, calc((100vw - 78rem) / 2 + 56px));
    width: min(46vw, 40rem);
    display: block;
    aspect-ratio: var(--scene-ratio, 8 / 3);
    transform: translateY(-50%);
    animation: none;
  }

  /* Play on a desktop: the world fills the window, and the sheet docks where the game says. */
  .app[data-view='play'] { max-width: none; padding: 0; }
  .app[data-view='play'] .topbar { padding-left: 40px; padding-right: 40px; }
  .app[data-view='play'] .screen-play { max-width: none; padding: 0; }
  .app[data-view='play'] .screen-play > .scene-slot { position: absolute; inset: 0; width: auto; transform: none; }
  .play-sheet { padding: 24px 26px; gap: 16px; border-radius: 24px; box-shadow: none; }
  .prompt { font-size: 28px; line-height: 1.18; }
  .stage { min-height: 66px; }
  .countin { font-size: 64px; }
  .verdict-tier { font-size: 30px; }

  .screen-play[data-dock='left'] .play-sheet,
  .screen-play[data-dock='right'] .play-sheet { top: max(96px, 14vh); bottom: auto; width: 26rem; margin: 0; }
  .screen-play[data-dock='left'] .play-sheet { left: 40px; right: auto; }
  .screen-play[data-dock='right'] .play-sheet { left: auto; right: 40px; }
  /* A side panel has room for the note inside it. */
  .screen-play[data-dock='left'] .answer-note,
  .screen-play[data-dock='right'] .answer-note { position: static; max-width: none; justify-self: start; }

  .screen-play[data-dock='bottom'] .play-sheet {
    left: 40px;
    right: 40px;
    bottom: 28px;
    max-width: 72rem;
    grid-template-columns: minmax(0, 1fr) minmax(18rem, 25rem);
    grid-template-areas: 'status timer' 'stage answer';
    align-items: end;
    column-gap: 32px;
  }
  .screen-play[data-dock='bottom'] .play-status { grid-area: status; }
  .screen-play[data-dock='bottom'] .timer { grid-area: timer; }
  .screen-play[data-dock='bottom'] .stage { grid-area: stage; align-self: center; }
  .screen-play[data-dock='bottom'] .answer { grid-area: answer; }
  .screen-play[data-dock='bottom'] .answer-note { left: 26px; }
}
