/* v17 Report Card: tokens, surfaces (chalkboard, lined paper), buttons, the stage window. */
:root {
  --board: #21372b;
  --board-2: #2a4536;
  --board-3: #18291f;
  --chalk: #f4f1e6;
  --chalk-dim: rgba(244, 241, 230, .66);
  --chalk-faint: rgba(244, 241, 230, .18);
  --chalk-yellow: #f2dc7d;
  --chalk-pink: #f4aaa4;
  --paper: #fbf8ef;
  --paper-2: #f3eedf;
  --rule: #b9cfe9;
  --margin: #eaa29c;
  --ink: #1c3478;
  --pencil: #3e3c38;
  --pencil-2: #77736a;
  --red: #d3241c;
  --red-2: #a8150f;
  --green-ink: #1f7a3d;
  --wood: #8b5b34;
  --wood-2: #6d4424;

  --f-chalk: 'Chalkduster', 'Chalkboard SE', 'Chalkboard', 'Comic Sans MS', cursive;
  --f-chalk2: 'Chalkboard SE', 'Chalkboard', 'Comic Sans MS', cursive;
  --f-hand: 'Bradley Hand', 'Noteworthy', 'Segoe Print', 'Comic Sans MS', cursive;
  --f-ink: 'Noteworthy', 'Marker Felt', 'Segoe Print', 'Comic Sans MS', cursive;
  --f-ui: 'Avenir Next', 'Avenir', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-form: 'Baskerville', 'Georgia', ui-serif, serif;

  --sa-t: env(safe-area-inset-top, 0px);
  --sa-b: env(safe-area-inset-bottom, 0px);
  --sa-l: env(safe-area-inset-left, 0px);
  --sa-r: env(safe-area-inset-right, 0px);
  --pad: 16px;
  --rough: 255px 14px 225px 14px / 14px 225px 14px 255px;
  --ease: cubic-bezier(.2, .9, .2, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background: var(--board);
  color: var(--chalk);
  font: 500 16px/1.4 var(--f-ui);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- the page layer (below the stage) ---------- */
.screen { position: relative; z-index: 1; min-height: 100%; overflow-x: clip; }
body[data-phase="play"] .screen { display: none; }

/* chalkboard surface: slate green, chalk dust, smudges */
.board {
  position: relative;
  min-height: 100vh; min-height: 100dvh;
  background:
    radial-gradient(60% 40% at 22% 18%, rgba(255, 255, 255, .07), transparent 70%),
    radial-gradient(50% 35% at 78% 62%, rgba(255, 255, 255, .05), transparent 70%),
    radial-gradient(120% 90% at 50% 50%, var(--board-2), var(--board) 60%, var(--board-3));
  overflow: hidden;
}
.board::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .42; mix-blend-mode: screen;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.board::after { /* old wiped-off chalk strokes */
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(172deg, transparent 46%, rgba(255, 255, 255, .035) 47%, rgba(255, 255, 255, .035) 52%, transparent 53%),
    linear-gradient(-8deg, transparent 70%, rgba(255, 255, 255, .03) 71%, rgba(255, 255, 255, .03) 77%, transparent 78%);
}

/* lined paper surface */
.paper {
  position: relative;
  background-color: var(--paper);
  color: var(--pencil);
  background-image:
    linear-gradient(90deg, transparent 38px, var(--margin) 38px, var(--margin) 40px, transparent 40px),
    repeating-linear-gradient(180deg, transparent 0 31px, var(--rule) 31px 32px);
  background-position: 0 0, 0 var(--rule-y, 20px);
}

/* ---------- type helpers ---------- */
.chalk { font-family: var(--f-chalk); font-weight: 400; color: var(--chalk); letter-spacing: .01em; }
.chalk2 { font-family: var(--f-chalk2); }
.hand { font-family: var(--f-hand); font-weight: 700; }
.inkf { font-family: var(--f-ink); }
.redpen { color: var(--red); font-family: var(--f-hand); font-weight: 700; }

/* chalk writing that appears left to right */
.write { display: inline-block; clip-path: inset(0 100% 0 0); animation: v17-write var(--d-write, .7s) steps(18, end) var(--d, 0s) forwards; }
@keyframes v17-write { to { clip-path: inset(0 -2% 0 0); } }
.rise { opacity: 0; transform: translateY(10px); animation: v17-rise .4s var(--ease) var(--d, 0s) forwards; }
@keyframes v17-rise { to { opacity: 1; transform: none; } }
.fade { opacity: 0; animation: v17-fade .45s ease var(--d, 0s) forwards; }
@keyframes v17-fade { to { opacity: 1; } }
.pop { animation: v17-pop .42s var(--ease) both; }
@keyframes v17-pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.06); opacity: 1; } 100% { transform: scale(1); } }

/* ---------- the one forward button ---------- */
.cta {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 60px; min-width: 220px; padding: 14px 28px;
  border: 0; border-radius: var(--rough);
  background: var(--red); color: #fff;
  font: 800 20px/1.1 var(--f-ui); letter-spacing: .01em;
  box-shadow: 0 5px 0 var(--red-2), 0 12px 24px rgba(0, 0, 0, .28);
  cursor: pointer; touch-action: manipulation;
  transition: transform .12s ease, box-shadow .12s ease, opacity .25s ease, filter .25s;
}
.cta .arr { font-size: 22px; transition: transform .2s ease; }
.cta:hover .arr { transform: translateX(4px); }
.cta:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--red-2), 0 6px 14px rgba(0, 0, 0, .25); }
.cta:disabled { cursor: default; filter: saturate(.55); opacity: .78; }
.cta.is-loading:disabled { filter: saturate(.25) brightness(.9); opacity: .7; }
.cta:focus-visible { outline: 3px solid var(--chalk-yellow); outline-offset: 4px; }
.cta.is-loading::after {
  content: ''; width: 18px; height: 18px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .35); border-top-color: #fff; animation: v17-spin .8s linear infinite;
}
.cta.nudge { animation: v17-nudge 1.4s ease-in-out infinite; }
@keyframes v17-nudge { 0%, 100% { transform: none; } 50% { transform: translateY(-3px) scale(1.03); } }
@keyframes v17-spin { to { transform: rotate(360deg); } }
.cta-sub { display: block; margin-top: 10px; font: 600 13px/1.3 var(--f-ui); opacity: .72; text-align: center; }

/* ---------- sound toggle ---------- */
.sound {
  position: fixed; z-index: 9; top: calc(10px + var(--sa-t)); right: calc(10px + var(--sa-r));
  min-width: 48px; height: 48px; padding: 0 12px; border-radius: 24px;
  border: 2px solid var(--chalk-faint); background: rgba(16, 28, 21, .72); color: var(--chalk);
  font: 700 13px/1 var(--f-ui); cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.sound svg { width: 20px; height: 20px; }
.sound.off { opacity: .7; }
body[data-phase="results"] .sound, body[data-phase="gate"] .sound, body[data-phase="play"] .sound, body[data-phase="reveal"] .sound { display: none; }

/* ---------- the stage: always full screen, shown through a "window" (clip-path) ---------- */
.stage {
  position: fixed; inset: 0; z-index: 2;
  pointer-events: none;
  clip-path: inset(50% 50% 50% 50%);
  transition: clip-path .6s var(--ease);
}
.stage.no-anim { transition: none; }
.stage.is-off { visibility: hidden; }
.stage.is-off > .pt-canvas { visibility: hidden; }
/* freeze frame: the engine skips drawing (stage hidden) but the last frame stays on the canvas */
.stage.is-frozen { visibility: hidden; }
.stage.is-frozen > .pt-canvas { visibility: visible; }
/* the real clip shows while the 3D is not drawn */
.stage.is-reveal { visibility: hidden; clip-path: none !important; }
.stage.is-reveal > .pt-clip { visibility: visible; }
body[data-phase="results"] .stage, body[data-phase="gate"] .stage { display: none; }

/* error box */
.oops { max-width: 420px; margin: 0 auto; padding: 22vh var(--pad) 0; text-align: center; }
.oops h2 { font: 400 34px/1.2 var(--f-chalk); margin: 0 0 12px; }
.oops p { color: var(--chalk-dim); margin: 0 0 24px; }

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