/* ============================================================
   THE INHERITANCE — style.css
   Dark parchment-and-gold. No external assets, no webfonts.
   ============================================================ */

:root {
  --ink: #14110c;
  --ink-2: #1d1810;
  --ink-3: #262017;
  --line: #3a3123;
  --cream: #ede3cd;
  --cream-dim: #c9bda2;
  --faint: #8f8368;
  --gold: #d4a94e;
  --gold-bright: #e8c069;
  --gold-dim: #96793c;
  --red: #c96b5a;
  --green: #8fae72;
  --book-ink: #3a2e19;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --hand: "Bradley Hand", "Segoe Print", "Comic Sans MS", cursive;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--ink);
  background-image:
    radial-gradient(1200px 800px at 50% -200px, rgba(212, 169, 78, 0.07), transparent 60%),
    radial-gradient(900px 600px at 90% 110%, rgba(212, 169, 78, 0.04), transparent 60%);
  color: var(--cream);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.65;
  min-height: 100vh;
}

.screen { display: none; padding: 76px 0 90px; }
.screen.active { display: block; animation: screenIn 420ms ease both; }
@keyframes screenIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.wrap { max-width: 660px; margin: 0 auto; padding: 0 22px; }

button { font-family: var(--sans); cursor: pointer; }

/* ================= HUD ================= */

#hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  display: none;
  align-items: center; gap: 10px;
  padding: 10px 14px;
  background: rgba(20, 17, 12, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
#hud.visible { display: flex; }

#hud-home {
  display: flex; align-items: center; gap: 7px;
  background: none; border: 1px solid var(--line); border-radius: 8px;
  color: var(--cream-dim); font-size: 12.5px; letter-spacing: 0.04em;
  padding: 6px 10px;
}
#hud-home:hover { color: var(--gold-bright); border-color: var(--gold-dim); }
#hud-home svg { color: var(--gold); }

.hud-ep {
  color: var(--faint); font-family: var(--sans); font-size: 12px;
  letter-spacing: 0.14em; text-transform: uppercase;
}

.hud-money { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.hud-chip {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--sans); font-size: 14px; font-weight: 600;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--ink-2);
}
.hud-chip .hud-k {
  font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--faint);
}
.hud-chip.purse { color: var(--gold-bright); border-color: rgba(212, 169, 78, 0.45); }
.hud-chip.debt { color: var(--red); }
.hud-chip.invest { color: var(--green); }

/* one-time coach mark under the purse chip */
.hud-tip {
  position: absolute; right: 0; top: calc(100% + 10px);
  width: max-content; max-width: 220px; text-align: left;
  background: var(--ink-3); border: 1px solid var(--gold-dim); border-radius: 8px;
  color: var(--cream); font-family: var(--sans); font-size: 12.5px; font-weight: 500; line-height: 1.4;
  padding: 8px 11px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  opacity: 0; transform: translateY(-4px); transition: opacity 260ms ease, transform 260ms ease;
  pointer-events: none; z-index: 50;
}
.hud-tip.show { opacity: 1; transform: none; }

.delta-chip {
  position: absolute; left: 50%; top: calc(100% + 4px); transform: translateX(-50%);
  font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: var(--ink-3); border: 1px solid var(--line);
  animation: floatDown 2.3s ease-out forwards;
  pointer-events: none; white-space: nowrap; z-index: 5;
}
.delta-chip.good { color: var(--green); }
.delta-chip.bad { color: var(--red); }
@keyframes floatDown {
  0% { opacity: 0; transform: translate(-50%, -6px); }
  12% { opacity: 1; }
  70% { opacity: 1; transform: translate(-50%, 10px); }
  100% { opacity: 0; transform: translate(-50%, 22px); }
}

/* ================= TITLE ================= */

#screen-title { padding-top: 40px; }
.title-wrap {
  max-width: 620px; margin: 0 auto; padding: 40px 24px 60px;
  text-align: center;
}
.zig-mark svg { width: 92px; height: auto; }
.zig-mark rect { fill: var(--gold); }
.zig-mark { filter: drop-shadow(0 0 24px rgba(212, 169, 78, 0.35)); margin-bottom: 26px; }

.title-kicker {
  font-family: var(--sans); font-size: 12px; letter-spacing: 0.28em;
  text-transform: uppercase; color: var(--gold);
  margin-bottom: 14px;
}
.title-main {
  font-size: clamp(52px, 11vw, 78px); line-height: 0.98;
  font-weight: 600; letter-spacing: 0.01em;
  color: var(--cream);
  margin-bottom: 26px;
}
.title-sub {
  font-size: 18.5px; line-height: 1.7; color: var(--cream-dim);
  max-width: 520px; margin: 0 auto 22px;
}
.title-sub em { color: var(--gold-bright); font-style: italic; }

.title-facts {
  font-family: var(--sans); font-size: 12.5px; letter-spacing: 0.06em;
  color: var(--faint); text-transform: uppercase;
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
  margin-bottom: 38px;
}
.title-facts .dot { color: var(--gold-dim); }

.title-form { display: flex; flex-direction: column; gap: 12px; align-items: center; margin-bottom: 40px; }

/* name affordance — collapsed by default, expands on tap (no field before the story) */
.name-affordance { margin-top: 4px; }
.name-toggle {
  background: none; border: none; color: var(--faint);
  font-family: var(--sans); font-size: 13px; letter-spacing: 0.02em;
  padding: 6px 10px; border-radius: 8px;
}
.name-toggle:hover { color: var(--gold); }
.name-toggle #name-display { color: var(--cream-dim); }
.name-edit { display: flex; flex-direction: column; gap: 8px; align-items: center; margin-top: 8px; }

.name-label { font-family: var(--sans); font-size: 13px; color: var(--faint); }
#name-input {
  background: var(--ink-2); border: 1px solid var(--line); border-radius: 10px;
  color: var(--cream); font-family: var(--serif); font-size: 18px; text-align: center;
  padding: 10px 16px; width: 220px; outline: none;
}
#name-input:focus { border-color: var(--gold-dim); }

.title-credit { font-size: 13.5px; color: var(--faint); max-width: 480px; margin: 0 auto; }

/* ================= BUTTONS ================= */

.btn {
  display: inline-block;
  background: var(--ink-3); color: var(--cream);
  border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; font-weight: 600; letter-spacing: 0.02em;
  padding: 13px 26px;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}
.btn:hover { border-color: var(--gold-dim); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-gold {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: #241b09; border-color: transparent;
  box-shadow: 0 4px 18px rgba(212, 169, 78, 0.25);
}
.btn-gold:hover { filter: brightness(1.06); border-color: transparent; }

.btn-ghost { background: transparent; color: var(--cream-dim); }
.btn-sm { padding: 8px 16px; font-size: 13.5px; }

/* ================= HUB ================= */

.hub-head { text-align: center; margin-bottom: 34px; }
.hub-head h2 { font-size: 34px; font-weight: 600; margin: 6px 0 10px; }
.hub-purse {
  font-family: var(--sans); font-size: 14px; font-weight: 600; color: var(--gold-bright);
  background: var(--ink-2); border: 1px solid rgba(212, 169, 78, 0.35);
  display: inline-block; border-radius: 999px; padding: 7px 16px;
}

/* v3 — hub journey progress track: "Month X of 24" over a gold-fill bar */
.progress-track {
  background: var(--ink-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px 16px; margin: 0 0 24px;
}
.pt-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 11px; flex-wrap: wrap; }
.pt-label { font-family: var(--sans); font-size: 13px; font-weight: 700; letter-spacing: 0.05em; color: var(--gold-bright); }
.pt-counts { font-family: var(--sans); font-size: 12px; color: var(--faint); }
.pt-sep { margin: 0 7px; color: var(--gold-dim); }
.pt-worn { color: var(--gold); }
.pt-bar { height: 7px; border-radius: 999px; background: var(--ink-3); border: 1px solid var(--line); overflow: hidden; }
.pt-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--gold-dim), var(--gold-bright)); transition: width 600ms ease; }

/* chapter waypoints under each ep-item — crossed = gold diamond + the player's recorded line */
.waypoints { margin: 9px 0 3px; display: flex; flex-direction: column; gap: 7px; }
.waypoint { display: flex; gap: 10px; align-items: flex-start; }
.wp-dot {
  flex: 0 0 auto; width: 9px; height: 9px; margin-top: 5px; transform: rotate(45deg);
  background: var(--ink-3); border: 1px solid var(--line);
}
.waypoint.crossed .wp-dot { background: var(--gold); border-color: var(--gold-bright); box-shadow: 0 0 8px rgba(212, 169, 78, 0.4); }
.wp-body { flex: 1; min-width: 0; }
.wp-title { font-family: var(--sans); font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold); }
.wp-title.wp-pending { color: var(--faint); letter-spacing: 0.22em; }
.wp-line { font-size: 14px; color: var(--cream-dim); line-height: 1.45; margin-top: 1px; }

/* finale ledger: the ten lines stacked tighter than the standalone passage version */
.ledger-list { margin: 10px 0 6px; }
.ledger-list .ledger-line { margin: 10px 0; }

#hub-episodes { position: relative; }
#hub-episodes::before {
  content: ''; position: absolute; left: 21px; top: 20px; bottom: 20px;
  width: 2px; background: var(--line);
}

.ep-item {
  position: relative;
  display: flex; gap: 18px;
  padding: 16px 0 26px;
}
.ep-marker {
  position: relative; z-index: 1;
  flex: 0 0 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--ink-3); border: 1.5px solid var(--line);
  font-family: var(--sans); font-size: 15px; font-weight: 700; color: var(--faint);
}
.ep-item.done .ep-marker { border-color: var(--gold-dim); color: var(--gold); }
.ep-item.current .ep-marker {
  border-color: var(--gold); color: var(--gold-bright);
  box-shadow: 0 0 0 4px rgba(212, 169, 78, 0.12), 0 0 20px rgba(212, 169, 78, 0.2);
}
.ep-item.locked { opacity: 0.45; }

.ep-body { flex: 1; padding-top: 2px; }
.ep-kicker { font-family: var(--sans); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--faint); margin-bottom: 3px; }
.ep-title { font-size: 22px; font-weight: 600; color: var(--cream); margin-bottom: 4px; }
.ep-hook { font-size: 15px; color: var(--cream-dim); font-style: italic; margin-bottom: 6px; }
.ep-learn {
  font-family: var(--sans); font-size: 12.5px; color: var(--gold);
  background: rgba(212, 169, 78, 0.07); border: 1px solid rgba(212, 169, 78, 0.18);
  border-radius: 8px; padding: 7px 10px; margin: 4px 0 10px;
}
.ep-actions { margin-top: 8px; }

.hub-finale { text-align: center; margin: 8px 0 26px; }

.hub-tools { text-align: center; margin: 24px 0 4px; }

/* spaced-review "margin quiz" panel at the top of the hub */
.review-panel {
  background: linear-gradient(165deg, #221b10, #191309);
  border: 1px solid var(--gold-dim); border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  padding: 18px 18px 16px; margin: 0 0 28px;
}
.review-kicker {
  font-family: var(--sans); font-size: 11px; font-weight: 700;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold);
  text-align: center; margin-bottom: 10px;
}
.review-prompt { font-size: 17px; line-height: 1.5; color: var(--cream); text-align: center; margin-bottom: 14px; }
.review-panel .quiz-opts { display: flex; flex-direction: column; gap: 8px; }
.review-panel .btn-gold { margin-top: 14px; display: block; margin-left: auto; margin-right: auto; }

/* rest point — a gentle "pause here" at an act boundary */
.rest-note {
  font-family: var(--sans); font-size: 12.5px; font-style: italic; color: var(--faint);
  text-align: center; margin: 18px auto 0; max-width: 360px;
}

.hub-ledger-head { text-align: center; margin: 34px 0 16px; border-top: 1px solid var(--line); padding-top: 30px; }
.hub-ledger-head h3 { font-size: 22px; color: var(--gold-bright); margin-bottom: 4px; }
.hub-ledger-head p { font-size: 14px; color: var(--faint); }

.mini-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 10px; margin: 14px 0;
}
.mini-card {
  background: var(--ink-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 10px; text-align: center; color: var(--faint);
  display: flex; flex-direction: column; gap: 6px; align-items: center;
  min-height: 86px; justify-content: center;
}
.mini-card.owned { border-color: rgba(212, 169, 78, 0.4); color: var(--cream); cursor: pointer; }
.mini-card.owned:hover { border-color: var(--gold); transform: translateY(-1px); }
.mini-num {
  font-family: var(--sans); font-size: 11px; font-weight: 700;
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--ink-3); border: 1px solid var(--line); color: var(--faint);
}
.mini-card.owned .mini-num { border-color: var(--gold-dim); color: var(--gold); }
.mini-title { font-family: var(--sans); font-size: 12px; font-weight: 600; line-height: 1.3; }

/* v3 — "worn smooth" mastery: a folded gold dog-ear, like a page turned a hundred times.
   Earned when a card's spaced-review box reaches 3 (answered right across days apart). */
.mini-card { position: relative; }
.mini-card.worn { border-color: rgba(212, 169, 78, 0.7); overflow: hidden; }
.mini-card.worn::after {
  content: ''; position: absolute; top: 0; right: 0; width: 0; height: 0;
  border-top: 15px solid var(--gold-bright); border-left: 15px solid transparent;
}
.p-card.worn { position: relative; overflow: hidden; }
.p-card.worn::after {
  content: ''; position: absolute; top: 0; right: 0; width: 0; height: 0;
  border-top: 26px solid var(--gold-bright); border-left: 26px solid transparent;
}
.worn-note { margin-top: 8px; font-size: 12.5px; color: var(--gold); font-style: italic; }
.worn-note em { color: var(--gold-bright); font-style: italic; }

/* honest surfacing of the spaced-review loop — quiet facts, never urgency */
.title-review-note {
  font-family: var(--sans); font-size: 12.5px; color: var(--gold); font-style: italic;
  margin-top: 4px; text-align: center;
}
.summary-unlock {
  font-family: var(--sans); font-size: 13px; color: var(--faint); font-style: italic;
  margin: 12px 0 4px; text-align: center;
}

/* ================= STORY ================= */

.story-wrap { max-width: 620px; }

/* scene illustrations */
.scene-img {
  margin: 10px 0 28px; border-radius: 14px; overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.5);
  position: relative; line-height: 0;
}
/* a mid-text image (not the first block) gets a little more breathing room above */
#passage > .scene-img:not(:first-child) { margin-top: 22px; }
.scene-img img { display: block; width: 100%; height: auto; }
/* soft bottom fade so the art melts into the dark page */
.scene-img::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 34%;
  background: linear-gradient(to bottom, transparent, rgba(20, 17, 12, 0.5));
  pointer-events: none;
}

.title-hero {
  margin: 0 auto 30px; max-width: 560px;
  border-radius: 14px; overflow: hidden; line-height: 0;
  border: 1px solid var(--line);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.55);
}
.title-hero img { display: block; width: 100%; height: auto; }

/* ================= CHAPTER COVER ================= */

.cover-wrap {
  max-width: 620px; margin: 0 auto; padding: 30px 24px 60px;
  text-align: center;
}
.cover-img {
  margin: 0 auto 30px; max-width: 560px;
  border-radius: 14px; overflow: hidden; line-height: 0;
  border: 1px solid var(--line);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.55);
  position: relative;
  animation: blockIn 620ms ease both;
}
.cover-img img { display: block; width: 100%; height: auto; }
/* soft bottom fade so the art melts into the dark page */
.cover-img::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 40%;
  background: linear-gradient(to bottom, transparent, rgba(20, 17, 12, 0.55));
  pointer-events: none;
}
.cover-kicker {
  font-family: var(--sans); font-size: 12px; letter-spacing: 0.26em;
  text-transform: uppercase; color: var(--gold);
  margin-bottom: 12px;
  animation: blockIn 520ms ease both; animation-delay: 120ms;
}
.cover-title {
  font-size: clamp(34px, 8vw, 46px); line-height: 1.04;
  font-weight: 600; color: var(--cream);
  margin-bottom: 20px;
  animation: blockIn 520ms ease both; animation-delay: 200ms;
}
.cover-preview {
  font-size: 18px; line-height: 1.7; color: var(--cream-dim);
  max-width: 500px; margin: 0 auto 40px;
  animation: blockIn 520ms ease both; animation-delay: 300ms;
}
.cover-preview em { color: var(--gold-bright); font-style: italic; }
.cover-goal {
  font-family: var(--sans); font-size: 12.5px; letter-spacing: 0.06em;
  color: var(--gold); background: rgba(212, 169, 78, 0.08);
  border: 1px solid rgba(212, 169, 78, 0.2); border-radius: 999px;
  display: inline-block; padding: 6px 16px; margin: 0 auto 34px;
  animation: blockIn 520ms ease both; animation-delay: 340ms;
}
.cover-btns {
  display: flex; flex-direction: column; gap: 12px; align-items: center;
  animation: blockIn 520ms ease both; animation-delay: 400ms;
}

#passage.fade-in > * { animation: blockIn 520ms ease both; animation-delay: var(--d, 0ms); }
@keyframes blockIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

#passage .para { margin-bottom: 18px; font-size: 17.5px; }

.caption {
  font-family: var(--sans); font-size: 11.5px; font-weight: 600;
  letter-spacing: 0.24em; text-transform: uppercase; color: var(--gold);
  text-align: center; margin: 26px 0 22px;
}
.caption::before, .caption::after { content: ' — '; color: var(--gold-dim); }

/* --- dialogue = chat-style speech bubbles, everywhere a character speaks (in-person
   conversation). Sides alternate: You = right (amber), everyone else = left (grey);
   palette matched to the messenger images. Texting exchanges use the -messenger PNGs. --- */
.dialogue {
  margin: 0 0 12px; display: flex; flex-direction: column; max-width: 82%;
}
.dialogue.from-them { align-items: flex-start; margin-right: auto; }
.dialogue.from-me { align-items: flex-end; margin-left: auto; }
.dialogue .speaker {
  font-family: var(--sans); font-size: 11px; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold);
  margin: 0 8px 3px;
}
.dialogue.from-me .speaker { color: var(--gold-bright); }
.dialogue .line {
  display: inline-block; position: relative;
  padding: 9px 14px; border-radius: 15px;
  font-size: 16.5px; line-height: 1.5; text-align: left;
}
.dialogue.from-them .line {
  background: #2b2519; border: 1px solid rgba(237, 227, 205, 0.14);
  border-bottom-left-radius: 5px; color: var(--cream);
}
.dialogue.from-me .line {
  background: #3f3116; border: 1px solid rgba(212, 169, 78, 0.4);
  border-bottom-right-radius: 5px; color: var(--gold-bright);
}
/* tails */
.dialogue .line::after {
  content: ''; position: absolute; bottom: 7px;
  width: 0; height: 0; border-style: solid;
}
.dialogue.from-them .line::after {
  left: -7px; border-width: 6px 7px 6px 0;
  border-color: transparent #2b2519 transparent transparent;
}
.dialogue.from-me .line::after {
  right: -7px; border-width: 6px 0 6px 7px;
  border-color: transparent transparent transparent #3f3116;
}

/* ---- book quotes: parchment pages that lift off the dark background. Short quotes
   (≤2 sentences) render as a minimal epigraph named with the book it's from; long quotes
   (3+ sentences) as an aged loose page with a drop cap. Variant chosen in renderBlocks(). ---- */
.book-passage { margin: 16px 0 22px; font-family: var(--serif); color: var(--book-ink); }

/* short quotes (≤2 sentences) — minimal epigraph: gilt quote mark, airy italic, book name */
.book-passage.book-epigraph { position: relative; padding: 10px 6px 6px 52px; }
.book-passage.book-epigraph::before {
  content: '\201C'; position: absolute; left: 0; top: 2px;
  font-family: var(--serif); font-size: 68px; line-height: 0.8; color: var(--gold-dim);
}
.book-passage.book-epigraph p {
  font-style: italic; font-size: 20.5px; line-height: 1.6; color: var(--cream); margin: 0 0 8px;
}
.book-passage.book-epigraph p:last-of-type { margin-bottom: 0; }
.book-passage.book-epigraph .book-src {
  margin-top: 12px; font-family: var(--sans); font-size: 11.5px;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold-dim);
}

/* long quotes (3+ sentences) — aged loose page with a drop cap */
.book-passage.book-page {
  padding: 28px 32px; border-radius: 2px; transform: rotate(-0.7deg);
  background: linear-gradient(160deg, #efe5cb, #e3d4b2);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.5);
}
.book-passage.book-page p { font-size: 17.5px; line-height: 1.72; margin: 0 0 10px; }
.book-passage.book-page p:last-child { margin-bottom: 0; }
.book-passage.book-page p:first-child::first-letter {
  float: left; font-family: var(--serif); font-size: 58px; line-height: 0.72;
  padding: 6px 10px 0 0; color: #9a5e2b;
}

/* ---- grandpa's margin notes: an unevenly cut/torn scrap of paper set on the page you're
   reading (no tape), always signed "— Grandpa" bottom-right so it's clear whose note it is.
   Structure from renderBlocks(): .margin-note > .note-scrap > .note-paper (torn, handwriting). ---- */
.margin-note { margin: 20px 0 26px; display: flex; justify-content: center; }
.note-scrap { position: relative; max-width: 84%; transform: rotate(-1.2deg); }
.note-paper {
  background: linear-gradient(155deg, #f0e8d1, #e1d4b5);
  padding: 26px 30px 24px;
  box-shadow: 0 13px 30px rgba(0, 0, 0, 0.55), 0 2px 5px rgba(0, 0, 0, 0.35);
  clip-path: polygon(0% 3%,4% 0%,30% 2%,52% 0%,74% 2%,97% 0%,100% 4%,99% 40%,100% 70%,98% 97%,80% 99%,55% 97%,32% 100%,10% 98%,2% 100%,1% 60%,0% 30%);
}
.note-paper p { font-family: var(--hand); font-size: 18px; line-height: 1.6; color: #574733; margin: 0 0 6px; }
.note-paper p:last-child { margin-bottom: 0; }
.note-paper p.note-sig { text-align: right; color: #6a583e; margin-top: 10px; }

.receipt {
  font-family: var(--sans);
  background: var(--ink-2); border: 1px dashed var(--line); border-radius: 6px;
  padding: 14px 18px; margin: 8px 0 20px;
}
.receipt-row { display: flex; justify-content: space-between; gap: 16px; padding: 4px 0; font-size: 14.5px; color: var(--cream-dim); }
.receipt-row .r-val { font-variant-numeric: tabular-nums; color: var(--cream); white-space: nowrap; }
.receipt-row.total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 9px; font-weight: 700; color: var(--cream); }
.receipt-row.total .r-val { color: var(--gold-bright); }

.beat {
  text-align: center; font-style: italic; font-size: 18px; color: var(--gold-bright);
  margin: 26px auto 26px; max-width: 480px; line-height: 1.6;
}

/* ---- journey milestone: one ruled ledger entry, written into the book as you pass it.
   Shared by the live passage, the chapter summary, the hub waypoints, and the finale. ---- */
.ledger-line {
  display: flex; gap: 16px; align-items: flex-start;
  margin: 26px 0; padding: 14px 18px 14px 16px;
  background: linear-gradient(150deg, rgba(212, 169, 78, 0.10), rgba(212, 169, 78, 0.03));
  border: 1px solid var(--gold-dim); border-left: 3px solid var(--gold);
  border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.26);
}
.ledger-line.is-new { box-shadow: 0 0 0 3px rgba(212, 169, 78, 0.14), 0 8px 24px rgba(0, 0, 0, 0.34); }
.ledger-stamp {
  flex: 0 0 auto; padding-top: 3px; white-space: nowrap;
  font-family: var(--sans); font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold);
}
.ledger-body { flex: 1; min-width: 0; }
.ledger-title {
  font-family: var(--sans); font-size: 11px; font-weight: 700;
  letter-spacing: 0.13em; text-transform: uppercase; color: var(--faint); margin-bottom: 3px;
}
.ledger-entry { font-family: var(--serif); font-size: 16.5px; line-height: 1.5; color: var(--cream); }
.ledger-tip {
  font-family: var(--sans); font-size: 12.5px; font-style: italic; color: var(--faint);
  text-align: center; margin: -6px auto 22px; max-width: 384px; line-height: 1.5;
}

/* choices */
#choices { margin-top: 34px; display: flex; flex-direction: column; gap: 12px; padding-bottom: 30px; }
#choices .btn { align-self: center; }

.choice {
  text-align: left;
  background: var(--ink-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 15px 18px; width: 100%;
  transition: border-color 130ms ease, transform 130ms ease, background 130ms ease;
  animation: blockIn 400ms ease both;
}
.choice:hover { border-color: var(--gold); background: var(--ink-3); transform: translateY(-1px); }
.choice-label { display: block; font-family: var(--serif); font-size: 17px; color: var(--cream); line-height: 1.45; }
.choice-sub { display: block; font-family: var(--sans); font-size: 12.5px; color: var(--faint); margin-top: 4px; }

/* reflection */
.reflect-box {
  background: var(--ink-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 18px; margin: 8px 0 8px;
}
.reflect-prompt { font-size: 16.5px; font-style: italic; color: var(--gold-bright); margin-bottom: 12px; }
.reflect-input {
  width: 100%; min-height: 74px; resize: vertical;
  background: var(--ink); border: 1px solid var(--line); border-radius: 8px;
  color: var(--cream); font-family: var(--serif); font-size: 16px; line-height: 1.5;
  padding: 10px 12px; outline: none;
}
.reflect-input:focus { border-color: var(--gold-dim); }
.reflect-hint { font-family: var(--sans); font-size: 12px; color: var(--faint); margin-top: 8px; }

/* ================= OVERLAY / CARDS ================= */

.overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(10, 8, 5, 0.82);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; transition: opacity 220ms ease;
  overflow-y: auto;
}
.overlay.open { opacity: 1; }
.overlay-inner {
  max-width: 460px; width: 100%;
  display: flex; flex-direction: column; gap: 16px; align-items: center;
  transform: translateY(10px) scale(0.98); transition: transform 260ms ease;
  margin: auto;
}
.overlay.open .overlay-inner { transform: none; }

.p-card {
  width: 100%;
  background: linear-gradient(165deg, #241d10, #1a150c);
  border: 1.5px solid var(--gold-dim);
  border-radius: 14px;
  box-shadow: 0 12px 50px rgba(0, 0, 0, 0.6), inset 0 0 60px rgba(212, 169, 78, 0.05);
  padding: 24px 24px 20px;
}
.p-card-kicker {
  font-family: var(--sans); font-size: 11px; font-weight: 700;
  letter-spacing: 0.22em; text-transform: uppercase; color: var(--gold);
  text-align: center; margin-bottom: 8px;
}
.p-card-title {
  font-size: 27px; font-weight: 700; text-align: center; color: var(--cream);
  margin-bottom: 16px;
}
.p-card-babylon {
  border-top: 1px solid rgba(212, 169, 78, 0.25);
  border-bottom: 1px solid rgba(212, 169, 78, 0.25);
  padding: 14px 6px; margin-bottom: 14px;
}
.p-card-babylon p { font-style: italic; font-size: 15.5px; line-height: 1.65; color: var(--gold-bright); }
.p-card-cite { font-family: var(--sans); font-size: 11.5px; color: var(--faint); margin-top: 8px; }
.p-card-modern { font-size: 15px; line-height: 1.65; color: var(--cream-dim); margin-bottom: 14px; }
.p-card-action {
  background: rgba(212, 169, 78, 0.08); border: 1px solid rgba(212, 169, 78, 0.2);
  border-radius: 8px; padding: 10px 12px;
  font-family: var(--sans); font-size: 13px; line-height: 1.5; color: var(--cream);
  display: flex; flex-direction: column; gap: 3px;
}
.p-card-action-k {
  font-size: 10px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--gold);
}

/* retrieval / attribution / prediction question modal */
.quiz-card {
  background: linear-gradient(165deg, #201a10, #191309);
  border: 1.5px solid var(--gold-dim); border-radius: 14px;
  box-shadow: 0 12px 50px rgba(0, 0, 0, 0.6);
  padding: 24px 22px 20px; text-align: center; gap: 0;
}
.quiz-kicker {
  font-family: var(--sans); font-size: 11px; font-weight: 700;
  letter-spacing: 0.2em; text-transform: uppercase; color: var(--gold);
  margin-bottom: 10px;
}
.quiz-prompt { font-size: 19px; line-height: 1.5; color: var(--cream); margin-bottom: 18px; }
.quiz-prompt em { color: var(--gold-bright); font-style: italic; }
.quiz-opts { display: flex; flex-direction: column; gap: 10px; }
.quiz-opt {
  text-align: left; background: var(--ink-2); border: 1px solid var(--line); border-radius: 11px;
  padding: 13px 16px; width: 100%; color: var(--cream);
  transition: border-color 130ms ease, background 130ms ease, transform 130ms ease, opacity 130ms ease;
}
.quiz-opt:hover:not(:disabled) { border-color: var(--gold); background: var(--ink-3); transform: translateY(-1px); }
.quiz-opt:disabled { cursor: default; }
.quiz-opt-label { font-family: var(--serif); font-size: 16px; line-height: 1.4; }
.quiz-opt.correct { border-color: var(--green); background: rgba(143, 174, 114, 0.14); }
.quiz-opt.correct .quiz-opt-label { color: #b9d69b; }
.quiz-opt.wrong { border-color: var(--red); background: rgba(201, 107, 90, 0.12); }
.quiz-opt.dim { opacity: 0.5; }
.quiz-resp {
  font-size: 15px; line-height: 1.55; text-align: left;
  border-radius: 10px; padding: 12px 14px; margin: 16px 0 4px;
}
.quiz-resp.ok { background: rgba(143, 174, 114, 0.1); border: 1px solid rgba(143, 174, 114, 0.3); color: var(--cream); }
.quiz-resp.no { background: rgba(201, 107, 90, 0.08); border: 1px solid rgba(201, 107, 90, 0.28); color: var(--cream); }
.quiz-card .btn-gold { margin-top: 16px; align-self: stretch; }

.overlay-inner.confirm {
  background: var(--ink-2); border: 1px solid var(--line); border-radius: 14px;
  padding: 26px; text-align: center;
}
.overlay-inner.confirm h3 { font-size: 21px; margin-bottom: 10px; color: var(--cream); }
.overlay-inner.confirm p { font-size: 15px; color: var(--cream-dim); margin-bottom: 6px; }
.confirm-row { display: flex; gap: 10px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }

/* ================= SUMMARY / FINALE ================= */

.summary-title, .finale-title { font-size: 34px; font-weight: 600; text-align: center; margin: 4px 0 24px; }

.summary-stats {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
  margin-bottom: 26px;
}
.stat {
  background: var(--ink-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 20px; text-align: center; min-width: 108px;
}
.stat-k { font-family: var(--sans); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); }
.stat-v { font-family: var(--sans); font-size: 21px; font-weight: 700; color: var(--gold-bright); margin-top: 2px; }
.stat.bad .stat-v { color: var(--red); }

.summary-h {
  font-family: var(--sans); font-size: 12px; font-weight: 700;
  letter-spacing: 0.2em; text-transform: uppercase; color: var(--gold);
  text-align: center; margin: 34px 0 14px;
}

.paths { display: flex; flex-direction: column; gap: 10px; }
.path-item {
  background: var(--ink-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 18px;
}
.path-you { font-size: 15.5px; color: var(--cream); margin-bottom: 6px; }
.path-other { font-size: 14.5px; color: var(--faint); font-style: italic; }
.paths-note { font-family: var(--sans); font-size: 12.5px; color: var(--faint); text-align: center; margin-top: 12px; }

.summary-btns {
  display: flex; flex-direction: column; gap: 12px; align-items: center;
  margin-top: 38px;
}

.finale-vignette {
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--ink-2);
  padding: 26px 24px 12px; margin-bottom: 30px;
}

.spark { margin: 6px 0 4px; }
.spark svg { width: 100%; height: auto; }
.spark-line { fill: none; stroke: var(--gold); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.spark-dot { fill: var(--gold-bright); }
.spark-zero { stroke: var(--line); stroke-width: 1; stroke-dasharray: 4 5; }
.spark-label { fill: var(--faint); font-family: var(--sans); font-size: 12px; }
.spark-val { fill: var(--cream-dim); font-family: var(--sans); font-size: 11px; }
.spark-note { font-family: var(--sans); font-size: 12.5px; color: var(--faint); text-align: center; margin-bottom: 8px; }

.refl-note { font-size: 14px; color: var(--faint); text-align: center; margin-bottom: 14px; }
.refl-list { display: flex; flex-direction: column; gap: 10px; }
.refl-item { background: var(--ink-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; }
.refl-k { font-family: var(--sans); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); margin-bottom: 5px; }
.refl-v { font-size: 16.5px; font-style: italic; color: var(--cream); }

.checklist { display: flex; flex-direction: column; gap: 10px; }
.chk-row {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--ink-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; cursor: pointer;
}
.chk-row:hover { border-color: var(--gold-dim); }
.chk-row input {
  appearance: none; -webkit-appearance: none;
  width: 22px; height: 22px; flex: 0 0 22px; margin-top: 2px;
  border: 1.5px solid var(--gold-dim); border-radius: 6px;
  background: var(--ink); cursor: pointer; position: relative;
}
.chk-row input:checked { background: var(--gold); border-color: var(--gold); }
.chk-row input:checked::after {
  content: '✓'; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #241b09; font-size: 15px; font-weight: 800;
}
.finale-goal { text-align: center; font-size: 15.5px; font-style: italic; color: var(--gold-bright); margin: -14px 0 14px; }
.finale-exam { text-align: center; font-size: 14.5px; color: var(--cream-dim); margin: 0 auto 24px; max-width: 520px; }

/* post-story return greeting at the top of the hub */
.return-panel {
  background: linear-gradient(165deg, #201a10, #191309);
  border: 1px solid var(--gold-dim); border-radius: 14px;
  padding: 18px; margin: 0 0 22px; text-align: center;
}
.return-kicker {
  font-family: var(--sans); font-size: 11px; font-weight: 700;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); margin-bottom: 8px;
}
.return-line { font-size: 15.5px; line-height: 1.55; color: var(--cream); margin-bottom: 14px; }

.chk-row.chk-first { border-color: var(--gold-dim); background: rgba(212, 169, 78, 0.06); }
.chk-badge {
  display: inline-block; font-family: var(--sans); font-size: 10px; font-weight: 700;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold);
  border: 1px solid var(--gold-dim); border-radius: 999px; padding: 2px 8px; margin-bottom: 6px;
}
.chk-t { font-family: var(--sans); font-size: 15px; font-weight: 600; color: var(--cream); }
.chk-d { font-family: var(--sans); font-size: 13px; color: var(--faint); margin-top: 2px; line-height: 1.5; }
.chk-row input:checked ~ .chk-body .chk-t { text-decoration: line-through; color: var(--faint); }

/* ================= RESPONSIVE ================= */

@media (max-width: 520px) {
  body { font-size: 16px; }
  .screen { padding-top: 66px; }
  #screen-title { padding-top: 18px; }
  .hud-chip .hud-k { display: none; }
  .title-main { margin-bottom: 20px; }
  .title-sub { font-size: 16.5px; }
  #passage .para { font-size: 16.5px; }
  .dialogue .line { font-size: 16.5px; }
  .mini-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .stat { min-width: 90px; padding: 10px 14px; }
  .stat-v { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
