:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --ink: #1c1d21;
  --muted: #5c6370;
  --card: #ffffff;
  --line: #e3e6eb;
  --accent: #2f5bff;
  --accent-ink: #ffffff;
  --ok: #1b7f4e;
  --bad: #b42318;
  --shadow: 0 8px 24px rgba(28, 29, 33, 0.06);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.4;
}
.top, main, .sheet {
  width: min(440px, calc(100% - 32px));
  margin-inline: auto;
}
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
}
.brand { margin: 0; font-weight: 750; font-size: 1.25rem; letter-spacing: -0.03em; }
nav { display: flex; gap: 8px; }
button, input {
  font: inherit;
  color: inherit;
}
button {
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--card);
  padding: 0 16px;
}
button.primary {
  width: 100%;
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 650;
}
button.secondary { background: #12141a; }
button.link {
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0 8px;
}
h1 { font-size: 1.6rem; letter-spacing: -0.03em; margin: 0 0 12px; }
h2 { font-size: 1.15rem; margin: 28px 0 0; }
.lede, .note, .meta, .error { color: var(--muted); }
.error { color: var(--bad); min-height: 1.2em; }
.steps { padding-left: 1.2rem; }
.steps li { margin: 8px 0; }
label { display: block; font-size: 0.9rem; margin: 12px 0 6px; }
input {
  width: 100%;
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 0 14px;
  background: var(--card);
}
.chapter, .card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 14px;
  margin: 10px 0;
}
.chapter h2 { margin: 0 0 10px; font-size: 1.05rem; }
.row { display: flex; gap: 8px; }
.row button { flex: 1; }
.lock { display: inline-flex; vertical-align: -3px; margin-left: 6px; }
.options { display: grid; gap: 8px; position: relative; }
.options button { text-align: left; width: 100%; }
.options button.correct { outline: 3px solid var(--ok); }
.options button.chosen { outline: 3px solid var(--ink); }
.code { font-size: 2rem; letter-spacing: 0.28em; font-weight: 750; margin: 0; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff6d8;
  border-radius: 999px;
  padding: 8px 12px;
}
.score { font-size: 3.5rem; font-weight: 750; letter-spacing: -0.04em; margin: 0; }
.points { min-height: 1.4em; color: var(--ok); font-weight: 700; }
.cards { display: grid; gap: 10px; }
.card strong { display: block; font-size: 1.8rem; letter-spacing: -0.04em; }
.card span { color: var(--muted); font-size: 0.9rem; }
.board { list-style: none; padding: 0; margin: 12px 0; }
.board li {
  display: flex;
  justify-content: space-between;
  min-height: 44px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.prize {
  margin-top: 12px;
  padding: 16px;
  border-radius: 16px;
  background: #12141a;
  color: white;
  text-align: center;
}
#live-confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.paywall {
  position: fixed;
  inset: 0;
  background: rgba(18, 20, 26, 0.45);
  display: grid;
  align-items: end;
}
.sheet {
  background: var(--card);
  border-radius: 20px 20px 0 0;
  padding: 20px 16px 28px;
  width: min(480px, 100%);
}
.sheet button { margin-top: 8px; }
.host { display: grid; gap: 8px; margin-top: 12px; }

@media (prefers-reduced-motion: no-preference) {
  .pop { animation: pop 450ms ease; }
  .shake { animation: shake 180ms linear; }
  .prize.show { animation: prize 280ms ease; }
  .dot {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ok);
    animation: burst 500ms ease-out forwards;
  }
}
@keyframes pop { from { transform: scale(0.96); } to { transform: scale(1); } }
@keyframes shake {
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
@keyframes burst { to { transform: translate(var(--x), var(--y)); opacity: 0; } }
@keyframes prize { from { transform: scale(0.92); } to { transform: scale(1); } }

@media (prefers-reduced-motion: reduce) {
  .pop, .shake, .prize.show, .dot { animation: none; }
}
