/* ================= BIO REACTOR — UI theme ================= */
:root {
  --acc: #9dff1e;
  --acc-soft: rgba(150, 255, 30, .5);
  --acc-dim: #7ea653;
  --txt: #d6f0c2;
  --dim: #7c9a64;
  --line: #2c4a1c;
  --line-soft: rgba(120, 200, 60, .25);
  --panel-a: rgba(13, 21, 11, .93);
  --panel-b: rgba(6, 10, 6, .95);
  --red: #ff4b2e;
  --amber: #ffb300;
}
body.state-crashed {
  --acc: #ff4b2e;
  --acc-soft: rgba(255, 75, 46, .5);
  --acc-dim: #b06246;
  --txt: #ffd9ce;
  --dim: #a97862;
  --line: #5a2014;
  --line-soft: rgba(255, 90, 50, .3);
  --panel-a: rgba(24, 10, 7, .93);
  --panel-b: rgba(12, 5, 3, .95);
}
body.state-recovery {
  --acc: #ffc63f;
  --acc-soft: rgba(255, 198, 63, .45);
  --acc-dim: #a98d4a;
  --txt: #efe3c2;
  --dim: #99885d;
  --line: #4d3d14;
  --line-soft: rgba(255, 198, 63, .25);
  --panel-a: rgba(20, 17, 9, .93);
  --panel-b: rgba(10, 8, 4, .95);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  display: grid;
  grid-template-columns: 356px 1fr;
  overflow: hidden;
  background: #04070a;
  font-family: "Chakra Petch", "Segoe UI", sans-serif;
  color: var(--txt);
  user-select: none;
}

/* ---------------- panels ---------------- */
.panel {
  background: linear-gradient(180deg, var(--panel-a), var(--panel-b));
  border: 1px solid var(--line);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .8), 0 0 22px rgba(140, 255, 0, .06), inset 0 0 26px rgba(0, 0, 0, .5);
  clip-path: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px);
  padding: 10px 12px;
  position: relative;
}
body.state-crashed .panel { box-shadow: 0 0 0 1px rgba(0, 0, 0, .8), 0 0 26px rgba(255, 60, 30, .10), inset 0 0 26px rgba(0, 0, 0, .5); }
.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .26em;
  color: var(--dim);
  white-space: nowrap;
}
.panel-title::before, .panel-title::after {
  content: "";
  height: 1px;
  flex: 1;
  background: linear-gradient(90deg, transparent, var(--line-soft));
}
.panel-title::after { background: linear-gradient(90deg, var(--line-soft), transparent); }
.pt-right { margin-left: auto; letter-spacing: .2em; }

/* ---------------- left column ---------------- */
#side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  min-height: 0;
  z-index: 20;
  background: linear-gradient(90deg, rgba(4, 7, 4, .95), rgba(4, 7, 4, .75));
  border-right: 1px solid #17240f;
}

/* logo */
.logo { text-align: center; padding: 10px 8px 10px; }
.logo-haz {
  position: absolute;
  top: 7px; right: 16px;
  font-size: 22px;
  color: #aaff20;
  text-shadow: 0 0 12px rgba(150, 255, 20, .8);
  animation: pulse 2.4s infinite;
}
.logo-bio {
  font-family: "Russo One", "Arial Black", sans-serif;
  font-size: 72px;
  line-height: .92;
  letter-spacing: 6px;
  background: linear-gradient(180deg, #e2ff70 0%, #9ade1d 45%, #4a8a00 80%, #2c5800 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 rgba(10, 30, 0, .9)) drop-shadow(0 0 20px rgba(150, 255, 20, .35));
}
.logo-reactor {
  font-family: "Russo One", "Arial Black", sans-serif;
  font-size: 39px;
  letter-spacing: 6px;
  margin-top: 2px;
  background: linear-gradient(180deg, #f2f4f0 0%, #a8b0a6 40%, #4e564c 75%, #6d766b 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 0 #000) drop-shadow(0 0 8px rgba(255, 255, 255, .12));
}
.logo-sub { margin-top: 6px; font-size: 9px; letter-spacing: .3em; color: var(--dim); }
body.state-crashed .logo-bio { filter: drop-shadow(0 3px 0 rgba(30, 5, 0, .9)) drop-shadow(0 0 22px rgba(255, 60, 20, .4)); }

/* multiplier */
#mult-value {
  text-align: center;
  font-size: 58px;
  font-weight: 700;
  line-height: 1.05;
  margin-top: 4px;
  color: var(--acc);
  text-shadow: 0 0 16px var(--acc-soft), 0 0 44px var(--acc-soft);
  font-variant-numeric: tabular-nums;
}
#mult-sub {
  text-align: center;
  font-size: 9.5px;
  letter-spacing: .34em;
  color: var(--dim);
  margin: 2px 0 8px;
}
#chart { width: 100%; height: 128px; display: block; }
#history-row { display: flex; gap: 5px; margin-top: 8px; flex-wrap: nowrap; overflow: hidden; min-height: 18px; }
.chip {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, .4);
  white-space: nowrap;
}
.chip.good { color: #9dff1e; border-color: rgba(150, 255, 30, .35); }
.chip.bad { color: #ff6a4e; border-color: rgba(255, 90, 50, .35); }
.chip.gold { color: #ffd44d; border-color: rgba(255, 200, 60, .45); text-shadow: 0 0 8px rgba(255, 200, 60, .5); }

/* players */
#players-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#players-rows { flex: 1; min-height: 0; overflow: hidden; margin-top: 6px; }
.prow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  font-size: 12.5px;
  border-bottom: 1px solid rgba(120, 180, 80, .08);
}
.prow.me { background: rgba(150, 255, 30, .06); outline: 1px solid rgba(150, 255, 30, .18); }
body.state-crashed .prow.me { background: rgba(255, 75, 46, .08); outline-color: rgba(255, 75, 46, .25); }
.prow.empty, .prow.more { color: var(--dim); font-size: 10.5px; letter-spacing: .12em; justify-content: center; }
.picon { width: 16px; text-align: center; text-shadow: 0 0 6px currentColor; }
.pname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--txt); }
.pbet { font-variant-numeric: tabular-nums; color: var(--txt); min-width: 52px; text-align: right; }
.pb { font-size: 10px; font-weight: 700; padding: 1px 5px; }
.pb.live { color: var(--dim); animation: pulse 1.2s infinite; }
.pb.cashed { color: #9dff1e; text-shadow: 0 0 8px rgba(150, 255, 30, .6); }
.pb.lost { color: #ff5a3a; }
.players-foot {
  display: flex; justify-content: space-between;
  font-size: 9.5px; letter-spacing: .2em; color: var(--dim);
  border-top: 1px solid var(--line); padding-top: 6px; margin-top: 4px;
}
.players-foot b { color: var(--txt); font-variant-numeric: tabular-nums; letter-spacing: 0; }

/* bet panel */
.op-row { display: flex; justify-content: space-between; font-size: 11px; color: var(--dim); margin-bottom: 8px; }
.op-row b { color: var(--txt); }
.op-bal b { color: var(--acc); text-shadow: 0 0 10px var(--acc-soft); font-variant-numeric: tabular-nums; display: inline-block; }
.op-bal b.bump { animation: bump .4s; }
@keyframes bump { 0% { transform: scale(1.25); } 100% { transform: scale(1); } }

.steppers { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stepper label { display: block; text-align: center; font-size: 9px; letter-spacing: .24em; color: var(--dim); margin-bottom: 4px; }
.step-row { display: flex; gap: 4px; }
.step-btn {
  width: 34px; height: 34px;
  background: linear-gradient(180deg, #18220f, #0b0f07);
  color: var(--acc);
  border: 1px solid var(--line);
  font-size: 18px;
  cursor: pointer;
  font-family: inherit;
}
.step-btn:hover { background: #1d2a12; box-shadow: 0 0 10px rgba(150, 255, 30, .2); }
.step-row input {
  flex: 1; width: 40px;
  background: rgba(0, 0, 0, .55);
  border: 1px solid var(--line);
  color: var(--txt);
  font: 600 15px "Chakra Petch", monospace;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.step-row input:focus { outline: 1px solid var(--acc-soft); }

/* action button */
.action {
  margin-top: 10px;
  width: 100%;
  min-height: 74px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-family: "Russo One", "Arial Black", sans-serif;
  font-size: 25px;
  letter-spacing: .06em;
  color: #eaffd0;
  background: linear-gradient(180deg, #3a5510 0%, #22380a 55%, #16260a 100%);
  border: 1px solid #86c000;
  box-shadow: inset 0 0 26px rgba(160, 255, 0, .28), 0 0 24px rgba(140, 255, 0, .3);
  text-shadow: 0 0 12px #bfff30;
  clip-path: polygon(16px 0, 100% 0, 100% calc(100% - 16px), calc(100% - 16px) 100%, 0 100%, 0 16px);
  cursor: pointer;
  transition: filter .15s;
}
.action:hover:not(:disabled) { filter: brightness(1.25); }
.action:active:not(:disabled) { filter: brightness(1.5); }
.action:disabled { cursor: default; filter: grayscale(.5) brightness(.62); }
.action #action-sub, .action span:last-child { font-family: "Chakra Petch"; font-size: 11.5px; letter-spacing: .18em; color: #c9e0a8; text-shadow: none; }
.action.cash {
  background: linear-gradient(180deg, #62810f 0%, #33500c 55%, #1c300a 100%);
  animation: cashPulse 0.9s infinite;
}
@keyframes cashPulse {
  0%, 100% { box-shadow: inset 0 0 26px rgba(190, 255, 40, .35), 0 0 22px rgba(160, 255, 20, .35); }
  50% { box-shadow: inset 0 0 34px rgba(210, 255, 80, .55), 0 0 40px rgba(180, 255, 40, .6); }
}
.action.armed { filter: none; opacity: .92; }
.action.safe {
  background: linear-gradient(180deg, #2a4d18 0%, #17300e 60%, #0e2008 100%);
  border-color: #4fae2a;
}
.action.dead {
  background: linear-gradient(180deg, #58120a 0%, #380b05 55%, #200502 100%);
  border-color: #c0301a;
  color: #ffd0c4;
  text-shadow: 0 0 12px #ff5030;
  box-shadow: inset 0 0 26px rgba(255, 60, 30, .3), 0 0 24px rgba(255, 60, 30, .3);
  filter: none;
  animation: deadFlash .6s 3;
}
@keyframes deadFlash { 50% { filter: brightness(1.6); } }

/* ---------------- stage ---------------- */
#stage { position: relative; min-width: 0; overflow: hidden; }
#stage-canvas, #stage-canvas canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
body.no-gl #stage {
  background:
    radial-gradient(ellipse at 50% 60%, rgba(60, 160, 30, .18), transparent 55%),
    repeating-linear-gradient(45deg, #05080a 0 24px, #060a08 24px 48px);
}

.hud { position: absolute; z-index: 10; }
.top-mid { top: 12px; left: 24px; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.info-box { min-width: 168px; text-align: center; padding: 7px 14px; }
.ib-label { font-size: 9.5px; letter-spacing: .26em; color: var(--dim); }
.ib-value { font-size: 21px; font-weight: 700; color: var(--acc); text-shadow: 0 0 12px var(--acc-soft); font-variant-numeric: tabular-nums; letter-spacing: .06em; }

/* risk panel */
.risk { top: 12px; right: 14px; width: 208px; text-align: center; pointer-events: none; }
.risk-mid { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 5px 0; }
.tri {
  width: 34px; height: 30px;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  background: linear-gradient(180deg, #d6ff4d, #5d9a00);
  color: #0a1400;
  font-size: 15px;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 1px;
}
.risk.warn .tri { background: linear-gradient(180deg, #ffd44d, #a97400); }
.risk.danger .tri { background: linear-gradient(180deg, #ff8060, #a01000); animation: pulse .5s infinite; }
.risk-label { font-size: 19px; font-weight: 700; letter-spacing: .08em; color: var(--acc); text-shadow: 0 0 12px var(--acc-soft); }
.risk.warn .risk-label { color: var(--amber); text-shadow: 0 0 12px rgba(255, 179, 0, .5); }
.risk.danger .risk-label { color: var(--red); text-shadow: 0 0 12px rgba(255, 60, 30, .6); }
.risk .segs { margin: 4px 10px; }
.risk-pct { font-size: 26px; font-weight: 700; color: var(--acc); text-shadow: 0 0 14px var(--acc-soft); font-variant-numeric: tabular-nums; }
.risk.warn .risk-pct { color: var(--amber); }
.risk.danger .risk-pct { color: var(--red); }

/* segment bars */
.segs { display: flex; gap: 3px; height: 10px; }
.segs i { flex: 1; background: #0b110a; border: 1px solid rgba(0, 0, 0, .8); outline: 1px solid rgba(120, 180, 80, .12); }
.segs i.on { background: #8dff1e; box-shadow: 0 0 7px rgba(150, 255, 30, .7); }
.segs i.on.warm { background: #ffd400; box-shadow: 0 0 7px rgba(255, 212, 0, .7); }
.segs i.on.hot { background: #ff5a2e; box-shadow: 0 0 7px rgba(255, 90, 46, .7); }
.segs i.on.amber { background: var(--amber); box-shadow: 0 0 7px rgba(255, 179, 0, .7); }
.risk.warn .segs i.on { background: #ffd400; box-shadow: 0 0 7px rgba(255, 212, 0, .6); }
.risk.danger .segs i.on { background: #ff5a2e; box-shadow: 0 0 7px rgba(255, 90, 46, .6); }

/* status panel */
#status-panel { right: 14px; bottom: 14px; width: 252px; pointer-events: none; }
.st-title { font-size: 17px; font-weight: 700; letter-spacing: .1em; color: var(--acc); text-shadow: 0 0 10px var(--acc-soft); margin: 6px 0 8px; }
.st-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 10px; letter-spacing: .12em; color: var(--dim); }
.st-row span { width: 118px; white-space: nowrap; }
.st-row .segs { flex: 1; height: 8px; }
.sd-title { font-size: 17px; font-weight: 700; letter-spacing: .08em; color: var(--red); text-shadow: 0 0 12px rgba(255, 60, 30, .6); text-align: center; margin-top: 4px; }
.sd-sub { text-align: center; font-size: 11px; letter-spacing: .18em; color: #ff9070; margin: 3px 0 8px; }
.sd-tri {
  width: 64px; height: 56px; margin: 4px auto;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  background: linear-gradient(180deg, #ff7040, #7a0c00);
  color: #200300;
  font-size: 28px;
  display: flex; align-items: flex-end; justify-content: center;
  animation: pulse .6s infinite;
}
.sd-note { text-align: center; font-size: 10.5px; letter-spacing: .16em; color: #ffb49c; line-height: 1.7; margin: 8px 0 4px; }

/* in-scene signs */
.sign {
  position: absolute;
  z-index: 8;
  left: 0; top: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(8, 12, 6, .92), rgba(4, 6, 3, .94));
  border: 1px solid var(--line);
  padding: 5px 12px;
  text-align: center;
  font-size: 11px;
  letter-spacing: .14em;
}
.sign.pressure .sg-label { font-size: 8.5px; letter-spacing: .3em; color: var(--dim); }
.sign.pressure .sg-value { font-size: 14px; font-weight: 700; color: var(--acc); text-shadow: 0 0 8px var(--acc-soft); }
.sign.pressure.warn .sg-value { color: var(--amber); }
.sign.pressure.danger .sg-value { color: var(--red); }
.sg-bar { display: flex; gap: 2px; height: 5px; margin-top: 3px; }
.sg-bar i { flex: 1; background: #8dff1e44; }
.sign.pressure.warn .sg-bar i { background: #ffd40055; }
.sign.pressure.danger .sg-bar i { background: #ff5a2e66; }
.sign.breach {
  border-color: #6a1408;
  color: #ff8560;
  font-weight: 700;
  font-size: 13px;
  padding: 9px 20px;
  text-shadow: 0 0 10px rgba(255, 80, 40, .6);
  box-shadow: 0 0 20px rgba(255, 60, 20, .25), inset 0 0 18px rgba(120, 10, 0, .5);
  animation: pulse 1s infinite;
}
.sign.evac {
  right: 24px; top: 46%; left: auto;
  border-color: #6a1408;
  color: #ff7a55;
  font-weight: 700;
  line-height: 1.8;
  padding: 12px 16px;
  text-shadow: 0 0 10px rgba(255, 80, 40, .6);
  animation: pulse 1.4s infinite;
}
.sign.maint {
  right: 26px; top: 44%; left: auto;
  border-color: #4d3d14;
  color: var(--amber);
  font-weight: 600;
  line-height: 1.8;
  padding: 10px 14px;
}
.sign.lock {
  left: 50%; bottom: 5%; top: auto;
  transform: translateX(-50%);
  border-color: #4d3d14;
  color: #d8b44a;
  line-height: 1.7;
  font-size: 10px;
}

/* repair overlay */
#ovl-repair {
  position: absolute;
  z-index: 12;
  left: 50%; top: 54%;
  transform: translate(-50%, -50%);
  width: min(430px, 60%);
  text-align: center;
  background: linear-gradient(180deg, rgba(16, 13, 5, .93), rgba(8, 6, 2, .95));
  border: 1px solid #8a6a14;
  box-shadow: 0 0 30px rgba(255, 190, 40, .12), inset 0 0 30px rgba(0, 0, 0, .6);
  clip-path: polygon(18px 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 0 100%, 0 18px);
  padding: 18px 20px 20px;
  pointer-events: none;
}
.rp-title { font-family: "Russo One", sans-serif; font-size: 24px; color: #ffc63f; text-shadow: 0 0 14px rgba(255, 198, 63, .5); letter-spacing: .04em; }
.rp-sub { font-size: 11px; letter-spacing: .26em; color: #b89a56; margin: 6px 0 12px; }
.rp-est { font-size: 10px; letter-spacing: .3em; color: #8a7440; border-top: 1px solid #4d3d14; padding-top: 10px; }
.rp-count { font-size: 44px; font-weight: 700; color: #ffc63f; text-shadow: 0 0 18px rgba(255, 198, 63, .5); font-variant-numeric: tabular-nums; }

/* vignette + alarm */
#vignette {
  position: absolute; inset: 0; z-index: 6;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 52%, rgba(255, 30, 8, .32));
  opacity: 0;
  transition: opacity .4s;
}
body.state-crashed #vignette { opacity: 1; animation: alarm 1s infinite; }
body.state-running #vignette { opacity: var(--risk-glow, 0); }
@keyframes alarm { 50% { opacity: .45; } }
@keyframes pulse { 50% { opacity: .45; } }

/* toasts / win pop */
#toasts { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 30; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast {
  background: rgba(6, 10, 5, .95);
  border: 1px solid var(--line);
  padding: 7px 16px;
  font-size: 11.5px;
  letter-spacing: .14em;
  transition: opacity .4s, transform .4s;
}
.toast.bad { border-color: #6a1408; color: #ff8560; }
.toast.good { border-color: #3f6a14; color: #b5ff5e; }
.toast.out { opacity: 0; transform: translateY(-8px); }
#win-pop {
  position: absolute; z-index: 31;
  left: 50%; top: 33%;
  transform: translate(-50%, -50%);
  font-family: "Russo One", sans-serif;
  font-size: 30px;
  padding: 14px 30px;
  pointer-events: none;
  opacity: 0;
  letter-spacing: .04em;
}
#win-pop.show { animation: winIn 1.9s forwards; }
#win-pop.good { color: #c8ff4d; text-shadow: 0 0 22px rgba(170, 255, 40, .8); background: rgba(10, 20, 4, .82); border: 1px solid #5d9a1e; }
#win-pop.bad { color: #ff6a48; text-shadow: 0 0 22px rgba(255, 70, 30, .8); background: rgba(22, 6, 2, .82); border: 1px solid #8a2410; }
#win-pop.hide { opacity: 0; }
@keyframes winIn {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.7); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
  20% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -62%); }
}

/* ---------------- provably-fair archive ---------------- */
.mono { font-family: "Share Tech Mono", monospace; letter-spacing: 0; }
.fair-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
  border-top: 1px solid rgba(120, 180, 80, .12);
  padding-top: 6px;
}
.link-btn {
  background: none;
  border: 1px solid var(--line);
  color: var(--acc-dim);
  font: 600 9.5px "Chakra Petch", sans-serif;
  letter-spacing: .18em;
  padding: 4px 9px;
  cursor: pointer;
  white-space: nowrap;
}
.link-btn:hover { color: var(--acc); border-color: var(--acc-soft); box-shadow: 0 0 8px rgba(150, 255, 30, .15); }
#fair-commit { font-size: 9.5px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; }

#fair-modal {
  position: fixed; inset: 0; z-index: 60;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(2, 4, 2, .78);
  backdrop-filter: blur(3px);
}
#fair-modal.shown { display: flex; }
.fair-panel {
  width: min(880px, 94vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  padding: 14px 16px;
}
.fair-top { display: flex; align-items: center; gap: 10px; }
.fair-title { flex: 1; font-family: "Russo One", sans-serif; font-size: 18px; color: var(--acc); text-shadow: 0 0 12px var(--acc-soft); }
.fair-title span { font-family: "Chakra Petch"; font-size: 9.5px; letter-spacing: .3em; color: var(--dim); margin-left: 10px; }
#fair-help {
  display: none;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--txt);
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, .35);
  padding: 10px 12px;
  margin-top: 10px;
}
#fair-help.shown { display: block; }
#fair-help p + p { margin-top: 8px; }
#fair-help .mono { color: var(--acc); font-size: 10.5px; }
#fair-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 9.5px;
  letter-spacing: .12em;
  color: var(--dim);
  margin: 10px 0 8px;
}
#fair-meta b { color: var(--txt); letter-spacing: 0; }
.fair-cols {
  display: grid;
  grid-template-columns: 70px 76px 1fr 1fr 130px 30px;
  gap: 8px;
  font-size: 9px;
  letter-spacing: .2em;
  color: var(--dim);
  padding: 4px 10px;
  border-bottom: 1px solid var(--line);
}
#fair-list { overflow-y: auto; min-height: 120px; flex: 1; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.fr-empty { text-align: center; color: var(--dim); letter-spacing: .18em; font-size: 11px; padding: 30px 0; }
.fr-row { border-bottom: 1px solid rgba(120, 180, 80, .08); }
.fr-head {
  display: grid;
  grid-template-columns: 70px 76px 1fr 1fr 130px 30px;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
  font-size: 11.5px;
  cursor: pointer;
}
.fr-head:hover { background: rgba(150, 255, 30, .05); }
.fr-id { color: var(--dim); }
.fr-time, .fr-pot { font-size: 10.5px; color: var(--dim); font-variant-numeric: tabular-nums; }
.fr-hash { font-size: 10px; color: var(--acc-dim); overflow: hidden; text-overflow: ellipsis; }
.fr-mine { font-size: 10px; font-weight: 700; justify-self: start; }
.fr-mine.good { color: #9dff1e; }
.fr-mine.bad { color: #ff6a4e; }
.fr-verify { text-align: center; font-size: 12px; color: var(--dim); }
.fr-verify.ok { color: #9dff1e; text-shadow: 0 0 8px rgba(150, 255, 30, .6); }
.fr-verify.fail { color: #ff4b2e; text-shadow: 0 0 8px rgba(255, 60, 30, .6); }
.fr-detail { display: none; padding: 4px 12px 10px; }
.fr-row.expanded .fr-detail { display: block; }
.fr-row.expanded { background: rgba(150, 255, 30, .03); }
.fr-bet {
  display: flex;
  gap: 12px;
  font-size: 11px;
  padding: 2.5px 8px;
  border-left: 2px solid rgba(120, 180, 80, .2);
}
.fr-bet.me { background: rgba(150, 255, 30, .07); border-left-color: var(--acc); }
.fr-bet.none { color: var(--dim); letter-spacing: .14em; font-size: 10px; }
.fb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.fb-amt { min-width: 64px; text-align: right; font-variant-numeric: tabular-nums; color: var(--dim); }
.fb-res { min-width: 130px; text-align: right; font-variant-numeric: tabular-nums; }
.fb-res.good { color: #9dff1e; }
.fb-res.bad { color: #ff6a4e; }
.fr-hash-full { font-size: 9.5px; color: var(--dim); margin-top: 6px; word-break: break-all; }
body.mini .fair-line { display: none; }

/* connection overlay */
#conn-overlay {
  position: absolute; inset: 0; z-index: 40;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(2, 4, 2, .8);
  backdrop-filter: blur(3px);
}
body.state-connecting #conn-overlay { display: flex; }
.conn-box { text-align: center; letter-spacing: .3em; font-size: 13px; color: var(--acc); }
.conn-spin { font-size: 54px; animation: spin 2.4s linear infinite; text-shadow: 0 0 24px var(--acc-soft); }
@keyframes spin { to { transform: rotate(360deg); } }

/* phase visibility helpers */
.only-crashed, .only-recovery { display: none; }
body.state-crashed .only-crashed { display: block; }
body.state-recovery .only-recovery { display: block; }
body.state-crashed .only-not-crashed { display: none; }
body.state-crashed .st-row.only-recovery { display: none; }
body.state-recovery .st-row.only-recovery { display: flex; }
#ovl-repair { display: none; }
body.state-recovery #ovl-repair { display: block; }

/* ---------------- mini (multi-instance) mode ---------------- */
#mini-hud { display: none; }
body.mini { grid-template-columns: 1fr; }
body.mini #side, body.mini .top-mid, body.mini #risk-panel, body.mini #status-panel,
body.mini .sign.evac, body.mini .sign.maint, body.mini .sign.lock, body.mini .sign.pressure,
body.mini #ovl-repair .rp-sub, body.mini #ovl-repair .rp-est { display: none !important; }
body.mini #ovl-repair { width: auto; padding: 8px 18px 10px; }
body.mini .rp-title { font-size: 14px; }
body.mini .rp-count { font-size: 22px; }
body.mini #win-pop { font-size: 16px; padding: 8px 14px; }
body.mini #mini-hud { display: block; }
.mh-top {
  position: absolute; top: 6px; left: 8px; right: 8px; z-index: 15;
  display: flex; justify-content: space-between; gap: 6px;
  pointer-events: none;
}
.mh-chip {
  background: rgba(5, 8, 4, .85);
  border: 1px solid var(--line);
  font-size: 10.5px;
  padding: 3px 9px;
  letter-spacing: .08em;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mh-chip b { color: var(--txt); }
#mini-auto { color: var(--amber); font-weight: 700; letter-spacing: .1em; }
.mh-bottom {
  position: absolute; bottom: 8px; left: 10px; right: 10px; z-index: 15;
  display: flex; align-items: center; gap: 10px;
}
#mini-mult {
  font-size: 34px; font-weight: 700;
  color: var(--acc);
  text-shadow: 0 0 14px var(--acc-soft);
  font-variant-numeric: tabular-nums;
  min-width: 118px;
}
.mini-action {
  margin: 0; flex: 1;
  min-height: 44px;
  font-size: 15px;
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}

/* tiny multi-view tiles (50+ frames) */
@media (max-width: 360px) {
  body.mini #mini-mult { font-size: 20px; min-width: 62px; }
  body.mini .mini-action { font-size: 10px; min-height: 26px; letter-spacing: .02em; gap: 0; }
  body.mini .mh-chip { font-size: 8.5px; padding: 2px 5px; letter-spacing: .02em; }
  body.mini .mh-top { top: 3px; left: 4px; right: 4px; gap: 3px; }
  body.mini .mh-bottom { bottom: 4px; left: 5px; right: 5px; gap: 6px; }
  body.mini #win-pop { font-size: 11px; padding: 4px 8px; }
  body.mini .rp-title { font-size: 10px; }
  body.mini .rp-count { font-size: 13px; }
  body.mini #ovl-repair { padding: 4px 10px 6px; }
}
@media (max-width: 200px) {
  body.mini .mh-chip:last-child { display: none; }
  body.mini #mini-mult { font-size: 15px; min-width: 46px; }
}

/* narrow screens */
@media (max-width: 1080px) {
  body:not(.mini) { grid-template-columns: 300px 1fr; }
  .logo-bio { font-size: 56px; }
  .bio-o { font-size: 48px; }
  .logo-reactor { font-size: 30px; }
  #mult-value { font-size: 44px; }
  .action { font-size: 20px; min-height: 64px; }
}

/* ============== mobile portrait: scene on top, controls below ============== */
@media (max-width: 760px) {
  body:not(.mini) {
    display: flex;
    flex-direction: column;
    height: 100dvh;
  }
  button, .action, .step-btn, .link-btn { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

  /* stage strip on top */
  body:not(.mini) #stage {
    order: 0;
    flex: none;
    height: 38vh;
    min-height: 225px;
    border-bottom: 1px solid #17240f;
  }
  /* controls column below */
  body:not(.mini) #side {
    order: 1;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    border-right: none;
    padding: 8px;
    gap: 8px;
    background: linear-gradient(180deg, rgba(4, 7, 4, .95), rgba(4, 7, 4, .8));
  }
  #side > .panel { flex-shrink: 0; }
  .logo { display: none; }

  /* order: multiplier -> bet controls -> players */
  #mult-panel { order: 0; }
  #bet-panel { order: 1; }
  #players-panel { order: 2; flex: none; }
  #players-rows { max-height: 190px; overflow-y: auto; }

  #mult-value { font-size: 40px; margin-top: 2px; }
  #mult-sub { font-size: 8.5px; letter-spacing: .28em; margin: 1px 0 5px; }
  #chart { height: 64px; }
  #history-row { margin-top: 6px; min-height: 16px; }
  .chip { font-size: 9px; padding: 2px 6px; }
  .fair-line { margin-top: 5px; padding-top: 5px; }

  .steppers { gap: 6px; }
  .step-btn { width: 42px; height: 42px; font-size: 20px; }
  .step-row input { font-size: 16px; } /* ≥16px stops iOS focus zoom */
  .action { min-height: 58px; font-size: 19px; margin-top: 8px; }
  .action span:last-child { font-size: 10px; }
  .op-row { font-size: 10.5px; margin-bottom: 6px; }
  .prow { font-size: 12px; padding: 3px 5px; }

  /* HUD over the scene: compact stacked boxes left, slim risk right */
  .top-mid { top: 6px; left: 6px; gap: 4px; }
  .info-box { min-width: 118px; padding: 3px 9px; }
  .ib-label { font-size: 7.5px; letter-spacing: .2em; }
  .ib-value { font-size: 13px; }
  .risk { top: 6px; right: 6px; width: 142px; padding: 5px 8px; }
  .risk-mid { gap: 6px; margin: 2px 0; }
  .tri { width: 20px; height: 18px; font-size: 9px; }
  .risk-label { font-size: 12px; }
  .risk .segs { height: 6px; margin: 2px 4px; gap: 2px; }
  .risk-pct { font-size: 15px; }
  #status-panel, .sign.pressure, .sign.evac, .sign.maint, .sign.lock { display: none !important; }

  .sign.breach { font-size: 9.5px; padding: 5px 10px; letter-spacing: .08em; white-space: nowrap; }
  #ovl-repair { width: min(300px, 86%); padding: 10px 12px 12px; }
  .rp-title { font-size: 15px; }
  .rp-sub { font-size: 8px; letter-spacing: .2em; margin: 4px 0 8px; }
  .rp-est { font-size: 8px; letter-spacing: .22em; padding-top: 7px; }
  .rp-count { font-size: 26px; }
  #win-pop { font-size: 17px; padding: 8px 16px; white-space: nowrap; }
  .toast { font-size: 10px; padding: 5px 10px; }

  /* provably-fair archive on a phone: drop time & hash columns */
  .fair-panel { max-height: 92dvh; padding: 10px; }
  .fair-title { font-size: 14px; }
  .fair-title span { display: block; margin: 2px 0 0; }
  #fair-meta { gap: 4px 12px; font-size: 8.5px; }
  #fair-help { font-size: 10.5px; }
  .fair-cols, .fr-head { grid-template-columns: 56px 66px 1fr 26px; gap: 6px; }
  .fair-cols span:nth-child(3), .fair-cols span:nth-child(5),
  .fr-head .fr-time, .fr-head .fr-hash { display: none; }
  .fr-head { font-size: 11px; padding: 6px 6px; }
  .fb-res { min-width: 96px; }
}
/* very short phones: sacrifice the chart, keep the button on screen */
@media (max-width: 760px) and (max-height: 660px) {
  body:not(.mini) #stage { height: 33vh; min-height: 200px; }
  #chart { display: none; }
  #mult-value { font-size: 33px; }
}

/* ============== mobile landscape / short wide windows ============== */
@media (max-height: 520px) and (min-width: 600px) {
  body:not(.mini) { grid-template-columns: 262px 1fr; }
  #side { overflow-y: auto; padding: 8px; gap: 8px; }
  #side > .panel { flex-shrink: 0; }
  .logo { display: none; }
  /* bet controls right under the multiplier so the button stays on screen */
  #mult-panel { order: 0; }
  #bet-panel { order: 1; }
  #players-panel { order: 2; }
  #mult-value { font-size: 34px; }
  #mult-sub { margin-bottom: 4px; }
  #chart { height: 54px; }
  #players-panel { flex: none; }
  #players-rows { max-height: 150px; overflow-y: auto; }
  .action { min-height: 46px; font-size: 16px; margin-top: 6px; }
  .step-btn { width: 32px; height: 32px; }
  #status-panel, .sign.evac, .sign.maint { display: none !important; }
  .risk { width: 150px; padding: 5px 8px; }
  .risk-label { font-size: 13px; }
  .risk-pct { font-size: 16px; }
  .tri { width: 22px; height: 19px; font-size: 10px; }
  .info-box { min-width: 128px; padding: 4px 10px; }
  .ib-value { font-size: 14px; }
  #ovl-repair { padding: 10px 14px; }
  .rp-title { font-size: 16px; }
  .rp-count { font-size: 26px; }
}
