/* ============================================================
   CODE IS LAW — playable whitepaper
   The paper's palette at night: ink bg, cream text, clay accent.
   z-scale: stage 10 < hud 20 < overlay/modal 30 < fx 40 < crt 50 < boot 60
   ============================================================ */

:root {
  --void: #0c0a07;          /* page behind the cabinet */
  --ink: #14110c;           /* paper --ink, used as game bg */
  --ink-2: #1d1812;         /* raised surfaces */
  --ink-3: #29221a;         /* higher surfaces / borders soft */
  --cream: #f6f1e6;         /* paper --paper, used as text */
  --cream-dim: #c9c0ab;
  --cream-faint: #8d8470;
  --clay: #b94e2c;          /* paper --accent */
  --clay-bright: #e06a40;
  --blood: #d23b2f;
  --gold: #e8c558;
  --good: #8fc97a;
  --sky: #7da7c9;

  --font-pixel: 'Press Start 2P', monospace;
  --font-body: 'VT323', monospace;

  --bevel: 3px;
}

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

html, body { height: 100%; }

body {
  background: var(--void);
  background-image: radial-gradient(ellipse at 50% 40%, #16120c 0%, var(--void) 70%);
  color: var(--cream);
  font-family: var(--font-body);
  font-size: 22px;
  line-height: 1.35;
  display: flex;
  justify-content: center;
  overflow: hidden;
  -webkit-font-smoothing: none;
}

button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input { font-family: inherit; color: inherit; }

/* ---------- cabinet frame ---------- */

#frame {
  position: relative;
  width: min(100vw, 840px);
  height: 100dvh;
  background: var(--ink);
  overflow: hidden;
  box-shadow: 0 0 0 3px #000, 0 0 80px rgba(185, 78, 44, 0.08);
}

/* ---------- boot screen ---------- */

#boot {
  position: absolute; inset: 0; z-index: 60;
  background: var(--void);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.3s steps(4);
}
#boot.is-done { opacity: 0; pointer-events: none; }
.boot-cursor {
  width: 14px; height: 26px; background: var(--cream);
  animation: blink 1s steps(1) infinite;
}

/* ---------- CRT overlay ---------- */

.crt {
  position: absolute; inset: 0; z-index: 50; pointer-events: none;
  background:
    repeating-linear-gradient(0deg,
      rgba(0,0,0,0.22) 0px, rgba(0,0,0,0.22) 1px,
      transparent 1px, transparent 3px);
}
.crt::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 58%, rgba(0,0,0,0.42) 100%);
}

/* ---------- HUD ---------- */

.hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px;
  background: var(--ink-2);
  border-bottom: var(--bevel) solid var(--ink-3);
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: 0.04em;
  min-height: 42px;
}
.hud.is-hidden { display: none; }
.hud-act { color: var(--cream-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-stats { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: flex-end; }
.hud-money { color: var(--gold); white-space: nowrap; }
.hud-money-label { color: var(--cream-faint); }
.hud-money.is-flash { animation: hudflash 0.5s steps(3); }
.hud-wounds { color: var(--blood); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.hud-recovered { color: var(--good); white-space: nowrap; }
.hud-recovered.is-hidden, .hud-money.is-hidden { display: none; }
.hud-btns { display: flex; gap: 8px; }
.hud-btn {
  font-family: var(--font-pixel); font-size: 8px;
  color: var(--cream-dim);
  padding: 6px 8px;
  border: 2px solid var(--ink-3);
  background: var(--ink);
}
.hud-btn:hover { color: var(--cream); border-color: var(--cream-faint); }
.hud-btn.is-hidden { display: none; }

.hud-sword { width: 14px; height: 28px; }
.sw-blade { fill: var(--cream-dim); }
.sw-core { fill: var(--cream); }
.sw-tip { fill: var(--cream); }
.sw-guard { fill: var(--clay); }
.sw-hilt { fill: #7a5b3a; }
.sw-pommel { fill: var(--clay); }
.sw-crack { fill: var(--ink); opacity: 0; }
.sw-crack.is-on { opacity: 1; }

@keyframes hudflash { 0%,100% { color: var(--gold); } 50% { color: var(--blood); } }

/* ---------- stage ---------- */

#stage {
  position: absolute; inset: 0; z-index: 10;
  padding: 58px 18px 170px;
  overflow-y: auto;
  scrollbar-width: none;
}
#stage::-webkit-scrollbar { display: none; }

.scene { display: flex; flex-direction: column; gap: 14px; min-height: 100%; }
.scene > .spacer { flex: 1; }

/* generic panel */
.panel {
  background: var(--ink-2);
  border: var(--bevel) solid var(--ink-3);
  box-shadow: 4px 4px 0 rgba(0,0,0,0.45);
  padding: 14px 16px;
  animation: rise 0.22s steps(4) both;
}
.panel.is-center { text-align: center; }
.panel.is-plain { background: none; border-color: transparent; box-shadow: none; }
.panel-title {
  font-family: var(--font-pixel); font-size: 10px; color: var(--clay-bright);
  margin-bottom: 10px; letter-spacing: 0.06em;
}
.panel .muted { color: var(--cream-faint); }
.panel .good { color: var(--good); }
.panel .bad { color: var(--blood); }
.panel .gold { color: var(--gold); }

@keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- dialogue box ---------- */

.dlg {
  position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 15;
  background: var(--ink);
  border: var(--bevel) solid var(--cream);
  box-shadow: 0 0 0 3px var(--ink), 6px 6px 0 rgba(0,0,0,0.5);
  padding: 12px 16px 14px;
  min-height: 96px;
  cursor: pointer;
  user-select: none;
}
.dlg-speaker {
  position: absolute; top: -12px; left: 10px;
  font-family: var(--font-pixel); font-size: 9px;
  background: var(--clay); color: var(--cream);
  padding: 4px 8px;
  border: 2px solid var(--ink);
}
.dlg-speaker:empty { display: none; }
.dlg-text { font-size: 24px; line-height: 1.25; min-height: 60px; }
.dlg-text em { color: var(--gold); font-style: normal; }
.dlg-text strong { color: var(--clay-bright); font-weight: normal; }
.dlg-next {
  position: absolute; right: 12px; bottom: 8px;
  color: var(--clay-bright); font-size: 20px;
  animation: bob 0.7s steps(2) infinite;
  opacity: 0;
}
.dlg.is-revealed .dlg-next { opacity: 1; }

@keyframes bob { 0% { transform: translateY(0); } 50% { transform: translateY(3px); } }
@keyframes blink { 0%, 60% { opacity: 1; } 61%, 100% { opacity: 0; } }

/* ---------- choice menu ---------- */

.menu {
  background: var(--ink);
  border: var(--bevel) solid var(--cream);
  box-shadow: 6px 6px 0 rgba(0,0,0,0.5);
  padding: 10px 12px;
  animation: rise 0.18s steps(3) both;
}
.menu-title { font-family: var(--font-pixel); font-size: 9px; color: var(--cream-faint); padding: 4px 6px 10px; }
.menu-item {
  display: block; width: 100%; text-align: left;
  font-size: 24px; line-height: 1.2;
  padding: 9px 10px 9px 34px;
  position: relative;
  color: var(--cream);
  min-height: 44px;
}
.menu-item .hint { color: var(--cream-faint); font-size: 19px; display: block; }
.menu-item.is-sel { background: var(--ink-2); color: var(--gold); }
.menu-item.is-sel::before {
  content: '►'; position: absolute; left: 10px; color: var(--clay-bright);
  animation: bobx 0.5s steps(2) infinite;
}
.menu-item:disabled { color: var(--cream-faint); cursor: not-allowed; text-decoration: line-through; }
@keyframes bobx { 0% { transform: translateX(0); } 50% { transform: translateX(2px); } }

/* dialogue-anchored menus sit above the dlg box */
.menu.is-floating { position: absolute; right: 12px; bottom: 124px; z-index: 16; min-width: min(420px, 70%); }

/* ---------- pixel buttons ---------- */

.pxbtn {
  display: inline-block;
  font-family: var(--font-pixel); font-size: 11px;
  color: var(--cream);
  background: var(--ink-3);
  border: 3px solid var(--cream-dim);
  box-shadow: 0 4px 0 rgba(0,0,0,0.6);
  padding: 12px 16px 11px;
  text-align: center;
  min-height: 44px;
  text-decoration: none;
}
.pxbtn:hover { border-color: var(--cream); background: #332a1f; }
.pxbtn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,0.6); }
.pxbtn-primary { background: var(--clay); border-color: var(--clay-bright); }
.pxbtn-primary:hover { background: var(--clay-bright); border-color: var(--cream); }
.pxbtn-good { background: #2c4423; border-color: var(--good); }
.pxbtn-ghost { background: none; border-color: var(--ink-3); color: var(--cream-dim); }
.pxbtn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.pxbtn-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------- modal ---------- */

#overlay { position: absolute; inset: 0; z-index: 30; pointer-events: none; }
#overlay > * { pointer-events: auto; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(5, 4, 2, 0.72);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: fadein 0.15s steps(3) both;
}
.pmodal {
  width: min(440px, 100%);
  background: var(--ink-2);
  border: var(--bevel) solid var(--cream);
  box-shadow: 8px 8px 0 rgba(0,0,0,0.6);
  animation: rise 0.18s steps(3) both;
}
.pmodal-head {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--font-pixel); font-size: 9px;
  background: var(--ink-3); color: var(--cream);
  padding: 9px 12px;
  border-bottom: 3px solid var(--ink);
}
.pmodal-head .dots { color: var(--cream-faint); letter-spacing: 2px; }
.pmodal-body { padding: 14px 16px; font-size: 22px; }
.pmodal-actions { display: flex; gap: 10px; padding: 0 16px 16px; }
.pmodal-actions .pxbtn { flex: 1; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* wallet popup rows */
.wallet-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 7px 0;
  border-bottom: 2px dotted var(--ink-3);
  font-size: 21px;
}
.wallet-row:last-child { border-bottom: none; }
.wallet-row .k { color: var(--cream-faint); white-space: nowrap; }
.wallet-row .v { text-align: right; overflow-wrap: anywhere; }
.wallet-row .v.warn { color: var(--gold); }
.wallet-action { font-size: 26px; color: var(--cream); padding: 8px 0 10px; text-align: center; }
.wallet-data { cursor: pointer; text-decoration: underline; text-decoration-style: dotted; color: var(--sky); }

/* hex dump */
.hexdump {
  font-family: var(--font-body); font-size: 18px; line-height: 1.3;
  color: var(--cream-faint);
  background: var(--ink);
  border: 2px solid var(--ink-3);
  padding: 10px;
  max-height: 180px; overflow: hidden;
  overflow-wrap: anywhere;
  position: relative;
}
.hexdump::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 60px;
  background: linear-gradient(transparent, var(--ink));
}

/* ---------- lesson card ---------- */

.lesson-wrap {
  position: absolute; inset: 0; z-index: 30;
  background: rgba(5, 4, 2, 0.85);
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
  animation: fadein 0.25s steps(4) both;
  overflow-y: auto;
}
.lesson {
  width: min(560px, 100%);
  background: var(--cream);
  color: var(--ink);
  border: var(--bevel) solid var(--ink);
  box-shadow: 0 0 0 3px var(--cream-faint), 10px 10px 0 rgba(0,0,0,0.6);
  padding: 22px 24px;
  margin: auto;
}
.lesson-label {
  font-family: var(--font-pixel); font-size: 10px;
  color: var(--cream); background: var(--clay);
  display: inline-block; padding: 5px 9px;
  margin-bottom: 16px;
}
.lesson-quote { font-size: 27px; line-height: 1.22; }
.lesson-quote::before { content: '“'; color: var(--clay); }
.lesson-quote::after { content: '”'; color: var(--clay); }
.lesson-cite { margin-top: 12px; font-size: 19px; color: #6b6250; }
.lesson-fact {
  margin-top: 14px; padding: 10px 12px;
  background: #ece5d4; border-left: 4px solid var(--clay);
  font-size: 20px; color: #4a4334;
}
.lesson-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.lesson-actions .pxbtn { box-shadow: 0 4px 0 rgba(20,17,12,0.35); font-size: 10px; }
.lesson-link { background: none; border-color: #b3a98f; color: #4a4334; }
.lesson-link:hover { border-color: var(--ink); background: #ece5d4; }

/* ---------- ticker ---------- */

.ticker {
  position: absolute; top: 42px; left: 0; right: 0; z-index: 14;
  background: var(--ink);
  border-bottom: 2px solid var(--ink-3);
  overflow: hidden;
  white-space: nowrap;
  font-size: 20px;
  color: var(--gold);
  padding: 4px 0;
}
.ticker.is-breaking { color: var(--blood); border-color: var(--blood); }
.ticker-inner { display: inline-block; padding-left: 100%; animation: tick 18s linear infinite; }
.ticker-inner span { margin-right: 48px; }
@keyframes tick { to { transform: translateX(-100%); } }

/* ---------- bars ---------- */

.bar {
  position: relative; height: 26px;
  background: var(--ink);
  border: 3px solid var(--cream-dim);
}
.bar-fill {
  position: absolute; top: 0; left: 0; bottom: 0;
  background: var(--blood);
  transition: width 0.6s steps(8);
}
.bar-fill.is-good { background: var(--good); }
.bar-fill.is-gold { background: var(--gold); }
.bar-label {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-pixel); font-size: 9px;
  color: var(--cream); text-shadow: 1px 1px 0 #000;
}

/* ---------- chart box ---------- */

.chartbox { background: var(--ink); border: 3px solid var(--ink-3); padding: 6px; }
.chartbox canvas { display: block; width: 100%; image-rendering: pixelated; }
.chartbox .chart-caption { font-size: 18px; color: var(--cream-faint); padding: 4px 4px 0; }

/* ---------- shop ---------- */

.shop { display: flex; flex-direction: column; gap: 8px; }
.shop-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  text-align: left;
  background: var(--ink);
  border: 3px solid var(--ink-3);
  padding: 10px 12px;
  font-size: 22px;
  color: var(--cream);
  min-height: 52px;
}
.shop-item:hover:not(:disabled) { border-color: var(--cream-dim); background: var(--ink-2); }
.shop-item:disabled { cursor: not-allowed; opacity: 0.55; }
.shop-item.is-bought { border-color: var(--good); opacity: 0.7; }
.shop-item .shop-name { flex: 1; }
.shop-item .shop-note { display: block; font-size: 18px; color: var(--cream-faint); }
.shop-item .shop-cost { color: var(--gold); white-space: nowrap; font-size: 20px; }
.shop-item.is-bought .shop-cost { color: var(--good); }

/* stat strip (runway / month / tvl dashboards) */
.stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat {
  flex: 1; min-width: 110px;
  background: var(--ink); border: 3px solid var(--ink-3);
  padding: 8px 10px; text-align: center;
}
.stat .stat-k { font-family: var(--font-pixel); font-size: 8px; color: var(--cream-faint); display: block; margin-bottom: 6px; }
.stat .stat-v { font-size: 26px; color: var(--gold); }
.stat .stat-v.bad { color: var(--blood); }
.stat .stat-v.good { color: var(--good); }

/* ---------- badges ---------- */

.badges { display: flex; gap: 8px; flex-wrap: wrap; }
.badge {
  font-size: 18px; color: var(--good);
  border: 2px solid #3c5530; background: #1a2415;
  padding: 3px 8px;
}
.badge.is-dead { color: var(--blood); border-color: #553030; background: #241515; text-decoration: line-through; }

/* ---------- tx log / terminal ---------- */

.txlog {
  background: var(--ink);
  border: 3px solid var(--ink-3);
  padding: 10px 12px;
  font-size: 20px;
  line-height: 1.45;
  color: var(--cream-dim);
  min-height: 40px;
}
.txlog .ok { color: var(--good); }
.txlog .err { color: var(--blood); }
.txlog .warn { color: var(--gold); }
.txlog div { overflow-wrap: anywhere; }

/* ---------- countdown ---------- */

.countdown {
  font-family: var(--font-pixel);
  font-size: 26px;
  color: var(--blood);
  text-align: center;
  padding: 8px 0;
}
.countdown.is-calm { color: var(--gold); }
.countdown .countdown-label { display: block; font-size: 9px; color: var(--cream-faint); margin-bottom: 8px; }

/* ---------- rekt overlay ---------- */

.rekt {
  position: absolute; inset: 0; z-index: 32;
  background: #1a0805;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 20px; text-align: center;
  animation: fadein 0.2s steps(3) both;
  cursor: pointer;
}
.rekt-wound { font-family: var(--font-pixel); font-size: 12px; color: var(--blood); letter-spacing: 0.2em; }
.rekt-title { font-family: var(--font-pixel); font-size: clamp(16px, 4.4vw, 30px); color: var(--cream); line-height: 1.6; }
.rekt-sub { font-size: 24px; color: var(--cream-dim); max-width: 460px; }
.rekt-hint { font-size: 19px; color: var(--cream-faint); animation: blink 1.2s steps(1) infinite; }
.rekt .hud-sword { width: 28px; height: 56px; }

/* ---------- title screen ---------- */

.titlewrap {
  min-height: calc(100dvh - 240px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 26px; text-align: center; padding-top: 30px;
}
.title-eyebrow { font-family: var(--font-pixel); font-size: 9px; color: var(--cream-faint); letter-spacing: 0.3em; }
.title-big {
  font-family: var(--font-pixel);
  font-size: clamp(26px, 7.4vw, 58px);
  line-height: 1.35;
  color: var(--cream);
  text-shadow: 4px 4px 0 var(--clay), 8px 8px 0 rgba(0,0,0,0.55);
}
.title-big .flicker { animation: lawflicker 6s steps(1) infinite; }
.title-sub { font-size: 24px; color: var(--cream-dim); }
.title-start { animation: blink 1.3s steps(1) infinite; }
.title-foot { font-size: 18px; color: var(--cream-faint); }
@keyframes lawflicker {
  0%, 91%, 95%, 100% { opacity: 1; }
  92%, 94% { opacity: 0.25; }
}
.title-big .ghost {
  opacity: 0;
  color: var(--clay-bright);
  text-shadow: none;
  animation: ghostpulse 3s ease-in-out infinite;
}
.title-big .ghost + .ghost, .title-big .ghost:last-child { animation-delay: 1.5s; }
@keyframes ghostpulse {
  0%, 100% { opacity: 0; }
  50% { opacity: 0.75; }
}
.title-big.is-flawed .ghost { opacity: 1; animation: none; color: var(--cream); text-shadow: inherit; }

/* glitch text morph (epilogue) */
.glitching { animation: glitchpos 0.09s steps(2) infinite; }
@keyframes glitchpos {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-3px, 1px); }
  50% { transform: translate(2px, -2px); }
  75% { transform: translate(-1px, 2px); }
}

/* ---------- item get ---------- */

.itemget {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 22px 16px; text-align: center;
  border: var(--bevel) solid var(--gold);
  background: radial-gradient(ellipse at 50% 30%, #2a2210 0%, var(--ink-2) 70%);
  box-shadow: 6px 6px 0 rgba(0,0,0,0.5);
  animation: rise 0.3s steps(5) both;
}
.itemget .hud-sword { width: 42px; height: 88px; filter: drop-shadow(0 0 8px rgba(232,197,88,0.45)); }
.itemget-name { font-family: var(--font-pixel); font-size: 12px; color: var(--gold); line-height: 1.7; }
.itemget-stats { font-size: 22px; color: var(--cream-dim); }
.itemget-flavor { font-size: 21px; color: var(--cream-faint); max-width: 430px; }

/* ---------- graveyard ---------- */

.graveyard {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px; align-items: end;
  padding: 18px 8px 0;
}
.tombstone {
  background: var(--ink-3);
  border: 3px solid var(--cream-faint);
  border-bottom: none;
  border-radius: 14px 14px 0 0;
  padding: 16px 8px 12px;
  text-align: center;
  font-size: 18px; line-height: 1.3;
  color: var(--cream-dim);
  animation: rise 0.3s steps(4) both;
}
.tombstone .rip { font-family: var(--font-pixel); font-size: 9px; color: var(--cream); display: block; margin-bottom: 8px; }
.tombstone .cause { color: var(--cream-faint); font-size: 17px; }
.tombstone.is-open {
  background: none; border: 3px dashed var(--clay); border-bottom: none;
  color: var(--clay-bright);
}
.grass { height: 6px; background: #2c3a22; border-top: 2px solid #43552f; margin: 0 -16px; }

/* ---------- two-edges figure ---------- */

.edges {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px;
  align-items: stretch;
}
.edges-col { display: flex; flex-direction: column; gap: 8px; justify-content: center; }
.edges-col .edges-label { font-family: var(--font-pixel); font-size: 9px; margin-bottom: 4px; }
.edges-col.is-good .edges-label { color: var(--good); }
.edges-col.is-bad .edges-label { color: var(--blood); }
.edges-col ul { list-style: none; font-size: 20px; line-height: 1.3; }
.edges-col.is-good li::before { content: '+ '; color: var(--good); }
.edges-col.is-bad li::before { content: '− '; color: var(--blood); }
.edges-col.is-bad { text-align: right; }
.edges-blade { display: flex; align-items: center; }
.edges-blade .hud-sword { width: 34px; height: 150px; }

/* ---------- policy cards ---------- */

.policy-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.policy-card {
  text-align: left;
  background: var(--ink);
  border: 3px solid var(--ink-3);
  padding: 12px;
  color: var(--cream);
  font-size: 19px;
  display: flex; flex-direction: column; gap: 8px;
}
.policy-card:hover { border-color: var(--gold); background: var(--ink-2); transform: translateY(-2px); }
.policy-card .pc-name { font-family: var(--font-pixel); font-size: 10px; color: var(--gold); line-height: 1.6; }
.policy-card .pc-tag { font-size: 18px; color: var(--clay-bright); }
.policy-card dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 18px; }
.policy-card dt { color: var(--cream-faint); }
.policy-card dd { color: var(--cream-dim); }

/* ---------- npc card ---------- */

.npc {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--ink-2); border: var(--bevel) solid var(--ink-3);
  box-shadow: 4px 4px 0 rgba(0,0,0,0.45);
  padding: 14px;
  animation: rise 0.25s steps(4) both;
}
.npc-face {
  width: 56px; height: 56px; flex: none;
  border: 3px solid var(--cream-dim);
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
  background: var(--ink);
  image-rendering: pixelated;
}
.npc-info { flex: 1; }
.npc-name { font-family: var(--font-pixel); font-size: 10px; color: var(--sky); margin-bottom: 6px; }
.npc-bag { font-size: 18px; color: var(--cream-faint); }

/* ---------- pending exit queue (act 6) ---------- */

.queue-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--ink); border: 3px solid var(--ink-3);
  padding: 10px 12px; font-size: 20px;
}
.queue-row .q-id { color: var(--cream-faint); }
.queue-row .q-time { font-family: var(--font-pixel); font-size: 11px; color: var(--gold); }
.queue-row.is-cancelled { border-color: var(--blood); }
.queue-row.is-cancelled .q-time { color: var(--blood); }

/* ---------- score / epilogue ---------- */

.score-table { width: 100%; border-collapse: collapse; font-size: 22px; }
.score-table td { padding: 7px 6px; border-bottom: 2px dotted var(--ink-3); }
.score-table td:last-child { text-align: right; }
.score-table .lost { color: var(--blood); }
.score-table .won { color: var(--good); }
.score-table tr.total td { font-family: var(--font-pixel); font-size: 10px; padding-top: 14px; border-bottom: none; }

/* ---------- fx layer ---------- */

#fx-layer { position: absolute; inset: 0; z-index: 40; pointer-events: none; overflow: hidden; }

.coin {
  position: absolute;
  width: 12px; height: 12px;
  background: var(--gold);
  box-shadow: 0 0 0 2px #9a7e2c inset;
  transition: transform 0.9s cubic-bezier(.2,-0.4,.8,1), opacity 0.9s steps(6);
}
.confetto {
  position: absolute;
  width: 8px; height: 8px;
  transition: transform 1.6s linear, opacity 1.6s steps(8);
}
.flash {
  position: absolute; inset: 0;
  background: var(--cream);
  animation: flashout 0.35s steps(4) both;
}
.flash.is-red { background: var(--blood); }
@keyframes flashout { from { opacity: 0.85; } to { opacity: 0; } }

#frame.is-shaking { animation: shake 0.45s steps(12); }
@keyframes shake {
  0%,100% { transform: translate(0,0); }
  10% { transform: translate(-6px,2px); } 20% { transform: translate(5px,-3px); }
  30% { transform: translate(-4px,-2px); } 40% { transform: translate(6px,3px); }
  50% { transform: translate(-5px,1px); } 60% { transform: translate(4px,-2px); }
  70% { transform: translate(-3px,3px); } 80% { transform: translate(3px,-1px); }
  90% { transform: translate(-2px,1px); }
}

.glitch-el { animation: glitchclip 0.5s steps(8) both; }
@keyframes glitchclip {
  0% { clip-path: inset(0 0 0 0); transform: translateX(0); filter: none; }
  20% { clip-path: inset(20% 0 40% 0); transform: translateX(-8px); filter: invert(1); }
  40% { clip-path: inset(60% 0 10% 0); transform: translateX(8px); }
  60% { clip-path: inset(10% 0 70% 0); transform: translateX(-5px); filter: invert(1); }
  80% { clip-path: inset(40% 0 30% 0); transform: translateX(5px); }
  100% { clip-path: inset(0 0 0 0); transform: translateX(0); filter: none; }
}

/* crumble (the UNDO button) */
.crumbling { animation: crumble 0.8s steps(8) both; }
@keyframes crumble {
  0% { transform: none; opacity: 1; }
  30% { transform: translateY(2px) rotate(-2deg); }
  60% { transform: translateY(8px) rotate(3deg) scaleY(0.7); opacity: 0.7; }
  100% { transform: translateY(26px) rotate(-6deg) scaleY(0.1); opacity: 0; }
}

/* sword swing */
.swing-wrap { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.swing-wrap .hud-sword { width: 60px; height: 130px; transform-origin: 50% 90%; animation: swing 0.55s steps(7) both; }
@keyframes swing {
  0% { transform: rotate(-110deg); opacity: 0; }
  25% { transform: rotate(-90deg); opacity: 1; }
  60% { transform: rotate(40deg); }
  75% { transform: rotate(160deg); }   /* the backswing */
  100% { transform: rotate(200deg); opacity: 0; }
}

/* ---------- inputs ---------- */

.pxinput {
  background: var(--ink);
  border: 3px solid var(--cream-dim);
  color: var(--gold);
  font-size: 28px;
  padding: 8px 12px;
  width: min(280px, 100%);
  text-align: center;
  outline: none;
}
.pxinput:focus { border-color: var(--gold); }

/* ---------- loop diagram (act 5) ---------- */

.loop { text-align: center; font-size: 21px; line-height: 1.7; color: var(--cream-dim); }
.loop .loop-arrow { color: var(--clay-bright); }

/* ---------- split compare (act 6) ---------- */

.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.compare-col { background: var(--ink); border: 3px solid var(--ink-3); padding: 12px; font-size: 20px; }
.compare-col h4 { font-family: var(--font-pixel); font-size: 9px; margin-bottom: 10px; line-height: 1.6; }
.compare-col.is-before h4 { color: var(--blood); }
.compare-col.is-after h4 { color: var(--good); }
.compare-col ul { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.compare-col.is-before li::before { content: '✗ '; color: var(--blood); }
.compare-col.is-after li::before { content: '✓ '; color: var(--good); }

/* ---------- utility ---------- */

.is-hidden { display: none !important; }
.center { text-align: center; }
.small { font-size: 18px; }
.spacer { flex: 1; }

/* ---------- mobile ---------- */

@media (max-width: 560px) {
  body { font-size: 20px; }
  #stage { padding: 96px 10px 175px; }
  .hud { flex-wrap: wrap; min-height: 0; padding: 6px 8px; gap: 6px; }
  .hud-act { width: 100%; font-size: 8px; }
  .hud-stats { gap: 10px; font-size: 8px; }
  .ticker { top: 64px; }
  .dlg { left: 8px; right: 8px; bottom: 8px; }
  .dlg-text { font-size: 21px; }
  .menu.is-floating { left: 8px; right: 8px; min-width: 0; }
  .menu-item { font-size: 21px; }
  .compare { grid-template-columns: 1fr; }
  .edges-col.is-bad { text-align: left; }
  .title-big { font-size: clamp(22px, 9vw, 40px); }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .panel, .menu, .pmodal, .itemget, .tombstone, .npc { animation: none; }
  .ticker-inner { animation: none; padding-left: 0; white-space: normal; }
  .dlg-next, .title-start, .rekt-hint, .boot-cursor { animation: none; opacity: 1; }
  .menu-item.is-sel::before { animation: none; }
  .title-big .flicker { animation: none; }
  #frame.is-shaking { animation: none; }
  .glitch-el, .glitching { animation: none; }
  .coin, .confetto { transition: none; opacity: 0; }
  .flash { animation-duration: 0.01s; }
  .bar-fill { transition: none; }
  .swing-wrap .hud-sword { animation: none; opacity: 0; }
  .crumbling { animation: crumble 0.01s steps(1) both; }
}
