@font-face { font-family: "Atkinson"; src: url("assets/fonts/atkinson-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url("assets/fonts/atkinson-400i.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url("assets/fonts/atkinson-700.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url("assets/fonts/fraunces-600.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }

:root {
  --ink: #1d2230;
  --muted: #5d6475;
  --paper: #fbf8f3;
  --card: #ffffff;
  --line: #e4ddd2;
  --night: #172033;
  --night-2: #1f2a40;
  --pane: #243049;
  --pane-flat: #262b36;
  --text-night: #eef1f7;
  --muted-night: #9aa5bd;
  --lantern: #f2b84b;
  --danger: #ff7b6b;
  --good: #7fd49b;
  --wps: 140ms;
  --radius: 14px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 "Atkinson", system-ui, sans-serif;
}
main { max-width: 720px; margin: 0 auto; padding: 24px 16px 40px; }

h1, h2 { font-family: "Fraunces", Georgia, serif; font-weight: 600; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(28px, 6vw, 38px); }
.lede { margin: 8px 0 14px; font-size: 17px; }
.howto { color: var(--muted); font-size: 15px; margin: 12px 0 0; }

.cast { list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0; padding: 0; }
.cast li { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px; min-width: 0; }
.cast img { width: 38px; height: 38px; flex: none; }
.cast b { display: block; font-size: 15px; }
.cast span { display: block; font-size: 12px; color: var(--muted); line-height: 1.25; }

/* ---------- demo card ---------- */
.demo { margin: 28px 0; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; scroll-margin-top: 12px; }
.demo.flash { animation: flash 1.6s ease-out; }
@keyframes flash { from { box-shadow: 0 0 0 4px var(--lantern); } to { box-shadow: 0 0 0 0 transparent; } }
.demo-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.demo-head .num { font: 700 13px/1 "Atkinson", sans-serif; color: #fff; background: var(--night); border-radius: 99px; padding: 5px 9px; align-self: center; }
.demo-head h2 { font-size: 24px; }
.demo-head .solo-link { margin-left: auto; font-size: 13px; color: var(--muted); }
.tagline { margin: 4px 0 12px; color: var(--muted); }

/* ---------- stage ---------- */
.stage { background: radial-gradient(120% 90% at 50% 0%, var(--night-2), var(--night)); color: var(--text-night); border-radius: var(--radius); padding: 10px; position: relative; overflow: hidden; }
.setting { font-size: 13px; color: var(--muted-night); margin: 2px 4px 10px; display: flex; gap: 8px; align-items: center; min-height: 20px; }
.setting::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--lantern); box-shadow: 0 0 10px 3px rgba(242,184,75,.55); flex: none; }
.stage.lurch { animation: lurch .7s cubic-bezier(.36,.07,.19,.97); }
.stage.lurched .setting { color: var(--danger); }
.stage.lurched .setting::before { background: var(--danger); box-shadow: 0 0 10px 3px rgba(255,123,107,.6); }
@keyframes lurch {
  10%, 90% { transform: translate(-1px, 1px) rotate(-.2deg); }
  20%, 80% { transform: translate(3px, -1px) rotate(.3deg); }
  30%, 50%, 70% { transform: translate(-5px, 2px) rotate(-.4deg); }
  40%, 60% { transform: translate(5px, -2px) rotate(.4deg); }
}

.panes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pane { border-radius: 10px; padding: 8px; min-width: 0; display: flex; flex-direction: column; }
.pane.flat { background: var(--pane-flat); }
.pane.voiced { background: var(--pane); box-shadow: inset 0 0 0 1px rgba(242,184,75,.35); }
.pane-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted-night); margin: 0 2px 8px; }
.pane.voiced .pane-head .label { color: var(--lantern); }
.pane-head .score { font-weight: 700; color: var(--text-night); letter-spacing: 0; text-transform: none; font-size: 13px; }

.lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.line { display: flex; gap: 8px; align-items: flex-start; opacity: .14; transition: opacity .25s; }
.line.shown { opacity: 1; }
.ava { width: 32px; height: 32px; flex: none; border-radius: 50%; }
.body { min-width: 0; flex: 1; }
.name { display: block; font-size: 12px; font-weight: 700; line-height: 1.2; margin-bottom: 1px; }
.txt { margin: 0; display: grid; font-size: 15px; line-height: 1.4; overflow-wrap: break-word; }
.layer { grid-area: 1 / 1; }
.w { opacity: 0; transition: opacity .12s; }
.line.shown .calm .w { opacity: 1; transition-delay: calc(var(--i) * var(--wps)); }
.stress-layer .w { opacity: 0; }
.line.cracked .calm { animation: crack .35s forwards; }
.line.cracked .stress-layer .w { opacity: 1; transition-delay: calc(.3s + var(--i) * var(--wps)); }
@keyframes crack { 30% { transform: translateX(-3px); } 60% { transform: translateX(3px); } to { opacity: 0; transform: none; visibility: hidden; } }
.noanim, .noanim * { transition: none !important; animation: none !important; }

mark { background: rgba(242,184,75,.22); color: #ffd98a; border-radius: 4px; padding: 0 2px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }

/* stressed voices: colour drains to alarm; some type changes (cf. Undertale's Sans) */
.line.cracked .stress-layer { color: #ffe1dc; }
.pane.voiced .line.cracked[data-who="maren"] .stress-layer { font-family: "Fraunces", Georgia, serif; font-weight: 600; letter-spacing: .02em; }
.pane.voiced .line.cracked[data-who="odile"] .stress-layer { font-weight: 700; }
.pane.voiced .line.cracked[data-who="pip"] .stress-layer { color: #c9cfdb; }

/* rhythm bars */
.bars { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; min-height: 14px; opacity: 0; transition: opacity .3s .2s; }
.line.shown .bars { opacity: 1; }
.bar { height: 12px; border-radius: 3px; background: rgba(242,184,75,.75); font-size: 10px; line-height: 12px; color: #1a1a1a; padding: 0 3px; min-width: 14px; text-align: right; font-weight: 700; }
.pane.flat .bar { background: rgba(170,180,200,.65); }
.pane-foot { font-size: 12px; color: var(--muted-night); margin: 8px 2px 0; }
.pane-foot b { color: var(--text-night); }

/* caption + controls */
.caption { margin: 10px 2px 0; min-height: 3em; font-size: 15px; color: var(--ink); }
.caption .who { font-weight: 700; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }
button, .chip { font: 600 14px/1 "Atkinson", sans-serif; border-radius: 99px; padding: 9px 14px; border: 1px solid var(--line); background: #f4efe7; color: var(--ink); cursor: pointer; min-height: 38px; }
button:hover { background: #ece4d7; }
button:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid var(--lantern); outline-offset: 2px; }
button.primary { background: var(--night); color: #fff; border-color: var(--night); }
button.primary:hover { background: #2a3654; }
button[aria-pressed="true"] { background: var(--lantern); border-color: #d49a2d; color: #241a05; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.chips .lbl { font-size: 13px; color: var(--muted); margin-right: 2px; }
.chip { padding: 7px 12px; min-height: 34px; font-size: 13px; }

/* extras */
.extra { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 10px; }
.extra summary { cursor: pointer; font-weight: 700; font-size: 15px; }
.extra p.note { color: var(--muted); font-size: 14px; margin: 6px 0; }
.chapter { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; }
.chapter li { display: grid; grid-template-columns: 26px 1fr; gap: 2px 8px; align-items: start; }
.chapter .step { grid-row: span 2; width: 22px; height: 22px; border-radius: 50%; background: var(--night); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; margin-top: 2px; }
.chapter q { font-style: italic; }
.chapter small { color: var(--muted); }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; font-size: 14px; width: 100%; margin-top: 8px; }
th, td { border-bottom: 1px solid var(--line); padding: 6px 6px; text-align: left; vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
td.self { color: #b8b0a2; }
td .nick { font-weight: 700; }
.mini { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.mini img { width: 22px; height: 22px; }

/* guess mode */
.guess .w, .guess .line { opacity: 1 !important; }
.g { display: flex; gap: 8px; align-items: flex-start; }
.g .q { width: 32px; height: 32px; border-radius: 50%; background: #3a4560; display: grid; place-items: center; font-weight: 700; color: var(--muted-night); flex: none; }
.g.right .q, .g.wrong .q { background: transparent; }
.picks { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.pick { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px 3px 3px; min-height: 30px; font-size: 12px; background: #34405a; color: var(--text-night); border-color: #45526e; }
.pick:hover { background: #3f4c69; }
.pick img { width: 22px; height: 22px; }
.pick[disabled] { cursor: default; opacity: .45; }
.pick.is-right { opacity: 1; background: rgba(127,212,155,.25); border-color: var(--good); }
.pick.is-wrong { opacity: 1; background: rgba(255,123,107,.22); border-color: var(--danger); text-decoration: line-through; }
.verdict { font-size: 12px; margin-top: 4px; font-weight: 700; }
.g.right .verdict { color: var(--good); }
.g.wrong .verdict { color: var(--danger); }

/* outro */
.outro { margin-top: 24px; font-size: 14px; color: var(--muted); }
.bible summary { cursor: pointer; font-weight: 700; color: var(--ink); }
.bible td:first-child { white-space: nowrap; }
.credits { margin-top: 12px; }
.credits a { color: inherit; }
.notice { background: #fff3d6; border: 1px solid #f0d28c; border-radius: 10px; padding: 8px 12px; font-size: 14px; }

/* solo: just the one demo, ready to embed */
body.solo { background: transparent; }
body.solo main { padding: 8px; }
body.solo .intro, body.solo .outro { display: none; }
body.solo .demo { margin: 0; }

@media (max-width: 560px) {
  main { padding: 16px 10px 32px; }
  .demo { padding: 12px; border-radius: 14px; }
  .panes { grid-template-columns: 1fr; }
  .cast { grid-template-columns: 1fr 1fr; }
  .demo-head h2 { font-size: 21px; }
  .demo-head .solo-link { margin-left: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  :root { --wps: 0ms; }
  .stage.lurch { animation: none; }
  .line.cracked .calm { animation: none; visibility: hidden; }
  .line.cracked .stress-layer .w { transition-delay: 0s; }
}

/* caption: live text stacked over invisible sizers */
.caption { display: grid; min-height: 0; }
.caption > .live, .caption .sizers > p { grid-area: 1 / 1; margin: 0; }
.caption .sizers { grid-area: 1 / 1; display: grid; visibility: hidden; }
.caption .sizers > p { grid-area: 1 / 1; }

/* guess picks: four compact portrait buttons in one row */
.picks { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; max-width: 300px; }
.pick { flex-direction: column; justify-content: center; gap: 2px; padding: 4px 2px; border-radius: 10px; font-size: 11px; min-height: 44px; }
.pick img { width: 24px; height: 24px; }

/* highlights appear with their first word, not before */
mark { background: transparent; transition: background .12s; }
.line.shown .calm mark { background: rgba(242,184,75,.22); transition-delay: calc(var(--i) * var(--wps)); }
