:root {
  /* Same palette as the rest of the site (site/shared.css): graphite, steel, red, amber, green on cool paper. */
  --ink: #16191C;      /* graphite */
  --teal: #38516E;     /* steel: primary */
  --sage: #B4BEC9;     /* steel-grey mid tone */
  --cream: #EEEFF1;    /* paper */
  --paper: #FFFFFF;    /* plate */
  --ochre: #B8923A;    /* amber, lightened for fills */
  --rust: #A32B1E;     /* red */
  --shadow: #0E1114;
  --green: #2F6B44;
  --faint: #8D959D;
  /* pixel-character tones (skin and hair), used only by js/characters.js */
  --skin-1: #F3D2B3; --skin-2: #D9A877; --skin-3: #8A5A3C;
  --hair-dark: #2B2420; --hair-brown: #6E4528; --hair-grey: #BDC0C4;
  color-scheme: light;
  font-family: "Assistant", Arial, "Noto Sans Hebrew", sans-serif;
  color: var(--ink);
  background: var(--ink);
  font-size: 16px;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; min-height: 100svh; background: repeating-linear-gradient(0deg, transparent 0 47px, var(--shadow) 48px 49px); }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; min-height: 48px; border-radius: 0; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 4px solid var(--rust); outline-offset: 4px; }
h1:focus { outline: none; }
h1, h2, p { margin-top: 0; }
h1 { font-family: "Rubik", Arial, sans-serif; font-weight: 700; font-size: clamp(1.9rem, 6.5vw, 2.8rem); line-height: 1.2; letter-spacing: 0; margin-bottom: 20px; }
h2 { font-size: 1.15rem; line-height: 1.4; }
p { line-height: 1.65; }
a { color: var(--teal); font-weight: 700; text-underline-offset: 4px; overflow-wrap: anywhere; }
small { font-size: .85rem; }
#app { max-width: 720px; margin: 28px auto; padding: 0 16px; }
.cabinet { background: var(--cream); border: 4px solid var(--shadow); box-shadow: 8px 8px 0 var(--shadow); }
.topbar { background: var(--teal); color: var(--paper); padding: 14px 20px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; font-size: .875rem; font-weight: bold; border-bottom: 4px solid var(--ink); }
.cabinet-lights { color: var(--ochre); font-size: .75rem; letter-spacing: 4px; margin-inline-start: auto; }
.screen { padding: 28px; min-height: 420px; background-image: radial-gradient(var(--ochre) .5px, transparent .5px); background-size: 8px 8px; }
.cabinet-bottom { display: flex; justify-content: space-between; padding: 12px 20px; background: var(--sage); border-top: 4px solid var(--ink); }
.cabinet-bottom i { display: block; width: 36px; height: 8px; background: repeating-linear-gradient(90deg, var(--ink) 0 4px, transparent 4px 8px); }
.office { display: block; width: 100%; height: auto; border: 4px solid var(--ink); margin: 0 0 24px; }
.title-screen, .ending-screen { text-align: center; }
.title-screen h1 { font-size: clamp(2.3rem, 9vw, 3.8rem); text-shadow: 2px 2px 0 var(--ochre); }
.subtitle { font-size: 1.15rem; max-width: 480px; margin: 0 auto 24px; }
.primary { display: block; width: 100%; padding: 14px 20px; background: var(--teal); color: var(--paper); border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); font-size: 1.1rem; font-weight: bold; }
.primary:not(:disabled):hover { background: var(--ink); }
.primary:not(:disabled):active, .choice:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.primary:disabled { background: var(--sage); color: var(--ink); box-shadow: none; }
.disclaimer { font-size: .82rem; line-height: 1.7; padding-top: 20px; margin: 16px 0 0; border-top: 1px dashed var(--teal); }
.eyebrow { font-size: .875rem; font-weight: bold; color: var(--teal); margin-bottom: 10px; }
.side-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.side-card { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; padding: 22px; text-align: start; line-height: 1.6; background: var(--paper); border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ochre); }
.side-card:hover { background: var(--cream); }
.side-icon { font-size: 2.4rem; color: var(--rust); line-height: 1; }
.side-meter-labels { font-size: .85rem; border-top: 1px dashed var(--teal); padding-top: 12px; margin-top: auto; }
.card-name { display: block; font-size: 1.15rem; font-weight: bold; }
.meters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 16px 20px; background: var(--paper); border-bottom: 3px solid var(--ink); }
.meter { position: relative; min-width: 0; }
.meter-label { display: flex; gap: 4px; justify-content: space-between; margin-bottom: 6px; font-size: .875rem; }
.meter-hint { display: block; font-size: .75rem; line-height: 1.5; margin-top: 6px; }
meter, progress { display: block; appearance: none; width: 100%; height: 12px; border: 2px solid var(--ink); border-radius: 0; background: var(--cream); overflow: hidden; }
meter::-webkit-meter-bar { border: 0; border-radius: 0; background: var(--cream); }
meter::-webkit-meter-optimum-value, progress::-webkit-progress-value { background: var(--teal); }
meter::-moz-meter-bar, progress::-moz-progress-bar { background: var(--teal); }
progress::-webkit-progress-bar { background: var(--cream); }
.danger meter::-webkit-meter-optimum-value { background: var(--rust); }
.danger meter::-moz-meter-bar { background: var(--rust); }
.delta { position: absolute; background: var(--ink); color: var(--paper); padding: 2px 5px; top: 28px; inset-inline-end: 0; z-index: 1; font-weight: bold; animation: delta-rise .5s steps(4) both; }
.path { list-style: none; padding: 0; margin: 0; }
.node { display: flex; gap: 16px; align-items: flex-start; position: relative; padding-bottom: 28px; }
.node:not(:last-child)::before { content: ''; position: absolute; inset-inline-start: 19px; top: 36px; bottom: 0; width: 4px; background: var(--teal); }
.node-number { display: grid; place-items: center; background: var(--sage); border: 3px solid var(--ink); width: 42px; height: 42px; flex: 0 0 42px; font-weight: bold; z-index: 1; }
.current .node-number { background: var(--rust); color: var(--paper); }
.station-button { text-align: start; flex: 1; min-width: 0; padding: 18px; display: grid; gap: 8px; border: 2px solid var(--teal); background: var(--paper); line-height: 1.5; }
.current .station-button { border: 3px solid var(--ink); box-shadow: 5px 5px 0 var(--ochre); }
.current .station-button:hover { background: var(--cream); }
.locked .station-button { background: var(--cream); border-style: dashed; }
.done .station-button { background: var(--sage); }
.chip { display: inline-block; width: fit-content; padding: 2px 7px; border: 1px solid currentColor; font-size: .78rem; font-weight: bold; line-height: 1.5; }
.place { color: var(--teal); }
.intro-copy { font-size: 1.2rem; padding: 16px; background: var(--paper); border-inline-start: 5px solid var(--ochre); }
.dialogue { background: var(--paper); border: 3px solid var(--ink); box-shadow: 5px 5px 0 var(--ochre); margin-bottom: 24px; }
.choices { display: grid; gap: 14px; }
.choice { text-align: start; background: var(--paper); border: 2px solid var(--ink); padding: 18px; line-height: 1.5; box-shadow: 3px 3px 0 var(--teal); }
.choice:hover { background: var(--sage); }
.outcome { padding: 20px; background: var(--paper); border: 2px solid var(--teal); margin-bottom: 22px; }
.outcome > p { margin: 14px 0 0; }
.stamp { display: inline-block; padding: 4px 14px; color: var(--rust); border: 3px double currentColor; font-weight: bold; transform: rotate(-5deg); animation: stamp-in .25s steps(3); margin: 4px 0 16px; }
.large { font-size: 1.5rem; margin: 12px 0 24px; }
.hand { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mini-card { display: flex; flex-direction: column; align-items: stretch; gap: 10px; text-align: start; background: var(--paper); padding: 14px; border: 2px solid var(--ink); min-width: 0; }
.card-text { display: block; font-size: 1rem; line-height: 1.55; }
.card-meta { display: block; font-size: .85rem; margin-top: auto; font-weight: bold; }
button.mini-card:hover:not(:disabled) { border-color: var(--rust); }
.mini-card.selected { background: var(--sage); outline: 3px solid var(--teal); outline-offset: -5px; }
button.mini-card:disabled { background: var(--cream); border-style: dashed; color: var(--teal); }
.submit-bar { position: sticky; bottom: 0; background: var(--cream); border-top: 2px solid var(--ink); padding: 12px 0 8px; margin-top: 16px; z-index: 2; }
.submit-bar small { display: block; text-align: center; padding-top: 8px; }
.source { background: var(--paper); padding: 18px; border: 2px solid var(--ink); margin: 16px 0; }
.laws { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.laws a { padding: 10px; border: 1px solid var(--teal); background: var(--paper); }
.sources + h2 { margin-top: 28px; }
.screen > .disclaimer { margin-bottom: 24px; }
.disclaimer a { color: var(--teal); font-weight: 600; }
.ending-copy { font-size: 1.25rem; }
.debug { max-width: 688px; margin: 24px auto; padding: 16px; background: var(--paper); border: 3px solid var(--sage); }
.debug summary { cursor: pointer; padding: 8px; }
.debug button { background: var(--cream); border: 2px solid var(--ink); padding: 8px 16px; margin: 12px 0; }
.debug pre { max-height: 260px; overflow: auto; font-size: .75rem; white-space: pre-wrap; overflow-wrap: anywhere; text-align: left; }
.sr-only { position: absolute; top: 0; left: 0; width: 1px; height: 1px; padding: 0; margin: -1px; border: 0; overflow: hidden; clip: rect(0, 0, 0, 0); clip-path: inset(50%); white-space: nowrap; }
@keyframes stamp-in { from { transform: scale(1.3) rotate(-10deg); opacity: 0; } to { transform: scale(1) rotate(-5deg); opacity: 1; } }
@keyframes delta-rise { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@media (max-width: 520px) {
  #app { margin: 12px auto; padding: 0 12px; }
  .screen { padding: 20px 16px; }
  .topbar { padding: 12px; gap: 8px; }
  .meters { padding: 12px 10px; gap: 8px; }
  .meter-label { flex-wrap: wrap; }
  .meter-hint { font-size: .75rem; }
  .side-choices { grid-template-columns: 1fr; }
  .side-card { padding: 18px; }
  .hand { grid-template-columns: 1fr; }
  .node { gap: 10px; }
  .station-button { padding: 12px; }
  .outcome { padding: 14px; }
  .debug { margin: 20px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
.chain { list-style: none; text-align: start; margin: 8px 0; padding: 0; font-size: .95rem; line-height: 1.35;
  border: 2px solid var(--ink); background: rgba(255,255,255,.35); }
.chain-row { display: grid; grid-template-columns: 4.2em 1fr; gap: 8px; align-items: start; padding: 5px 8px;
  border-inline-start: 6px solid var(--faint); }
.chain-row + .chain-row { border-top: 1px dashed rgba(0,0,0,.25); }
.chain-row { position: relative; }
.chain-row::before { content: ''; position: absolute; inset-inline-start: -6px; top: 9px; width: 6px; height: 6px; background: var(--paper, #fff); }
.chain-label { font-weight: 700; font-size: .78rem; padding: 1px 4px; text-align: center; background: var(--faint); color: #fff; align-self: start; }
.chain-gap { border-inline-start-color: var(--ochre); } .chain-gap .chain-label { background: var(--ochre); }
.chain-passed { border-inline-start-color: var(--green); background: rgba(47,107,68,.12); } .chain-passed .chain-label { background: var(--green); }
.chain-stopped { border-inline-start-color: var(--rust); background: rgba(163,43,30,.10); } .chain-stopped .chain-label { background: var(--rust); }
.chain-neutral { border-inline-start-color: var(--ink); } .chain-neutral .chain-label { background: var(--ink); }
.chain-details summary { list-style: none; cursor: pointer; }
.chain-details summary::-webkit-details-marker { display: none; }
.chain-details summary .chain { margin-bottom: 0; }
.chain-details[open] summary .chain { border-bottom: 0; }
.chain-details > .chain { margin-top: 0; border-top: 0; }
.chain-toggle { display: inline-block; font-size: .8rem; text-decoration: underline; margin: 2px 0 6px; }
.chain-details[open] .chain-toggle { display: none; }
.mini-card { position: relative; }
.mini-card.used { cursor: not-allowed; background: #DEE1E5; }
.mini-card.used > :not(.used-stamp) { opacity: .45; filter: grayscale(1); }
.used-stamp { position: absolute; inset-block-start: 10px; inset-inline-end: 10px; transform: rotate(-10deg); z-index: 2;
  font-weight: 800; font-size: 1.05rem; padding: 2px 10px; border: 3px solid currentColor; background: rgba(255,255,255,.85); }
.used-green { color: var(--green); } .used-red { color: var(--rust); }
.hint { padding: 12px; border-inline-start: 6px solid var(--ochre); background: var(--paper); font-weight: bold; }
.round-pips { display: flex; gap: 8px; padding: 0; list-style: none; }
.round-pips li { flex: 1; border: 2px solid var(--ink); padding: 8px 4px; text-align: center; font-size: .875rem; }
.round-pips .passed, .chip.passed { background: var(--rust); color: var(--paper); }
.round-pips .stopped, .chip.stopped { background: var(--teal); color: var(--paper); }
.station-summary { font-weight: bold; border-top: 3px double var(--ink); padding-top: 16px; }
.report { border-top: 8px double var(--ink); padding-top: 18px; }
.report h1 { font-size: clamp(2rem, 7vw, 3.6rem); border-bottom: 4px solid var(--ink); padding-bottom: 20px; }
.report > h2 { border-top: 3px double var(--ink); padding-top: 18px; margin-top: 28px; }
.final-meters { display: flex; flex-wrap: wrap; gap: 8px 20px; border-block: 1px solid var(--ink); padding: 10px 0; font-size: .875rem; }
.timeline ol { padding-inline-start: 22px; }
.timeline li { padding: 10px; margin-bottom: 8px; border-inline-start: 3px solid var(--sage); }
.timeline li.passed { border-color: var(--rust); background: var(--paper); font-weight: bold; }
.timeline li.stopped { color: var(--teal); }
.factors { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.factors section { border: 2px solid var(--ink); padding: 12px; }
.factors ul { padding-inline-start: 18px; }
.factor-bar { height: 12px; background: var(--sage); margin: 8px 0; }
.factor-bar i { height: 100%; display: block; background: var(--rust); }
.fixes { width: 100%; border-collapse: collapse; margin-top: 28px; text-align: start; }
.fixes th, .fixes td { padding: 12px; border: 2px solid var(--ink); width: 50%; }
.fixes thead { background: var(--ink); color: var(--paper); }
.report-actions { display: grid; gap: 12px; }
.screen, .mini-card, .source, .report { overflow-wrap: anywhere; }
@media (max-width: 520px) {
  .factors { grid-template-columns: 1fr; }
  .fixes, .fixes tbody, .fixes tr, .fixes th, .fixes td { display: block; width: 100%; }
  .fixes thead { display: block; }
  .fixes tr { margin-bottom: 12px; }
  .fixes td { border-top: 0; }
}
/* V3: short feedback animations never gate controls. */
.sound-toggle { width: 48px; padding: 10px; background: var(--teal); color: var(--paper); border: 2px solid var(--sage); }
.sound-toggle svg { display: block; width: 24px; height: 24px; fill: currentColor; }
.vignette { width: 100%; max-width: 640px; display: block; border: 4px solid var(--ink); margin: 0 auto 24px; }
.station-outro h1 { color: var(--rust); border-block: 4px double; padding: 12px; animation: stamp-in .3s both; }
.outro-lines p { animation: reveal .25s both; animation-delay: var(--delay); }
.bridge { background: var(--paper); border-inline-start: 6px solid var(--ochre); padding: 18px; margin: 24px 0; }
.bridge p { margin: 0; }
.bridge-reminder { font-size: .875rem; color: var(--teal); }
.node-number { position: relative; }
.flying-coin { position: fixed; width: 12px; height: 10px; background: var(--ochre); border: 2px solid var(--ink); z-index: 20; pointer-events: none; }
.meter-loss { animation: shake .25s; }
.delta { animation: float-delta .65s both; pointer-events: none; }
[data-screen="intro"] .office { animation: pan-in .5s both; }
[data-screen="decisions"] .dialogue, [data-screen="duel"] .scene { animation: paper-in .3s both; }
[data-screen="decisions"]:has(.outcome) { animation: nudge 32ms steps(2); }
[data-screen="decisions"]:has(.outcome) .dialogue { animation: none; }
[data-screen="decisions"] .outcome { position: relative; }
[data-screen="decisions"] .outcome .stamp { position: absolute; top: -40px; inset-inline-end: 12px; background: var(--paper); }
.reveal-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; perspective: 700px; }
.reveal-cards .mini-card { animation: card-flip .3s both; }
.duel-resolution .stamp { animation: stamp-in .1s .6s both; }
.duel-resolution > p { animation: reveal .1s .6s both; }
.pip-pop { animation: pop .2s .6s both; }
.scroll-reveal { transition: opacity .35s, transform .35s; }
.reveal-pending { opacity: 0; transform: translateY(16px); }
.glass-left { animation: clink-left 2s infinite; }
.glass-right { animation: clink-right 2s infinite; }
.wink { animation: wink 2s steps(1) infinite; transform-box: fill-box; transform-origin: center; }
.spark { animation: sparkle 2s steps(1) infinite; }
.clap { animation: clap .5s steps(2) infinite; transform-box: fill-box; transform-origin: center bottom; }
.ribbon { animation: ribbon 2s infinite; transform-origin: center; }
.scissors { animation: cut 2s infinite; transform-origin: 160px 90px; }
.banknote { animation: drift 2.5s linear infinite; }
.newspaper { animation: news 3s infinite; }
.flash { animation: flash 3s steps(1) infinite; opacity: 0; }
.rubber { animation: rubber 2.5s infinite; }
.rejected { animation: mark 2.5s steps(1) infinite; }
.fluorescent { animation: flicker 4s steps(1) infinite; }
@keyframes reveal { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes float-delta { 0% { transform: translateY(10px); opacity: 0; } 20% { opacity: 1; } 100% { transform: translateY(-28px); opacity: 0; } }
@keyframes shake { 25%,75% { transform: translateX(-3px); } 50% { transform: translateX(3px); } }
@keyframes nudge { from { transform: translateY(2px); } to { transform: none; } }
@keyframes paper-in { from { transform: translateX(24px) rotate(2deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pan-in { from { transform: translateX(-16px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes card-flip { from { transform: rotateY(90deg); } to { transform: rotateY(0); } }
@keyframes pop { 0% { transform: scale(.85); } 60% { transform: scale(1.1); } 100% { transform: scale(1); } }
@keyframes clink-left { 40%,60% { transform: translate(22px,-10px); } }
@keyframes clink-right { 40%,60% { transform: translate(-22px,-10px); } }
@keyframes wink { 45%,60% { transform: scaleY(.25); } }
@keyframes sparkle { 0%,65% { opacity: 0; } 45% { opacity: 1; } }
@keyframes clap { 50% { transform: scaleX(.65) translateY(-4px); } }
@keyframes ribbon { 40%,85% { transform: translateY(18px) scaleX(1.08); } }
@keyframes cut { 40%,60% { transform: scaleX(.3); } }
@keyframes drift { from { transform: translate(-12px,-40px) rotate(-4deg); } to { transform: translate(12px,160px) rotate(8deg); } }
@keyframes news { 0% { transform: translateX(-280px) rotate(-5deg); } 25%,90% { transform: none; } 100% { transform: translateY(180px); } }
@keyframes flash { 30% { opacity: .7; } 34% { opacity: 0; } }
@keyframes rubber { 0%,90%,100% { transform: translateY(-48px); } 25%,40% { transform: translateY(12px); } 55% { transform: translateY(-48px); } }
@keyframes mark { 0%,100% { opacity: 0; } 28%,99% { opacity: 1; } }
@keyframes flicker { 0%,45%,51%,100% { opacity: 1; } 48%,54% { opacity: .4; } }
@media (prefers-reduced-motion: reduce) {
  .reveal-pending { opacity: 1; transform: none; }
  .delta { opacity: 1; }
  .flash { display: none; }
  .rubber { transform: translateY(-48px); }
}

/* opened: show the three rows in order (rule, gap, gain) instead of gain-first */
.chain-details[open] summary .chain { display: none; }
.chain-details[open] > .chain { border-top: 2px solid var(--ink); margin-top: 8px; }
.chain-details[open] .chain-toggle { display: inline-block; }


/* ===== V4: characters, how-to, visible rules ===== */
.px { display: block; flex: none; }
.px-sm { width: 28px; height: 28px; }
.px-md { width: 72px; height: 72px; }
.px-lg { width: 120px; height: 120px; }
.px-icon { width: 48px; height: 48px; }
.px-bob { animation: px-bob 1.6s steps(1) infinite; }
.px-eyes { animation: px-blink 4s steps(1) infinite; transform-box: fill-box; transform-origin: center; }
@keyframes px-bob { 50% { transform: translateY(1px); } }
@keyframes px-blink { 0%, 93%, 100% { transform: scaleY(1); } 94%, 97% { transform: scaleY(.15); } }
@media (prefers-reduced-motion: reduce) { .px-bob, .px-eyes { animation: none !important; } }

.top-player { display: inline-flex; align-items: center; gap: 8px; }
.howto-open { width: 40px; min-height: 40px; padding: 0; background: var(--teal); color: var(--paper); border: 2px solid var(--sage); font-weight: bold; font-size: 1.2rem; line-height: 1; }
.howto-open:hover { background: var(--ink); }

.player-token { position: absolute; inset-inline-start: -3px; bottom: calc(100% - 4px); z-index: 3; pointer-events: none; }
.player-token .px { width: 48px; height: 48px; }
.screen[data-screen="map"] .path { padding-top: 46px; }
.char-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.char-head > .px { align-self: flex-end; }
.char-head h1, .char-head-text { flex: 1; min-width: 0; }
.char-head h1 { margin-bottom: 0; }
.char-head-text h1 { margin-bottom: 0; }

.meter-bar { position: relative; }
.meter-bar.has-goal { margin-bottom: 16px; }
.danger-zone { position: absolute; top: 0; bottom: 0; width: 25%; pointer-events: none;
  background: repeating-linear-gradient(135deg, rgba(163,43,30,.55) 0 3px, transparent 3px 6px); }
.zone-high { inset-inline-end: 0; }
.zone-low { inset-inline-start: 0; }
.goal-tick { position: absolute; top: -3px; bottom: -3px; width: 3px; margin-inline-start: -1px; background: var(--ink); pointer-events: none; }
.goal-label { position: absolute; top: calc(100% + 2px); margin-inline-start: -2px; font-size: .7rem; font-weight: bold; line-height: 1.2; white-space: nowrap; }
.status-line { margin: 0; padding: 10px 20px; min-height: 2.9em; background: var(--cream); border-bottom: 3px solid var(--ink); font-weight: 700; font-size: .95rem; line-height: 1.5; }
.status-line[data-status="heat_high"], .status-line[data-status="ties_low"], .status-line[data-status="kupa_low"],
.status-line[data-status="service_low"], .status-line[data-status="chair_low"] { color: var(--rust); border-inline-start: 6px solid var(--rust); }
.status-line[data-status="reached"], .status-line[data-status="ok"] { color: var(--green); }

.choice { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.hints { display: flex; flex-wrap: wrap; gap: 6px; }
.hint-chip { display: inline-block; font-size: .78rem; font-weight: 700; line-height: 1.5; padding: 0 7px; border: 2px solid currentColor; }
.hint-chip.good { color: var(--green); background: rgba(47,107,68,.1); }
.hint-chip.bad { color: var(--rust); background: rgba(163,43,30,.08); }

.dialogue { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 18px; align-items: start; padding: 16px; }
.speaker { margin: 0; text-align: center; }
.speaker .px { width: 80px; height: 80px; margin: 0 auto; background: var(--cream); border: 3px solid var(--ink); }
.speaker figcaption h2 { margin: 6px 0 0; font-size: .85rem; line-height: 1.25; }
.say { position: relative; margin: 0; padding: 16px 18px; background: var(--cream); border: 3px solid var(--ink); font-size: 1.15rem; }
.say::before, .say::after { content: ''; position: absolute; top: 20px; border-block: solid transparent; border-inline-end: solid var(--ink); }
.say::before { inset-inline-start: -15px; border-block-width: 9px; border-inline-end-width: 12px; }
.say::after { inset-inline-start: -12px; top: 23px; border-block-width: 6px; border-inline-end-width: 12px; border-inline-end-color: var(--cream); }

.howto-hero { display: flex; gap: 18px; align-items: center; background: var(--paper); border: 3px solid var(--ink); box-shadow: 5px 5px 0 var(--ochre); padding: 14px 16px; margin-bottom: 20px; }
.howto-char .px { background: var(--cream); border: 3px solid var(--ink); }
.howto-name { margin: 0 0 4px; font-size: 1.4rem; }
.howto-bio { margin: 0; }
.howto-steps { list-style: none; padding: 0; margin: 0 0 20px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.howto-step { position: relative; background: var(--paper); border: 2px solid var(--ink); padding: 12px; }
.howto-step h3 { margin: 8px 0 6px; font-size: 1.05rem; }
.howto-step p { margin: 0; font-size: .92rem; line-height: 1.5; }
.howto-num { position: absolute; top: -2px; inset-inline-end: -2px; width: 26px; height: 26px; display: grid; place-items: center; background: var(--ink); color: var(--paper); font-weight: bold; }
.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(14,17,20,.78); display: grid; place-items: center; padding: 16px; overflow: auto; }
.modal { background: var(--cream); border: 4px solid var(--ink); box-shadow: 6px 6px 0 var(--shadow); width: 100%; max-width: 680px; max-height: calc(100svh - 32px); overflow: auto; padding: 20px; }
.modal h1 { font-size: 1.6rem; }
@media (max-width: 520px) {
  .status-line { padding: 8px 12px; }
  .dialogue { grid-template-columns: 72px minmax(0, 1fr); gap: 16px; padding: 12px; }
  .speaker .px { width: 64px; height: 64px; }
  .say { padding: 14px; font-size: 1.05rem; }
  .howto-hero { flex-direction: column; text-align: center; }
  .howto-steps { grid-template-columns: 1fr; }
  .howto-step { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 2px 12px; }
  .howto-step .howto-icon { grid-row: span 2; }
  .howto-step h3 { margin: 0; align-self: end; }
  .char-head > .px { width: 56px; height: 56px; }
}


/* ===== V5: intro sequence, side clips, single-row top bar ===== */
/* Scenes: each layer (.sp) is positioned in % of the logical scene size by js/clips.js. Motion is transform/opacity only.
   The BASE style of every layer is the static frame shown under prefers-reduced-motion (animations are switched off). */
.px-fill { width: 100%; height: auto; }
.scene { position: relative; display: block; overflow: hidden; direction: ltr; background: var(--sage); border: 4px solid var(--ink); width: 100%; }
.scene-intro { aspect-ratio: 320 / 180; max-width: 640px; margin: 0 auto; }
.clip-scene { aspect-ratio: 300 / 150; border-width: 3px; }
.sc-bg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sp { position: absolute; display: block; line-height: 0; transform-origin: 50% 50%; }
.sp svg { display: block; width: 100%; height: auto; }
@keyframes sc-spin { to { transform: rotate(360deg); } }

/* ----- intro screen ----- */
.story-top { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.story-skip { min-height: 44px; padding: 6px 18px; background: var(--cream); border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); font-weight: bold; }
.story-skip:hover { background: var(--paper); }
.pips { display: flex; gap: 6px; list-style: none; margin: 14px auto; padding: 0; max-width: 640px; }
.pip { position: relative; flex: 1; height: 10px; overflow: hidden; background: var(--paper); border: 2px solid var(--ink); }
.pip i { position: absolute; inset: 0; background: var(--ochre); transform: scaleX(0); transform-origin: right center; }
.pip.done i, .pip.on:last-child i { transform: scaleX(1); }
.pip.on i { animation: pip-fill 3.5s linear forwards; }
.pip.on:last-child i { animation: none; }
@keyframes pip-fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.story-text { position: relative; max-width: 640px; margin: 0 auto 18px; min-height: 3em; font-size: 1.5rem; line-height: 1.45; font-weight: 700; }
.story-ghost { visibility: hidden; }
.story-typed { position: absolute; inset: 0 0 auto 0; }
.story > .primary { max-width: 640px; margin: 0 auto; }

/* fill: many hands drop coins into the public safe */
.fl-hand { transform-origin: 50% 0; animation: fl-tip 1.75s ease-in-out infinite alternate; }
.fl-coin { opacity: 1; transform: translate(calc(var(--dx) * .45), calc(var(--dy) * .2)); animation: fl-drop 1.75s linear infinite; }
.fl-bar { transform: scaleX(.7); transform-origin: left center; animation: fl-fill 3.5s linear infinite; }
.fl-safe, .fl-door { animation: fl-thump .875s steps(1) infinite; }
@keyframes fl-tip { from { transform: rotate(-5deg); } to { transform: rotate(5deg); } }
@keyframes fl-drop {
  0% { opacity: 0; transform: translate(0, 0); }
  10% { opacity: 1; }
  45% { transform: translate(calc(var(--dx) * .7), calc(var(--dy) * .12)); }
  85% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)); }
}
@keyframes fl-fill { 0% { transform: scaleX(.03); } 92%, 100% { transform: scaleX(1); } }
@keyframes fl-thump { 50% { transform: translateY(1.2%); } }

/* form: a paper slides over the desk, a stamp comes down, the safe opens, banknotes float out */
.fo-paper { animation: fo-paper 3.5s ease-out infinite; }
.fo-hand { opacity: 1; animation: fo-hand 3.5s ease-out infinite; }
.fo-stamp { opacity: 1; animation: fo-stamp 3.5s ease-in-out infinite; }
.fo-mark { opacity: 1; animation: fo-mark 3.5s steps(1) infinite; }
.fo-door { transform: scaleX(.14); transform-origin: left center; animation: fo-door 3.5s ease-in-out infinite; }
.fo-note { opacity: 1; transform: translate(var(--sw), calc(var(--up) * .7)); animation: fo-note 3.5s ease-out infinite; }
@keyframes fo-paper { 0% { transform: translateX(var(--from)); opacity: 1; } 28%, 95% { transform: translateX(0); opacity: 1; } 100% { transform: translateX(0); opacity: 0; } }
@keyframes fo-hand { 0% { transform: translateX(var(--from)); } 28%, 40% { transform: translateX(0); } 52%, 100% { transform: translateX(var(--from)); } }
@keyframes fo-stamp {
  0%, 30% { opacity: 0; transform: translateY(-120%); }
  32% { opacity: 1; transform: translateY(-120%); }
  40%, 44% { opacity: 1; transform: translateY(0); }
  52% { opacity: 1; transform: translateY(-120%); }
  54%, 100% { opacity: 0; transform: translateY(-120%); }
}
@keyframes fo-mark { 0%, 40% { opacity: 0; } 41%, 95% { opacity: 1; } 100% { opacity: 0; } }
@keyframes fo-door { 0%, 52% { transform: scaleX(1); } 62%, 95% { transform: scaleX(.14); } 100% { transform: scaleX(1); } }
@keyframes fo-note {
  0%, 58% { opacity: 0; transform: translate(0, 0) rotate(0); }
  62% { opacity: 1; }
  80% { transform: translate(var(--sw), calc(var(--up) * .6)) rotate(8deg); }
  96% { opacity: 1; transform: translate(calc(var(--sw) * -.5), var(--up)) rotate(-6deg); }
  100% { opacity: 0; transform: translate(calc(var(--sw) * -.5), var(--up)); }
}

/* guard: Dana between tall stacks of binders; she goes from neutral to worried while the clock spins */
.gd-n { opacity: 0; animation: gd-n 3.5s steps(1) infinite; }
.gd-w { opacity: 1; animation: gd-w 3.5s steps(1) infinite; }
.gd-stack { transform-origin: 50% 100%; animation: gd-sway 2.4s ease-in-out infinite alternate; }
.gd-stack-2 { animation-delay: -1.1s; }
.gd-stamp { animation: gd-hop 1.75s ease-in-out infinite; }
.gd-min, .gd-hr { transform-origin: 50% 100%; }
.gd-min { animation: sc-spin 1.2s linear infinite; }
.gd-hr { animation: sc-spin 9.6s linear infinite; }
@keyframes gd-n { 0% { opacity: 1; } 45% { opacity: 0; } 100% { opacity: 0; } }
@keyframes gd-w { 0% { opacity: 0; } 45% { opacity: 1; } 100% { opacity: 1; } }
@keyframes gd-sway { from { transform: rotate(-.9deg); } to { transform: rotate(.9deg); } }
@keyframes gd-hop { 0%, 40%, 100% { transform: translateY(0); } 15% { transform: translateY(-22%); } }

/* choose: both characters idle (the existing bob), a question mark pops over the safe */
.ch-q { transform-origin: 50% 100%; animation: ch-pop 3.5s ease-out infinite; }
.ch-shuki { animation: ch-lean-a 1.75s ease-in-out infinite alternate; }
.ch-dana { animation: ch-lean-b 1.75s ease-in-out infinite alternate; }
@keyframes ch-pop {
  0% { opacity: 0; transform: scale(0) translateY(40%); }
  10% { opacity: 1; transform: scale(1.3) translateY(0); }
  18%, 60% { opacity: 1; transform: scale(1); }
  70% { transform: translateY(-8%); }
  80% { transform: translateY(0); }
  95% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes ch-lean-a { to { transform: translateX(3%); } }
@keyframes ch-lean-b { to { transform: translateX(-3%); } }

/* ----- side clips: one 8 second loop, four beats of 2 seconds ----- */
.clip { display: block; width: 100%; align-self: stretch; }
.clip-caps { position: relative; display: block; min-height: 3.1em; margin-top: 8px; }
.clip-cap { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center;
  font-weight: 700; font-size: 1rem; line-height: 1.3; opacity: 0; animation: cl-cap 8s infinite; animation-delay: calc(var(--i) * 2s); }
@keyframes cl-cap { 0% { opacity: 0; } 4%, 21% { opacity: 1; } 25%, 100% { opacity: 0; } }
.clip-paused *, .tab-hidden .scene *, .tab-hidden .clip-cap { animation-play-state: paused !important; }

/* attack: favour, loot, heat, spotlight */
.ca-contractor { opacity: 0; animation: ca-contractor 8s ease-in-out infinite; }
.ca-bubble { opacity: 0; transform-origin: 10% 100%; animation: ca-bubble 8s ease-out infinite; }
.ca-n { opacity: 0; animation: ca-n 8s steps(1) infinite; }
.ca-h { opacity: 1; animation: ca-h 8s steps(1) infinite; }
.ca-w { opacity: 0; animation: ca-w 8s steps(1) infinite; }
.ca-door { transform: scaleX(.14); transform-origin: left center; animation: ca-door 8s ease-in-out infinite; }
.ca-bag { opacity: 1; animation: ca-bag 8s ease-in-out infinite; }
.ca-coin { opacity: 1; transform: translate(calc(var(--cx) * .4), calc(var(--cy) * .4)); animation: ca-coin 8s ease-out infinite; }
.ca-loot { transform: scaleX(.55); transform-origin: left center; animation: ca-loot 8s ease-out infinite; }
.ca-heat { transform: scaleX(.1); transform-origin: left center; animation: ca-heat 8s ease-in infinite; }
.ca-eye { opacity: 0; animation: ca-eye 8s ease-out infinite; }
.ca-cone { opacity: 0; transform-origin: 50% 0; animation: ca-cone 8s ease-in-out infinite; }
@keyframes ca-contractor {
  0% { opacity: 0; transform: translateX(-60%); }
  4% { opacity: 1; transform: translateX(0); }
  9% { transform: translateX(14%) rotate(6deg); }
  12%, 22% { opacity: 1; transform: translateX(12%) rotate(0); }
  26%, 100% { opacity: 0; transform: translateX(12%); }
}
@keyframes ca-bubble { 0%, 5% { opacity: 0; transform: scale(0); } 8% { opacity: 1; transform: scale(1.2); } 10%, 22% { opacity: 1; transform: scale(1); } 25%, 100% { opacity: 0; transform: scale(1); } }
@keyframes ca-n { 0%, 24% { opacity: 1; } 25%, 49% { opacity: 0; } 50%, 69% { opacity: 1; } 70%, 99% { opacity: 0; } 100% { opacity: 1; } }
@keyframes ca-h { 0%, 24% { opacity: 0; } 25%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes ca-w { 0%, 69% { opacity: 0; } 70%, 97% { opacity: 1; } 98%, 100% { opacity: 0; } }
@keyframes ca-door { 0%, 24% { transform: scaleX(1); } 28%, 96% { transform: scaleX(.14); } 100% { transform: scaleX(1); } }
@keyframes ca-bag {
  0%, 25% { opacity: 0; transform: translate(-190%, -20%); }
  26% { opacity: 1; transform: translate(-190%, -20%); }
  33% { transform: translate(-100%, -110%); }
  40%, 96% { opacity: 1; transform: translate(0, 0); }
  99%, 100% { opacity: 0; transform: translate(0, 0); }
}
@keyframes ca-coin {
  0%, 27% { opacity: 0; transform: translate(0, 0); }
  29% { opacity: 1; }
  38% { transform: translate(calc(var(--cx) * .5), calc(var(--cy) * 1.1)); }
  46% { opacity: 1; transform: translate(var(--cx), var(--cy)); }
  48%, 100% { opacity: 0; transform: translate(var(--cx), var(--cy)); }
}
@keyframes ca-loot { 0%, 25% { transform: scaleX(.06); } 44%, 96% { transform: scaleX(.55); } 100% { transform: scaleX(.06); } }
@keyframes ca-heat { 0%, 50% { transform: scaleX(.1); } 72%, 96% { transform: scaleX(.9); } 100% { transform: scaleX(.1); } }
@keyframes ca-eye { 0%, 52% { opacity: 0; transform: translateY(-80%); } 58%, 96% { opacity: 1; transform: translateY(0); } 99%, 100% { opacity: 0; transform: translateY(0); } }
@keyframes ca-cone {
  0%, 58% { opacity: 0; transform: rotate(-35deg); }
  62% { opacity: .55; transform: rotate(-35deg); }
  72% { transform: rotate(28deg); }
  77%, 96% { opacity: .55; transform: rotate(0); }
  99%, 100% { opacity: 0; transform: rotate(0); }
}

/* defend: a request is stamped "rejected", a leaking roof is stamped "approved", the safe stays shut */
.cd-hand { opacity: 0; animation: cd-hand 8s ease-out infinite; }
.cd-p1 { opacity: 1; animation: cd-p1 8s ease-out infinite; }
.cd-p2 { opacity: 0; animation: cd-p2 8s ease-out infinite; }
.cd-drop { opacity: 0; animation: cd-drop 8s ease-in infinite; }
.cd-stamp1 { opacity: 1; animation: cd-stamp1 8s ease-in-out infinite; }
.cd-stamp2 { opacity: 0; animation: cd-stamp2 8s ease-in-out infinite; }
.cd-m1 { opacity: 1; animation: cd-m1 8s steps(1) infinite; }
.cd-m2 { opacity: 0; animation: cd-m2 8s steps(1) infinite; }
.cd-n { opacity: 1; animation: cd-n 8s steps(1) infinite; }
.cd-h { opacity: 0; animation: cd-h 8s steps(1) infinite; }
.cd-sky { opacity: 0; animation: cd-sky 8s ease-out infinite; }
.cd-tw svg { animation: cd-twinkle 1s steps(1) infinite; }
.cd-spark { opacity: 0; animation: cd-spark 8s ease-in-out infinite; }
@keyframes cd-hand {
  0% { opacity: 1; transform: translateX(var(--from)); }
  12%, 16% { opacity: 1; transform: translateX(0); }
  22% { opacity: 1; transform: translateX(var(--from)); }
  23%, 100% { opacity: 0; transform: translateX(var(--from)); }
}
@keyframes cd-p1 {
  0% { opacity: 1; transform: translateX(var(--from)); }
  12%, 46% { opacity: 1; transform: translateX(0); }
  52%, 100% { opacity: 0; transform: translateX(var(--from)); }
}
@keyframes cd-p2 {
  0%, 50% { opacity: 0; transform: translateX(var(--from)); }
  51% { opacity: 1; transform: translateX(var(--from)); }
  58%, 77% { opacity: 1; transform: translateX(0); }
  81%, 100% { opacity: 0; transform: translateY(40%); }
}
@keyframes cd-drop {
  0%, 58% { opacity: 0; transform: translateY(0); }
  60% { opacity: 1; }
  66% { opacity: 1; transform: translateY(260%); }
  67% { opacity: 0; transform: translateY(260%); }
  68%, 70% { opacity: 0; transform: translateY(0); }
  71% { opacity: 1; }
  77% { opacity: 1; transform: translateY(260%); }
  78%, 100% { opacity: 0; transform: translateY(260%); }
}
@keyframes cd-stamp1 {
  0%, 27% { opacity: 0; transform: translateY(-120%); }
  29% { opacity: 1; transform: translateY(-120%); }
  33%, 36% { opacity: 1; transform: translateY(0); }
  41% { opacity: 1; transform: translateY(-120%); }
  43%, 100% { opacity: 0; transform: translateY(-120%); }
}
@keyframes cd-stamp2 {
  0%, 59% { opacity: 0; transform: translateY(-120%); }
  61% { opacity: 1; transform: translateY(-120%); }
  64%, 67% { opacity: 1; transform: translateY(0); }
  72% { opacity: 1; transform: translateY(-120%); }
  74%, 100% { opacity: 0; transform: translateY(-120%); }
}
@keyframes cd-m1 { 0%, 32% { opacity: 0; transform: scale(1.5); } 35%, 47% { opacity: 1; transform: scale(1); } 50%, 100% { opacity: 0; transform: scale(1); } }
@keyframes cd-m2 { 0%, 63% { opacity: 0; transform: scale(1.5); } 66%, 77% { opacity: 1; transform: scale(1); } 80%, 100% { opacity: 0; transform: scale(1); } }
@keyframes cd-n { 0%, 74% { opacity: 1; } 75%, 98% { opacity: 0; } 100% { opacity: 1; } }
@keyframes cd-h { 0%, 74% { opacity: 0; } 75%, 98% { opacity: 1; } 100% { opacity: 0; } }
@keyframes cd-sky { 0%, 74% { opacity: 0; transform: translateY(30%); } 80%, 96% { opacity: 1; transform: translateY(0); } 99%, 100% { opacity: 0; transform: translateY(0); } }
@keyframes cd-twinkle { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
@keyframes cd-spark {
  0%, 76% { opacity: 0; transform: scale(0); }
  80% { opacity: 1; transform: scale(1.2); }
  83%, 89% { opacity: 1; transform: scale(.7); }
  86% { opacity: 1; transform: scale(1.1); }
  92%, 96% { opacity: 1; transform: scale(1); }
  99%, 100% { opacity: 0; transform: scale(1); }
}

/* side card with a clip on top */
.side-card .clip { margin-bottom: 2px; }

@media (prefers-reduced-motion: reduce) {
  /* no typewriter, no auto-advance: the current pip is simply full */
  .pip.on i { transform: scaleX(1); }
  /* clips: beat 2 as a static frame, all four caption lines listed */
  .clip-caps { min-height: 0; }
  .clip-cap { position: static; display: block; opacity: 1; padding: 2px 0; text-align: start; font-weight: 400; font-size: .95rem; }
}

/* secondary button (how-to overlay: replay the intro) */
.secondary { display: block; width: 100%; margin-top: 16px; padding: 12px 16px; background: var(--cream); color: var(--ink); border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); font-weight: bold; }
.secondary:hover { background: var(--paper); }
.secondary + .primary { margin-top: 12px; }

/* top bar: one row at 360px; the title truncates, avatar, sound and "?" stay */
.topbar { flex-wrap: nowrap; }
.topbar > span:first-child { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sound-toggle, .howto-open, .top-player { flex: none; }
@media (max-width: 520px) {
  .topbar { padding: 10px 12px; gap: 6px; }
  .cabinet-lights { display: none; }
  .top-player { gap: 6px; }
  .top-player > span:last-child { max-width: 5.5em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .story-text { font-size: 1.3rem; }
}
