/* Afterimage: light by default, dark on request (Settings) or when the device
   asks for it ("Match device"). Phone first; tablets and desktop get a
   side-by-side play screen. */

:root,
[data-theme="light"] {
  --bg: #ffffff;
  --surface: #f6f3ee;
  --surface-2: #eee9e1;
  --text: #221f1c;
  --text-soft: #6f6860;
  --line: #e7e1d8;
  --accent: #ff6b3d;
  --accent-ink: #ffffff;
  --accent-soft: #ffeadf;
  --figure: #ff6b3d;
  --pen: #221f1c;
  --board: #fbfaf8;
  --board-line: #ece6dd;
  --good: #1f9d63;
  --good-soft: #e0f4e9;
  --gold: #f5b400;
  --danger: #d9434b;
  --shadow: 0 10px 30px rgba(60, 40, 20, 0.08);
  --font: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #131211;
  --surface: #1f1d1b;
  --surface-2: #2a2724;
  --text: #f4f1ec;
  --text-soft: #a79f94;
  --line: #34312c;
  --accent: #ff7d52;
  --accent-ink: #1a1411;
  --accent-soft: #3b2419;
  --figure: #ff8a5c;
  --pen: #f4f1ec;
  --board: #1a1917;
  --board-line: #2e2b27;
  --good: #4cc38a;
  --good-soft: #17301f;
  --gold: #ffc94a;
  --danger: #ff6b6b;
  --shadow: none;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --bg: #131211;
    --surface: #1f1d1b;
    --surface-2: #2a2724;
    --text: #f4f1ec;
    --text-soft: #a79f94;
    --line: #34312c;
    --accent: #ff7d52;
    --accent-ink: #1a1411;
    --accent-soft: #3b2419;
    --figure: #ff8a5c;
    --pen: #f4f1ec;
    --board: #1a1917;
    --board-line: #2e2b27;
    --good: #4cc38a;
    --good-soft: #17301f;
    --gold: #ffc94a;
    --danger: #ff6b6b;
    --shadow: none;
    color-scheme: dark;
  }
}

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

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body { min-height: 100dvh; }
body.playing { overflow: hidden; height: 100dvh; overscroll-behavior: none; }

h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; }
svg.i { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }

#app {
  width: min(560px, 100%);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(10px + env(safe-area-inset-top)) 18px calc(18px + env(safe-area-inset-bottom));
}

body.playing #app { height: 100dvh; min-height: 0; overflow: hidden; }

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
}

.brand {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font-weight: 900;
  font-size: 24px;
  letter-spacing: -0.02em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.brand em { font-style: normal; color: var(--accent); }
.brand .logo { width: 30px; height: 30px; }

.top-right { display: flex; align-items: center; gap: 6px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px 6px 8px;
  border-radius: 999px;
  background: var(--surface);
  font-weight: 800;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.chip svg.i { width: 20px; height: 20px; }
.chip.flame svg.i { color: #ff8a2a; fill: #ffb347; stroke: #ff7a1a; }
.chip.flame.cold svg.i { color: var(--text-soft); fill: none; stroke: var(--text-soft); }

.icon-btn {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  color: var(--text);
}

.icon-btn:hover { background: var(--surface); }

/* ---------- buttons ---------- */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 54px;
  padding: 12px 22px;
  border-radius: 18px;
  border: 0;
  background: var(--surface);
  font-weight: 800;
  font-size: 17px;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease;
}

.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 0 rgba(0, 0, 0, 0.12); }
.btn.primary:active { box-shadow: 0 2px 0 rgba(0, 0, 0, 0.12); transform: translateY(3px); }
.btn.wide { width: 100%; }
.btn.danger { background: var(--danger); color: #fff; }
.row.danger { color: var(--danger); }
.btn.quiet { background: transparent; color: var(--text-soft); min-height: 44px; }

.link {
  background: none;
  border: 0;
  padding: 10px 0;
  color: var(--text-soft);
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- home ---------- */

.home { display: flex; flex-direction: column; gap: 18px; padding-bottom: 12px; }

.hello { font-size: 28px; font-weight: 900; letter-spacing: -0.02em; margin-top: 6px; }
.hello-sub { color: var(--text-soft); margin-top: 2px; font-weight: 600; }

.card {
  background: var(--surface);
  border-radius: 24px;
  padding: 16px;
}

.level-card { display: flex; align-items: center; gap: 14px; }
button.level-card, button.level-line { border: 0; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
button.level-line { background: none; padding: 0; }
.level-card .grow { flex: 1; min-width: 0; display: block; }
.level-name { display: block; font-weight: 900; font-size: 20px; }
.level-sub { display: block; color: var(--text-soft); font-size: 14px; font-weight: 700; margin-top: 2px; }

/* Eight segments, one per level, each in that level's colour. */
.ladder { display: flex; gap: 4px; margin: 8px 0 4px; width: 100%; }
.ladder span { flex: 1; height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; position: relative; }
.ladder span i { display: block; height: 100%; border-radius: 999px; background: var(--c); transition: width 0.8s cubic-bezier(0.2, 0.8, 0.2, 1); }
.ladder span.now { height: 14px; margin-top: -2px; box-shadow: 0 0 0 2px var(--c); }
.card .ladder span { background: var(--bg); }

.level-line .emblem { width: 40px; height: 40px; border-radius: 14px; }
.level-line .emblem svg.i { width: 22px; height: 22px; }
.levels .level-row { display: flex; align-items: center; gap: 14px; padding: 12px 16px; }
.levels .level-row + .level-row { border-top: 1px solid var(--line); }
.levels .level-row .grow { flex: 1; min-width: 0; }
.levels .level-row.ahead .emblem { filter: grayscale(1); opacity: 0.45; }
.levels .level-row.ahead .level-name { color: var(--text-soft); }
.levels .level-row.now { background: var(--accent-soft); }
.levels .emblem { width: 44px; height: 44px; border-radius: 14px; }
.levels .emblem svg.i { width: 24px; height: 24px; }
.you-tag { display: inline-block; font-size: 12px; font-weight: 900; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); vertical-align: middle; }
.tick { color: var(--good); }
.celebrate .list.levels { max-height: 56vh; overflow: auto; width: 100%; }

.emblem {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: #fff;
  flex: 0 0 auto;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.15);
}

.emblem svg.i { width: 28px; height: 28px; }
.emblem.big { width: 96px; height: 96px; border-radius: 30px; }
.emblem.big svg.i { width: 48px; height: 48px; }

.bar {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin-top: 8px;
}

.bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.dots { display: flex; gap: 6px; align-items: center; }
.dots i { width: 10px; height: 10px; border-radius: 99px; background: var(--surface-2); display: block; }
.dots i.on { background: var(--accent); }
.dots i.star { background: var(--gold); }
.dots i.now { background: var(--text); }

.play-hero { display: grid; place-items: center; padding: 6px 0 2px; }

.play-btn {
  position: relative;
  width: min(62vw, 230px);
  aspect-ratio: 1;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.12), var(--shadow);
  transition: transform 0.1s ease;
}

.play-btn:active { transform: translateY(4px); box-shadow: 0 5px 0 rgba(0, 0, 0, 0.12); }
.play-btn .ring { position: absolute; inset: -14px; width: calc(100% + 28px); height: calc(100% + 28px); pointer-events: none; }
.play-btn .ring circle { fill: none; stroke-width: 8; }
.play-btn .ring .track { stroke: var(--surface-2); }
.play-btn .ring .progress { stroke: var(--gold); stroke-linecap: round; transition: stroke-dashoffset 1s ease; }
.play-btn .label { font-size: 34px; font-weight: 900; letter-spacing: -0.01em; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.play-btn .label small { font-size: 14px; font-weight: 800; opacity: 0.9; }
.play-btn .label svg.i { width: 40px; height: 40px; fill: currentColor; stroke: none; }

.goal-note { text-align: center; color: var(--text-soft); font-weight: 700; margin-top: 12px; }

.section-title { font-size: 18px; font-weight: 900; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: baseline; }
.section-title button { font-size: 14px; }

.strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.strip::-webkit-scrollbar { display: none; }
.empty { color: var(--text-soft); font-weight: 600; font-size: 15px; }

.thumb {
  position: relative;
  flex: 0 0 auto;
  width: 96px;
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  text-align: left;
}

.thumb canvas {
  display: block;
  width: 96px;
  height: 96px;
  border-radius: 18px;
  background: var(--board);
  box-shadow: inset 0 0 0 1px var(--board-line);
}

.thumb .badge {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 28px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
  box-shadow: 0 0 0 1px var(--line);
}

.thumb .badge.win { background: var(--gold); color: #3a2a00; box-shadow: none; }
.thumb .cap { display: block; font-size: 12px; font-weight: 700; color: var(--text-soft); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  border: 0;
  border-radius: 22px;
  background: var(--surface);
  padding: 16px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 900;
  font-size: 17px;
}
.tile small { font-weight: 700; font-size: 13px; color: var(--text-soft); }
.tile .tile-icon { width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; background: var(--bg); }

.notice { background: var(--accent-soft); border-radius: 18px; padding: 12px 14px; font-weight: 700; }

/* ---------- splash (the front door) ---------- */

#view-splash { flex: 1; display: flex; flex-direction: column; }
.splash {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  padding: 24px 0 20px;
}
.splash-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; width: min(340px, 100%); }
.splash .logo { width: 88px; height: 88px; filter: drop-shadow(0 8px 0 rgba(0, 0, 0, 0.08)); }
.splash-title { font-size: 44px; font-weight: 900; letter-spacing: -0.03em; }
.splash-title span { color: var(--accent); }
.splash-line { font-size: 19px; font-weight: 700; color: var(--text-soft); max-width: 300px; }
.splash-actions { display: flex; flex-direction: column; gap: 12px; width: 100%; margin-top: 18px; }
.btn.outline { background: transparent; color: var(--text); box-shadow: inset 0 0 0 2px var(--text); }
.splash-date { display: flex; flex-direction: column; gap: 2px; color: var(--text-soft); font-weight: 600; font-size: 14px; }
.splash-date b { color: var(--text); font-weight: 800; }
.splash-who { margin-top: 6px; font-size: 13px; }
.fine-print { color: var(--text-soft); font-size: 12px; font-weight: 600; text-align: center; }
.splash-date .fine-print { margin-top: 8px; }

.home-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0 16px; }
.save-card { display: flex; align-items: center; gap: 10px; }
.save-card .grow { flex: 1; min-width: 0; }
.save-card small { display: block; color: var(--text-soft); font-weight: 600; font-size: 13px; }
.save-card .icon-btn { width: 36px; height: 36px; flex: 0 0 auto; color: var(--text-soft); }
.btn.small { min-height: 42px; padding: 8px 16px; border-radius: 14px; }
.btn:disabled { opacity: 0.6; cursor: default; }

/* ---------- account (email code) ---------- */

.account { display: flex; flex-direction: column; gap: 16px; max-width: 460px; }
.lead { font-weight: 700; font-size: 17px; }
.fine { color: var(--text-soft); font-weight: 600; font-size: 14px; }
.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 800; }
.field input {
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  min-height: 54px;
  padding: 12px 16px;
  border-radius: 16px;
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--text);
  width: 100%;
}
.field input:focus { outline: none; border-color: var(--accent); }
.field input.code-input { font-size: 26px; letter-spacing: 0.3em; text-align: center; }
.form-error { color: var(--danger); font-weight: 700; }
.form-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; }

/* ---------- pages (settings, sketchbook, how to play, credits, set summary) ---------- */

.page { display: flex; flex-direction: column; gap: 16px; padding-bottom: 20px; }
.page-head { display: flex; align-items: center; gap: 6px; min-height: 52px; }
.page-head h1 { font-size: 24px; font-weight: 900; }

.list { display: flex; flex-direction: column; background: var(--surface); border-radius: 22px; overflow: hidden; }
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
  padding: 10px 16px;
  border: 0;
  background: none;
  text-align: left;
  font-weight: 800;
  cursor: pointer;
  width: 100%;
}
.row + .row { border-top: 1px solid var(--line); }
.row small { display: block; color: var(--text-soft); font-weight: 600; font-size: 13px; }

.switch { width: 52px; height: 32px; border-radius: 999px; background: var(--surface-2); position: relative; flex: 0 0 auto; transition: background 0.2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.2s; }
[aria-checked="true"] .switch { background: var(--good); }
[aria-checked="true"] .switch::after { transform: translateX(20px); }

.seg { display: flex; gap: 4px; background: var(--surface-2); border-radius: 14px; padding: 4px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 10px; min-height: 40px; font-weight: 800; font-size: 14px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--bg); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.setting { padding: 12px 16px; }
.setting + .setting { border-top: 1px solid var(--line); }
.setting-label { font-weight: 800; margin-bottom: 8px; }

.grid-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 12px; }
.grid-thumbs.five { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.grid-thumbs.five .thumb .badge { top: 4px; right: 4px; min-width: 24px; padding: 1px 5px; font-size: 11px; }
.grid-thumbs .thumb, .grid-thumbs .thumb canvas { width: 100%; height: auto; }
.grid-thumbs .thumb canvas { aspect-ratio: 1; }

.steps { display: flex; flex-direction: column; gap: 12px; }
.step { display: flex; gap: 14px; align-items: center; }
.step .num { width: 52px; height: 52px; border-radius: 18px; display: grid; place-items: center; color: #fff; flex: 0 0 auto; }
.step h3 { font-size: 18px; font-weight: 900; }
.step p { color: var(--text-soft); font-weight: 600; }

.faq details { background: var(--surface); border-radius: 18px; padding: 4px 16px; }
.faq details + details { margin-top: 10px; }
.faq summary { min-height: 52px; display: flex; align-items: center; font-weight: 800; cursor: pointer; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; margin-left: auto; font-size: 22px; color: var(--text-soft); }
.faq details[open] summary::after { content: "–"; }
.faq p { color: var(--text-soft); font-weight: 600; padding-bottom: 14px; line-height: 1.5; }

.credits { color: var(--text-soft); font-size: 14px; line-height: 1.55; font-weight: 600; }
.credits li { margin: 4px 0; }

.summary-hero { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 8px; }
.summary-hero h1 { font-size: 32px; font-weight: 900; }
.stars { display: flex; gap: 4px; justify-content: center; }
.stars svg.i { width: 40px; height: 40px; stroke: none; fill: var(--surface-2); }
.stars svg.i.on { fill: var(--gold); animation: pop 0.4s both; }
.stars svg.i.on:nth-child(2) { animation-delay: 0.1s; }
.stars svg.i.on:nth-child(3) { animation-delay: 0.2s; }
.stars svg.i.on:nth-child(4) { animation-delay: 0.3s; }
.stars svg.i.on:nth-child(5) { animation-delay: 0.4s; }

.bonus { display: flex; gap: 14px; align-items: center; background: var(--accent-soft); }
.bonus .grow { flex: 1; }
.bonus h3 { font-weight: 900; }
.bonus p { font-size: 14px; font-weight: 600; color: var(--text-soft); }

/* ---------- play ---------- */

#view-play { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.play-top { display: flex; align-items: center; justify-content: space-between; min-height: 52px; gap: 8px; }
.play-top .dots { flex: 1; justify-content: center; }
.mode-tag { font-weight: 800; color: var(--text-soft); font-size: 15px; flex: 1; text-align: center; }

.prompt {
  text-align: center;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.02em;
  min-height: 38px;
  margin-top: 2px;
}
.prompt small { display: block; font-size: 15px; font-weight: 700; color: var(--text-soft); letter-spacing: 0; }
.prompt.pop { animation: pop 0.35s both; }

.timebar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 10px 0 4px; }
.timebar > span { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: left; border-radius: 999px; }
.timebar.draw > span { background: var(--text); }
.timebar.urgent > span { background: var(--danger); animation: blink 0.5s infinite alternate; }
.timebar.off { visibility: hidden; }

.board-wrap { flex: 1 1 auto; min-height: 0; display: grid; place-items: center; position: relative; margin: 8px 0; }

canvas#board {
  background: var(--board);
  border-radius: 28px;
  box-shadow: inset 0 0 0 2px var(--board-line), var(--shadow);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#pauseVeil {
  position: absolute;
  inset: 0;
  margin: auto;
  border: 0;
  border-radius: 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  color: var(--text);
  font-weight: 900;
  font-size: 28px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
#pauseVeil span { display: block; margin-top: 6px; font-size: 16px; font-weight: 700; color: var(--text-soft); }

.play-bottom { flex: 0 0 auto; max-height: 52dvh; overflow: auto; }

.toolbar { display: flex; gap: 10px; align-items: center; }
.toolbar .icon-btn { width: 54px; height: 54px; border-radius: 18px; background: var(--surface); }
.toolbar .btn { flex: 1; }

.result { display: flex; flex-direction: column; gap: 10px; padding-bottom: 12px; }
.verdict-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.verdict { font-size: 32px; font-weight: 900; letter-spacing: -0.02em; animation: pop 0.4s both; }
.score { font-size: 44px; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1; }
.score small { font-size: 16px; color: var(--text-soft); font-weight: 800; }

.goalbar { position: relative; height: 16px; border-radius: 999px; background: var(--surface-2); margin: 20px 0 4px; }
.goalbar > span { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 999px; background: var(--text-soft); transition: width 0.9s cubic-bezier(0.2, 0.8, 0.2, 1); }
.goalbar.beat > span { background: var(--good); }
.goalbar .goal { position: absolute; top: -6px; bottom: -6px; width: 4px; margin-left: -2px; border-radius: 4px; background: var(--text); }
.goalbar .goal em { position: absolute; bottom: calc(100% + 2px); left: 50%; transform: translateX(-50%); font-style: normal; font-size: 12px; font-weight: 900; white-space: nowrap; color: var(--text-soft); }
.goal-line { font-weight: 800; }
.goal-line.beat { color: var(--good); }

.tip { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); border-radius: 16px; padding: 12px 14px; font-weight: 700; }
.tip svg.i { color: var(--accent); }

.level-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 800; }
.level-line .grow { flex: 1; min-width: 0; }
.level-line small { color: var(--text-soft); font-weight: 700; display: block; }
.delta { font-weight: 900; padding: 4px 10px; border-radius: 999px; background: var(--surface); color: var(--text-soft); font-variant-numeric: tabular-nums; }
.delta.up { background: var(--good-soft); color: var(--good); }

.why summary { min-height: 44px; display: flex; align-items: center; font-weight: 800; color: var(--text-soft); cursor: pointer; }
.meter { display: grid; grid-template-columns: 1fr 120px; gap: 10px; align-items: center; margin-top: 8px; font-weight: 700; font-size: 14px; }
.meter .bar { margin-top: 0; }
.why-note { color: var(--text-soft); font-weight: 600; font-size: 14px; margin-top: 10px; line-height: 1.5; }

.result-actions { display: flex; gap: 10px; }
.result-actions .btn.primary { flex: 1; }
.result-actions .icon-btn { width: 54px; height: 54px; border-radius: 18px; background: var(--surface); }

/* ---------- overlays, confetti, toast ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fade 0.25s both;
}

.celebrate {
  width: min(380px, 100%);
  background: var(--bg);
  border-radius: 32px;
  padding: 28px 22px 22px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
  animation: pop 0.45s both;
}
.celebrate h2 { font-size: 30px; font-weight: 900; letter-spacing: -0.02em; }
.celebrate p { color: var(--text-soft); font-weight: 700; }
.celebrate .btn { margin-top: 8px; width: 100%; }

.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 30; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 12px 18px;
  border-radius: 999px;
  font-weight: 800;
  z-index: 40;
  animation: rise 0.25s both;
}

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.checks { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.checks li { padding: 6px 0; border-top: 1px solid var(--line); }
.checks li.ok { color: var(--good); }
.checks li.bad { color: var(--danger); }

button:focus-visible, summary:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

@keyframes pop { 0% { transform: scale(0.6); opacity: 0; } 70% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { transform: translate(-50%, 12px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
@keyframes blink { from { opacity: 1; } to { opacity: 0.45; } }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; animation-iteration-count: 1 !important; transition-duration: 0.001s !important; }
}

/* ---------- tablets and desktop: board beside the panel ---------- */

@media (min-width: 860px) and (min-height: 560px) {
  body.playing #app { width: min(1180px, 100%); }
  #view-play {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
    grid-template-rows: auto auto auto 1fr;
    grid-template-areas: "top top" "board prompt" "board time" "board bottom";
    column-gap: 32px;
  }
  .play-top { grid-area: top; }
  .prompt { grid-area: prompt; text-align: left; font-size: 34px; align-self: end; }
  .timebar { grid-area: time; }
  .board-wrap { grid-area: board; margin: 0 0 8px; }
  .play-bottom { grid-area: bottom; max-height: none; overflow: auto; align-self: start; padding-top: 8px; }
  .home { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); column-gap: 32px; align-items: start; }
  #app { width: min(960px, 100%); }
  .home > .span-2 { grid-column: 1 / -1; }
}
