:root {
  --paper: #f4efe6;
  --paper-2: #ece5d8;
  --card: #fffdf8;
  --ink: #1c1a17;
  --muted: #5d574e;
  --line: #d8cfbf;
  --red: #d93a1e;
  --red-ink: #b02d14;
  --green: #2f6b4f;
  --term: #1d1b19;
  --term-ink: #f1ebe0;
  --term-muted: #a59d90;
  --mark: #ffe08a;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --col: min(600px, 46vw);
  --gutter: clamp(16px, 4.5vw, 64px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html, .cards { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.55 var(--sans);
  overflow-x: hidden;
}
a { color: inherit; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); text-underline-offset: 3px; }
a:hover { color: var(--red-ink); }
code { font-family: var(--mono); font-size: 0.88em; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* ---- the fixed stage behind the copy ---- */
.stage { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.stage::after {
  /* a paper wash behind the copy column, so text over the scene keeps its contrast */
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, color-mix(in srgb, var(--paper) 82%, transparent) 0, color-mix(in srgb, var(--paper) 55%, transparent) calc(var(--col) + var(--gutter)), transparent calc(var(--col) + var(--gutter) + 140px));
}
.stage .poster {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: 72% 50%;
  transition: opacity 0.5s ease;
}
#scene { position: absolute; inset: 0; opacity: 0; transition: opacity 0.5s ease; }
#scene canvas { display: block; width: 100%; height: 100%; }
.scene-ready #scene { opacity: 1; }
.scene-ready .stage .poster { opacity: 0; }
#labels { position: absolute; inset: 0; overflow: hidden; }
.lbl {
  position: absolute; left: 0; top: 0;
  font: 600 11px/1.2 var(--mono);
  color: var(--ink); background: var(--card);
  border: 1px solid var(--ink);
  padding: 2px 5px; white-space: nowrap;
  transform-origin: 0 100%;
  opacity: 0; will-change: transform, opacity;
}
.lbl.cost { white-space: pre; text-align: center; line-height: 1.25; transform-origin: 50% 100%; }
.lbl.red { color: #fff; background: var(--red); border-color: var(--red); }
.lbl.green { color: #fff; background: var(--green); border-color: var(--green); }
.lbl.ghost { background: var(--card); border-style: dashed; color: var(--red-ink); border-color: var(--red); }

/* ---- header and rail ---- */
.top {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px var(--gutter);
}
.brand { font: 800 20px/1 var(--sans); letter-spacing: -0.02em; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.brand img { display: block; }
.brand b { color: var(--red); }
.top nav { display: flex; gap: 18px; flex-wrap: wrap; font-size: 14px; }
.top nav a { text-decoration: none; color: var(--muted); }
.top nav a:hover { color: var(--ink); }

.rail {
  position: fixed; z-index: 3; right: 18px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 4px;
  font: 600 11px/1 var(--mono); text-transform: uppercase; letter-spacing: 0.06em;
}
.rail { transition: opacity 0.25s; }
.rail.gone { opacity: 0; pointer-events: none; }
.rail a {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 6px 0; text-decoration: none; color: var(--muted);
}
.rail a::after { content: ""; width: 8px; height: 8px; border: 1.5px solid currentColor; border-radius: 50%; }
.rail a span { opacity: 0; transition: opacity 0.2s; }
.rail:hover a span, .rail a[aria-current] span { opacity: 1; }
.rail a[aria-current] { color: var(--red); }
.rail a[aria-current]::after { background: currentColor; }

/* ---- content ---- */
main { position: relative; z-index: 1; }
.chapter { padding: 0 var(--gutter); }
.eyebrow {
  font: 600 12px/1.4 var(--mono); letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 14px;
}
.eyebrow .tools { color: var(--red-ink); margin-left: 10px; text-transform: none; letter-spacing: 0; }

.hero { min-height: calc(100vh - 64px); padding-top: clamp(16px, 5vh, 56px); padding-bottom: 72px; }
.hero > * { max-width: var(--col); }
h1 {
  font: 800 clamp(36px, 4.4vw, 64px)/1.02 var(--sans);
  letter-spacing: -0.025em; margin: 0 0 18px;
  text-wrap: balance;
}
.h1-kicker { display: block; font: 600 12.5px/1.4 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--red-ink); margin: 0 0 14px; }
.lede { font-size: 18px; color: var(--muted); margin: 0 0 22px; max-width: min(30em, var(--col)); }

.term { background: var(--term); color: var(--term-ink); border-radius: 10px; overflow: hidden; box-shadow: 0 1px 0 rgba(0,0,0,.05), 0 12px 30px -14px rgba(40,30,20,.45); }
.term-tabs { display: flex; flex-wrap: wrap; gap: 2px; padding: 8px 8px 0; background: #2a2724; }
.term-tabs button {
  font: 600 12.5px/1 var(--sans); color: var(--term-muted);
  background: transparent; border: 0; border-radius: 6px 6px 0 0;
  padding: 9px 12px 10px; cursor: pointer;
}
.term-tabs button[aria-selected="true"] { color: var(--term-ink); background: var(--term); box-shadow: inset 0 2px 0 var(--red); }
.term-pane { padding: 12px 14px 6px; }
.term-pane[hidden] { display: none; }
.line { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 0; }
.line code { font-size: 13.5px; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
.ps { color: var(--red); margin-right: 6px; user-select: none; }
.term-note, .term-req { font-size: 12.5px; color: var(--term-muted); margin: 6px 0 8px; }
.term-req { padding: 0 14px 12px; margin: 0; }
.term-note a, .term-req a { color: var(--term-ink); }
.copy {
  flex: none; font: 600 11px/1 var(--mono); text-transform: uppercase; letter-spacing: 0.05em;
  color: inherit; background: transparent; border: 1px solid currentColor; border-radius: 4px;
  padding: 6px 8px; cursor: pointer; opacity: 0.8;
}
.copy:hover { opacity: 1; }
.copy.done { color: #7fd1a2; }

.starter { margin-top: 18px; }
.starter-head { font: 600 12px/1.4 var(--mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 8px; }
.starter-box {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--card); border: 1.5px solid var(--ink); border-radius: 8px; padding: 14px 14px 14px 16px;
}
.starter-box p { margin: 0; font-size: 15px; line-height: 1.5; }
.starter-box .copy { color: var(--ink); }
.starter-box .copy.done { color: var(--green); }

.links { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: -8px 0 22px; font: 600 13px/1.4 var(--mono); }
.links a { color: var(--ink); }

/* ---- parts ---- */
.part { min-height: 160vh; padding-top: 20vh; padding-bottom: 30vh; }
.part-copy { max-width: var(--col); }
h2 { font: 800 clamp(26px, 2.5vw, 36px)/1.12 var(--sans); letter-spacing: -0.02em; margin: 0 0 14px; text-wrap: balance; }
.part-copy > p { margin: 0 0 18px; max-width: 36em; }
.part-copy > p, .part-copy h2, .part-copy .eyebrow { text-shadow: 0 0 12px var(--paper), 0 0 2px var(--paper); }
.reply { margin: 22px 0 0; background: var(--card); border: 1.5px solid var(--ink); border-radius: 8px; overflow: hidden; }
.reply figcaption { font-size: 12.5px; line-height: 1.45; color: var(--muted); padding: 9px 14px; border-bottom: 1px solid var(--line); background: var(--paper-2); }
.reply figcaption span { font: 700 11px/1 var(--mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--red-ink); margin-right: 6px; }
.reply pre { margin: 0; padding: 14px; overflow-x: auto; font-size: 12.5px; line-height: 1.55; tab-size: 2; }
.reply pre code { font-size: inherit; white-space: pre-wrap; overflow-wrap: anywhere; }
.reply .call { color: var(--red-ink); font-weight: 700; }
mark { background: var(--mark); color: inherit; padding: 0 1px; }
mark.bad { background: #ffd2c6; }
.more-fold, details.more { margin: 18px 0 0; }
details.more > summary { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; font: 600 13px/1.4 var(--mono); color: var(--red-ink); background: var(--card); border: 1.5px solid var(--ink); border-radius: 999px; padding: 6px 12px; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "+"; font-weight: 800; }
details.more[open] > summary::before { content: "−"; }
details.more > p { margin: 14px 0 0; max-width: 36em; background: color-mix(in srgb, var(--paper) 90%, transparent); }
.part-copy > p:not(.eyebrow):not(.live):not(.more) { font-size: 20px; line-height: 1.4; }
.live { font: 13px/1.5 var(--mono); background: var(--card); border-left: 3px solid var(--red); padding: 8px 12px; }

/* the two stages shown as pictures: copy on the left, the sheet beside it, held while the part scrolls */
.has-shot { display: flex; align-items: flex-start; gap: clamp(24px, 4vw, 72px); }
.has-shot .part-copy { flex: 0 0 var(--col); }
.shot { position: sticky; top: 16vh; flex: 1 1 auto; max-width: 620px; margin: 0 120px 0 auto; background: var(--card); border: 1.5px solid var(--ink); border-radius: 8px; overflow: hidden; box-shadow: 0 18px 40px -22px rgba(40,30,20,.55); }
.shot img, .inline-shot img { display: block; width: 100%; height: auto; }
.shot figcaption, .inline-shot figcaption { font-size: 12.5px; line-height: 1.45; color: var(--muted); padding: 9px 14px; border-top: 1px solid var(--line); background: var(--paper-2); }
.inline-shot { margin: 4px 0 0; background: var(--card); border: 1.5px solid var(--ink); border-radius: 8px; overflow: hidden; }
.tall { min-height: 220vh; }
/* a part with two views keeps its copy in sight through both, unless its long "How it works" is open */
.tall .part-copy:not(:has(details[open])) { position: sticky; top: 16vh; }
/* the tools, grouped by stage */
.tools-part { min-height: 0; padding-bottom: 18vh; }
.toolgroups { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 6px 0 0; }
.tg { background: var(--card); border: 1.5px solid var(--ink); border-radius: 8px; padding: 12px 14px 6px; }
.tg h3 { font: 700 11.5px/1.3 var(--mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--red-ink); margin: 0 0 8px; }
.tg dl { margin: 0; }
.tg dl > div { padding: 0 0 8px; }
.tg dt { font: 700 13px/1.3 var(--mono); }
.tg dd { margin: 2px 0 0; font-size: 13.5px; line-height: 1.4; color: var(--muted); }
.part-copy > p.more { font: 600 13px/1.4 var(--mono); margin-top: 14px; }

/* ---- after the parts: solid sections ---- */
.showcase, .results, .proof { position: relative; background: var(--paper); }
.showcase { padding-top: 96px; padding-bottom: 72px; border-top: 1.5px solid var(--ink); }
.section-lede { color: var(--muted); max-width: 44em; margin: 0 0 28px; }
.carousel-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 0 0 28px; }
.carousel-head .section-lede { margin: 0; }
.carousel-nav { display: flex; gap: 8px; flex: none; }
.carousel-btn { width: 42px; height: 42px; border: 1.5px solid var(--ink); border-radius: 50%; background: var(--card); color: var(--ink); font: 600 17px/1 var(--mono); cursor: pointer; }
.carousel-btn:hover:not(:disabled) { background: var(--ink); color: var(--card); }
.carousel-btn:disabled { opacity: 0.3; cursor: default; }
/* the games: a row that scrolls sideways, three cards in view (two, then one and a peek on narrower screens) */
.cards { list-style: none; margin: 0 -2px; padding: 0 2px 4px; scroll-padding-inline: 2px; display: flex; gap: 22px; overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth; overscroll-behavior-x: contain; scrollbar-width: none; }
.cards::-webkit-scrollbar { display: none; }
.cards:focus-visible { outline: 2px solid var(--red-ink); outline-offset: 4px; }
.card { flex: 0 0 calc((100% - 44px) / 3); scroll-snap-align: start; background: var(--card); border: 1.5px solid var(--ink); border-radius: 8px; overflow: hidden; }
.card > a { display: flex; flex-direction: column; text-decoration: none; color: inherit; height: 100%; }
.card-main { display: flex; flex-direction: column; flex: 1; padding: 14px 16px 16px; }
.card img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; border-bottom: 1.5px solid var(--ink); }
.card .tag { margin: 0 0 6px; font: 600 11.5px/1.3 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--red-ink); }
.card h3 { font: 800 22px/1.15 var(--sans); margin: 0 0 6px; }
.card .what { margin: 0 0 14px; font-size: 15px; line-height: 1.5; min-height: 3em; color: var(--muted); }
.facts { margin: 0 0 16px; border-top: 1px solid var(--line); }
.facts > div { display: grid; grid-template-columns: 6.5em 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.facts dt { font: 600 11.5px/1.6 var(--mono); text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.facts dd { margin: 0; }
.card .url { margin-top: auto; align-self: flex-start; font: 600 13px/1 var(--mono); color: var(--card); background: var(--ink); border-radius: 6px; padding: 9px 12px; }
.card > a:hover .url { background: var(--red-ink); }
.reel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 56px 0 16px; }
.reel-head h3 { font: 800 24px/1.2 var(--sans); margin: 0; }
.reel-head a { font: 600 13px/1.4 var(--mono); color: var(--red-ink); }
.clips { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.clip video { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border: 1.5px solid var(--ink); border-radius: 8px; background: var(--term); }
.clip p { margin: 10px 0 0; font-size: 15px; color: var(--muted); }
.clip b { color: var(--ink); margin-right: 4px; }
.card > a:hover h3 { color: var(--red-ink); }

.results { padding: 72px var(--gutter); border-top: 1.5px solid var(--ink); }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin: 0; border: 1.5px solid var(--ink); border-radius: 8px; overflow: hidden; background: var(--card); }
.stats > div { padding: 18px; border-right: 1px solid var(--line); }
.stats > div:last-child { border-right: 0; }
.stats dt { font-size: 13.5px; color: var(--muted); margin-bottom: 8px; }
.stats dd { margin: 0; }
.stats dd b { display: block; font: 800 30px/1.1 var(--sans); letter-spacing: -0.02em; margin-bottom: 6px; }
.stats dd span { font-size: 13px; color: var(--muted); }
.more { margin: 16px 0 0; font: 600 13px/1.4 var(--mono); }
.res-h { font: 800 22px/1.2 var(--sans); margin: 44px 0 14px; }
.results h2 + .res-h { margin-top: 8px; }
.compare-wrap { overflow-x: auto; border: 1.5px solid var(--ink); border-radius: 8px; background: var(--card); margin: 0 0 16px; }
.compare { width: 100%; border-collapse: collapse; font-size: 15px; }
.compare th, .compare td { padding: 11px 16px; text-align: left; border-bottom: 1px solid var(--line); }
.compare tbody tr:last-child > * { border-bottom: 0; }
.compare thead th { font: 600 12px/1.3 var(--mono); text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); background: var(--paper-2); }
.compare thead th:nth-child(2) { color: var(--red-ink); }
.compare tbody th { font-weight: 500; }
.compare td { white-space: nowrap; width: 9em; }
.compare td.yes { font-weight: 700; color: var(--green); }
.compare td.yes::before { content: "✓ "; }
.compare td.no { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.stats-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stats-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.proof { padding: 56px var(--gutter) 64px; border-top: 1px solid var(--line); }
.proof p { max-width: 52em; color: var(--muted); margin: 0 0 20px; }
.proof-stats { display: flex; flex-wrap: wrap; gap: 12px 36px; margin: 0; }
.proof-stats dt { font: 600 11.5px/1.4 var(--mono); text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.proof-stats dd { margin: 2px 0 0; font: 800 26px/1.1 var(--sans); letter-spacing: -0.02em; }

footer { position: relative; z-index: 1; background: var(--ink); color: var(--term-ink); padding: 40px var(--gutter) 48px; font-size: 14px; }
footer nav { display: flex; flex-wrap: wrap; gap: 8px 22px; font: 600 13px/1.4 var(--mono); margin-bottom: 18px; }
footer a { color: var(--term-ink); }
footer p { margin: 0 0 8px; color: var(--term-muted); max-width: 60em; }

/* ---- poster-only (reduced motion, no WebGL): same page, a still behind ---- */
.poster-only #scene, .poster-only #labels { display: none; }

/* ---- narrower screens ---- */
@media (max-width: 1100px) {
  .card { flex-basis: calc((100% - 22px) / 2); }
  .clips { grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats > div:nth-child(2) { border-right: 0; }
  .stats > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 760px) {
  :root { --col: 100%; }
  body { font-size: 16px; }
  .top nav { display: none; }
  .rail { display: none; }
  .stage .poster { object-position: 50% 50%; }
  .stage::after { background: none; }
  .hero { min-height: 0; padding-top: 34vh; }
  .hero > *:not(h1):not(.eyebrow) { position: relative; }
  .hero h1, .hero .lede, .hero .links { background: color-mix(in srgb, var(--paper) 88%, transparent); }
  h1 { font-size: 36px; padding: 4px 0; }
  .part-copy > p:not(.eyebrow):not(.live):not(.more) { font-size: 18px; }
  .part { min-height: 140vh; padding-top: 55vh; }
  .part-copy { background: color-mix(in srgb, var(--paper) 92%, transparent); padding: 16px; margin: 0 -16px; border-top: 1.5px solid var(--ink); }
  .part-copy > p, .part-copy h2, .part-copy .eyebrow { text-shadow: none; }
  .reply pre { font-size: 11.5px; }
  .card { flex-basis: 85%; }
  .stats, .stats-2, .stats-3 { grid-template-columns: 1fr; }
  .compare th, .compare td { padding: 9px 10px; font-size: 13.5px; }
  .compare td { width: auto; }
  .stats > div { border-right: 0; border-bottom: 1px solid var(--line); }
  .stats > div:last-child { border-bottom: 0; }
  .starter-box { flex-direction: column; }
  .has-shot { display: block; }
  .shot { position: relative; top: 0; margin: 0 -16px; border-radius: 0; border-left: 0; border-right: 0; max-width: none; box-shadow: none; }
  .tall { min-height: 180vh; }
  .tall .part-copy:not(:has(details[open])) { position: static; }
  .toolgroups { grid-template-columns: 1fr; }
  .tools-part { padding-top: 55vh; }
  .line code { font-size: 12.5px; }
}
