

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background .25s, color .25s;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

.wrap { width: min(1180px, 100% - 32px); margin-inline: auto; }

/* ---------- header ---------- */
.hdr {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.hdr-in { display: flex; align-items: center; gap: 14px; height: 64px; }

.logo { display: flex; align-items: center; gap: 9px; font-weight: 900; font-size: 19px; letter-spacing: -.035em; white-space: nowrap; }
/* The mark is favicon.svg itself — one drawing for the header and the icon, so the two
   cannot drift apart the way a text glyph could. */
.logo img { width: 30px; height: 30px; flex: none; }

/* Three links, so the nav stays inline at every width — no menu to open.
   The shelves sit next to the logo; About is pinned to the right edge of the bar. */
.nav { display: flex; flex: 1; gap: 2px; }
.nav a { padding: 8px 12px; border-radius: 999px; font-size: 14px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.nav a:hover, .nav a.on { background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--ink); }
.nav a.about { margin-left: auto; }

@media (max-width: 420px) {
  .hdr-in { gap: 8px; }
  .logo { font-size: 17px; }
  .nav { gap: 0; }
  .nav a { padding: 7px 7px; font-size: 13px; }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; border: 0; cursor: pointer;
  padding: 12px 20px; border-radius: 999px; font-size: 15px; font-weight: 700;
  font-family: inherit; letter-spacing: -.01em;
}
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff; box-shadow: 0 8px 20px rgba(255, 92, 61, .3); }
.btn-light { background: #fff; color: #191521; }
.btn-ghost { background: transparent; border: 1.5px solid var(--line); color: var(--ink); }
.btn-sm { padding: 9px 16px; font-size: 13px; }

/* ---------- hero ---------- */
.hero {
  margin-top: 22px; border-radius: 30px; overflow: hidden; color: #fff;
  background: linear-gradient(115deg, #5B3BFF 0%, #FF5C3D 58%, #FFB020 100%);
  display: grid; gap: 10px; padding: 30px 26px;
  position: relative; isolation: isolate;
}
.hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: radial-gradient(circle at 82% 18%, rgba(255, 255, 255, .34), transparent 46%);
}
.hero .kicker {
  display: inline-flex; align-items: center; gap: 7px; width: fit-content;
  background: rgba(255, 255, 255, .18); border: 1px solid rgba(255, 255, 255, .3);
  padding: 6px 13px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
}
.hero h1 { margin: 6px 0 4px; font-size: clamp(30px, 5.4vw, 52px); line-height: 1.03; letter-spacing: -.045em; font-weight: 900; }
.hero p { margin: 0; font-size: 15px; opacity: .9; max-width: 42ch; }
.hero .row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

@media (min-width: 860px) {
  .hero { padding: 40px 44px; }
  .hero p { max-width: 56ch; }
}

/* ---------- section ---------- */
.sec { margin-top: 34px; }
.sec-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.sec-head h2 { margin: 0; font-size: clamp(19px, 2.6vw, 24px); letter-spacing: -.03em; font-weight: 850; }
.sec-head p { margin: 0; font-size: 13px; color: var(--muted); }
.sec-head .more { margin-left: auto; font-size: 13px; font-weight: 700; color: var(--brand); }

/* ---------- grid + card ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 13px; }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 18px; } }
.grid.five { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; transition: transform .18s ease, box-shadow .18s ease, border-color .18s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: transparent; }
.thumb { aspect-ratio: 1 / 1; display: grid; place-items: center; position: relative; font-size: 52px; }
@media (min-width: 700px) { .thumb { font-size: 66px; } }
.thumb::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 28% 18%, rgba(255, 255, 255, .6), transparent 58%); }
.thumb b { position: relative; z-index: 1; filter: drop-shadow(0 8px 12px rgba(0, 0, 0, .16)); }
.card-b { padding: 10px 12px 13px; }
.card h3 { margin: 0 0 3px; font-size: 14px; font-weight: 750; letter-spacing: -.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.meta .dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .55; }

.badge {
  position: absolute; top: 9px; left: 9px; z-index: 2;
  padding: 3px 8px; border-radius: 8px; font-size: 10px; font-weight: 800; letter-spacing: .08em;
  background: rgba(255, 255, 255, .92); color: #191521; text-transform: uppercase;
}
.badge.hot { background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff; }

/* thumb palettes */
.g1 { background: linear-gradient(150deg, #FFE9BE, #FFB020); }
.g2 { background: linear-gradient(150deg, #D9F2FF, #62C8FF); }
.g3 { background: linear-gradient(150deg, #FFE2EC, #FF7EA8); }
.g4 { background: linear-gradient(150deg, #E6E1FF, #8B7CFF); }
.g5 { background: linear-gradient(150deg, #DDF7EC, #52D8A6); }
.g6 { background: linear-gradient(150deg, #FFF0C4, #FFC24D); }
.g7 { background: linear-gradient(150deg, #E6EFFF, #7EA8FF); }
.g8 { background: linear-gradient(150deg, #F4E8FF, #B47CFF); }

/* ---------- prose ---------- */
.prose h2 { font-size: 17px; letter-spacing: -.02em; margin: 26px 0 8px; font-weight: 800; }
.prose p { margin: 0 0 10px; color: var(--muted); font-size: 15px; }
.prose ol, .prose ul { margin: 0 0 12px; padding-left: 20px; color: var(--muted); font-size: 15px; }
.prose li { margin: 6px 0; }
.prose li b { color: var(--ink); font-weight: 700; }

/* ---------- detail ---------- */
.crumb { font-size: 12.5px; color: var(--muted); padding: 16px 0 0; display: flex; gap: 7px; flex-wrap: wrap; }
.crumb a:hover { color: var(--ink); }
.crumb .sep { opacity: .5; }

/* one column now, but the article keeps the measure the sidebar used to give it */
#main-col { margin-top: 14px; max-width: 880px; }

.stage {
  position: relative; aspect-ratio: 16 / 10; border-radius: 24px; overflow: hidden;
  background: radial-gradient(circle at 50% 42%, #2A2140, var(--stage) 70%);
  display: grid; place-items: center; color: #fff;
}
.stage .art { font-size: 92px; opacity: .55; filter: blur(.4px); }
.stage .playwrap { position: absolute; inset: 0; display: grid; place-items: center; gap: 10px; }
.stage .playbtn {
  width: 76px; height: 76px; border-radius: 50%; border: 0; cursor: pointer;
  background: #fff; color: #191521; font-size: 26px; display: grid; place-items: center;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .45); transition: transform .18s;
}
.stage .playbtn:hover { transform: scale(1.06); }
.stage .hint {
  position: absolute; bottom: 14px; left: 0; right: 0; text-align: center;
  font-size: 12px; color: rgba(255, 255, 255, .62);
}

.game-title { margin: 18px 0 6px; font-size: clamp(24px, 4vw, 34px); letter-spacing: -.04em; font-weight: 900; }
.tagrow { display: flex; flex-wrap: wrap; gap: 7px; }
.tag { font-size: 12px; font-weight: 650; padding: 5px 11px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--muted); }
.tag.live { color: var(--mint); background: color-mix(in srgb, var(--mint) 12%, transparent); }

/* ---------- share row ---------- */
/* Links first, buttons second: this row is finished markup. The two buttons ship `hidden`
   and `platform/share-client.mjs` is what removes the attribute, so without JavaScript the
   reader sees a row of links and no control that does nothing. `[hidden]` needs the extra
   rule — an author `display` beats the browser's own `[hidden] { display: none }`. */
/* the bottom margin is for the maths pages, where the blurb follows the row immediately */
.share-row { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin: 18px 0 8px; }
.share-cap {
  font-size: 11px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase;
  color: var(--muted); margin-right: 3px;
}
.share-btn {
  display: inline-flex; align-items: center; padding: 5px 11px;
  border: 1px solid var(--line); border-radius: 999px; background: transparent;
  color: var(--muted); font: inherit; font-size: 12px; font-weight: 650;
  text-decoration: none; cursor: pointer;
}
.share-btn[hidden] { display: none; }
.share-btn:hover, .share-btn:focus-visible {
  color: var(--ink); border-color: color-mix(in srgb, var(--ink) 32%, transparent);
}
.share-btn[data-state="copied"] { color: var(--mint); border-color: color-mix(in srgb, var(--mint) 42%, transparent); }
[data-shelf="math"] .share-cap,
[data-shelf="math"] .share-btn { font-family: var(--font-mono); }
[data-shelf="math"] .share-btn { border-radius: 3px; }

details.faq { border-top: 1px solid var(--line); padding: 12px 0; }
details.faq summary { cursor: pointer; font-weight: 700; font-size: 14.5px; list-style: none; display: flex; gap: 8px; }
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::after { content: "+"; margin-left: auto; color: var(--muted); }
details.faq[open] summary::after { content: "−"; }
details.faq p { margin: 8px 0 0; font-size: 14px; color: var(--muted); }

/* ---------- category head ---------- */
.cat-head { padding: 26px 0 6px; }
.cat-head h1 { margin: 0 0 8px; font-size: clamp(26px, 4.4vw, 38px); letter-spacing: -.04em; font-weight: 900; }
.cat-head p { margin: 0; color: var(--muted); font-size: 15px; max-width: 68ch; }

/* ---------- footer ---------- */
footer { border-top: 1px solid var(--line); margin-top: 46px; padding: 30px 0 40px; }
.foot-note { margin-top: 24px; font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
/* The footer is one line and it is a copyright: the header is the only navigation, so
   nothing here needs the twenty-four pixels that used to separate it from a grid above,
   and there is no link left to underline. */
footer .foot-note { margin-top: 0; }

.note { font-size: 12px; color: var(--muted); }

/* ---------- titles wired in from story/ and math/ ---------- */
.hero.scene {
  background-image:
    linear-gradient(100deg, rgba(12, 11, 15, .94) 0%, rgba(12, 11, 15, .70) 44%, rgba(12, 11, 15, .34) 100%),
    url("play/story/assets/scenes/case-01.jpg");
  background-size: cover;
  background-position: center 42%;
}
.thumb.has-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thumb.has-img::after { background: linear-gradient(180deg, rgba(255, 255, 255, .10), rgba(12, 10, 18, .45)); }

.stage.has-img {
  background-size: cover;
  background-position: center 45%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08), inset 0 -130px 150px rgba(6, 4, 10, .70);
}

/* ---------- case hero (Mystery detail page) ---------- */
.hero-case {
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; align-items: flex-end;
  min-height: clamp(420px, 74vh, 660px);
  background: #07060a;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.hero-shot {
  position: absolute; inset: 0;
  background-size: cover; background-position: center 42%;
  transform: scale(1.02);
}
@media (prefers-reduced-motion: no-preference) {
  .hero-shot { animation: case-drift 34s ease-in-out infinite alternate; }
  @keyframes case-drift {
    from { transform: scale(1.02) translate3d(0, 0, 0); }
    to { transform: scale(1.11) translate3d(0, -1.6%, 0); }
  }
}
.hero-scrim {
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(7, 6, 10, .80) 0%, rgba(7, 6, 10, .18) 26%, rgba(7, 6, 10, .60) 60%, #0c0b0f 96%),
    radial-gradient(130% 92% at 50% 36%, rgba(7, 6, 10, 0) 34%, rgba(5, 4, 8, .62) 100%);
}
.hero-inner {
  position: relative; z-index: 1;
  width: min(1180px, calc(100% - 40px)); margin: 0 auto;
  padding: 0 0 clamp(26px, 5vw, 54px);
}
.hero-kicker {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 11px; font-weight: 800; letter-spacing: .2em; text-transform: uppercase;
  color: var(--brand);
}
.hero-kicker i { display: inline-block; width: 26px; height: 1px; background: currentColor; opacity: .55; }
.hero-case h1 {
  font-family: var(--font-serif);
  font-size: clamp(34px, 5.6vw, 64px); line-height: .98; letter-spacing: -.02em;
  margin: 14px 0 14px; color: #fff;
  text-shadow: 0 6px 34px rgba(0, 0, 0, .55);
}
.hero-blurb { max-width: 56ch; margin: 0 0 24px; color: #d5cdc1; font-size: clamp(15px, 1.4vw, 17px); line-height: 1.5; }
.hero-cta { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.btn-play {
  display: inline-flex; align-items: center; gap: 12px;
  padding: 14px 26px; border-radius: 999px; text-decoration: none;
  background: linear-gradient(135deg, #f2c884, #d79b3f); color: #1a1305;
  font-size: 15.5px; font-weight: 800; letter-spacing: -.01em;
  box-shadow: 0 18px 42px rgba(227, 180, 105, .30);
  transition: transform .18s ease, box-shadow .18s ease;
}
.btn-play:hover { transform: translateY(-2px); box-shadow: 0 24px 54px rgba(227, 180, 105, .42); }
.btn-play .tri { font-size: 12px; line-height: 1; }
.hero-meta { font-size: 12.5px; color: #a89f90; }
.hero-case .tagrow { margin-top: 22px; }
.hero-case .tag { background: rgba(255, 255, 255, .07); color: #ddd4c7; border: 1px solid rgba(255, 255, 255, .10); }
/* the row sits on the photograph, so its border has to come from the ink, not the shelf line */
.hero-case .share-row { margin-top: 16px; }
.hero-case .share-btn { border-color: color-mix(in srgb, var(--ink) 26%, transparent); }
.hero-case .share-btn:hover, .hero-case .share-btn:focus-visible { border-color: color-mix(in srgb, var(--ink) 60%, transparent); }

/* a drawn cover fills the stage like a photograph, but on its own paper */
.stage.has-art { background: #f1ebdc; }
.stage.has-art .stage-art {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: center;
}
.stage.has-art .playbtn { box-shadow: 0 12px 30px rgba(20, 18, 15, .34), 0 0 0 1px rgba(20, 18, 15, .10); }
/* the drawn cover runs to the edge, so the usual footer line would sit on the art */
.stage.has-art .hint { display: none; }
.stage .playbtn { text-decoration: none; }
.stage .playbtn[disabled] { opacity: .5; cursor: not-allowed; }
.stage .playbtn[disabled]:hover { transform: none; }
.prose .lede { color: var(--ink); font-size: 16px; }

/* shelf tokens live in ../platform/tokens.css */
[data-shelf="story"] {
  --bg: #0c0b0f;
  --surface: #14121a;
  --line: #2d2739;
  --ink: #efe8dd;
  --muted: #9b9385;
  --brand: #e3b469;
  --brand2: #9a7f4e;
  --stage: #0a0910;
  --radius: 18px;
  --shadow: 0 18px 44px rgba(0, 0, 0, .55);
  --ad: #16131f;
  --adline: #332b45;
  --adink: #7f7590;
  --fam-font: Georgia, "Iowan Old Style", "Times New Roman", serif;
}
[data-shelf="math"] {
  --bg: #f7f2e6;
  --surface: #fffdf7;
  --line: #e3ddd0;
  --ink: #14120f;
  --muted: #6b665d;
  --brand: #1b4dff;
  --brand2: #00a6a0;
  --stage: #efe9da;
  --radius: 6px;
  --shadow: 0 12px 30px rgba(20, 18, 15, .10);
  --fam-font: ui-monospace, SFMono-Regular, Menlo, "Roboto Mono", monospace;
}

.band {
  margin-top: 30px; padding: 24px 22px; position: relative; isolation: isolate;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: 26px;
  overflow: hidden;
}
.band > * { position: relative; z-index: 1; }
.band::before { content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none; }
[data-shelf="story"].band::before {
  background:
    radial-gradient(120% 80% at 12% -10%, rgba(227, 180, 105, .10), transparent 58%),
    radial-gradient(90% 60% at 100% 110%, rgba(88, 74, 120, .22), transparent 70%);
}
[data-shelf="math"].band { border-radius: 10px; }
[data-shelf="math"].band::before {
  background:
    linear-gradient(rgba(20, 18, 15, .05) 1px, transparent 1px) 0 0 / 100% 26px,
    linear-gradient(90deg, rgba(20, 18, 15, .05) 1px, transparent 1px) 0 0 / 26px 100%;
}

.band-head {
  display: grid; grid-template-columns: auto auto 1fr; align-items: baseline;
  gap: 4px 12px; margin-bottom: 16px;
}
.band-head > p { grid-column: 1 / -1; }
.band-head .more { justify-self: end; }
.band-kicker {
  font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--brand); font-weight: 750;
}
.band-head h2 {
  margin: 0; font-size: clamp(22px, 3.4vw, 30px); letter-spacing: -.035em;
  font-family: var(--fam-font); font-weight: 850;
}
.band-head p { flex: 0 0 100%; margin: 0; max-width: 72ch; font-size: 14px; color: var(--muted); }
.band-head .more { margin-left: auto; font-size: 13px; font-weight: 700; color: var(--brand); }

.band .grid { grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); }
.band .card { background: var(--surface); border-color: var(--line); }
.band .card:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); box-shadow: var(--shadow); }
.band .card-b h3 {
  font-family: var(--fam-font); letter-spacing: -.02em;
  white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.band .badge.hot { background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #241b0c; }
[data-shelf="math"] .badge.hot { color: #fff; }

[data-shelf="story"] .thumb { background: linear-gradient(160deg, #1b1723, #100d16); }
[data-shelf="math"] .thumb {
  background: #f1ebdc;
  box-shadow: inset 0 0 0 1px rgba(20, 18, 15, .07), inset 0 0 0 8px rgba(20, 18, 15, .022);
}
[data-shelf="math"] .thumb::after { background: linear-gradient(180deg, rgba(255, 255, 255, .55), rgba(20, 18, 15, .05)); }
[data-shelf="math"] .thumb.has-img::after { background: linear-gradient(180deg, rgba(255, 255, 255, .30), rgba(20, 18, 15, .05)); }

/* category + detail pages inherit a whole family skin from <html data-shelf> */
[data-shelf] .hdr { background: color-mix(in srgb, var(--bg) 88%, transparent); }
/* the shelf owns the palette: there is no global light/dark switch to step aside for */
[data-shelf="story"] .game-title,
[data-shelf="story"] .cat-head h1 { font-family: var(--fam-font); }
[data-shelf="math"] .game-title,
[data-shelf="math"] .cat-head h1 { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif; letter-spacing: -.04em; font-weight: 900; }
[data-shelf="math"] .band-kicker,
[data-shelf="math"] .tagrow,
[data-shelf="math"] .meta { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
[data-shelf] .stage .art { font-size: 150px; opacity: .16; filter: blur(1px); }
[data-shelf="story"] .stage.has-img { background-color: #0a0910; }
[data-shelf="math"] .stage {
  border-radius: 8px; border: 1px solid var(--line); color: var(--ink);
  background:
    linear-gradient(rgba(20, 18, 15, .055) 1px, transparent 1px) 0 0 / 100% 32px,
    linear-gradient(90deg, rgba(20, 18, 15, .055) 1px, transparent 1px) 0 0 / 32px 100%,
    radial-gradient(circle at 50% 40%, #fffdf7, #ece5d4 78%);
}
[data-shelf="math"] .stage .art { display: none; }
[data-shelf="math"] .stage .playbtn {
  border-radius: 6px; background: var(--brand); color: #fff;
  box-shadow: 0 12px 26px rgba(27, 77, 255, .28);
}
[data-shelf="math"] .stage .hint { color: var(--muted); }
[data-shelf="math"] .tag { border-radius: 3px; border: 1px solid var(--line); background: transparent; }
[data-shelf="story"] .tag { border: 1px solid var(--line); background: transparent; }
[data-shelf="math"] .prose h2 { font-family: var(--fam-font); letter-spacing: -.01em; }
[data-shelf="story"] .prose h2 { font-family: var(--fam-font); }

