/* KING PILE — dark console, one gold accent, crimson for danger, royal display type. */
:root {
  --bg: #0a0a0b;
  --ink: #0b0b0c;
  --panel: #0f0f11;
  --panel2: #141417;
  --line: #26262a;
  --line2: #1b1b1e;
  --paper: #ececec;
  --muted: #8b8b92;
  --dim: #55555c;
  --faint: rgba(236, 236, 236, 0.06);
  --gold: #f5b82e;
  --crimson: #ff3b3b;
  --accent: var(--gold);
  --glow: rgba(245, 184, 46, 0);
  --s0: #f5b82e;
  --s1: #ff9a2e;
  --s2: #ff5a2e;
  --s3: #ff2b3b;
  --royal: 'Pirata One', 'UnifrakturCook', Georgia, serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --display: var(--mono);
}

body[data-stage='0'] { --accent: var(--s0); --glow: rgba(245, 184, 46, 0.10); }
body[data-stage='1'] { --accent: var(--s1); --glow: rgba(255, 154, 46, 0.16); }
body[data-stage='2'] { --accent: var(--s2); --glow: rgba(255, 90, 46, 0.24); }
body[data-stage='3'] { --accent: var(--s3); --glow: rgba(255, 43, 59, 0.34); }
body[data-stage='fell'] { --accent: var(--gold); --glow: rgba(245, 184, 46, 0.2); }

/* King's Ransom (1 in 25): the whole arena turns royal violet */
body[data-ransom='1'] {
  --bg: #0b0814; --ink: #0b0814; --panel: #110c1d; --panel2: #171026;
  --line: #2e2546; --line2: #1d1730;
  --gold: #c9b6ff;
  --s0: #c9b6ff; --s1: #e38bff; --s2: #ff6fc8; --s3: #ff3d81;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg) radial-gradient(circle, #1d1d21 1px, transparent 1.2px) 0 0 / 18px 18px;
  color: var(--paper);
  font: 12.5px/1.5 var(--mono);
  min-height: 100svh;
  padding: 14px;
  display: flex; flex-direction: column; gap: 12px;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.6s;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: 0.5; }
a { color: var(--paper); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 3px; }
.phead {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted);
}
.phead b { color: var(--paper); font-weight: 800; }
.phead.sub { border-top: 1px solid var(--line); margin-top: 6px; }
.live { display: inline-flex; align-items: center; gap: 6px; color: #7ee787; }
.live i { width: 7px; height: 7px; background: #7ee787; display: inline-block; animation: blink 1.6s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

.crownIcon { width: 28px; height: 21px; color: var(--gold); flex: none; }

/* ---- top ---- */
.top { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 18px; padding: 10px 14px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand b, .brand h1 { display: block; margin: 0; font: 400 30px/0.9 var(--royal); color: var(--gold); letter-spacing: 0.01em; }
.brand small { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }
.tstats { display: flex; justify-content: flex-end; gap: 22px; flex-wrap: wrap; }
.tstat { display: flex; align-items: baseline; gap: 8px; }
.tstat span { font-size: 11px; color: var(--muted); }
.tstat b { font-weight: 800; font-size: 13px; color: var(--paper); font-variant-numeric: tabular-nums; }
.ransomStat b { color: #c9b6ff; }
.actions { display: flex; gap: 6px; }
.ghost {
  background: transparent; border: 1px solid var(--line); border-radius: 2px;
  padding: 7px 11px; font-size: 11px; color: var(--muted);
}
.ghost:hover:not(:disabled) { border-color: var(--muted); color: var(--paper); }
.ghost[aria-pressed='true'] { border-color: var(--paper); color: var(--paper); }
.wide { width: calc(100% - 28px); margin: 10px 14px 14px; }
.ca { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: copy; }
.ca:hover { color: var(--gold); }

/* ---- how it works ---- */
.how { display: grid; grid-template-columns: repeat(3, 1fr); }
.step { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; }
.step + .step { border-left: 1px solid var(--line); }
.step i {
  flex: none; width: 26px; height: 26px; display: grid; place-items: center;
  background: var(--gold); color: var(--ink); font-style: normal; font-weight: 800; border-radius: 2px;
}
.step p { margin: 0; }
.step b { display: block; color: var(--paper); font-size: 13px; }
.step span { color: var(--muted); font-size: 11.5px; }

/* ---- Royal Treasury strip: fills from creator fees; King's Ransom state in a ransom round ---- */
.treasury {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap;
  padding: 7px 16px; border: 1px solid #4a3a1a; border-radius: 3px;
  background: linear-gradient(90deg, #17130a, #1d170b 50%, #17130a);
  color: var(--muted); font-size: 11.5px;
}
.tqName { display: flex; align-items: center; gap: 8px; flex: none; }
.tqName .crownIcon { width: 20px; height: 15px; color: #f5b82e; }
.tqTitle { font: 400 21px/1 var(--royal); color: #f5b82e; letter-spacing: 0.01em; white-space: nowrap; }
.tqAmt { display: flex; align-items: baseline; gap: 6px; flex: none; color: #ffe2a0; font: 800 21px/1 var(--mono); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tqAmt > i { font: 800 11px var(--mono); font-style: normal; color: #f5b82e; letter-spacing: 0.04em; }
.tqText { margin: 0; flex: 1 1 260px; min-width: 0; line-height: 1.35; }
.tqText b { color: var(--paper); }
.treasury .ran { display: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* odometer: each digit is a 0-9 strip that rolls */
.odo { display: inline-flex; height: 1em; line-height: 1; overflow: hidden; }
.odc { display: inline-block; height: 1em; overflow: hidden; }
.ods { display: block; will-change: transform; }
.ods i { display: block; height: 1em; font-style: normal; }
.odp { display: inline-block; }
/* growing: a slow light sweep + warm glow on the number */
.treasury::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.6s;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 214, 120, 0.13) 50%, transparent 65%);
  background-size: 260% 100%; animation: tqShimmer 2.2s linear infinite;
}
.treasury.growing::after { opacity: 1; }
.treasury.growing .tqAmt { text-shadow: 0 0 14px rgba(245, 184, 46, 0.55); }
@keyframes tqShimmer { from { background-position: 130% 0; } to { background-position: -130% 0; } }
/* King's Ransom: the strip becomes the big violet banner */
body[data-ransom='1'] .treasury {
  padding: 10px 18px; border-color: #7c3aed; color: #e9ddff; justify-content: center;
  background: linear-gradient(90deg, #2a1052, #4c1d95, #2a1052); background-size: 200% 100%;
  animation: ransomSlide 5s linear infinite;
}
body[data-ransom='1'] .treasury .norm { display: none; }
body[data-ransom='1'] .treasury .ran { display: block; }
body[data-ransom='1'] .tqName .crownIcon { color: #e9ddff; width: 28px; height: 21px; }
body[data-ransom='1'] .tqTitle { font-size: 30px; color: #fff; }
body[data-ransom='1'] .tqAmt { color: #fff; font-size: 26px; }
body[data-ransom='1'] .tqAmt > i { color: #e9ddff; }
body[data-ransom='1'] .tqText { flex: 0 1 auto; color: #f3ecff; font-size: 12.5px; }
body[data-ransom='1'] .tqText b { color: #fff; }
body[data-ransom='1'] .treasury::after { background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.12) 50%, transparent 65%); background-size: 260% 100%; }
body[data-ransom='1'] .split75 .c { display: none; }
body[data-ransom='1'] .split75 .w { flex: 1; }
@keyframes ransomSlide { to { background-position: 200% 0; } }

/* ---- arena ---- */
.arena {
  display: grid; grid-template-columns: 290px minmax(0, 1fr) 330px; gap: 12px;
  height: max(620px, calc(100svh - 224px)); min-height: 0;
}
.rail { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: auto; }
.rail.right .log { flex: 1 1 auto; min-height: 120px; }

.bigPot { padding: 16px 14px 6px; }
.bigPot b { font-size: clamp(40px, 3.6vw, 56px); font-weight: 800; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.bigPot small { color: var(--gold); font-weight: 800; margin-left: 6px; font-size: 13px; }

.ledger { margin: 0; padding: 4px 14px 8px; }
.ledger div { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line2); }
.ledger div:last-child { border-bottom: 0; }
.ledger dt { color: var(--muted); }
.ledger dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.ledger .em dd { color: var(--gold); font-weight: 800; }

.splitbar { display: flex; height: 20px; margin: 12px 14px 0; font-size: 10px; font-weight: 800; gap: 2px; }
.splitbar span { display: flex; align-items: center; padding-left: 6px; color: var(--ink); white-space: nowrap; overflow: hidden; min-width: 5px; }
.splitbar span:nth-child(1) { background: var(--gold); }
.splitbar span + span { padding: 0; }
.splitbar .sb-burn, .k-burn { background: #ff6a3d; }
.splitbar .sb-stk, .k-stk { background: #7ee787; }
.splitbar .sb-keep, .k-keep { background: var(--dim); }
.splitkey b { color: var(--paper); }
.splitkey .k-burn, .splitkey .k-stk, .splitkey .k-keep { color: var(--ink); padding: 0 3px; }
.fine { color: var(--muted); font-size: 11.5px; margin: 10px 14px 14px; }
.rules { margin: 10px 0 14px; padding: 0 14px 0 32px; color: var(--muted); display: grid; gap: 7px; font-size: 11.5px; }
.rules b { color: var(--paper); }

/* ---- stage ---- */
.stage {
  --dock: 112px;
  position: relative; overflow: hidden; min-height: 0;
  display: grid; grid-template-rows: 1fr auto; grid-template-columns: minmax(0, 1fr);
  background:
    radial-gradient(ellipse 55% 42% at 50% 74%, var(--glow), transparent 72%),
    radial-gradient(ellipse 80% 60% at 50% 100%, var(--panel2), var(--panel));
  transition: background 0.8s;
}
.phead.over { position: absolute; z-index: 4; left: 0; right: 0; top: 0; background: var(--panel); }
#pile, .pile-gl { position: absolute; inset: 0 0 var(--dock) 0; width: 100%; height: calc(100% - var(--dock)); }
#pile { cursor: pointer; touch-action: manipulation; }   /* poke the pile (cosmetic, ui.js) */
.vignette {
  position: absolute; inset: 0 0 var(--dock) 0; z-index: 1; pointer-events: none; opacity: 0;
  box-shadow: inset 0 0 140px 30px var(--crimson);
}

.hud { position: relative; z-index: 2; text-align: center; padding-top: 54px; pointer-events: none; align-self: start; transition: opacity 0.3s; }
.stageName { display: flex; width: fit-content; margin: 0 auto; flex-wrap: wrap; justify-content: center; gap: 4px 10px; align-items: center; font-size: 11px; letter-spacing: 0.14em; max-width: calc(100% - 32px); }
.stageName b { color: var(--accent); }
.stageName em { font-style: normal; color: var(--muted); letter-spacing: 0.02em; }
#stageDot { width: 8px; height: 8px; background: var(--accent); }
body[data-stage='3'] #stageDot { animation: blink 0.35s steps(2) infinite; }

.timer {
  font: 800 clamp(64px, 8.4vw, 118px)/0.95 var(--mono); letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums; color: var(--paper); margin-top: 6px;
  transition: color 0.4s; display: block;
}
body[data-stage='2'] .timer, body[data-stage='3'] .timer { color: var(--accent); text-shadow: 0 0 34px var(--glow); }
.timer small { font-size: 0.34em; color: var(--muted); letter-spacing: 0; margin-left: 2px; }
.timer.snap { animation: snap 0.45s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes snap { 0% { transform: scale(1.16); color: var(--gold); } 100% { transform: scale(1); } }

/* segmented fuse: 60 cells of 2s, coloured by the stage they fall in */
.fuse { display: flex; gap: 2px; width: min(520px, 86%); height: 12px; margin: 12px auto 0; }
.fuse i { flex: 1; background: var(--line); transition: background 0.2s; }
.fuse i.on[data-s='0'] { background: var(--s0); }
.fuse i.on[data-s='1'] { background: var(--s1); }
.fuse i.on[data-s='2'] { background: var(--s2); }
.fuse i.on[data-s='3'] { background: var(--s3); }
.fuse i.now { background: #fff; box-shadow: 0 0 10px 2px var(--accent); animation: blink 0.4s steps(2) infinite; }
.fuse i.edge { margin-left: 3px; }

.next10 { margin-top: 10px; font-size: 12px; color: var(--muted); min-height: 18px; }
.next10 b { color: var(--accent); font-size: 15px; }
.holderLine { margin-top: 6px; color: var(--muted); font-size: 12px; display: inline-flex; gap: 8px; align-items: center; }
.holderLine b { color: var(--gold); }
.holderLine .crownIcon { width: 18px; height: 14px; }

/* "it can fall any second" caption + per-second survival roll */
.timerCap { margin-top: 2px; font-size: 11px; letter-spacing: 0.08em; color: var(--muted); text-transform: uppercase; }
.timerCap b { color: var(--accent); font-weight: 800; }
.roll { display: inline-block; margin-left: 8px; color: #7ee787; font-weight: 800; opacity: 0; }
.roll.go { animation: roll 0.9s ease-out; }
@keyframes roll { 0% { opacity: 1; transform: translateY(0); } 60% { opacity: 1; } 100% { opacity: 0; transform: translateY(-6px); } }
body[data-stage='unlit'] .timerCap, body[data-stage='fell'] .timerCap { visibility: hidden; }

/* ---- clock reset: digits spin back, gold flash, chip pops ---- */
.timer.rewind { color: var(--gold) !important; filter: blur(0.6px) drop-shadow(0 0 18px rgba(245, 184, 46, 0.7)); }
.timer.rewind small { color: var(--gold); }
.resetChip {
  position: absolute; left: 50%; top: 150px; transform: translate(-50%, 0) scale(0.8); z-index: 3;
  padding: 4px 10px; background: var(--gold); color: var(--ink); font-weight: 800; font-size: 12px;
  letter-spacing: 0.12em; text-transform: uppercase; white-space: nowrap; opacity: 0; pointer-events: none;
}
.resetChip.go { animation: chipPop 1.3s cubic-bezier(.2, 1.4, .4, 1) forwards; }
@keyframes chipPop {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.6); }
  15% { opacity: 1; transform: translate(-50%, 0) scale(1.08); }
  70% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -14px) scale(1); }
}
.fuse i { transition: background 0.12s; }
.tickup { animation: tickUp 0.6s ease-out; }
@keyframes tickUp { 0% { color: var(--gold); text-shadow: 0 0 14px rgba(245, 184, 46, 0.8); } 100% { } }

/* ---- each stage acts itself out on the timer ---- */
.stageName b { padding: 2px 7px; transition: background 0.3s, color 0.3s; }
body[data-stage='1'] .stageName b, body[data-stage='2'] .stageName b, body[data-stage='3'] .stageName b { background: var(--accent); color: var(--ink); }
body[data-stage='1'] .timer { color: var(--s1); animation: creak 4.2s ease-in-out infinite; }
@keyframes creak { 0%, 86%, 100% { rotate: 0deg; } 89% { rotate: -1.2deg; } 93% { rotate: 0.8deg; } 96% { rotate: -0.3deg; } }
body[data-stage='2'] .timer { rotate: -3deg; translate: -6px 0; animation: lean 2.6s ease-in-out infinite; }
@keyframes lean { 50% { rotate: -4.5deg; translate: -10px 2px; } }
body[data-stage='3'] .timer { animation: teeter 0.9s ease-in-out infinite, tremble 0.09s steps(2) infinite; }
@keyframes teeter { 0%, 100% { rotate: -5deg; } 50% { rotate: 5deg; } }
@keyframes tremble { 50% { translate: 1px -1px; } }
.timer, .timer small { transition: color 0.4s, rotate 0.5s, translate 0.5s; }
body[data-stage='3'] .timer small { color: var(--s3); }
.timer.count { animation: countPop 0.5s ease-out !important; }
@keyframes countPop { 0% { scale: 1.25; color: #fff; } 100% { scale: 1; } }
body[data-stage='3'] .hud { animation: tremble 0.12s steps(2) infinite; }
body[data-stage='2'] .fuse i.now { box-shadow: 0 0 14px 4px var(--accent); }
body[data-stage='3'] .fuse i.now { box-shadow: 0 0 20px 7px var(--s3); animation-duration: 0.2s; }

/* cinematic bars close in as the risk rises */
.bars { position: absolute; inset: 0 0 var(--dock) 0; z-index: 3; pointer-events: none; }
.bars i { position: absolute; left: 0; right: 0; height: 0; background: #000; transition: height 0.9s cubic-bezier(.2, .8, .2, 1); }
.bars i:first-child { top: 41px; }
.bars i:last-child { bottom: 0; }
body[data-stage='2'] .bars i { height: 7px; }
body[data-stage='3'] .bars i { height: 12px; }
body[data-stage='3'] .potTag { bottom: calc(var(--dock) + 26px); }

/* stage-change banner */
.stamp.danger b { color: var(--accent); font-size: clamp(38px, 4vw, 56px); }
.stamp.danger span { background: var(--accent); color: var(--ink); }
.stage.surge { animation: surge 0.6s ease-out; }
@keyframes surge { 0% { box-shadow: inset 0 0 0 3px var(--accent), inset 0 0 120px var(--accent); } 100% { box-shadow: inset 0 0 0 0 transparent; } }

.warn {
  position: absolute; z-index: 3; left: 50%; bottom: calc(var(--dock) + 24px); transform: translateX(-50%);
  font: 400 clamp(26px, 3vw, 40px)/1 var(--royal); color: var(--crimson); letter-spacing: 0.02em;
  text-shadow: 0 0 24px rgba(255, 43, 59, 0.6); pointer-events: none; opacity: 0; white-space: nowrap;
}
body[data-stage='3'] .warn { opacity: 1; animation: warnPulse 0.7s ease-in-out infinite; }
@keyframes warnPulse { 50% { opacity: 0.35; transform: translateX(-50%) scale(1.04); } }

.hud.lurch, .stage.lurch .timer { animation: lurch 0.32s; }
@keyframes lurch { 15% { transform: translate(-3px, 4px) rotate(-0.6deg); } 40% { transform: translate(3px, -2px); } 70% { transform: translate(-1px, 1px); } }

.potTag { position: absolute; z-index: 2; left: 18px; bottom: calc(var(--dock) + 14px); pointer-events: none; }
.potTag span { display: block; font-size: 10px; letter-spacing: 0.16em; color: var(--muted); text-transform: uppercase; }
.potTag b { display: inline-block; font: 800 clamp(30px, 3.4vw, 46px)/1 var(--mono); letter-spacing: -0.03em; color: var(--paper); font-variant-numeric: tabular-nums; transform-origin: left bottom; }
.potTag i { font-style: normal; font-weight: 800; color: var(--gold); margin-left: 6px; }
.potTag b.bump { animation: bump 0.16s; }
@keyframes bump { 40% { transform: scale(1.06); color: var(--gold); } }

.dock {
  position: relative; z-index: 4; grid-row: 2;
  display: flex; flex-direction: column; justify-content: center; gap: 7px;
  padding: 10px 14px; height: var(--dock);
  border-top: 1px solid var(--line); background: var(--panel);
}
.take {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  height: 52px; padding: 0 20px; border: 0; border-radius: 2px;
  background: var(--gold); color: var(--ink);
  font: 800 17px/1 var(--mono); letter-spacing: 0.22em; text-transform: uppercase;
  transition: transform 0.08s, background 0.3s, box-shadow 0.3s;
}
.take b { letter-spacing: 0; font-size: 16px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.winline { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--muted); }
.winline b { color: var(--gold); font-variant-numeric: tabular-nums; }
body[data-stage='2'] .take, body[data-stage='3'] .take { background: var(--accent); box-shadow: 0 0 30px var(--glow); }
.take:hover:not(:disabled) { filter: brightness(1.08); }
.take:active:not(:disabled) { transform: translateY(1px); }
.take.mine { background: transparent; color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); opacity: 1; }
.consequence { display: none; margin: 0; color: var(--paper); font-size: 12px; }
.dock.flashing .consequence { display: block; }
.dock.flashing .winline { display: none; }
.consequence b { color: var(--paper); }

/* the king card */
.king { padding: 4px 0 6px; }
.kName { display: flex; align-items: center; gap: 10px; padding: 12px 14px 4px; }
.kName b { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; color: var(--paper); }
.kName .crownIcon { width: 24px; height: 18px; }
body[data-stage='unlit'] .kName b { color: var(--dim); font-size: 16px; }
body[data-stage='unlit'] .kName .crownIcon { color: var(--dim); }
.dare { margin: 2px 14px 8px; color: var(--dim); font-size: 11px; }
body[data-stage='3'] .king { animation: kingHot 0.7s ease-in-out infinite; }
@keyframes kingHot { 50% { background: rgba(255, 43, 59, 0.08); } }

/* ---- mode switches: sim (default), pump (legacy pump.fun buys), custodial (takes on this site) ---- */
body:not([data-mode='pump']) .pump-only,
body:not([data-mode='custodial']) .cust-only,
body[data-mode='pump'] .sim-only, body[data-mode='custodial'] .sim-only,
body[data-mode='pump'] .not-pump,
body[data-mode='custodial'] .not-cust,
body:not([data-mode='pump']):not([data-mode='custodial']) .live-only { display: none !important; }

/* ---- custodial dock: the consequence line is always visible under the exact price ---- */
body[data-mode='custodial'] .stage { --dock: 132px; }
body[data-mode='custodial'] .dock { gap: 6px; }
body[data-mode='custodial'] .consequence { display: block; font-size: 11.5px; line-height: 1.35; color: var(--muted); min-height: 2.7em; }
body[data-mode='custodial'] .consequence b { color: var(--paper); }
body[data-mode='custodial'] .dock.flashing .winline { display: flex; }
body[data-mode='custodial'] .dock.flashing .consequence { color: var(--paper); }
.consequence a { color: inherit; }
body[data-mode='custodial'] .consequence.st-wait { color: #ffd98a; }
body[data-mode='custodial'] .consequence.st-ok { color: #7ee787; }
body[data-mode='custodial'] .consequence.st-bad { color: #ff8f8f; }
.consequence.st-bad b, .consequence.st-wait b { color: inherit; }
.take.busy { background: transparent; color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); opacity: 1; animation: busyPulse 1.2s ease-in-out infinite; }
@keyframes busyPulse { 50% { box-shadow: inset 0 0 0 1px var(--gold), 0 0 18px rgba(245, 184, 46, 0.35); } }

/* wallet button + picker */
#btnWallet.connect { border-color: var(--gold); color: var(--gold); font-weight: 800; }
#btnWallet .wb::before { content: ' · '; }
#btnWallet .wa { color: var(--paper); }
#btnWallet.connect:hover { background: var(--gold); color: var(--ink); }
.wmodal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, 0.62); backdrop-filter: blur(3px); }
.wbox { width: min(380px, 100%); max-height: calc(100svh - 32px); overflow: auto; box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6); }
.wx { background: none; border: 0; color: var(--muted); font-size: 20px; line-height: 1; padding: 0 2px; }
.wx:hover { color: var(--paper); }
.wbody { padding: 12px 14px 14px; display: grid; gap: 10px; }
.wlist { display: grid; gap: 6px; }
.wopt { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 10px; padding: 9px 10px; background: var(--panel2); border: 1px solid var(--line); border-radius: 2px; text-align: left; }
.wopt:hover:not(:disabled) { border-color: var(--gold); }
.wopt img, .wopt i { width: 28px; height: 28px; border-radius: 6px; background: var(--line); display: block; }
.wopt b { font-size: 13px; }
.wopt span { font-size: 10.5px; color: #7ee787; letter-spacing: 0.06em; }
.wnote { margin: 0; color: var(--paper); }
.wget { display: flex; flex-wrap: wrap; gap: 6px; }
.wget a, .wget button { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 2px; padding: 6px 9px; text-decoration: none; background: none; }
.wget a:hover, .wget button:hover { color: var(--paper); border-color: var(--muted); }
.wfine { margin: 0; font-size: 11px; color: var(--dim); }
.wacct { display: flex; align-items: center; gap: 10px; }
.wacct img { width: 28px; height: 28px; border-radius: 6px; }
.wacct code { font: 600 11px var(--mono); color: var(--paper); word-break: break-all; }
.wbody .ledger { padding: 0; }

/* refunds in the court log */
.log li.refund .who { color: var(--muted); }
.log li.refund .who em { color: #ff8f8f; }
.log li.refund.me .who { color: #ff8f8f; font-weight: 800; }
.log li.refund .amt, .log li.refund .amt a { color: var(--dim); }

/* buybacks & burns */
.log.bb { flex: none; min-height: 0; overflow: visible; font-size: 11.5px; }
.log.bb li { grid-template-columns: 30px 1fr auto; }
.log.bb .who a { color: var(--paper); }
.log.bb .amt b { color: #ff8a5c; }

/* staking panel */
.stakeP { flex: 1 1 auto; overflow: auto; min-height: 220px; }
.stk { padding: 2px 0 6px; }
.stkClosed { margin: 14px; padding: 14px; border: 1px dashed var(--line); border-radius: 3px; color: var(--muted); }
.stkClosed b { display: block; color: var(--paper); font-size: 13px; margin-bottom: 6px; }
.stkClosed p { margin: 0; font-size: 11.5px; }
.stkNote { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 12px 14px; color: var(--muted); }
.lots { list-style: none; margin: 0 14px; padding: 0; display: grid; gap: 4px; font-size: 11.5px; }
.lots li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 8px; background: var(--panel2); border-left: 2px solid #ff8f8f; }
.lots li.free { border-left-color: #7ee787; }
.lots li span { color: var(--muted); }
.lots li.free span { color: #7ee787; }
.lots .empty { border: 0; background: none; color: var(--dim); padding: 4px 0; }
.lots.sends { margin-top: 4px; }
.lots.sends:empty { display: none; }
.lots li.send { border-left-color: var(--gold); }
.lots li.send span { color: var(--gold); }
.lots li.send a { color: inherit; }
.stkRow { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; margin: 8px 14px 0; }
.stkRow input { min-width: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 2px; color: var(--paper); font: 600 12.5px var(--mono); padding: 8px 9px; }
.stkRow input:focus { outline: none; border-color: var(--gold); }
.stkRow .ghost { padding: 7px 9px; }
.act { background: var(--gold); color: var(--ink); border: 0; border-radius: 2px; font-weight: 800; letter-spacing: 0.1em; padding: 8px 12px; font-size: 11px; }
.act:hover:not(:disabled) { filter: brightness(1.08); }
.act2 { font-weight: 800; letter-spacing: 0.1em; }
.stkWarn { margin: 10px 14px 0; padding: 10px 12px; border: 1px solid #7ee787; background: rgba(126, 231, 135, 0.06); border-radius: 2px; }
.stkWarn.loss { border-color: var(--crimson); background: rgba(255, 59, 59, 0.08); }
.stkWarn > b { display: block; color: #ff8f8f; font-size: 12px; }
.stkWarn:not(.loss) > b { color: var(--muted); font-weight: 600; }
.stkWarn p { margin: 6px 0 8px; font-size: 11.5px; color: var(--paper); }
.stkWarn p b { color: #fff; }
.stkBtns { display: flex; gap: 6px; }
.stkStatus { margin: 8px 14px 0; font-size: 11.5px; color: var(--muted); min-height: 1em; }
.stkStatus.st-wait { color: #ffd98a; }
.stkStatus.st-ok { color: #7ee787; }
.stkStatus.st-bad { color: #ff8f8f; }
.stkStatus a { color: inherit; }
.stk code { font-size: 10.5px; color: var(--paper); }
.rail.right[data-tab='stake'] .yourPos { display: none; }

.stage.jolt { animation: jolt 0.22s; }
@keyframes jolt { 30% { transform: translate(0, 3px); } 60% { transform: translate(0, -1px); } }

/* pot level meter */
.meter { position: absolute; z-index: 2; right: 18px; top: 36%; bottom: calc(var(--dock) + 16px); width: 40px; display: flex; flex-direction: column-reverse; gap: 2px; pointer-events: none; }
.meter i { flex: 1; background: var(--line); position: relative; transition: background 0.25s; }
.meter i.on { background: var(--gold); }
.meter i.next { background: color-mix(in srgb, var(--gold) 25%, var(--line)); }
.meter i::after { content: attr(data-l); position: absolute; right: calc(100% + 6px); top: 50%; transform: translateY(-50%); font-size: 9px; color: var(--dim); }
.meter i em { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font: 800 8px var(--mono); font-style: normal; color: var(--ink); opacity: 0; }
.meter i.on em { opacity: 0.7; }
.meter i.rec::before { content: 'REC'; position: absolute; left: calc(100% + 4px); top: 50%; transform: translateY(-50%); font-size: 8px; font-weight: 800; color: var(--crimson); }

/* stamps */
.stamp { position: absolute; z-index: 3; left: 50%; top: 44%; transform: translate(-50%, -50%) scale(0.6); text-align: center; pointer-events: none; opacity: 0; }
.next10, .holderLine { transition: opacity 0.15s; }
.hud.stamping .next10, .hud.stamping .holderLine { opacity: 0; }
.stamp b { display: block; font: 400 clamp(34px, 3.6vw, 48px)/0.95 var(--royal); color: var(--gold); text-shadow: 0 3px 0 #000, 0 0 30px rgba(0,0,0,.8); }
.stamp span { display: inline-block; white-space: nowrap; margin-top: 8px; padding: 3px 8px; background: var(--paper); color: var(--ink); font-weight: 800; font-size: 11px; letter-spacing: 0.1em; }
.stamp.you b { color: var(--paper); }
.stamp.go { animation: stampIn 1.2s cubic-bezier(.2, 1.4, .4, 1) forwards; }
@keyframes stampIn {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(1.8); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -70%) scale(0.95); }
}

/* dethroned */
.toast {
  position: absolute; z-index: 6; left: 50%; top: 48px; transform: translate(-50%, -24px);
  display: flex; gap: 16px; align-items: center;
  background: var(--crimson); color: #fff; padding: 10px 10px 10px 16px; border-radius: 2px;
  box-shadow: 0 14px 50px rgba(0, 0, 0, 0.6);
  transition: transform 0.35s cubic-bezier(.2, 1.4, .4, 1), opacity 0.2s, visibility 0.2s;
  width: max-content; max-width: calc(100% - 32px); opacity: 0; visibility: hidden;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }
.toast b { display: block; font: 400 22px/1 var(--royal); }
.toast span { font-size: 11.5px; opacity: 0.92; }
.toast button { background: #fff; color: #000; border: 0; border-radius: 2px; padding: 10px 12px; font-weight: 800; white-space: nowrap; }

/* the fall */
.fall {
  position: absolute; z-index: 5; left: 50%; top: 52px; transform: translateX(-50%) translateY(-12px);
  width: min(500px, calc(100% - 28px)); background: color-mix(in srgb, var(--panel) 94%, transparent);
  border: 1px solid var(--gold); border-radius: 3px; padding: 18px 20px; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity 0.4s, transform 0.4s; backdrop-filter: blur(8px);
}
.fall.show { opacity: 1; transform: translateX(-50%); pointer-events: auto; }
body[data-stage='fell'] .hud, body[data-stage='fell'] .warn { opacity: 0; }
.fallHead { font: 400 40px/1 var(--royal); color: var(--paper); }
.fallSub { font: 400 20px/1.2 var(--royal); color: var(--gold); margin-top: 4px; }
body[data-ransom='1'] .fallHead { color: #e9ddff; }
.winner { display: inline-flex; gap: 8px; align-items: center; margin-top: 10px; padding: 6px 12px; background: var(--paper); color: var(--ink); font-weight: 800; }
.winner .crownIcon { width: 18px; height: 14px; color: var(--ink); }
.winner.you { background: var(--gold); }
.payout { margin-top: 8px; color: var(--muted); font-weight: 800; }
.payout b { font-size: 44px; letter-spacing: -0.03em; color: var(--gold); font-variant-numeric: tabular-nums; }
.split75 { display: flex; margin-top: 12px; font-size: 11px; text-align: left; gap: 2px; }
.split75 > div { padding: 7px 10px; }
.split75 .w { flex: 75; background: var(--gold); color: var(--ink); }
.split75 .c { flex: 25; background: var(--line); min-width: 120px; }
.split75 span { display: block; opacity: 0.75; }
.fstats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0 0; }
.fstats dt { font-size: 10px; letter-spacing: 0.1em; color: var(--muted); text-transform: uppercase; }
.fstats dd { margin: 2px 0 0; font-weight: 800; font-size: 18px; }
.fNext { margin-top: 12px; font-size: 11px; color: var(--muted); }

/* log */
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; background: none; border: 0; padding: 11px 0; font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected='true'] { color: var(--paper); border-color: var(--gold); }
.log { list-style: none; margin: 0; padding: 4px 14px; font-size: 12px; flex: 1; min-height: 220px; overflow: auto; }
.log li { display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line2); align-items: baseline; }
.log li.new { animation: rowIn 0.8s; }
@keyframes rowIn { from { background: color-mix(in srgb, var(--gold) 18%, transparent); } }
.log .t { color: var(--dim); }
.log .who { color: var(--paper); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log .who em { font-style: normal; color: var(--muted); }
.log li.king .who::before { content: '♛ '; color: var(--gold); }
.log li.me .who { color: var(--gold); font-weight: 800; }
.log .amt { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.log .amt a { color: var(--muted); }
.log .empty { display: block; color: var(--muted); border: 0; }

/* footer */
.xlink { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-weight: 800; }
.xlink:hover { color: var(--paper); }
.xlink svg { width: 13px; height: 13px; }

/* FAQ: plain-language rules below the game */
.faq h2 { margin: 0; font: inherit; color: inherit; letter-spacing: inherit; }
.faqGrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 28px; padding: 6px 16px 14px; }
.faq details { border-bottom: 1px solid var(--line2); padding: 10px 0; }
.faq summary { cursor: pointer; color: var(--paper); font-weight: 800; font-size: 13px; list-style: none; display: flex; gap: 10px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before { content: '+'; color: var(--gold); width: 12px; flex: none; }
.faq details[open] summary::before { content: '−'; }
.faq p { margin: 8px 0 2px 22px; color: var(--muted); font-size: 12.5px; line-height: 1.6; max-width: 70ch; }
.faq p b { color: var(--paper); }
@media (max-width: 760px) { .faqGrid { grid-template-columns: 1fr; } }

.bottom { display: flex; align-items: center; gap: 14px; padding: 2px 4px; color: var(--muted); font-size: 11px; }
.modeTag { border: 1px solid var(--line); color: var(--paper); padding: 2px 7px; letter-spacing: 0.12em; }
.motto { font: 400 15px var(--royal); color: var(--dim); }
.spacer { flex: 1; }
.speeds { display: flex; gap: 2px; }
.speeds button { background: none; border: 1px solid var(--line); padding: 3px 8px; font-size: 11px; color: var(--muted); }
.speeds button[aria-pressed='true'] { color: var(--ink); background: var(--paper); border-color: var(--paper); }

/* King's Ransom badge in the throne bar: always visible, lights up on a ransom round */
.bonus {
  padding: 3px 8px; border: 1px solid #5b3fa8; color: #c9b6ff; letter-spacing: 0.1em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: help;
}
body[data-ransom='1'] .bonus { background: #7c3aed; border-color: #a78bfa; color: #fff; font-weight: 800; animation: ransomPulse 1.6s ease-in-out infinite; }
@keyframes ransomPulse { 50% { box-shadow: 0 0 16px 2px rgba(167, 139, 250, 0.7); } }
.show-sm { display: none; }
@media (max-width: 760px) {
  .bonus { font-size: 9.5px; padding: 2px 6px; letter-spacing: 0.05em; }
  .show-sm { display: inline; }
}

/* ---- short windows (laptops, 720p, small browser windows): give the pile the room ---- */
@media (max-height: 880px) and (min-width: 761px) {
  body { padding: 10px; gap: 8px; }
  .top { padding: 6px 12px; }
  .brand b, .brand h1 { font-size: 25px; }
  .brand small { display: none; }
  .step { padding: 7px 12px; align-items: center; }
  .step span { display: none; }
  .step i { width: 22px; height: 22px; }
  .hud { padding-top: 46px; }
  .stageName { font-size: 10.5px; }
  .timer { font-size: clamp(52px, 8.2vh, 92px); margin-top: 2px; }
  .timerCap { font-size: 10px; }
  .fuse { margin-top: 8px; height: 10px; }
  .next10 { margin-top: 6px; font-size: 11.5px; }
  .holderLine { display: none; }
  .potTag b { font-size: clamp(26px, 3vw, 38px); }
  .meter { top: 44%; width: 30px; }
  .treasury { padding: 5px 14px; }
  .tqTitle { font-size: 19px; }
  .tqAmt { font-size: 18px; }
  body[data-ransom='1'] .treasury { padding: 6px 16px; }
  body[data-ransom='1'] .tqTitle { font-size: 24px; }
  body[data-ransom='1'] .tqAmt { font-size: 21px; }
}
.tqShort { display: none; }

/* ---- responsive ---- */
/* desktop: the arena takes whatever height is left (with or without the ransom banner) */
@media (min-width: 1181px) {
  body { height: 100svh; position: relative; }
  .arena { flex: 1; height: auto; min-height: 560px; }
  /* the game fills one screen; the FAQ sits just below it without squeezing the game */
  .faq { position: absolute; left: 14px; right: 14px; top: 100%; }
  .faq::after { content: ''; position: absolute; top: 100%; height: 14px; width: 1px; }
}
.top, .how, .treasury, .bottom { flex: none; }
@media (max-height: 880px) and (min-width: 1181px) {
  .arena { min-height: 480px; }
}
@media (max-height: 720px) and (min-width: 1181px) {
  .arena { min-height: 430px; }
  .treasury { padding: 3px 12px; }
  .tqText { font-size: 11px; }
}
@media (max-width: 1180px) {
  .arena { grid-template-columns: minmax(0, 1fr) 300px; grid-template-rows: max(600px, calc(100svh - 270px)) auto; height: auto; }
  body[data-mode='pump'] .arena { grid-template-rows: max(600px, calc(100svh - 224px)) auto; }
  .rail.left { grid-column: 1 / -1; grid-row: 2; overflow: visible; }
}
@media (max-width: 760px) {
  body { padding: 8px; gap: 8px; font-size: 12px; }
  .top { grid-template-columns: 1fr auto; gap: 10px; }
  .tstats { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; gap: 14px; }
  .brand b, .brand h1 { font-size: 26px; }
  .brand small, .hide-sm { display: none; }
  .step { padding: 7px 8px; gap: 6px; align-items: center; }
  .step i { width: 18px; height: 18px; font-size: 11px; }
  .step b { font-size: 10.5px; line-height: 1.25; }
  .step span { display: none; }
  .arena { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; gap: 8px; height: auto; }
  .stage { order: -1; height: clamp(560px, calc(100svh - 150px), 760px); }
  .rail.left, .rail.right { grid-column: auto; grid-row: auto; overflow: visible; }
  .rail.right .log { max-height: 360px; }
  .hud { padding-top: 46px; }
  .timer { font-size: 68px; }
  .take { font-size: 14px; letter-spacing: 0.14em; height: 50px; }
  .potTag { left: 12px; }
  .meter { right: 10px; width: 10px; }
  .meter i::after, .meter i em, .meter i.rec::before { display: none; }
  .fstats { grid-template-columns: repeat(2, 1fr); }
  .bottom { flex-wrap: wrap; }
  .bars i:first-child, .warn { display: none; }
  /* treasury: one compact line */
  .treasury, body[data-ransom='1'] .treasury { padding: 5px 10px; gap: 8px; flex-wrap: nowrap; justify-content: flex-start; font-size: 10.5px; }
  .tqLong, .tqMid, .tqRoyal { display: none; }
  .tqShort { display: inline; }
  .tqName { gap: 6px; }
  .tqName .crownIcon, body[data-ransom='1'] .tqName .crownIcon { width: 16px; height: 12px; }
  .tqTitle, body[data-ransom='1'] .tqTitle { font-size: 17px; }
  .tqAmt, body[data-ransom='1'] .tqAmt { font-size: 15px; gap: 4px; }
  .tqAmt > i { font-size: 9.5px; }
  .tqText, body[data-ransom='1'] .tqText { flex: 1 1 auto; font-size: 10px; line-height: 1.2; white-space: normal; }
  .stage { height: clamp(560px, calc(100svh - 188px), 760px); }
  body[data-mode='pump'] .stage { height: clamp(560px, calc(100svh - 150px), 760px); }
  body[data-mode='custodial'] .stage { --dock: 136px; }
  body[data-mode='custodial'] .take { height: 48px; }
  body[data-mode='custodial'] .consequence { font-size: 10.5px; }
  #btnWallet { display: inline-flex; flex-direction: column; align-items: flex-end; line-height: 1.2; padding: 4px 9px; }
  #btnWallet .wb { font-size: 10px; }
  #btnWallet .wb::before { content: none; }
  .motto { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .timer, .warn, .treasury, .treasury::after, .fuse i.now, .hud.lurch, .take.busy { animation: none !important; }
}
