/* =========================================================================
   FAKLE — Cell Block
   - The page is a place: a two-tone painted prison wall.
   - Inmates are the heroes: big portrait cells with a mugshot height chart.
   - Motion answers the player. Unprompted motion: lights-on at home, gate on entry.
   - Sprites move in steps (pixel art); light and camera move smoothly.
   ========================================================================= */

:root {
  --paint-hi: #26332f;
  --paint-lo: #1b2724;
  --stripe: #3b4c45;
  --pillar: #121916;
  --cell: #0e1412;
  --chart: rgba(236, 231, 216, 0.09);
  --bars: #76837d;
  --text: #ece7d8;
  --muted: #9aa69f;
  --jumpsuit: #ff6b1a;
  --jumpsuit-deep: #b6440a;
  --on-jumpsuit: #1d1009;
  --sodium: #f4c35a;
  --alarm: #e8413b;
  --free: #7bd88f;
  --paper: #ebe3cc;
  --paper-ink: #2b261d;

  --display: "Big Shoulders Stencil Display", "Impact", sans-serif;
  --body: "Atkinson Hyperlegible", system-ui, sans-serif;
  --typewriter: "Courier Prime", "Courier New", monospace;

  --bar-h: 88px;
  color-scheme: dark;
}
[data-theme="light"] {
  --paint-hi: #e7e0cc;
  --paint-lo: #a7c1b0;
  --stripe: #6f8f7c;
  --pillar: #cfc7b1;
  --cell: #34403b;
  --bars: #59645f;
  --text: #1b2320;
  --muted: #4e5b55;
  --jumpsuit: #ea5f12;
  --jumpsuit-deep: #a34008;
  --sodium: #b77d00;
  --alarm: #c42f2a;
  --free: #1d8748;
  color-scheme: light;
}
.cb { --free: #5aa9ff; }
[data-theme="light"].cb { --free: #2565d6; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--text);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.4;
  overflow-x: hidden;
  background:
    linear-gradient(to bottom,
      var(--paint-hi) 0, var(--paint-hi) 38vh,
      var(--stripe) 38vh, var(--stripe) calc(38vh + 10px),
      var(--paint-lo) calc(38vh + 10px)) fixed;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.16;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}
[data-theme="light"] body::before { opacity: 0.1; }

button { font: inherit; color: inherit; }
a { color: inherit; }
.small { font-size: 0.85rem; }
.muted { color: var(--muted); }
:focus-visible { outline: 3px solid var(--sodium); outline-offset: 2px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn:hover { color: var(--sodium); }

/* ---------------------------------------------------------------- Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 0 24px;
  border: 0;
  border-radius: 3px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.45rem;
  letter-spacing: 0.04em;
  text-decoration: none;
  cursor: pointer;
  transition: transform 60ms, box-shadow 60ms;
}
.btn-primary { background: var(--jumpsuit); color: var(--on-jumpsuit); box-shadow: 0 6px 0 var(--jumpsuit-deep); }
.btn-primary:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 1px 0 var(--jumpsuit-deep); }
.btn-primary:disabled { background: var(--pillar); color: var(--muted); box-shadow: 0 6px 0 color-mix(in srgb, var(--pillar) 60%, #000); cursor: default; }
.btn-primary.armed { animation: arm 240ms steps(2); }
@keyframes arm { 50% { transform: translateY(-3px); } }
.btn-ghost { background: transparent; color: var(--text); box-shadow: inset 0 0 0 2px var(--stripe); }
.btn-ghost:active { transform: translateY(2px); }
.btn-small { min-height: 44px; font-size: 1.1rem; }
.btn-big { min-height: 64px; font-size: 1.7rem; }

/* =========================================================================
   HOME
   ========================================================================= */
.home {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 760px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 28px);
  text-align: center;
}
.home-icons { display: flex; gap: 2px; align-self: flex-end; }
.home-logo {
  margin: 2vh 0 0;
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(5.2rem, 27vw, 11rem);
  line-height: 0.82;
  letter-spacing: 0.02em;
  color: var(--jumpsuit);
  text-shadow: 0 0 1px var(--jumpsuit), 0 0 18px color-mix(in srgb, var(--jumpsuit) 25%, transparent);
}
.home-tag { margin: 10px 0 22px; font-weight: 700; font-size: clamp(1.1rem, 4.4vw, 1.4rem); }

.lineup {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
  width: 100%;
  padding: 5px;
  background: var(--pillar);
  box-shadow: 0 0 0 2px var(--stripe);
}
.mini { position: relative; aspect-ratio: 3 / 4; overflow: hidden; background: var(--cell); }
.mini .inmate { width: 74%; margin-left: -37%; }
.mini .bars { border-width: 3px; }
.mini .no {
  position: absolute;
  top: 8px;
  left: 50%;
  z-index: 3;
  padding: 1px 4px 0;
  background: var(--pillar);
  transform: translateX(-50%);
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(0.75rem, 3vw, 1.15rem);
  line-height: 1;
  color: var(--jumpsuit);
}

.home-case { margin: 18px 0 14px; font-family: var(--typewriter); font-weight: 700; color: var(--muted); }
.home-actions { display: grid; gap: 14px; width: 100%; max-width: 420px; }
.home-wall { margin-top: 26px; }
.home-served { margin: 6px 0 0; font-family: var(--display); font-weight: 800; font-size: 1.4rem; }
.home-next { margin: 12px 0 0; color: var(--muted); }
.home-next span { font-family: var(--typewriter); font-weight: 700; color: var(--text); }

/* =========================================================================
   GATE: drops and lifts when you enter the cell block
   ========================================================================= */
.gate {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  transform: translateY(-101%);
  background:
    linear-gradient(var(--bars), var(--bars)) 0 22% / 100% 16px no-repeat,
    linear-gradient(var(--bars), var(--bars)) 0 70% / 100% 16px no-repeat,
    repeating-linear-gradient(90deg, rgba(5, 8, 7, 0.6) 0 38px, var(--bars) 38px 50px);
  border-bottom: 18px solid var(--bars);
}
.gate.drop { animation: gate-drop 260ms steps(5) forwards; }
.gate.lift { animation: gate-lift 560ms steps(8) forwards; }
@keyframes gate-drop { from { transform: translateY(-101%); } to { transform: translateY(0); } }
@keyframes gate-lift { from { transform: translateY(0); } to { transform: translateY(-101%); } }

/* =========================================================================
   GAME
   ========================================================================= */
.game { position: relative; z-index: 1; }
.topbar {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 4px 12px;
  max-width: 1180px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 0;
}
.logo { font-family: var(--display); font-weight: 900; font-size: 2.1rem; line-height: 1; color: var(--jumpsuit); text-decoration: none; }
.placard { font-family: var(--typewriter); font-weight: 700; color: var(--muted); }
.tries { display: flex; gap: 6px; }
.try { display: block; width: 20px; height: 24px; }
.try svg { display: block; width: 100%; height: 100%; }
.try.used { opacity: 0.3; }
.try.just-used { animation: try-pop 420ms steps(4) both; }
@keyframes try-pop { 0% { opacity: 1; } 30% { transform: translateY(-6px); } 100% { transform: none; opacity: 0.3; } }
.topbar-icons { display: flex; }

main {
  position: relative;
  max-width: 1180px;
  margin: 0 auto;
  padding: 8px 12px calc(var(--bar-h) + env(safe-area-inset-bottom) + 28px);
}
.tagline { margin: 4px 0 14px; font-family: var(--display); font-weight: 800; font-size: clamp(1.5rem, 6vw, 2.3rem); line-height: 1; }

/* ---------------------------------------------------------------- Cell block */
.block { position: relative; padding: 6px; background: var(--pillar); box-shadow: 0 0 0 2px var(--stripe); }
.cellblock {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
@media (min-width: 700px) { .cellblock { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .cellblock { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

.cell { position: relative; display: flex; flex-direction: column; background: var(--paint-lo); }
.cell-btn {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

/* Cell interior: mugshot height chart on the back wall */
.cell-window, .mini {
  background:
    repeating-linear-gradient(to top, transparent 0 calc(25% - 2px), var(--chart) calc(25% - 2px) 25%),
    var(--cell);
}
.cell-window { position: relative; aspect-ratio: 5 / 4; overflow: hidden; }
@media (min-width: 1100px) { .cell-window { aspect-ratio: 4 / 5; } }
.lamp {
  position: absolute;
  top: 0;
  right: 22%;
  left: 22%;
  z-index: 1;
  height: 3px;
  background: #fff6d8;
  box-shadow: 0 0 12px 2px rgba(255, 238, 190, 0.5);
}
.cell-window::before, .mini::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 70% 90% at 50% 0%, rgba(255, 238, 190, 0.18), transparent 70%);
}
.darkness { position: absolute; inset: 0; z-index: 4; background: #050807; opacity: 0; pointer-events: none; }
.inmate { position: absolute; bottom: -2px; left: 50%; width: 52%; margin-left: -26%; }
.inmate-svg { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.bars {
  position: absolute;
  inset: 0;
  z-index: 2;
  background:
    linear-gradient(var(--bars), var(--bars)) 0 6px / 100% 6px no-repeat,
    linear-gradient(var(--bars), var(--bars)) 0 64% / 100% 5px no-repeat,
    repeating-linear-gradient(90deg, transparent 0 calc(16.66% - 5px), var(--bars) calc(16.66% - 5px) 16.66%);
  border: 4px solid var(--bars);
}
.cell-no {
  position: absolute;
  top: 16px;
  left: 8px;
  z-index: 3;
  padding: 2px 6px 0;
  background: var(--pillar);
  font-family: var(--display);
  font-weight: 900;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--jumpsuit);
}
.lock-drop { position: absolute; top: 36%; left: 50%; z-index: 3; width: 30px; margin-left: -15px; opacity: 0; transform-origin: 50% 100%; }
.hole {
  position: absolute;
  right: -6px;
  bottom: 4px;
  z-index: 1;
  width: 46%;
  height: 62%;
  background: #000;
  clip-path: polygon(24% 0, 62% 8%, 100% 20%, 100% 100%, 6% 100%, 0 72%, 14% 38%);
  transform: scale(0);
  transform-origin: 80% 90%;
}

/* The fact, on the inmate's placard */
.placard-text {
  flex: 1;
  margin: 0;
  padding: 10px 12px 14px;
  font-weight: 700;
  font-size: 1.02rem;
  line-height: 1.3;
  text-wrap: pretty;
}

/* Rubber stamp */
.stamp {
  position: absolute;
  bottom: 10px;
  left: 50%;
  z-index: 5;
  padding: 0 7px;
  border: 3px solid currentColor;
  background: color-mix(in srgb, var(--cell) 70%, transparent);
  font-family: var(--display);
  font-weight: 900;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
  transform: translateX(-50%) rotate(-8deg);
  opacity: 0;
  pointer-events: none;
}
[data-theme="light"] .stamp { background: var(--paper); }
.stamp:empty { display: none; }
.stamp.slam { animation: slam 260ms cubic-bezier(0.2, 0, 0.3, 1) forwards; }
.stamp.shown { opacity: 1; }
@keyframes slam {
  0% { opacity: 0; transform: translateX(-50%) rotate(-14deg) scale(2.4); }
  70% { opacity: 1; transform: translateX(-50%) rotate(-7deg) scale(0.92); }
  100% { opacity: 1; transform: translateX(-50%) rotate(-8deg) scale(1); }
}

/* ---------------------------------------------------------------- Searchlight = cursor */
.spot {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 6;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
  transform: translate(var(--sx, 0), var(--sy, 0));
  transition:
    transform 460ms cubic-bezier(0.34, 1.45, 0.6, 1),
    width 460ms cubic-bezier(0.34, 1.45, 0.6, 1),
    height 460ms cubic-bezier(0.34, 1.45, 0.6, 1),
    opacity 200ms;
}
.spot::before {
  content: "";
  position: absolute;
  inset: -22px;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--sodium) 42%, transparent), transparent 85%);
  mix-blend-mode: screen;
}
[data-theme="light"] .spot::before { mix-blend-mode: multiply; background: radial-gradient(closest-side, color-mix(in srgb, var(--sodium) 24%, transparent), transparent 85%); }
.spot::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 3px solid var(--sodium);
  box-shadow: 0 0 24px color-mix(in srgb, var(--sodium) 45%, transparent);
}
.spot.on { opacity: 1; }
.spot.charge { transition: transform 140ms ease-in, width 140ms ease-in, height 140ms ease-in; }
.spot.charge::after { border-width: 5px; border-color: var(--jumpsuit); }

/* ---------------------------------------------------------------- Outcomes */
.cell.released .bars { animation: door-open 520ms steps(6) forwards; }
.cell.released .inmate { animation: walk-out 900ms steps(6) 300ms forwards; }
.cell.released .placard-text { color: var(--muted); }
.cell.released .cell-btn { cursor: default; }
.cell.released .stamp, .cell.innocent .stamp { color: var(--free); }
@keyframes door-open { to { transform: translateY(-104%); } }
@keyframes walk-out { to { transform: translateX(-60%); opacity: 0.5; filter: grayscale(0.9); } }

.cell.locked { background: color-mix(in srgb, var(--jumpsuit) 24%, var(--paint-lo)); }
.cell.locked .lock-drop { animation: lock-fall 520ms forwards; }
.cell.locked .stamp { color: var(--jumpsuit); }
.cell.locked .bars { animation: bars-rattle 300ms steps(3); }
@keyframes lock-fall {
  0% { opacity: 1; transform: translateY(-110px) scale(1, 1.15); animation-timing-function: cubic-bezier(0.55, 0, 1, 0.45); }
  55% { opacity: 1; transform: translateY(0) scale(1.25, 0.7); animation-timing-function: ease-out; }
  75% { transform: translateY(-6px) scale(0.92, 1.1); animation-timing-function: ease-in; }
  100% { opacity: 1; transform: none; }
}
@keyframes bars-rattle { 33% { transform: translateX(-2px); } 66% { transform: translateX(2px); } }

.cell.escaped { background: color-mix(in srgb, var(--alarm) 20%, var(--paint-lo)); }
.cell.escaped .hole { animation: hole 420ms steps(4) forwards; }
.cell.escaped .inmate { animation: run 700ms steps(7) 420ms forwards; }
.cell.escaped .stamp { color: var(--alarm); }
@keyframes hole { to { transform: scale(1); } }
@keyframes run { 30% { transform: translate(12px, -4px); } 100% { transform: translateX(200%); opacity: 0; } }

.no-anim, .no-anim * { animation-duration: 0s !important; animation-delay: 0s !important; }
.px { position: absolute; z-index: 7; width: 4px; height: 4px; pointer-events: none; }

/* ---------------------------------------------------------------- Lights on (home) */
body.lights-off .lineup .darkness { opacity: 1; }
body.intake .lineup .darkness { animation: room-on 900ms steps(1) both; animation-delay: calc(var(--i) * 150ms + 250ms); }
body.intake .lineup .lamp { animation: tube-on 900ms steps(1) both; animation-delay: calc(var(--i) * 150ms + 250ms); }
body.intake .home-logo { animation: tube-on 1000ms steps(1) both; }
@keyframes tube-on { 0% { opacity: 0.08; } 8% { opacity: 1; } 14% { opacity: 0.1; } 30% { opacity: 1; } 36% { opacity: 0.2; } 52%, 100% { opacity: 1; } }
@keyframes room-on { 0% { opacity: 1; } 8% { opacity: 0.1; } 14% { opacity: 0.9; } 30% { opacity: 0.15; } 36% { opacity: 0.7; } 52%, 100% { opacity: 0; } }

/* ---------------------------------------------------------------- Case file slips */
.casefile {
  margin: 0 8px 8px;
  padding: 10px 11px 11px;
  background: var(--paper);
  color: var(--paper-ink);
  font-family: var(--typewriter);
  font-size: 0.86rem;
  line-height: 1.35;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}
.casefile.unfold { animation: unfold 360ms steps(5) both; animation-delay: calc(var(--i) * 70ms); }
@keyframes unfold { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0); } }
.casefile p { margin: 4px 0 6px; }
.verdict { font-weight: 700; }
.v-true { color: #1e6e3f; }
.v-fake { color: #a3241f; }
.casefile a { color: var(--paper-ink); font-size: 0.8rem; text-underline-offset: 3px; }
body.game-over .cell-btn { cursor: default; }

.status-msg { min-height: 1.4em; margin: 14px 0 0; text-align: center; color: var(--muted); }
.empty { grid-column: 1 / -1; padding: 48px 16px; text-align: center; background: var(--paint-lo); }
.empty h2 { margin: 0 0 6px; font-family: var(--display); font-size: 2.2rem; color: var(--jumpsuit); }

.actionbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--paint-lo) 60%, transparent);
}
.actionbar .btn { width: 100%; max-width: 460px; }

/* =========================================================================
   MODALS
   ========================================================================= */
.modal {
  width: min(460px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 26px 20px 20px;
  border: 0;
  border-radius: 3px;
  background: var(--paint-lo);
  color: var(--text);
  box-shadow: 0 0 0 6px var(--pillar), 0 0 0 8px var(--stripe);
  overflow-y: auto;
  text-align: center;
}
.modal[open] { animation: drop-in 240ms steps(4); }
@keyframes drop-in { from { transform: translateY(-24px); opacity: 0; } }
.modal::backdrop { background: rgba(4, 7, 6, 0.78); }
.modal-close { position: absolute; top: 6px; right: 6px; width: 44px; height: 44px; border: 0; background: transparent; color: var(--muted); font-size: 1.2rem; cursor: pointer; }
.modal-title { margin: 4px 0 6px; font-family: var(--display); font-weight: 900; font-size: 2.6rem; line-height: 1; }
.modal-sub { margin: 0 0 16px; color: var(--muted); }
.section-title { margin: 20px 0 8px; font-size: 1rem; font-weight: 700; text-align: left; }

.stamp-big {
  display: inline-block;
  padding: 0 12px;
  border: 4px solid currentColor;
  font-family: var(--display);
  font-weight: 900;
  font-size: 1.3rem;
  letter-spacing: 0.04em;
  transform: rotate(-6deg);
  animation: slam-big 280ms 120ms cubic-bezier(0.2, 0, 0.3, 1) both;
}
@keyframes slam-big { 0% { opacity: 0; transform: rotate(-12deg) scale(2.4); } 70% { opacity: 1; transform: rotate(-5deg) scale(0.92); } 100% { opacity: 1; transform: rotate(-6deg); } }
.stamp-big.is-won { color: var(--jumpsuit); }
.stamp-big.is-lost { color: var(--alarm); }

.share-preview {
  display: inline-block;
  min-width: 220px;
  margin: 0 auto 14px;
  padding: 12px 16px;
  background: var(--paper);
  color: var(--paper-ink);
  font-family: var(--typewriter);
  font-size: 0.98rem;
  text-align: left;
  white-space: pre-wrap;
}
.btn-row { display: grid; gap: 12px; }

.wall { margin: 20px 0 12px; padding: 14px 12px 12px; background: var(--paint-hi); }
.wall-count { font-family: var(--display); font-weight: 800; font-size: 1.6rem; }
.tally { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; min-height: 42px; padding: 6px 0; }
.tally-group { position: relative; display: inline-flex; gap: 6px; height: 34px; padding: 0 3px; }
.tally-group i { display: block; width: 3px; height: 100%; background: currentColor; opacity: 0.85; transform: rotate(3deg); }
.tally-group i:nth-child(2n) { height: 92%; transform: rotate(-2deg); }
.tally-group i.slash { position: absolute; top: 50%; left: -5px; width: calc(100% + 10px); height: 3px; transform: rotate(-28deg); }
.tally-group i.fresh { color: var(--sodium); background: var(--sodium); animation: scratch 520ms steps(6) 650ms both; }
.tally-group i.slash.fresh { animation-name: scratch-x; }
@keyframes scratch { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0); } }
@keyframes scratch-x { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0); } }
.tally-more, .tally-empty { align-self: center; font-size: 0.85rem; color: var(--muted); }

.countdown { margin: 6px 0 12px; color: var(--muted); }
.countdown span { font-family: var(--typewriter); font-weight: 700; color: var(--text); }

.ad-slot { display: grid; place-items: center; max-width: 320px; min-height: 100px; margin: 14px auto 10px; border: 2px dashed var(--stripe); font-size: 0.8rem; color: var(--muted); }
.cold-teaser { width: 100%; margin-top: 6px; padding: 10px; border: 0; background: transparent; box-shadow: inset 0 0 0 2px var(--stripe); color: var(--muted); cursor: pointer; }
.soon { margin-left: 6px; padding: 0 6px; background: var(--sodium); color: #1d1608; font-size: 0.75rem; font-weight: 700; }

.grade { margin: 0 0 16px; color: var(--muted); }
.grade b { color: var(--jumpsuit); }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stat b { display: block; font-family: var(--display); font-size: 2.3rem; line-height: 1; }
.stat span { font-size: 0.78rem; color: var(--muted); }
.dist { display: grid; gap: 6px; }
.dist-row { display: grid; grid-template-columns: 80px 1fr; align-items: center; gap: 8px; text-align: left; }
.dist-label { font-size: 0.85rem; color: var(--muted); }
.dist-bar { width: var(--w); min-width: 28px; padding: 1px 8px; background: var(--stripe); font-family: var(--typewriter); font-weight: 700; font-size: 0.85rem; text-align: right; }
.dist-bar.today { background: var(--jumpsuit); color: var(--on-jumpsuit); }
.dist-bar.today.is-lost { background: var(--alarm); color: #fff; }
.stat-extra { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 18px; font-size: 0.8rem; color: var(--muted); }
.stat-extra b { display: block; font-family: var(--display); font-size: 1.7rem; color: var(--text); }

.help { text-align: left; }
.help .lead { font-size: 1.05rem; }
.help-steps { display: grid; gap: 10px; margin: 14px 0; padding: 0; list-style: none; }
.help-steps li { position: relative; min-height: 26px; padding-left: 38px; }
.help-steps .n { position: absolute; top: 0; left: 0; display: grid; place-items: center; width: 26px; height: 26px; background: var(--jumpsuit); color: var(--on-jumpsuit); font-family: var(--display); font-weight: 900; }
.ok { color: var(--free); }
.lock { color: var(--jumpsuit); }
.bad { color: var(--alarm); }
#modal-help .btn { width: 100%; margin-top: 8px; }

.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-bottom: 2px solid var(--stripe); text-align: left; cursor: pointer; }
.setting small { display: block; font-size: 0.85rem; color: var(--muted); }
.setting input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--jumpsuit); }
.setting select { padding: 6px 8px; border: 2px solid var(--stripe); background: var(--pillar); color: var(--text); font: inherit; }

.cold-list { display: grid; gap: 6px; margin-bottom: 14px; }
.cold-item { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 10px 12px; background: var(--pillar); font-family: var(--typewriter); text-align: left; }
.cold-lock { font-size: 0.8rem; color: var(--muted); }
.purchase-slot { padding: 14px; border: 2px dashed var(--jumpsuit); }

.toast {
  position: fixed;
  bottom: calc(var(--bar-h) + env(safe-area-inset-bottom) + 12px);
  left: 50%;
  z-index: 100;
  max-width: calc(100vw - 32px);
  padding: 8px 14px;
  background: var(--paper);
  color: var(--paper-ink);
  font-family: var(--typewriter);
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
  transform: translateX(-50%) rotate(-1deg);
  opacity: 0;
  pointer-events: none;
}
.toast.show { animation: toast 2400ms steps(1) forwards; }
@keyframes toast { 0%, 92% { opacity: 1; } 100% { opacity: 0; } }

.noscript { padding: 40px; text-align: center; }

@media (max-width: 420px) {
  .topbar { grid-template-columns: auto 1fr auto; }
  .placard { display: none; }
  .placard-text { padding: 8px 9px 12px; font-size: 0.95rem; }
  .cell-no { top: 14px; left: 6px; font-size: 1.1rem; }
  .stamp { font-size: 0.95rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0s !important; transition-duration: 1ms !important; }
}

/* Home lineup: fewer, thinner bars so the inmates read at small sizes */
.mini .bars {
  border-width: 3px;
  background:
    linear-gradient(var(--bars), var(--bars)) 0 5px / 100% 4px no-repeat,
    linear-gradient(var(--bars), var(--bars)) 0 64% / 100% 3px no-repeat,
    repeating-linear-gradient(90deg, transparent 0 calc(25% - 3px), var(--bars) calc(25% - 3px) 25%);
}
@media (max-width: 600px) {
  .lineup { grid-template-columns: repeat(3, 1fr); }
  .mini { aspect-ratio: 1 / 1; }
  .mini .inmate { width: 58%; margin-left: -29%; }
}

/* Bars leave the face clear: none in the middle third */
.bars, .mini .bars {
  background:
    linear-gradient(var(--bars), var(--bars)) 0 6px / 100% 5px no-repeat,
    linear-gradient(var(--bars), var(--bars)) 0 66% / 100% 4px no-repeat,
    linear-gradient(var(--bars), var(--bars)) 12% 0 / 4px 100% no-repeat,
    linear-gradient(var(--bars), var(--bars)) 30% 0 / 4px 100% no-repeat,
    linear-gradient(var(--bars), var(--bars)) 70% 0 / 4px 100% no-repeat,
    linear-gradient(var(--bars), var(--bars)) 88% 0 / 4px 100% no-repeat;
}
.mini .bars { background-size: 100% 4px, 100% 3px, 3px 100%, 3px 100%, 3px 100%, 3px 100%; }
.sources { margin: 0; padding: 0; list-style: none; font-size: 0.8rem; }
.sources li + li { margin-top: 2px; }

@media (min-width: 1100px) {
  .cell-window .inmate { width: 74%; margin-left: -37%; }
  .game main { display: flex; flex-direction: column; justify-content: center; min-height: calc(100dvh - 60px); }
}
body.game-over .cell-btn { flex: 0 0 auto; }
body.game-over .placard-text { flex: 0 0 auto; }

/* =========================================================================
   v3 — quieter selection, game intake, facts on paper placards
   ========================================================================= */

/* Selection: a thin rim of light, no glow. The inmate steps forward, the others dim. */
.spot::before { display: none; }
.spot::after { border-width: 2px; box-shadow: none; }
.spot.charge::after { border-width: 3px; }
.cell .cell-window .inmate { transition: transform 180ms steps(2); }
.cell.is-selected .cell-window .inmate { transform: translateY(-4%) scale(1.1); }
.cell-window { transition: filter 200ms steps(2); }
.cellblock.has-selection .cell:not(.is-selected) .cell-window { filter: brightness(0.62) saturate(0.8); }
.cellblock.has-selection .cell:not(.is-selected) .placard-text { opacity: 0.7; }

/* The fact is the hero: printed on the inmate's paper placard */
.placard-text {
  position: relative;
  flex: 1;
  margin: 8px;
  padding: 12px 12px 14px;
  background: var(--paper);
  color: var(--paper-ink);
  font-weight: 700;
  font-size: clamp(1.02rem, 0.55rem + 0.9vw, 1.3rem);
  line-height: 1.22;
  letter-spacing: -0.005em;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.4);
  transition: opacity 200ms steps(2);
}
.cell:nth-child(odd) .placard-text { transform: rotate(-0.6deg); }
.cell:nth-child(even) .placard-text { transform: rotate(0.5deg); }
[data-theme="light"] .placard-text { box-shadow: 0 0 0 2px var(--stripe), 0 3px 0 rgba(0, 0, 0, 0.25); }
.cell.released .placard-text { color: var(--paper-ink); opacity: 0.5; }
.cell.locked .placard-text, .cell.escaped .placard-text { opacity: 1; }
body.game-over .placard-text { flex: 0 0 auto; margin-bottom: 0; transform: none; }

/* Case file continues the same sheet of paper */
.casefile {
  margin: 0 8px 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(43, 38, 29, 0.35);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.4);
  font-size: 0.84rem;
}

/* Arrival in the cell block: lights come on cell by cell, then each placard flips into view */
body.intake-game .cell .darkness { animation: room-on 800ms steps(1) both; animation-delay: calc(var(--i) * 120ms + 150ms); }
body.intake-game .cell .lamp { animation: tube-on 800ms steps(1) both; animation-delay: calc(var(--i) * 120ms + 150ms); }
body.intake-game .cell .placard-text { animation: placard-flip 360ms steps(4) both; animation-delay: calc(var(--i) * 120ms + 700ms); }
body.intake-game .tagline { animation: tube-on 900ms steps(1) both; }
@keyframes placard-flip {
  0% { transform: perspective(500px) rotateX(90deg); opacity: 0; }
  60% { transform: perspective(500px) rotateX(-12deg); opacity: 1; }
  100% { transform: perspective(500px) rotateX(0); opacity: 1; }
}

/* Blink: eyelids shown for a frame */
.lids { opacity: 0; }
.blink .lids { opacity: 1; }

/* End-of-game reactions from the innocents (stepped, like sprites) */
.cell.cheer .cell-window .inmate { animation: cheer 600ms steps(2) 2; }
@keyframes cheer { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12%); } }
.cell.gasp .cell-window .inmate { animation: gasp 360ms steps(3) 1; }
@keyframes gasp { 0%, 100% { transform: translateX(0); } 33% { transform: translateX(-4%); } 66% { transform: translateX(4%); } }

/* =========================================================================
   v4 — personalities, crowd vote, duels, wall of liars
   ========================================================================= */

/* Who is speaking: signature at the bottom of the placard */
.signature {
  display: block;
  margin-top: 8px;
  font-family: var(--typewriter);
  font-weight: 700;
  font-size: 0.78rem;
  color: #6b5f48;
  text-align: right;
}

/* Speech bubble, pixel style */
.bubble {
  position: absolute;
  top: 8px;
  left: 50%;
  z-index: 8;
  width: max-content;
  max-width: 92%;
  padding: 5px 8px;
  background: #fffaf0;
  color: #1d1009;
  border: 2px solid #1d1009;
  font-family: var(--body);
  font-weight: 700;
  font-size: 0.82rem;
  line-height: 1.2;
  text-align: center;
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
}
.bubble::after {
  content: "";
  position: absolute;
  bottom: -8px;
  left: 50%;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  background: #fffaf0;
  border-right: 2px solid #1d1009;
  border-bottom: 2px solid #1d1009;
  transform: rotate(45deg);
}
.bubble.say { animation: say 2400ms steps(1) forwards; }
@keyframes say {
  0% { opacity: 1; transform: translateX(-50%) translateY(4px); }
  4% { transform: translateX(-50%) translateY(0); }
  90% { opacity: 1; }
  100% { opacity: 0; }
}

/* Crowd vote under each placard after the game */
.crowd { margin: 6px 0 2px; }
.crowd-bar { height: 8px; background: rgba(43, 38, 29, 0.15); }
.crowd-bar i { display: block; height: 100%; width: 0; background: var(--paper-ink); transition: width 700ms steps(7); }
.crowd-label { margin-top: 3px; font-size: 0.78rem; }
.cell.locked .crowd-bar i, .cell.escaped .crowd-bar i { background: var(--alarm); }
.crowd-demo { margin: 10px 0 0; font-size: 0.8rem; color: var(--muted); text-align: center; }

/* Duel banner on the home screen */
.duel-banner {
  width: 100%;
  max-width: 420px;
  margin: 0 0 14px;
  padding: 10px 14px;
  background: var(--paper);
  color: var(--paper-ink);
  font-weight: 700;
  transform: rotate(-1deg);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
}
.duel-banner small { display: block; font-family: var(--typewriter); font-weight: 400; }
.home-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Head-to-head card in the result */
.h2h { margin: 4px 0 16px; padding: 12px 14px; background: var(--paper); color: var(--paper-ink); text-align: left; }
.h2h-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 4px 0; font-weight: 700; }
.h2h-row + .h2h-row { border-top: 1px dashed rgba(43, 38, 29, 0.35); }
.h2h-row.win { color: #a3400a; }
.h2h-verdict { margin: 8px 0 0; font-family: var(--display); font-weight: 900; font-size: 1.4rem; text-align: center; }

/* Name dialog */
.name-form { display: grid; gap: 12px; }
.name-form input {
  min-height: 52px;
  padding: 0 14px;
  border: 0;
  background: var(--paper);
  color: var(--paper-ink);
  font: inherit;
  font-weight: 700;
  font-size: 1.15rem;
}

/* Wall of liars: a gallery of mugshots */
.modal-wide { width: min(640px, calc(100vw - 24px)); }
.stats-wall { width: 100%; margin-top: 18px; }
.wall-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.mug {
  position: relative;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: center;
  cursor: pointer;
}
.mug-photo {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background:
    repeating-linear-gradient(to top, transparent 0 calc(25% - 2px), var(--chart) calc(25% - 2px) 25%),
    var(--cell);
}
.mug-photo .inmate { width: 66%; margin-left: -33%; }
.mug-no {
  position: absolute;
  bottom: 4px;
  left: 50%;
  z-index: 2;
  padding: 0 5px;
  background: #0b0f0d;
  color: var(--paper);
  font-family: var(--typewriter);
  font-weight: 700;
  font-size: 0.72rem;
  transform: translateX(-50%);
}
.mug-tag { position: absolute; top: 6px; left: 50%; z-index: 2; padding: 0 5px; border: 2px solid currentColor; font-family: var(--display); font-weight: 900; font-size: 0.8rem; transform: translateX(-50%) rotate(-8deg); background: var(--cell); }
.mug.won .mug-tag { color: var(--jumpsuit); }
.mug.lost .mug-tag { color: var(--alarm); }
.mug.lost .inmate { opacity: 0.25; }
.mug-name { margin-top: 4px; font-size: 0.82rem; font-weight: 700; }
.mug.selected .mug-photo { outline: 2px solid var(--sodium); }
.wall-detail { margin: 0 0 14px; padding: 12px 14px; background: var(--paper); color: var(--paper-ink); text-align: left; }
.wall-detail q { display: block; font-weight: 700; font-size: 1.05rem; }
.wall-detail p { margin: 6px 0 0; font-family: var(--typewriter); font-size: 0.86rem; }
.wall-empty { grid-column: 1 / -1; color: var(--muted); }
