/* play.css: the "lesson as a video game" player for class.xhelio.ai (see play.js for the authoring guide).
   Layout: a fixed 1600x900 stage scaled to fit the window like a video, a control bar under it,
   a notes drawer on the right. Look: warm paper and clay, a serif display face, a pixel face for the HUD. */
:root {
  --paper: #faf9f5;      /* stage ground */
  --paper-2: #f0eee6;    /* cards, wells */
  --rule: #e3dfd2;       /* hairlines */
  --ink: #1f1e1b;        /* text */
  --ink-2: #5e5d58;      /* secondary text */
  --clay: #c96442;       /* accent, the agent */
  --clay-soft: #f3ddd2;
  --olive: #6b7f4f;
  --olive-soft: #e3e8d6;
  --sky: #4f7fae;
  --sky-soft: #dce7f1;
  --kraft: #b5835a;
  --kraft-soft: #f0e2d2;
  --plum: #8a5a83;
  --plum-soft: #eddfea;
  --good: #3f7d4e;
  --bad: #b3412f;
  --shell: #e9e6dc;      /* page around the stage */
  --bar: #1f1e1b;        /* control bar */
  --bar-ink: #f4f2ea;
  --f-display: "Newsreader", "Iowan Old Style", Georgia, serif;
  --f-body: "Hanken Grotesk", "Helvetica Neue", Arial, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --f-pixel: "Silkscreen", "JetBrains Mono", ui-monospace, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #262624; --paper-2: #30302d; --rule: #45443f; --ink: #f2f0e8; --ink-2: #b2afa5;
    --clay: #e0825f; --clay-soft: #4a3229; --olive: #9fb27f; --olive-soft: #343a2b;
    --sky: #86afd8; --sky-soft: #283545; --kraft: #d6a77e; --kraft-soft: #43372b;
    --plum: #c393bb; --plum-soft: #3d2f3b; --good: #7fbf8c; --bad: #ec8a76;
    --shell: #191917; --bar: #0f0f0e; --bar-ink: #f2f0e8; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #262624; --paper-2: #30302d; --rule: #45443f; --ink: #f2f0e8; --ink-2: #b2afa5;
  --clay: #e0825f; --clay-soft: #4a3229; --olive: #9fb27f; --olive-soft: #343a2b;
  --sky: #86afd8; --sky-soft: #283545; --kraft: #d6a77e; --kraft-soft: #43372b;
  --plum: #c393bb; --plum-soft: #3d2f3b; --good: #7fbf8c; --bad: #ec8a76;
  --shell: #191917; --bar: #0f0f0e; --bar-ink: #f2f0e8; color-scheme: dark;
}

html, body { height: 100%; }
body {
  margin: 0; background: var(--shell); color: var(--ink); font-family: var(--f-body);
  overflow: hidden; display: flex; flex-direction: column;
}
body.idle, body.idle * { cursor: none !important; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--clay); outline-offset: 2px; }

/* ---------- viewport and stage ---------- */
#pv { flex: 1; min-height: 0; position: relative; overflow: hidden; }
#stage {
  position: absolute; left: 0; top: 0; width: 1600px; height: 900px; transform-origin: 0 0;
  background: var(--paper); overflow: hidden; border-radius: 14px;
  box-shadow: 0 1px 0 var(--rule), 0 18px 50px -24px rgba(0,0,0,.35);
  background-image: radial-gradient(var(--rule) 1.2px, transparent 1.3px);
  background-size: 32px 32px; background-position: 16px 16px;
}
#stage, #stage * { box-sizing: border-box; }
#scene { position: absolute; inset: 0; }
#scene.instant *, #scene.instant { transition: none !important; }
body.paused #stage *, body.waiting #stage .spark:not(.live) { animation-play-state: paused !important; }

/* HUD, scaled with the stage */
#hud {
  position: absolute; left: 0; right: 0; top: 0; height: 64px; display: flex; align-items: center;
  gap: 18px; padding: 0 32px; font-family: var(--f-pixel); font-size: 15px; letter-spacing: .06em;
  color: var(--ink-2); z-index: 5; pointer-events: none;
}
#hud .wk { background: var(--ink); color: var(--paper); padding: 6px 10px 5px; border-radius: 6px; }
#stage.oncard #hud, #stage.oncard #hud .chap, #stage.oncard #hud b { color: var(--paper); }
#stage.oncard #hud .wk { background: var(--paper); color: var(--ink); }
#hud .chap { display: flex; align-items: center; gap: 10px; color: var(--ink); }
#hud .chap i { width: 14px; height: 14px; border-radius: 4px; background: var(--chc, var(--clay)); }
#hud .sp { flex: 1; }
#hud .score b { color: var(--ink); font-weight: 400; }
#hud .coins { display: flex; align-items: center; gap: 8px; }
#hud .coins i { width: 14px; height: 14px; border-radius: 50%; background: var(--kraft); box-shadow: inset 0 0 0 3px var(--kraft-soft); }
#hud .bump { animation: bump .5s ease; }
@keyframes bump { 40% { transform: scale(1.35); color: var(--clay); } }

/* captions */
#cap {
  position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%); width: 1240px; z-index: 6;
  display: flex; gap: 18px; align-items: flex-start; padding: 16px 24px; border-radius: 14px;
  background: color-mix(in srgb, var(--ink) 90%, transparent); color: var(--paper);
  font-size: 27px; line-height: 1.35; transition: opacity .3s; min-height: 40px;
}
#cap .who { font-family: var(--f-pixel); font-size: 14px; color: var(--clay); padding-top: 8px; white-space: nowrap; letter-spacing: .08em; }
#cap.empty, body.nocap #cap { opacity: 0; }
#cap .txt { text-wrap: pretty; }
#cap .txt b { color: color-mix(in srgb, var(--clay) 60%, var(--paper)); font-weight: 600; }

/* paused / waiting badges */
#badge {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 7; display: none;
  font-family: var(--f-pixel); font-size: 18px; letter-spacing: .1em; padding: 9px 16px 8px; border-radius: 8px;
  background: var(--ink); color: var(--paper); pointer-events: none;
}
body.paused.started #badge { display: block; }
body.waiting #badge { display: block; background: var(--clay); color: var(--paper); animation: blink 1.2s steps(2) infinite; }
@keyframes blink { 50% { opacity: .55; } }
.ping {
  position: absolute; width: 90px; height: 90px; margin: -45px 0 0 -45px; border-radius: 50%; z-index: 8;
  border: 5px solid var(--clay); pointer-events: none; animation: ping 1.4s ease-out infinite;
}
@keyframes ping { 0% { transform: scale(.4); opacity: 1; } 100% { transform: scale(1.25); opacity: .25; } }

/* title overlay */
#title {
  position: absolute; inset: 0; z-index: 20; background: var(--paper); display: flex; flex-direction: column;
  justify-content: center; padding: 0 140px; gap: 22px;
}
body.started #title { display: none; }
#title .k { font-family: var(--f-pixel); font-size: 22px; letter-spacing: .12em; color: var(--clay); }
#title h1 { font-family: var(--f-display); font-weight: 500; font-size: 150px; line-height: .95; margin: 0; letter-spacing: -.02em; }
#title p { font-size: 32px; color: var(--ink-2); max-width: 1100px; margin: 0; line-height: 1.35; }
#title .press {
  margin-top: 30px; font-family: var(--f-pixel); font-size: 26px; letter-spacing: .1em; color: var(--ink);
  display: flex; align-items: center; gap: 22px;
}
#title .press button {
  font-family: var(--f-pixel); font-size: 26px; letter-spacing: .1em; background: var(--clay); color: var(--paper);
  border: 0; border-radius: 10px; padding: 16px 26px 14px; cursor: pointer; box-shadow: 0 6px 0 color-mix(in srgb, var(--clay) 55%, #000);
  animation: blink 1.4s steps(2) infinite;
}
#title .press button.alt { background: var(--paper); color: var(--ink); border: 3px solid var(--ink); box-shadow: 0 6px 0 var(--ink); animation: none; }
#title .modes { display: flex; flex-direction: column; gap: 4px; font-size: 21px; color: var(--ink-2); }
#title .modes b { color: var(--ink); }
body.watch #title #watchbtn { animation: blink 1.4s steps(2) infinite; }
body.watch #title #startbtn { animation: none; }
#title .press button:active { transform: translateY(4px); box-shadow: 0 2px 0 color-mix(in srgb, var(--clay) 55%, #000); }
#title .keys { font-family: var(--f-mono); font-size: 20px; color: var(--ink-2); display: flex; gap: 28px; flex-wrap: wrap; }
#title .keys kbd { font-family: var(--f-pixel); font-size: 15px; border: 2px solid var(--rule); border-bottom-width: 4px; border-radius: 6px; padding: 3px 8px; margin-right: 6px; color: var(--ink); }
#title .hero-spark { position: absolute; right: 150px; top: 170px; width: 260px; color: var(--clay); }

/* level-select overlay */
#levels {
  position: absolute; inset: 0; z-index: 30; background: color-mix(in srgb, var(--paper) 96%, transparent);
  padding: 90px 80px 60px; display: none; overflow: auto;
}
body.levels #levels { display: block; }
#script {
  position: absolute; inset: 0; z-index: 30; background: color-mix(in srgb, var(--paper) 97%, transparent);
  padding: 90px 160px 60px; display: none; overflow: auto;
}
body.script #script { display: block; }
#script h2 { font-family: var(--f-pixel); font-weight: 400; font-size: 22px; letter-spacing: .12em; margin: 0 0 20px; color: var(--clay); }
#script h3 { font-family: var(--f-display); font-weight: 500; font-size: 40px; margin: 34px 0 6px; display: flex; gap: 14px; align-items: baseline; }
#script h3 small { font-family: var(--f-pixel); font-size: 14px; letter-spacing: .1em; color: var(--chc); }
#script h4 { font-size: 24px; margin: 18px 0 4px; }
#script button {
  display: flex; gap: 16px; width: 100%; text-align: left; background: none; border: 0; padding: 6px 10px;
  font-size: 23px; line-height: 1.45; color: var(--ink-2); cursor: pointer; border-radius: 8px;
}
#script button:hover { background: var(--paper-2); color: var(--ink); }
#script button span { flex: none; width: 64px; font-family: var(--f-mono); font-size: 15px; padding-top: 6px; color: var(--ink-2); }
#script button b { color: var(--ink); }
#levels h2 { font-family: var(--f-pixel); font-weight: 400; font-size: 22px; letter-spacing: .12em; margin: 0 0 26px; color: var(--clay); }
#levels .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 26px; }
#levels .ch h3 { font-family: var(--f-display); font-weight: 500; font-size: 34px; margin: 0 0 10px; display: flex; gap: 12px; align-items: baseline; }
#levels .ch h3 small { font-family: var(--f-pixel); font-size: 13px; color: var(--chc); letter-spacing: .1em; }
#levels .ch button {
  display: block; width: 100%; text-align: left; background: none; border: 0; border-left: 4px solid var(--chc);
  padding: 7px 12px; font-size: 21px; cursor: pointer; color: var(--ink);
}
#levels .ch button:hover, #levels .ch button.cur { background: var(--paper-2); }
#levels .ch button span { font-family: var(--f-mono); font-size: 15px; color: var(--ink-2); margin-right: 10px; }

/* ---------- control bar ---------- */
#bar {
  flex: none; background: var(--bar); color: var(--bar-ink); display: flex; align-items: center; gap: 6px;
  padding-block: 8px calc(8px + env(safe-area-inset-bottom, 0px));
  padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px));
  transition: opacity .3s; font-family: var(--f-mono); font-size: 13px; overflow: hidden;
}
body.idle #bar { opacity: 0; }
#bar button {
  background: none; border: 0; color: var(--bar-ink); height: 36px; min-width: 36px; border-radius: 8px;
  cursor: pointer; display: grid; place-items: center; padding: 0 8px; font-size: 13px;
}
#bar button:hover { background: rgba(255,255,255,.1); }
#bar button.on { color: #e0825f; }
#bar svg { width: 18px; height: 18px; fill: currentColor; }
#tl { flex: 1; min-width: 40px; position: relative; height: 36px; cursor: pointer; touch-action: none; }
#tl .segs { position: absolute; left: 0; right: 0; top: 14px; height: 8px; display: flex; gap: 3px; }
#tl .seg { height: 100%; border-radius: 4px; background: rgba(255,255,255,.16); position: relative; overflow: hidden; }
#tl .seg b { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--chc); }
#tl .tick { position: absolute; top: 12px; width: 2px; height: 12px; background: rgba(0,0,0,.5); pointer-events: none; }
#tl .gate { position: absolute; top: 4px; width: 8px; height: 8px; margin-left: -4px; background: #e0825f; transform: rotate(45deg); pointer-events: none; }
#tl .head { position: absolute; top: 9px; width: 18px; height: 18px; margin-left: -9px; border-radius: 50%; background: #fff; pointer-events: none; box-shadow: 0 0 0 4px rgba(224,130,95,.45); }
#tl .tip {
  position: absolute; bottom: 40px; transform: translateX(-50%); background: #fff; color: #1f1e1b; white-space: nowrap;
  padding: 5px 9px; border-radius: 6px; font-size: 13px; display: none; pointer-events: none;
}
#tl:hover .tip { display: block; }
#time { white-space: nowrap; font-variant-numeric: tabular-nums; padding: 0 6px; opacity: .85; }
@media (max-width: 700px) { #bar .opt-wide { display: none; } #bar { gap: 2px; } #bar button { padding: 0 4px; min-width: 30px; } }
@media (max-width: 520px) { #time { display: none; } }

/* notes drawer */
#notes {
  position: fixed; right: 0; top: 0; bottom: 0; width: min(420px, 90vw); z-index: 40; background: var(--paper);
  border-left: 1px solid var(--rule); box-shadow: -20px 0 50px -30px rgba(0,0,0,.4); padding: 24px 26px;
  overflow: auto; transform: translateX(105%); transition: transform .25s; font-size: 17px; line-height: 1.5;
}
body.notes #notes { transform: none; }
#notes .k { font-family: var(--f-pixel); font-size: 13px; letter-spacing: .1em; color: var(--clay); }
#notes h3 { font-family: var(--f-display); font-weight: 500; font-size: 28px; margin: 6px 0 14px; text-wrap: balance; }
#notes .caps { margin-top: 18px; border-top: 1px solid var(--rule); padding-top: 12px; font-size: 15px; color: var(--ink-2); }
#notes .caps p { margin: 0 0 8px; }
#notes .caps span { font-family: var(--f-mono); font-size: 12px; margin-right: 8px; }

/* ================= authoring kit (inside the stage) ================= */
.a { position: absolute; }
[data-at] { opacity: 0; transform: translateY(16px); transition: opacity .5s ease, transform .5s cubic-bezier(.2,.8,.2,1); }
[data-at].in { opacity: 1; transform: none; }
[data-fx="pop"] { transform: scale(.6); }
[data-fx="left"] { transform: translateX(-60px); }
[data-fx="right"] { transform: translateX(60px); }
[data-fx="drop"] { transform: translateY(-80px); }
[data-fx="fade"] { transform: none; }
[data-fx="pop"].in { transition: opacity .35s, transform .45s cubic-bezier(.3,1.6,.5,1); }
.gone { opacity: 0 !important; transform: scale(.92) !important; }
[data-fly] { transition: none !important; }
.dim { opacity: .28 !important; transition: opacity .4s; }
.strike { text-decoration: line-through; text-decoration-thickness: 3px; text-decoration-color: var(--bad); }

.kick { font-family: var(--f-pixel); font-size: 18px; letter-spacing: .12em; color: var(--chc, var(--clay)); text-transform: uppercase; }
.h1 { font-family: var(--f-display); font-weight: 500; font-size: 64px; line-height: 1.05; letter-spacing: -.01em; margin: 0; text-wrap: balance; }
.h2 { font-family: var(--f-display); font-weight: 500; font-size: 40px; line-height: 1.1; margin: 0; text-wrap: balance; }
.h3 { font-family: var(--f-body); font-weight: 700; font-size: 28px; line-height: 1.2; margin: 0; }
.p { font-size: 26px; line-height: 1.4; color: var(--ink-2); margin: 0; text-wrap: pretty; }
.p b, .h3 b { color: var(--ink); }
.big { font-family: var(--f-display); font-weight: 500; font-size: 120px; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--f-mono); }
.pix { font-family: var(--f-pixel); letter-spacing: .08em; }
.ttl { position: absolute; left: 80px; top: 92px; right: 80px; display: flex; flex-direction: column; gap: 10px; }

.card { background: var(--paper-2); border: 2px solid var(--rule); border-radius: 16px; padding: 22px 26px; }
.card.lift { background: var(--paper); box-shadow: 0 10px 0 -2px var(--rule); }
.card.clay { border-color: var(--clay); background: var(--clay-soft); }
.card.olive { border-color: var(--olive); background: var(--olive-soft); }
.card.sky { border-color: var(--sky); background: var(--sky-soft); }
.card.kraft { border-color: var(--kraft); background: var(--kraft-soft); }
.card.plum { border-color: var(--plum); background: var(--plum-soft); }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; font-size: 21px;
  background: var(--paper); border: 2px solid var(--rule); white-space: nowrap;
}
.chip.clay { border-color: var(--clay); color: var(--clay); }
.chip.olive { border-color: var(--olive); color: var(--olive); }
.chip.sky { border-color: var(--sky); color: var(--sky); }
.chip.kraft { border-color: var(--kraft); color: var(--kraft); }
.chip.plum { border-color: var(--plum); color: var(--plum); }
.chip.ink { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.c-clay { color: var(--clay); } .c-olive { color: var(--olive); } .c-sky { color: var(--sky); }
.c-kraft { color: var(--kraft); } .c-plum { color: var(--plum); } .c-good { color: var(--good); } .c-bad { color: var(--bad); }
.c-ink2 { color: var(--ink-2); }

.code {
  font-family: var(--f-mono); font-size: 21px; line-height: 1.5; background: var(--ink); color: #ece9df;
  border-radius: 14px; padding: 20px 24px; white-space: pre; overflow: hidden;
}
.code .t { display: block; font-family: var(--f-pixel); font-size: 13px; color: #a8a598; letter-spacing: .08em; margin-bottom: 8px; }
.code .k { color: #e0825f; } .code .s { color: #b9cc8f; } .code .c { color: #8f8c80; } .code .n { color: #9cc3e8; }
.code .hl { background: rgba(224,130,95,.25); border-radius: 4px; box-shadow: 0 0 0 3px rgba(224,130,95,.25); }

.tbl { border-collapse: collapse; font-size: 22px; }
.tbl th { font-family: var(--f-pixel); font-weight: 400; font-size: 14px; letter-spacing: .08em; text-align: left; color: var(--ink-2); padding: 8px 16px; border-bottom: 2px solid var(--ink); }
.tbl td { padding: 12px 16px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.tbl tr.hi td { background: var(--clay-soft); }

/* bar meters: <div class="meter"><b data-grow="t0 t1 pct"></b></div> */
.meter { height: 26px; border-radius: 8px; background: var(--paper-2); border: 2px solid var(--rule); overflow: hidden; position: relative; }
.meter b { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--clay); }
.meter.olive b { background: var(--olive); } .meter.sky b { background: var(--sky); } .meter.kraft b { background: var(--kraft); } .meter.plum b { background: var(--plum); }

/* the agent sprite: <i class="spark"></i>; size with width, colour with color */
.spark { display: block; width: 90px; color: var(--clay); font-style: normal; }
.spark > svg { animation: bob 2.4s ease-in-out infinite; }
.spark svg { display: block; width: 100%; height: auto; overflow: visible; }
.spark .rays { transform-origin: 50% 50%; }
.spark.work .rays { animation: spin 3s linear infinite; }
.spark .eyes { animation: blinkeye 4s infinite; transform-origin: 50% 46%; }
.spark.still > svg { animation: none; }
@keyframes bob { 50% { transform: translateY(-8px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blinkeye { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
.lbl-under { position: absolute; left: 50%; transform: translateX(-50%); top: 100%; margin-top: 6px; font-family: var(--f-pixel); font-size: 14px; white-space: nowrap; color: var(--ink-2); letter-spacing: .06em; }

/* tokens / packets */
.pkt { padding: 6px 12px; border-radius: 8px; background: var(--ink); color: var(--paper); font-family: var(--f-mono); font-size: 17px; white-space: nowrap; box-shadow: 0 4px 0 -1px var(--clay); }
.pkt.clay { background: var(--clay); color: var(--paper); box-shadow: none; }
.pkt.olive { background: var(--olive); color: var(--paper); box-shadow: none; }
.pkt.sky { background: var(--sky); color: var(--paper); box-shadow: none; }
.pkt.kraft { background: var(--kraft); color: var(--paper); box-shadow: none; }
.pkt.bad { background: var(--bad); color: var(--paper); box-shadow: none; }
.dot { width: 18px; height: 18px; border-radius: 50%; background: var(--clay); }
.coin { width: 26px; height: 26px; border-radius: 50%; background: var(--kraft); box-shadow: inset 0 0 0 5px var(--kraft-soft); }

svg.wire { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
svg.wire path, svg.wire line { fill: none; stroke: var(--ink-2); stroke-width: 3; stroke-linecap: round; }
svg.wire .dash { stroke-dasharray: 8 10; }
[data-fx="draw"] { transform: none; stroke-dasharray: 2000; stroke-dashoffset: 2000; transition: stroke-dashoffset 1.2s ease, opacity .2s !important; }
[data-fx="draw"].in { stroke-dashoffset: 0; }

/* chapter card scene */
.chcard { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; padding: 0 160px; gap: 18px; background: var(--chc); color: var(--paper); }
.chcard .tag { font-family: var(--f-pixel); font-size: 26px; letter-spacing: .14em; opacity: .85; }
.chcard h1 { font-family: var(--f-display); font-weight: 500; font-size: 150px; line-height: .95; margin: 0; letter-spacing: -.02em; }
.chcard p { font-size: 34px; max-width: 1100px; margin: 0; opacity: .92; line-height: 1.3; }
.chcard .runner { position: absolute; left: 0; top: 0; width: 120px; color: var(--paper); }
.chcard .track { position: absolute; left: 0; right: 0; top: 790px; height: 6px; background: repeating-linear-gradient(90deg, var(--paper) 0 30px, transparent 30px 50px); opacity: .6; }

/* quizzes: a quiz is a gate; see play.js */
.quiz { display: flex; flex-direction: column; gap: 16px; }
.quiz .qhead { font-family: var(--f-pixel); font-size: 18px; letter-spacing: .1em; color: var(--clay); display: flex; align-items: center; gap: 12px; }
.qrow { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.qrow .qt { font-size: 25px; flex: 1 1 520px; min-width: 0; }
.opt {
  font-family: var(--f-body); font-size: 21px; font-weight: 600; padding: 10px 18px; border-radius: 10px; cursor: pointer;
  background: var(--paper); border: 2px solid var(--ink); box-shadow: 0 5px 0 var(--ink); color: var(--ink);
  transition: transform .08s, box-shadow .08s, background .2s;
}
.opt:hover { background: var(--paper-2); }
.opt:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.qrow.done .opt { cursor: default; box-shadow: 0 2px 0 var(--rule); border-color: var(--rule); color: var(--ink-2); transform: translateY(3px); }
.qrow.done .opt.right { background: var(--good); border-color: var(--good); color: var(--paper); }
.qrow.done .opt.picked.wrong { background: var(--bad); border-color: var(--bad); color: var(--paper); }
.qrow.hi { background: var(--clay-soft); border-radius: 10px; box-shadow: 0 0 0 8px var(--clay-soft); }
.qrow .why { flex-basis: 100%; font-size: 21px; color: var(--ink-2); display: none; padding-left: 4px; }
.qrow.done .why { display: block; }
.qrow .why:empty { display: none; }

@media (prefers-reduced-motion: reduce) {
  .spark > svg, .ping, #badge, #title .press button { animation: none !important; }
  [data-at] { transition-duration: .15s !important; }
}

/* diagram parts */
.node {
  position: absolute; padding: 8px 14px; border-radius: 10px; background: var(--paper); border: 2px solid var(--ink);
  font-size: 19px; font-weight: 600; white-space: nowrap; line-height: 1.2;
}
.node.clay { border-color: var(--clay); background: var(--clay-soft); }
.node.olive { border-color: var(--olive); background: var(--olive-soft); }
.node.sky { border-color: var(--sky); background: var(--sky-soft); }
.node.kraft { border-color: var(--kraft); background: var(--kraft-soft); }
.node.plum { border-color: var(--plum); background: var(--plum-soft); }
.node.ghost { border-style: dashed; border-color: var(--ink-2); color: var(--ink-2); background: transparent; }
.node.lit { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.code .ln { display: block; min-height: 1.5em; }
.code .ln.hl { background: rgba(224,130,95,.22); margin: 0 -24px; padding: 0 24px; box-shadow: inset 4px 0 0 #e0825f; }
.stamp {
  font-family: var(--f-pixel); font-size: 30px; letter-spacing: .1em; color: var(--bad); border: 4px solid var(--bad);
  border-radius: 8px; padding: 6px 14px 4px; transform: rotate(-8deg); background: var(--paper); white-space: nowrap;
}
[data-at].stamp { transform: rotate(-8deg) scale(1.8); }
[data-at].stamp.in { transform: rotate(-8deg); transition: opacity .2s, transform .3s cubic-bezier(.3,1.6,.5,1); }
.box { position: absolute; border: 3px dashed var(--ink-2); border-radius: 14px; }
.box.solid { border-style: solid; }
.lbl { font-family: var(--f-pixel); font-size: 14px; letter-spacing: .08em; color: var(--ink-2); white-space: nowrap; }
.shake { animation: shake .4s 3; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.ach { display: flex; align-items: center; gap: 22px; padding: 14px 22px; border-radius: 14px; background: var(--paper-2); border: 2px solid var(--rule); }
.ach .ico { flex: none; width: 54px; height: 54px; border-radius: 12px; background: var(--chc, var(--clay)); color: var(--paper); display: grid; place-items: center; font-family: var(--f-pixel); font-size: 22px; }
.ach .tx { font-size: 26px; line-height: 1.3; }
.ach .tx small { display: block; font-family: var(--f-pixel); font-size: 13px; letter-spacing: .1em; color: var(--ink-2); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 16px; align-items: center; }
.sm { font-size: 20px !important; }
.cut { opacity: .35; text-decoration: line-through; text-decoration-thickness: 3px; text-decoration-color: var(--bad); }
#stage.oncard #badge { background: var(--paper); color: var(--ink); }
[data-at]:not(.in), .gone { pointer-events: none; }
#cap { pointer-events: none; }

/* explain stops */
#tl .stopm { position: absolute; top: 2px; width: 4px; height: 12px; margin-left: -2px; border-radius: 2px; background: #86afd8; pointer-events: none; }
#talk {
  position: absolute; left: 50%; bottom: 26px; width: 1240px; margin-left: -620px; z-index: 9; display: none; padding: 16px 24px 14px;
  background: var(--paper); border: 3px solid var(--sky); border-radius: 16px; box-shadow: 0 12px 0 -2px var(--sky-soft), 0 20px 40px -20px rgba(0,0,0,.4);
  animation: talkin .35s cubic-bezier(.3,1.6,.5,1);
}
body.stopped #talk { display: block; }
#talk .k { font-family: var(--f-pixel); font-size: 15px; letter-spacing: .1em; color: var(--sky); }
#talk .tx { font-family: var(--f-display); font-size: 32px; line-height: 1.2; margin: 6px 0 8px; text-wrap: pretty; }
body.stopped #cap { opacity: 0; }
#talk .hint { font-family: var(--f-pixel); font-size: 13px; letter-spacing: .1em; color: var(--ink-2); }
@keyframes talkin { from { transform: translateY(14px) scale(.96); opacity: 0; } }
body.stopped #badge { display: block; background: var(--sky); color: var(--paper); }
body.stopped #stage *:not(#talk) { animation-play-state: paused !important; }
#notes .caps p.stop { color: var(--sky); font-weight: 600; }
#script button.stop { color: var(--sky); }
#script button em { font-style: normal; font-family: var(--f-pixel); font-size: 14px; letter-spacing: .08em; }

/* speed menu, above the speed button */
#ratemenu {
  position: fixed; z-index: 50; display: none; flex-direction: column; min-width: 96px; padding: 6px;
  background: var(--bar); color: var(--bar-ink); border-radius: 10px; box-shadow: 0 12px 30px -10px rgba(0,0,0,.5);
  font-family: var(--f-mono); font-size: 14px;
}
body.rates #ratemenu { display: flex; }
#ratemenu .k { font-family: var(--f-pixel); font-size: 11px; letter-spacing: .1em; opacity: .6; padding: 4px 10px 6px; }
#ratemenu button { background: none; border: 0; color: inherit; text-align: left; padding: 7px 10px; border-radius: 6px; cursor: pointer; font: inherit; }
#ratemenu button:hover { background: rgba(255,255,255,.1); }
#ratemenu button.cur { color: #e0825f; }
#ratemenu button.cur::after { content: " ✓"; }
