:root {
  --bg: #f4efe6;
  --surface: #fffdf8;
  --ink: #1d1a16;
  --muted: #6b6258;
  --line: #ddd3c4;
  --accent: #b4432a;
  --accent-ink: #ffffff;
  --bubble-in: #ece5d8;
  --bubble-out: #1d1a16;
  --bubble-out-ink: #fffdf8;
  --ok: #2f6b45;
  --flyer-bg: #1d1a16;
  --flyer-ink: #f4d58d;
  --slip-bg: #fbf6e9;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12100e; --surface: #1c1916; --ink: #f1ebe1; --muted: #a59a8c; --line: #332e28;
    --accent: #e0694c; --bubble-in: #2a2622; --bubble-out: #f1ebe1; --bubble-out-ink: #12100e;
    --ok: #6fbf8b; --slip-bg: #26221d;
  }
}
:root[data-theme="dark"] {
  --bg: #12100e; --surface: #1c1916; --ink: #f1ebe1; --muted: #a59a8c; --line: #332e28;
  --accent: #e0694c; --bubble-in: #2a2622; --bubble-out: #f1ebe1; --bubble-out-ink: #12100e;
  --ok: #6fbf8b; --slip-bg: #26221d;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.5 var(--font);
}
a { color: var(--accent); }
button, input { font: inherit; }
.wrap { max-width: 520px; margin: 0 auto; padding: 16px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 8px; }
h1 { font-size: 28px; }
h2 { font-size: 21px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* top bar */
.bar {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.bar .wrap { display: flex; align-items: center; gap: 12px; padding-top: 10px; padding-bottom: 10px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; flex: none;
}
.bar .who { flex: 1; min-width: 0; }
.bar .who strong { display: block; }
.bar .who span { font-size: 13px; color: var(--muted); }
.iconbtn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 6px 12px; font-size: 14px; cursor: pointer;
}

/* cards */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin: 14px 0;
}
.btn {
  display: inline-block; border: 0; border-radius: 12px; padding: 13px 18px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 650; text-decoration: none;
  min-height: 48px;
}
.btn.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn:focus-visible, .iconbtn:focus-visible, input:focus-visible, .opt:focus-within {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* set header */
.sethead {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin: 26px 0 6px; padding-top: 10px; border-top: 1px dashed var(--line);
}
.sethead:first-child { border-top: 0; margin-top: 8px; }
.sethead .tag { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* items */
.item { margin: 12px 0; }
.meta { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.bubble {
  background: var(--bubble-in); border-radius: 18px 18px 18px 4px; padding: 11px 14px;
  white-space: pre-line; max-width: 92%;
}
.item.out .bubble { background: var(--bubble-out); color: var(--bubble-out-ink); border-radius: 18px 18px 4px 18px; margin-left: auto; }
.item.out .meta { text-align: right; }
.note {
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 10px; padding: 12px 14px; white-space: pre-line;
}
.doc {
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 14px;
  white-space: pre-line; font-family: var(--mono); font-size: 15px;
}
.flyer {
  background: var(--flyer-bg); color: var(--flyer-ink); border-radius: 6px; padding: 26px 18px;
  text-align: center; font-family: var(--serif);
}
.flyer p { margin: 6px 0; }
.flyer p:nth-child(1) { letter-spacing: .3em; font-size: 14px; }
.flyer p:nth-child(2) { font-size: 30px; font-weight: 700; letter-spacing: .04em; }
.flyer p:nth-child(3) { font-size: 14px; opacity: .85; }
.flyer p:nth-child(4) { font-size: 22px; font-style: italic; margin-top: 16px; }
.flyer p:nth-child(5) { font-size: 16px; }
.slip {
  background: var(--slip-bg); border: 1px solid var(--line); border-radius: 4px; padding: 16px;
  font-family: var(--serif); box-shadow: 0 1px 0 var(--line);
}
.slip p { margin: 6px 0; }
.slip p:first-child { font-family: var(--mono); font-size: 12px; letter-spacing: .15em; color: var(--muted); }
.slip p:nth-last-child(2) { font-style: italic; text-align: right; }
.slip p:last-child { font-family: var(--mono); font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 8px; margin-top: 12px; }

/* unlock + questions */
label { display: block; font-weight: 600; margin-bottom: 6px; }
input[type="text"] {
  width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); min-height: 48px; text-transform: uppercase;
}
.feedback { min-height: 1.5em; margin-top: 8px; font-size: 15px; }
.feedback.ok { color: var(--ok); }
.feedback.no { color: var(--accent); }
.opt {
  display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; margin: 8px 0; cursor: pointer; background: var(--bg);
}
.opt input { margin-top: 4px; width: 20px; height: 20px; flex: none; }
.hint { background: var(--bg); border-radius: 10px; padding: 10px 12px; margin: 8px 0; font-size: 15px; }
.word {
  font-family: var(--mono); font-size: 28px; letter-spacing: .12em; font-weight: 700;
  background: var(--bg); border: 2px dashed var(--accent); border-radius: 12px; padding: 12px; text-align: center;
}

/* ending */
.archive {
  background: var(--surface); border: 2px solid var(--ink); border-radius: 4px; padding: 26px 18px;
  text-align: center; font-family: var(--serif);
}
.archive p { margin: 6px 0; }
.archive p:first-child { font-size: 26px; letter-spacing: .12em; font-weight: 700; }
.archive p:nth-child(2) { font-size: 22px; color: var(--accent); }
.archive p:last-child { font-size: 13px; color: var(--muted); margin-top: 14px; }
.reveal-in { animation: rise .6s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .reveal-in { animation: none; } }

.hidden { display: none !important; }
.center { text-align: center; }
footer { padding: 30px 0 50px; font-size: 13px; color: var(--muted); text-align: center; }

/* ---------- art (decoration only; every clue also lives in text) ---------- */
.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.art { display: block; width: 100%; height: auto; border-radius: 14px; margin: 10px 0 14px; border: 1px solid var(--line); background: var(--surface); }
.card .art.cover { margin: -4px 0 14px; aspect-ratio: 16 / 9; object-fit: cover; }
.hero { display: block; width: 100%; height: auto; border-radius: 16px; margin: 0 0 14px; border: 1px solid var(--line); }

/* ---------- explainer + control panel ---------- */
.doc-page h2 { margin-top: 28px; }
.lede { font-size: 19px; line-height: 1.5; }
.steps li { margin: 0 0 10px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.two-col .card { margin: 0; }
@media (max-width: 520px) { .two-col { grid-template-columns: 1fr; } }
.avatar-lg { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; display: block; margin-bottom: 8px; }
.wrap.wide { max-width: 1040px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin: 12px 0; }
.tile { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; color: var(--ink); text-decoration: none; }
a.tile:hover { border-color: var(--accent); }
.tile h3 { margin: 0 0 4px; font-size: 17px; }
.tile p { margin: 0; font-size: 14px; color: var(--muted); }
.panel-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.panel-nav a { font-size: 14px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--ink); background: var(--surface); }
.status { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; background: var(--line); color: var(--ink); }
.status.ok { background: #2f7d4f; color: #fff; }
.status.todo { background: var(--accent); color: #fff; }
.status.open { background: #f4d58d; color: #1d1a16; }
table.grid { width: 100%; border-collapse: collapse; font-size: 15px; }
table.grid th, table.grid td { text-align: left; vertical-align: top; padding: 8px; border-bottom: 1px solid var(--line); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.gallery figure { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.gallery figcaption { font-size: 12px; padding: 6px 8px; color: var(--muted); }
.gallery figcaption b { color: var(--ink); }
section.block { scroll-margin-top: 12px; }

/* ---------- home walkthrough, demo, folded sets, finale ---------- */
.home h1 { margin-bottom: 6px; }
.walk { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 12px; }
.walk li { display: grid; grid-template-columns: 120px 1fr; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.walk img { width: 120px; height: 120px; object-fit: cover; border-radius: 10px; display: block; }
.walk h3 { margin: 2px 0 4px; font-size: 18px; }
.walk p { margin: 0; }
.walk .num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 14px; }
@media (max-width: 420px) { .walk li { grid-template-columns: 84px 1fr; } .walk img { width: 84px; height: 84px; } }
.card.bars img { width: 100%; height: auto; border-radius: 10px; display: block; margin-bottom: 10px; }
footer a { color: inherit; }
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 16px 0; }
.duo figure { margin: 0; }
.duo figcaption { margin: 0 0 6px; }
.duo iframe { width: 100%; height: 720px; border: 1px solid var(--line); border-radius: 24px; background: var(--bg); }
@media (max-width: 760px) { .duo { grid-template-columns: 1fr; } .duo iframe { height: 600px; } }
details.done-set { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin: 10px 0; }
details.done-set summary { cursor: pointer; font-weight: 600; list-style-position: inside; }
details.done-set[open] summary { margin-bottom: 8px; }
.card.finale ol { padding-left: 22px; }
.card.finale li { margin: 0 0 6px; }

/* ---------- watch-a-round play-by-play ---------- */
.pbp .premise { border-left: 4px solid var(--accent); }
.beat { margin: 22px 0; }
.beat-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.beat-head h2 { margin: 0; flex: 1; font-size: 20px; }
.beat .num, .walk .num { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 14px; flex: none; }
.clock { font: 600 13px/1 ui-monospace, Menlo, monospace; color: var(--muted); }
.screens { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 10px 0; }
@media (max-width: 620px) { .screens { grid-template-columns: 1fr; } }
.screen { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 12px; }
.screen.a { box-shadow: inset 0 4px 0 #b4432a; }
.screen.b { box-shadow: inset 0 4px 0 #d9b25c; }
.screen-top { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 8px; }
.screen-top img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.mini { font-size: 15px; line-height: 1.45; padding: 10px 12px; border-radius: 14px; margin: 6px 0; background: var(--bg); border: 1px solid var(--line); }
.mini.flyer { background: #f4d58d; color: #1d1a16; border-color: #e3bf6a; }
.mini.slip { background: #fffaf0; color: #1d1a16; border-style: dashed; }
.mini.bubble-in { border-radius: 16px 16px 16px 4px; }
.mini.lock { border-style: dashed; }
kbd { font: 700 14px/1 ui-monospace, Menlo, monospace; background: var(--ink); color: var(--bg); padding: 4px 7px; border-radius: 6px; letter-spacing: .04em; white-space: nowrap; }
.talk { display: grid; gap: 8px; margin: 10px 0; }
.say { margin: 0; padding: 10px 14px; border-radius: 16px; max-width: 88%; line-height: 1.45; }
.say.a { background: #b4432a; color: #fff; border-bottom-left-radius: 4px; justify-self: start; }
.say.b { background: #f4d58d; color: #1d1a16; border-bottom-right-radius: 4px; justify-self: end; }
.say.in { background: var(--surface); border: 1px solid var(--line); justify-self: start; }
.aside { border-left: 3px solid var(--accent); padding: 4px 0 4px 12px; color: var(--muted); font-style: italic; }

/* ---------- motion (only when the viewer allows it) ---------- */
@media (prefers-reduced-motion: no-preference) {
  .js-motion .beat { opacity: 0; transform: translateY(28px); transition: opacity .6s ease, transform .6s cubic-bezier(.2,.8,.2,1); }
  .js-motion .beat.in { opacity: 1; transform: none; }
  .js-motion .beat .screen { transform: translateY(14px) rotate(-1deg); opacity: 0; transition: all .55s cubic-bezier(.2,.8,.2,1); }
  .js-motion .beat .screen.b { transform: translateY(14px) rotate(1deg); }
  .js-motion .beat.in .screen { opacity: 1; transform: none; }
  .js-motion .beat.in .screen.b { transition-delay: .18s; }
  .js-motion .say { opacity: 0; transform: translateY(10px) scale(.96); transition: opacity .35s ease, transform .35s cubic-bezier(.2,.8,.2,1); }
  .js-motion .say.show { opacity: 1; transform: none; }
  .typing { display: inline-flex; gap: 4px; padding: 12px 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); width: max-content; }
  .typing.r { justify-self: end; }
  .typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: dot 1s infinite ease-in-out; }
  .typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
  @keyframes dot { 0%, 80%, 100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-4px); opacity: 1; } }
  .js-motion kbd.typed::after { content: "▍"; animation: blink .8s steps(1) infinite; margin-left: 1px; }
  @keyframes blink { 50% { opacity: 0; } }
  .js-motion .archive.flip { animation: flip .9s cubic-bezier(.2,.8,.2,1) both; transform-origin: 50% 0; }
  @keyframes flip { from { transform: perspective(700px) rotateX(-75deg); opacity: 0; } to { transform: none; opacity: 1; } }
  .js-motion .walk li { opacity: 0; transform: translateX(-16px); transition: all .5s cubic-bezier(.2,.8,.2,1); }
  .js-motion .walk li.in { opacity: 1; transform: none; }
  .hero { animation: heroIn 1.1s cubic-bezier(.2,.8,.2,1) both; }
  @keyframes heroIn { from { opacity: 0; transform: scale(1.03); } to { opacity: 1; transform: none; } }
}
.card.intro .art.cover { aspect-ratio: 21 / 9; }
.card.intro h1 { margin: 4px 0 8px; }
.card.intro .rule { margin: 8px 0 12px; }
details.story { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
details.story summary { cursor: pointer; font-weight: 600; }
