/* Dice to Seed, phone. "Midnight Garage" (design/midnight garage.md): rockabilly badass x broadcast
   control room. Mobile first, portrait, one handed, readable at arm's length.
   Tokens come from shared/brand.css. Orange = the one live or chosen thing. Blue = computed.
   Red (--live) = ON AIR and the burn banner only. Errors and re-rolls use --bad. */

:root {
  --gutter: 16px;
  --stage-max-h: 44vh;

  /* derived tokens (the only literals in this file live here) */
  --on-flame: #17110A;
  --white: #FFFFFF;
  --steel: #B9C4E0;
  --blue-hi: #A8E4FA;
  --blue-lo: #5BB8DF;
  --flap: #0A0D17;
  --onair-text: #FFD7DC;
  --steel-2: #AFBBD9;
  --orange-soft: rgba(247, 147, 26, .12);
  --orange-line: rgba(247, 147, 26, .42);
  --orange-glow: rgba(247, 147, 26, .35);
  --flame-shadow: 0 6px 22px rgba(232, 99, 10, .45), inset 0 1px 0 rgba(255, 255, 255, .4);
  --blue-soft: rgba(126, 211, 242, .10);
  --blue-line: rgba(126, 211, 242, .38);
  --bad-soft: rgba(255, 107, 107, .12);
  --bad-line: rgba(255, 107, 107, .5);
  --ok-line: rgba(61, 220, 132, .45);
  --live-soft: rgba(255, 71, 87, .12);
  --live-line: rgba(255, 71, 87, .45);
  --scrim: rgba(7, 9, 15, .66);
  --glass: rgba(7, 9, 15, .78);
  --card: linear-gradient(180deg, var(--ink-3) 0%, var(--ink-2) 100%);
  --card-shadow: 0 14px 34px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .045);
  --inset: linear-gradient(180deg, #0A0E1A 0%, var(--ink-1) 100%);
  --blue-fill: linear-gradient(135deg, var(--blue-hi), var(--blue-lo));
  --pipdot: radial-gradient(circle, var(--pip) 0 55%, transparent 61%);
  --grain: 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 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ------------------------------------------------------------ base */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--ink-0); }
body {
  min-height: 100dvh;
  background: var(--ink-0);
  font-size: 14px; line-height: 1.5;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; -webkit-appearance: none; appearance: none; }
button:disabled { opacity: .35; cursor: default; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
[hidden] { display: none !important; }
img { display: block; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.noselect, .noselect * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

/* Film grain over everything, very faint. Cheap: one static tile. */
.app::after {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: -1;
  background-image: var(--grain); background-size: 160px; opacity: .045; mix-blend-mode: overlay;
}

/* The shared burn banner wraps to two lines on a phone; main.js measures it into --banner-h.
   The banner already pads for the notch, so the page must not add the top inset again. */
body > .app {
  max-width: 560px;
  margin: var(--banner-h, 30px) auto 0;
  padding: 0 max(var(--gutter), env(safe-area-inset-right, 0px)) calc(var(--gutter) + env(safe-area-inset-bottom, 0px)) max(var(--gutter), env(safe-area-inset-left, 0px));
  min-height: calc(100dvh - var(--banner-h, 30px));
  display: flex; flex-direction: column;
  position: relative;
}
.view { animation: viewIn .38s cubic-bezier(.2, .8, .3, 1); }

/* ------------------------------------------------------------ type: slate, kicker, display */
.slate { position: relative; }
.slate .kicker { margin-bottom: 8px; }
.title {
  font-family: var(--font-display); font-weight: 400; font-size: clamp(52px, 16vw, 72px);
  letter-spacing: .03em; line-height: .88; margin: 0; text-transform: uppercase;
  background: linear-gradient(180deg, var(--white) 30%, var(--steel) 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent;
}
.title em {
  font-style: normal;
  background: var(--flame); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  filter: drop-shadow(0 0 18px var(--orange-glow));
}
.lede { color: var(--muted); margin: 12px 0 0; line-height: 1.55; font-size: 14.5px; }
.lede .mono { color: var(--text); font-size: 13px; }

/* ------------------------------------------------------------ surfaces */
.card {
  position: relative; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--card-shadow);
}

/* chips: mono micro pills */
.chip {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .02em; font-weight: 600;
  padding: 4px 10px; border-radius: 999px;
}
.chip.info { color: var(--blue); background: var(--blue-soft); border: 1px solid var(--blue-line); }
.chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.chip i.on { background: var(--blue); box-shadow: 0 0 8px var(--blue); }

/* stamp: rotated green mark for a verified win */
.stamp {
  display: inline-block; font-family: var(--font-display); font-size: 17px; letter-spacing: .14em;
  color: var(--ok); border: 2px solid var(--ok); border-radius: 7px; padding: 4px 10px 2px;
  transform: rotate(-6deg); opacity: .9; text-transform: uppercase; white-space: nowrap;
  box-shadow: 0 0 14px rgba(61, 220, 132, .25), inset 0 0 10px rgba(61, 220, 132, .08);
}

/* ------------------------------------------------------------ buttons (Bebas labels) */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 52px; padding: 2px 20px 0; border-radius: 12px;
  font-family: var(--font-display); font-weight: 400; font-size: 21px; letter-spacing: .09em; line-height: 1;
  color: var(--text); background: var(--ink-3); border: 1px solid var(--line-bright);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05);
  transition: transform .08s, box-shadow .2s;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn.primary { background: var(--flame); color: var(--on-flame); border: 0; box-shadow: var(--flame-shadow); }
.btn.ghost-blue { background: transparent; color: var(--blue); border-color: var(--blue-line); box-shadow: 0 0 16px rgba(126, 211, 242, .08); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad-line); }
.btn.danger[data-armed] { background: var(--bad); color: var(--on-flame); border-color: var(--bad); }
.btn.small { min-height: 40px; padding: 2px 14px 0; font-size: 17px; border-radius: 10px; }
.btn.wide { width: 100%; }
.btn-x { background: none; border: 0; font-size: 24px; line-height: 1; color: var(--muted); width: 40px; height: 40px; }

/* ------------------------------------------------------------ header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 0 10px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 38px; height: auto; flex: none; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .5)); }
.brand-word { display: flex; flex-direction: column; line-height: 1; white-space: nowrap; }
.brand-word b { font-family: var(--font-display); font-weight: 400; font-size: 21px; letter-spacing: .06em; color: var(--orange); }
.brand-word small { font-family: var(--font-mono); font-size: 8.5px; letter-spacing: .3em; color: var(--muted); text-transform: uppercase; margin-top: 4px; }
.top-right { display: flex; align-items: center; gap: 8px; }

/* Link status. Turns into the ON AIR pill when a laptop screen is watching. */
.net {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; min-height: 32px;
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  padding: 0 11px; border-radius: 999px; color: var(--muted); background: var(--ink-2); border: 1px solid var(--line);
}
.net i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.net[data-state="open"] { color: var(--blue); border-color: var(--blue-line); background: var(--blue-soft); }
.net[data-state="open"] i { background: var(--blue); box-shadow: 0 0 8px var(--blue); }
.net[data-state="auth"], .net[data-state="replaced"] { color: var(--bad); border-color: var(--bad-line); background: var(--bad-soft); }
.net[data-state="auth"] i, .net[data-state="replaced"] i { background: var(--bad); }
.net[data-state="connecting"] i { animation: blink 1s infinite; }
.net.onair {
  font-family: var(--font-display); font-weight: 400; font-size: 16px; letter-spacing: .14em; padding: 2px 13px 0;
  color: var(--onair-text); background: var(--live-soft); border-color: var(--live-line);
  box-shadow: 0 0 22px rgba(255, 71, 87, .25), inset 0 0 12px rgba(255, 71, 87, .08);
}
.net.onair i { width: 8px; height: 8px; background: var(--live); box-shadow: 0 0 10px var(--live); animation: onair 1.6s ease-in-out infinite; margin-top: -2px; }

.room-chip {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 38px; padding: 3px 10px 2px;
  background: var(--inset); border: 1px solid var(--line-bright); border-radius: 9px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.room-chip-label { font-family: var(--font-mono); font-size: 7.5px; line-height: 1; letter-spacing: .3em; text-transform: uppercase; color: var(--faint); }
.room-chip .mono { font-size: 15px; line-height: 1; color: var(--text); letter-spacing: .14em; padding-left: .14em; }
body[data-view="vStart"] .room-chip, body[data-view="vToken"] .room-chip { display: none; }

/* Music button: four equalizer bars. They dance while the track plays, lie flat when idle,
   and get a slash when muted. */
.music-btn {
  position: relative; display: inline-flex; align-items: flex-end; justify-content: center; gap: 2.5px;
  width: 38px; height: 38px; padding: 0 0 11px; flex: none;
  background: var(--inset); border: 1px solid var(--line-bright); border-radius: 9px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05);
}
.music-btn i { width: 3px; height: 4px; border-radius: 1.5px; background: var(--muted); transition: height .25s, background .25s; }
.music-btn[data-state="playing"] { border-color: var(--orange-line); box-shadow: 0 0 14px var(--orange-soft), inset 0 1px 0 rgba(255, 255, 255, .05); }
.music-btn[data-state="playing"] i { background: var(--orange); animation: eq .9s ease-in-out infinite alternate; }
.music-btn[data-state="playing"] i:nth-child(2) { animation-duration: .7s; animation-delay: -.3s; }
.music-btn[data-state="playing"] i:nth-child(3) { animation-duration: 1.1s; animation-delay: -.6s; }
.music-btn[data-state="playing"] i:nth-child(4) { animation-duration: .8s; animation-delay: -.15s; }
.music-btn[data-state="idle"] i:nth-child(2), .music-btn[data-state="idle"] i:nth-child(3) { height: 7px; }
.music-btn[data-state="muted"] i { background: var(--faint); }
.music-btn[data-state="muted"]::after {
  content: ''; position: absolute; left: 8px; right: 8px; top: 50%; height: 2px; border-radius: 1px;
  background: var(--bad); transform: rotate(-35deg); box-shadow: 0 0 0 2px var(--ink-1);
}

/* Narrow phones: the header carries brand, music, link and room. Tighten it so nothing touches. */
@media (max-width: 400px) {
  .top-right { gap: 6px; }
  .music-btn { width: 34px; }
  .brand { gap: 8px; }
  .brand-mark { width: 32px; }
  .brand-word b { font-size: 18px; }
  .brand-word small { font-size: 7.5px; letter-spacing: .24em; }
  .net { padding: 0 9px; }
  .net.onair { padding: 2px 10px 0; font-size: 15px; letter-spacing: .1em; }
  .room-chip { padding: 3px 8px 2px; }
}
@media (max-width: 359px) {
  body[data-view="vRun"] .brand-word, body[data-view="vSeed"] .brand-word { display: none; }
}

/* Music sheet */
.mu-level { padding: 14px 14px 10px; border-radius: 14px; background: var(--inset); border: 1px solid var(--line); }
.mu-read { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.mu-read .mono { font-size: 26px; color: var(--orange-hot); letter-spacing: .02em; }
.mu-read .mono.off { color: var(--bad); }
.mu-eq { display: inline-flex; align-items: flex-end; gap: 3px; height: 22px; }
.mu-eq i { width: 4px; height: 6px; border-radius: 2px; background: var(--orange); animation: eq .9s ease-in-out infinite alternate; }
.mu-eq i:nth-child(2) { animation-duration: .7s; animation-delay: -.3s; }
.mu-eq i:nth-child(3) { animation-duration: 1.1s; animation-delay: -.6s; }
.mu-eq i:nth-child(4) { animation-duration: .8s; animation-delay: -.15s; }
.mu-read:has(.off) .mu-eq i { animation: none; background: var(--faint); }
.mu-slider { width: 100%; height: 36px; accent-color: var(--orange); margin: 0; }
.mu-scale { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--faint); letter-spacing: .08em; }

/* ------------------------------------------------------------ token */
.view-token { padding-top: 9vh; }
.token-form { display: flex; gap: 10px; margin-top: 26px; }
.input {
  flex: 1; min-width: 0; min-height: 54px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line-bright); background: var(--inset); color: var(--text); font-size: 16px; /* 16px: no iOS zoom */
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, .35);
}
.input:focus { outline: 2px solid var(--orange); outline-offset: 1px; }

/* ------------------------------------------------------------ start */
.view-start { display: flex; flex-direction: column; gap: 14px; padding-top: 2px; flex: 1; }
.tagline { margin: 10px 0 0; color: var(--muted); font-size: 14.5px; }
.tagline b { color: var(--text); font-weight: 700; }

.room-card { padding: 14px 16px 14px; }
.room-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.room-plate {
  display: flex; justify-content: center; gap: 10px; margin: 14px 0 12px;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
}
/* split flap tiles, like a departure board the laptop can match */
.room-plate span {
  position: relative; width: clamp(54px, 16vw, 64px); aspect-ratio: 5 / 6; display: grid; place-items: center;
  font-family: var(--font-mono); font-size: clamp(38px, 11.5vw, 46px); color: var(--text); line-height: 1;
  background: linear-gradient(180deg, var(--ink-1) 0 50%, var(--flap) 50% 100%);
  border: 1px solid var(--line-bright); border-radius: 11px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .07);
  text-shadow: 0 2px 10px rgba(0, 0, 0, .6);
}
.room-plate span::after {
  content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 2px; margin-top: -1px;
  background: var(--ink-0); box-shadow: 0 1px 0 rgba(255, 255, 255, .05);
}
.room-plate span::before { /* the hinge pins */
  content: ''; position: absolute; left: -2px; right: -2px; top: 50%; height: 6px; margin-top: -3px;
  background: linear-gradient(90deg, var(--line-bright) 0 3px, transparent 3px calc(100% - 3px), var(--line-bright) calc(100% - 3px));
  border-radius: 2px;
}
.room-link { display: flex; align-items: baseline; justify-content: center; gap: 8px; flex-wrap: wrap; text-align: center; }
.room-link-label { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .25em; text-transform: uppercase; color: var(--faint); }
.room-link .mono { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }

.mode { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; border-radius: 14px; background: var(--inset); border: 1px solid var(--line); }
.mode-btn {
  display: flex; align-items: baseline; justify-content: center; gap: 8px; min-height: 46px; padding: 3px 10px 0;
  border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--muted);
}
.mode-btn b { font-family: var(--font-display); font-weight: 400; font-size: 22px; letter-spacing: .07em; line-height: 1; }
.mode-btn span { font-size: 10px; letter-spacing: .06em; color: var(--faint); }
.mode-btn.on { background: var(--card); border-color: var(--line-bright); color: var(--text); box-shadow: 0 4px 14px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .06); }
.mode-btn.on span { color: var(--orange-hot); }

.btn-start {
  position: relative; overflow: hidden; width: 100%; min-height: 100px; border: 0; border-radius: var(--r-lg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: var(--flame); color: var(--on-flame);
  box-shadow: 0 12px 36px rgba(232, 99, 10, .45), 0 0 70px rgba(247, 147, 26, .16), inset 0 1px 0 rgba(255, 255, 255, .45), inset 0 -4px 0 rgba(0, 0, 0, .16);
  transition: transform .08s;
}
.btn-start::after { /* a slow chrome glint */
  content: ''; position: absolute; top: 0; bottom: 0; left: -40%; width: 30%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .38), transparent);
  transform: skewX(-18deg); animation: glint 4.5s ease-in-out 1s infinite;
}
.btn-start:active { transform: translateY(2px) scale(.995); }
.bs-label { font-family: var(--font-display); font-size: 68px; letter-spacing: .14em; line-height: .86; padding: 6px 0 0 .14em; }
.bs-sub { font-size: 10.5px; letter-spacing: .24em; text-transform: uppercase; opacity: .72; }

.rehearse { flex-direction: column; gap: 3px; min-height: 54px; padding-top: 6px; }
.rehearse span { font-family: var(--font-mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

.how { list-style: none; margin: 2px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; counter-reset: how; }
.how li { counter-increment: how; display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 8px; border-radius: 10px; border: 1px solid var(--line); background: linear-gradient(180deg, rgba(26, 35, 56, .55), rgba(18, 24, 40, .25)); }
.how li::before { content: '0' counter(how); font-family: var(--font-mono); font-size: 9.5px; color: var(--orange); letter-spacing: .1em; }
.how b { font-family: var(--font-display); font-weight: 400; font-size: 18px; letter-spacing: .07em; line-height: 1; }
.how span { font-size: 10.5px; line-height: 1.3; color: var(--muted); }
.about { font-size: 11.5px; color: var(--faint); line-height: 1.45; margin: 0; padding-bottom: 4px; }

/* ------------------------------------------------------------ run */
.view-run { display: flex; flex-direction: column; gap: 12px; flex: 1; padding-bottom: 96px; }

.counter { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 0 2px; }
.stat .num {
  font-family: var(--font-display); font-size: 50px; line-height: .84; letter-spacing: .02em; white-space: nowrap;
  background: linear-gradient(180deg, var(--white) 20%, var(--steel-2) 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent;
}
.stat .num small { font-size: 24px; -webkit-text-fill-color: var(--faint); color: var(--faint); margin-left: 3px; letter-spacing: .04em; }
.stat .lbl { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .24em; color: var(--muted); text-transform: uppercase; margin-top: 6px; }
.stat.r { text-align: right; }
.dice-chip {
  align-self: center; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  font-family: var(--font-display); font-size: 19px; letter-spacing: .1em; text-transform: uppercase; line-height: 1;
  padding: 7px 13px 5px; border-radius: 999px; color: var(--blue); background: var(--blue-soft); border: 1px solid var(--blue-line);
}
.dice-chip::before {
  content: ''; width: 15px; height: 15px; border-radius: 4px; margin-top: -2px;
  background: var(--pipdot) 19% 19% / 26% 26% no-repeat, var(--pipdot) 81% 19% / 26% 26% no-repeat, var(--pipdot) 50% 50% / 26% 26% no-repeat,
              var(--pipdot) 19% 81% / 26% 26% no-repeat, var(--pipdot) 81% 81% / 26% 26% no-repeat, var(--die);
}
.dice-chip.hot {
  color: var(--on-flame); background: var(--flame); border-color: transparent; transform: rotate(-2deg);
  box-shadow: 0 4px 14px rgba(232, 99, 10, .45), inset 0 1px 0 rgba(255, 255, 255, .4), inset 0 -2px 0 rgba(0, 0, 0, .18);
  animation: wiggle 1.4s ease-in-out infinite;
}

/* the machined camera frame */
.frame {
  padding: 7px; border-radius: var(--r-lg); background: var(--card); border: 1px solid var(--line);
  box-shadow: 0 18px 44px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .06);
  position: relative;
}
.stage {
  --ar: 1.7778;
  position: relative; overflow: hidden; border-radius: 12px;
  aspect-ratio: var(--ar);
  width: min(100%, calc(var(--stage-max-h) * var(--ar)));
  margin: 0 auto; background: var(--ink-0);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .6);
  touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.stage video, .stage .frozen { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.stage .frozen { z-index: 1; }
.stage::before { /* lens vignette */
  content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: radial-gradient(120% 100% at 50% 50%, transparent 62%, rgba(0, 0, 0, .38) 100%);
}

/* orange viewfinder corners */
.guide { position: absolute; inset: 9px; z-index: 3; pointer-events: none; --gc: var(--orange); }
.guide i { position: absolute; width: 22px; height: 22px; border: 3px solid var(--gc); filter: drop-shadow(0 0 5px var(--orange-glow)); transition: border-color .2s; }
.guide i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 7px; }
.guide i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 7px; }
.guide i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 7px; }
.guide i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 7px; }
.stage[data-phase="moving"] .guide i { animation: breathe 1s ease-in-out infinite; }
.stage[data-phase="reading"] .guide, .stage[data-phase="settling"] .guide { --gc: var(--blue); }
.stage[data-phase="reading"] .guide i, .stage[data-phase="settling"] .guide i { filter: drop-shadow(0 0 6px rgba(126, 211, 242, .5)); }
.stage[data-phase="rejected"] .guide { --gc: var(--bad); }
.stage[data-phase="rejected"] .guide i { filter: none; }

/* reading: a scanning sweep over the frozen photo */
.scan { position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: 0; overflow: hidden; transition: opacity .2s; }
.scan::before {
  content: ''; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(126, 211, 242, .10) 1px, transparent 1px), linear-gradient(90deg, rgba(126, 211, 242, .10) 1px, transparent 1px);
  background-size: 22px 22px;
}
.scan::after {
  content: ''; position: absolute; left: 0; right: 0; height: 38%; top: -38%;
  background: linear-gradient(180deg, transparent, rgba(126, 211, 242, .22) 85%, rgba(214, 243, 255, .95) 99%, transparent);
  animation: sweep 1.15s cubic-bezier(.5, 0, .5, 1) -.45s infinite;
}
.stage[data-phase="reading"] .scan, .stage[data-phase="settling"] .scan { opacity: 1; }

.stage::after { /* shutter flash */
  content: ''; position: absolute; inset: 0; z-index: 6; background: var(--white); opacity: 0; pointer-events: none;
}
.stage.shutter::after { animation: shutter .35s ease-out; }
.stage.rejected { box-shadow: inset 0 0 0 2px var(--bad); }

.settle { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; z-index: 4; background: rgba(0, 0, 0, .45); }
.settle i { display: block; height: 100%; background: var(--flame); box-shadow: 0 0 12px var(--orange); transform-origin: left; transform: scaleX(0); transition: transform .1s linear; }

/* Blue pins float just above each die with the read value: the computed read, checkable by eye. */
.pins { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.pin {
  --ty: calc(-100% - 15px);
  position: absolute; transform: translate(-50%, var(--ty)) scale(0); transform-origin: 50% 100%;
  min-width: 32px; height: 32px; padding: 2px 7px 0; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--blue-fill); color: var(--on-flame);
  font-family: var(--font-display); font-size: 25px; line-height: 1;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .5), inset 0 -2px 0 rgba(0, 0, 0, .15);
  animation: pop .38s cubic-bezier(.2, 1.6, .4, 1) forwards;
}
.pin::after {
  content: ''; position: absolute; left: 50%; bottom: -5px; width: 10px; height: 10px; margin-left: -5px;
  background: var(--blue-lo); transform: rotate(45deg); border-radius: 2px; z-index: -1;
}
.pin.below { --ty: 15px; transform-origin: 50% 0; }
.pin.below::after { bottom: auto; top: -5px; background: var(--blue-hi); }
.pin.unused { background: var(--ink-3); color: var(--faint); text-decoration: line-through; box-shadow: 0 4px 12px rgba(0, 0, 0, .45); }
.pin.unused::after { background: var(--ink-3); }
.pin.rej { background: var(--glass); color: var(--text); border: 1px solid var(--line-bright); }
.pin.rej::after { background: var(--ink-1); }
.pin.unclear, .pin.rej.unclear { background: var(--bad); color: var(--on-flame); border: 0; }
.pin.unclear::after { background: var(--bad); }

/* good read: the accepted values as enamel stickers over the frozen photo */
.flash {
  position: absolute; inset: 0; z-index: 5; padding: 0 10px 12px; text-align: center;
  display: flex; flex-direction: column; justify-content: flex-end;
  background: linear-gradient(180deg, transparent 55%, rgba(7, 9, 15, .7) 100%);
  pointer-events: none;
}
.flash-label {
  position: absolute; top: 10px; left: 10px; padding: 5px 9px 4px; border-radius: 7px;
  background: var(--glass); border: 1px solid var(--orange-line);
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--orange-hot);
  animation: fade .25s ease-out;
}
.flash-label::before { content: '// '; color: var(--faint); }
.flash-row { display: flex; justify-content: center; gap: 9px; }
.flash-row span {
  width: 46px; height: 50px; display: grid; place-items: center; padding-top: 4px; border-radius: 10px;
  font-family: var(--font-display); font-size: 38px; line-height: 1;
  background: var(--flame); color: var(--on-flame); border: 1px solid rgba(0, 0, 0, .25);
  box-shadow: 0 6px 16px rgba(232, 99, 10, .45), inset 0 1px 0 rgba(255, 255, 255, .45), inset 0 -3px 0 rgba(0, 0, 0, .18);
  opacity: 0; --r: -2deg; transform: translateY(18px) scale(.5) rotate(var(--r));
}
.flash-row span:nth-child(2) { --r: 1.6deg; }
.flash-row span:nth-child(3) { --r: -1deg; }
.flash-row span:nth-child(4) { --r: 2.2deg; }
.flash-row span:nth-child(5) { --r: -2.6deg; }
.flash.go .flash-row span { animation: stick .46s cubic-bezier(.2, 1.5, .4, 1) forwards; }

.stage-msg {
  position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 16px; text-align: center; background: var(--scrim);
  -webkit-backdrop-filter: blur(1.5px); backdrop-filter: blur(1.5px);
  animation: fade .2s ease-out;
}
.stage-msg b {
  font-family: var(--font-display); font-weight: 400; font-size: clamp(30px, 9.5vw, 46px); letter-spacing: .04em; line-height: .95;
  color: var(--bad); text-transform: uppercase; text-shadow: 0 2px 18px rgba(0, 0, 0, .6);
  animation: shake .4s ease-out;
}
.stage-msg span { font-family: var(--font-mono); font-size: 11.5px; color: var(--text); opacity: .8; }
.stage-msg span::before { content: '// '; color: var(--faint); }

/* phase: the big animated state */
.phase {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 16px;
  min-height: 100px; padding: 14px 18px 14px 16px; border-radius: var(--r-lg);
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--card-shadow);
  transition: border-color .25s, box-shadow .25s;
}
.phase::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--ph-edge, var(--line-bright)); transition: background .25s; }
.ph-ind { --settle: 0; position: relative; flex: none; width: 68px; height: 68px; border-radius: 50%; display: grid; place-items: center; background: var(--inset); box-shadow: inset 0 2px 6px rgba(0, 0, 0, .5); }
.ph-ring {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from -90deg, var(--ring-c, var(--orange)) calc(var(--ring, 0) * 1turn), rgba(255, 255, 255, .06) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 5px), black calc(100% - 4.5px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 5px), black calc(100% - 4.5px));
}
.ph-core {
  position: relative; width: 26px; height: 26px; border-radius: 6px;
  background: var(--pipdot) 19% 19% / 24% 24% no-repeat, var(--pipdot) 81% 19% / 24% 24% no-repeat, var(--pipdot) 50% 50% / 24% 24% no-repeat,
              var(--pipdot) 19% 81% / 24% 24% no-repeat, var(--pipdot) 81% 81% / 24% 24% no-repeat, var(--die);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .25), 0 3px 8px rgba(0, 0, 0, .4);
  transition: opacity .2s;
}
.ph-core::before, .ph-core::after { content: ''; position: absolute; opacity: 0; }
.ph-text { display: flex; flex-direction: column; min-width: 0; }
.phase-word {
  font-family: var(--font-display); font-size: clamp(40px, 12.5vw, 54px); letter-spacing: .04em; line-height: .9;
  text-transform: uppercase; padding-top: 3px; color: var(--text); transition: color .2s;
}
.phase-sub { font-size: 13.5px; color: var(--muted); margin-top: 3px; min-height: 1.2em; line-height: 1.3; }

.phase[data-phase="idle"] .ph-core { opacity: .35; filter: grayscale(1); }
.phase[data-phase="waiting"] { --ph-edge: var(--flame); }
.phase[data-phase="waiting"] .phase-word,
.phase[data-phase="accepted"] .phase-word,
.phase[data-phase="lastThrow"] .phase-word {
  background: var(--flame); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent;
  filter: drop-shadow(0 0 14px rgba(247, 147, 26, .3));
}
.phase[data-phase="waiting"] .ph-core { animation: hop 1.1s cubic-bezier(.3, 0, .3, 1) infinite; }
.phase[data-phase="waiting"] .ph-ind::after { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--orange); animation: ripple 1.6s ease-out infinite; }
.phase[data-phase="moving"] { --ph-edge: var(--orange); }
.phase[data-phase="moving"] .ph-ring { --ring: var(--settle); }
.phase[data-phase="moving"] .ph-core { animation: tumble .5s linear infinite; }
.phase[data-phase="settling"] { --ph-edge: var(--blue); }
.phase[data-phase="settling"] .ph-ring { --ring: 1; --ring-c: var(--blue); }
.phase[data-phase="settling"] .ph-core { animation: thunk .3s ease-out; }
.phase[data-phase="reading"] { --ph-edge: var(--blue); border-color: rgba(126, 211, 242, .3); }
.phase[data-phase="reading"] .ph-ring { --ring: .3; --ring-c: var(--blue); animation: spin .8s linear infinite; }
.phase[data-phase="settling"] .phase-word, .phase[data-phase="reading"] .phase-word { color: var(--blue); }
.phase[data-phase="reading"] .phase-sub::after { content: ''; animation: dots 1.2s steps(4) infinite; }
.phase[data-phase="rejected"] { --ph-edge: var(--bad); border-color: var(--bad-line); box-shadow: var(--card-shadow), 0 0 30px rgba(255, 107, 107, .12); }
.phase[data-phase="rejected"] .ph-ring { --ring: 1; --ring-c: var(--bad); }
.phase[data-phase="rejected"] .phase-word { color: var(--bad); font-size: clamp(34px, 10.5vw, 46px); }
.phase[data-phase="rejected"] .ph-core { background: none; box-shadow: none; animation: shake .4s ease-out; }
.phase[data-phase="rejected"] .ph-core::before,
.phase[data-phase="rejected"] .ph-core::after { opacity: 1; left: 50%; top: 50%; width: 26px; height: 4px; margin: -2px 0 0 -13px; border-radius: 2px; background: var(--bad); transform: rotate(45deg); }
.phase[data-phase="rejected"] .ph-core::after { transform: rotate(-45deg); }
.phase[data-phase="accepted"] { --ph-edge: var(--flame); border-color: var(--orange-line); box-shadow: var(--card-shadow), 0 0 36px rgba(247, 147, 26, .14); }
.phase[data-phase="accepted"] .ph-ring { --ring: 1; }
.phase[data-phase="accepted"] .ph-ind { box-shadow: inset 0 2px 6px rgba(0, 0, 0, .5), 0 0 18px var(--orange-glow); }
.phase[data-phase="accepted"] .ph-core,
.phase[data-phase="done"] .ph-core { background: none; box-shadow: none; }
.phase[data-phase="accepted"] .ph-core::before,
.phase[data-phase="done"] .ph-core::before {
  opacity: 1; left: 6px; top: 1px; width: 10px; height: 18px; border: solid var(--orange); border-width: 0 4px 4px 0;
  transform: rotate(45deg); border-radius: 1px; animation: pop2 .35s cubic-bezier(.2, 1.6, .4, 1);
}
.phase[data-phase="done"] .ph-core::before { border-color: var(--blue); }
.phase[data-phase="done"] .ph-ring { --ring: 1; --ring-c: var(--blue); }
.phase[data-phase="done"] .phase-word { color: var(--blue); }
.phase[data-phase="lastThrow"] .ph-ring { --ring: 1; }

.err-banner {
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; border-radius: 12px;
  background: var(--bad-soft); border: 1px solid var(--bad-line); font-size: 14px; color: var(--text);
}
.err-banner span { flex: 1; }

/* roll tape: one mono plate per throw */
.tape-wrap { padding: 12px 12px 12px 14px; flex: 1 1 auto; min-height: 92px; }
.tape-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.tape-hint { font-size: 11px; color: var(--faint); }
.tape { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; max-height: 176px; overflow-y: auto; padding: 2px; scrollbar-width: none; }
.tape::-webkit-scrollbar { display: none; }
.tape .grp {
  position: relative; display: flex; align-items: center; justify-content: center;
  min-height: 38px; padding: 9px 0 2px; border-radius: 8px;
  font-family: var(--font-mono); font-size: 15px; letter-spacing: .06em; line-height: 1; color: var(--text);
  background: var(--inset); border: 1px solid var(--line);
}
.tape .grp::before { content: attr(data-n); position: absolute; top: 3px; left: 5px; font-size: 8px; letter-spacing: .08em; color: var(--faint); }
.tape .grp.src-keypad::after, .tape .grp.src-recorded::after { content: ''; position: absolute; left: 8px; right: 8px; bottom: 3px; height: 0; border-bottom: 1px dashed var(--muted); }
.tape .grp.src-recorded::after { border-bottom-color: var(--faint); }
.tape .grp.last { color: var(--orange-hot); border-color: var(--orange-line); background: linear-gradient(180deg, rgba(247, 147, 26, .14), rgba(247, 147, 26, .04)); box-shadow: 0 0 16px rgba(247, 147, 26, .12); }
.tape .grp.last::before { color: var(--orange); }
.tape .grp.new { animation: land .55s cubic-bezier(.2, 1.3, .4, 1); }
.tape .grp.ghost { color: var(--faint); background: none; border: 1px dashed var(--line-bright); letter-spacing: .2em; }
.tape .grp.ghost::before { content: none; }

/* entropy: a flame bar that fills to the goal */
.entropy { padding: 0 2px; }
.ent-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
#entText { font-size: 12.5px; color: var(--text); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.meter { position: relative; height: 12px; border-radius: 7px; background: var(--inset); border: 1px solid var(--line); overflow: hidden; box-shadow: inset 0 2px 4px rgba(0, 0, 0, .5); }
.meter i { position: absolute; inset: 0; background: var(--flame); transform-origin: left; transform: scaleX(0); transition: transform .6s cubic-bezier(.2, .8, .3, 1); box-shadow: 0 0 14px var(--orange); }
.meter::after { /* machined ticks every 10 percent */
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), rgba(7, 9, 15, .55) calc(10% - 1px) 10%);
}
.meter b { display: none; }

.actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;
  padding: 18px max(var(--gutter), env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) max(var(--gutter), env(safe-area-inset-left, 0px));
  background: linear-gradient(180deg, rgba(7, 9, 15, 0), var(--ink-0) 38%);
  max-width: 560px; margin: 0 auto;
}
.act {
  min-height: 62px; border-radius: 14px; border: 1px solid var(--line-bright); background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding-top: 3px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .4), inset 0 1px 0 rgba(255, 255, 255, .06);
}
.act b { font-family: var(--font-display); font-weight: 400; font-size: 24px; letter-spacing: .08em; line-height: 1; }
.act span { font-family: var(--font-mono); font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.act:active { transform: translateY(1px); }
.act.on { border-color: var(--orange-line); background: linear-gradient(180deg, rgba(247, 147, 26, .16), rgba(247, 147, 26, .05)); }
.act.on b { color: var(--orange); }
.act-end b { color: var(--bad); }
.act[data-armed] { background: var(--bad); border-color: var(--bad); }
.act[data-armed] b, .act[data-armed] span { color: var(--on-flame); }

/* ------------------------------------------------------------ last throw alert */
.last-alert {
  position: fixed; inset: 0; z-index: 900; overflow: hidden;
  padding: calc(var(--banner-h, 30px) + 30px) 22px calc(36px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 16px;
  background: radial-gradient(90% 60% at 50% 42%, rgba(255, 236, 190, .45), transparent 70%), var(--flame);
  color: var(--on-flame); cursor: pointer;
}
.last-alert::before { /* speed lines */
  content: ''; position: absolute; inset: -50%; pointer-events: none; opacity: .12;
  background: repeating-conic-gradient(from 0deg at 50% 50%, var(--on-flame) 0 2deg, transparent 2deg 12deg);
  animation: spin 40s linear infinite;
}
.last-alert > * { position: relative; }
.last-alert.go { animation: slam .5s cubic-bezier(.2, 1.4, .4, 1); }
.la-stripes { position: absolute; left: 0; right: 0; top: var(--banner-h, 30px); height: 16px; background: repeating-linear-gradient(-45deg, var(--on-flame) 0 14px, transparent 14px 28px); opacity: .85; }
.la-stripes.bottom { top: auto; bottom: 0; height: calc(16px + env(safe-area-inset-bottom, 0px)); }
.la-kicker { font-family: var(--font-mono); font-size: 14px; letter-spacing: .26em; text-transform: uppercase; opacity: .78; }
.la-kicker::before { content: '// '; opacity: .55; }
.la-big {
  font-family: var(--font-display); font-size: clamp(88px, 29vw, 150px); line-height: .82; letter-spacing: .01em;
  text-transform: uppercase; text-shadow: 0 3px 0 rgba(255, 255, 255, .25), 0 10px 30px rgba(120, 40, 0, .35);
}
.la-dice { display: flex; gap: 11px; margin: 4px 0; }
.la-dice i {
  width: clamp(46px, 13vw, 58px); aspect-ratio: 1; border-radius: 22%; background-color: var(--die);
  background-repeat: no-repeat; background-size: 23% 23%;
  background-image: var(--pipdot), var(--pipdot), var(--pipdot), var(--pipdot), var(--pipdot);
  background-position: 18% 18%, 82% 18%, 50% 50%, 18% 82%, 82% 82%;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .28), 0 6px 14px rgba(90, 20, 0, .4);
  animation: hop 1s cubic-bezier(.3, 0, .3, 1) infinite;
}
.la-dice i:nth-child(1) { background-image: var(--pipdot), var(--pipdot), var(--pipdot), var(--pipdot), var(--pipdot), var(--pipdot); background-position: 18% 18%, 82% 18%, 18% 50%, 82% 50%, 18% 82%, 82% 82%; transform: rotate(-6deg); }
.la-dice i:nth-child(2) { background-image: var(--pipdot), var(--pipdot), var(--pipdot); background-position: 18% 18%, 50% 50%, 82% 82%; animation-delay: .1s; }
.la-dice i:nth-child(3) { animation-delay: .2s; }
.la-dice i:nth-child(4) { background-image: var(--pipdot), var(--pipdot); background-position: 18% 18%, 82% 82%; animation-delay: .3s; }
.la-dice i.la-x { position: relative; background: transparent; border: 3px dashed rgba(23, 17, 10, .55); box-shadow: none; animation: none; }
.la-dice i.la-x::before, .la-dice i.la-x::after {
  content: ''; position: absolute; left: -10%; right: -10%; top: 50%; height: 5px; margin-top: -2.5px; border-radius: 3px;
  background: var(--on-flame); transform: rotate(45deg);
}
.la-dice i.la-x::after { transform: rotate(-45deg); }
.la-only { transform: skewX(-8deg); background: var(--on-flame); border-radius: 10px; padding: 10px 22px 4px; box-shadow: 0 10px 24px rgba(90, 20, 0, .35); }
.la-only span {
  display: block; transform: skewX(8deg);
  font-family: var(--font-display); font-size: clamp(40px, 12.5vw, 68px); line-height: 1; letter-spacing: .04em; text-transform: uppercase;
  background: var(--flame); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent;
}
.la-tap { font-family: var(--font-mono); font-size: 12px; letter-spacing: .22em; text-transform: uppercase; opacity: .62; }
.la-timer { width: min(320px, 70vw); height: 6px; border-radius: 3px; background: rgba(23, 17, 10, .2); overflow: hidden; margin-top: 4px; }
.la-timer i { display: block; height: 100%; background: var(--on-flame); transform-origin: left; }
.last-alert.go .la-timer i { animation: drain 2.5s linear forwards; }

/* ------------------------------------------------------------ sheets: keypad, editor, tuning */
.sheet {
  position: fixed; inset: 0; z-index: 800; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(3, 4, 8, .6); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  animation: fade .2s ease-out;
}
.sheet-card {
  position: relative; width: 100%; max-width: 560px; max-height: calc(100dvh - var(--banner-h, 30px) - 12px); overflow-y: auto;
  background: linear-gradient(180deg, var(--ink-3) 0%, var(--ink-2) 70%); border: 1px solid var(--line-bright); border-bottom: 0;
  border-radius: 24px 24px 0 0; padding: 10px max(var(--gutter), env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(var(--gutter), env(safe-area-inset-left, 0px));
  box-shadow: 0 -24px 60px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 255, 255, .07);
  animation: up .26s cubic-bezier(.2, .9, .3, 1);
}
.sheet-card::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 2px; border-radius: 24px 24px 0 0; background: var(--flame); opacity: .8; }
.sheet-grip { width: 42px; height: 4px; border-radius: 2px; background: var(--line-bright); margin: 0 auto 12px; }
#keypad { background: transparent; pointer-events: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
#keypad .sheet-card { pointer-events: auto; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.sheet-head > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.sheet-head b { font-family: var(--font-display); font-weight: 400; font-size: 30px; letter-spacing: .05em; line-height: 1; text-transform: uppercase; }
.sheet-note { margin: -6px 0 12px; color: var(--muted); font-size: 13px; }
.sheet-row { display: flex; gap: 10px; margin-top: 14px; }
.sheet-row .btn { flex: 1; white-space: nowrap; font-size: 19px; padding: 2px 10px 0; letter-spacing: .07em; }

.slots { display: flex; justify-content: center; gap: 9px; margin-bottom: 16px; }
.slot {
  width: 56px; height: 64px; border-radius: 12px; display: grid; place-items: center; padding-top: 5px;
  border: 2px dashed var(--line-bright); background: var(--inset);
  font-family: var(--font-display); font-size: 44px; line-height: 1; color: var(--text);
}
.slot.full {
  border: 1px solid rgba(0, 0, 0, .25); background: var(--flame); color: var(--on-flame);
  box-shadow: 0 5px 14px rgba(232, 99, 10, .4), inset 0 1px 0 rgba(255, 255, 255, .45), inset 0 -3px 0 rgba(0, 0, 0, .18);
  transform: rotate(-1.5deg); animation: stick .3s cubic-bezier(.2, 1.5, .4, 1) both;
}
.slot.full:nth-child(even) { transform: rotate(1.5deg); }
.slot.cur { border: 2px solid var(--orange); box-shadow: 0 0 16px var(--orange-glow); animation: caret 1s ease-in-out infinite; }
.slots.editable .slot { cursor: pointer; animation: none; }
.slots.editable .slot.full:not(.cur) { background: var(--card); color: var(--text); border: 1px solid var(--line-bright); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06); transform: none; }
.slots.editable .slot.cur { background: var(--flame); color: var(--on-flame); border: 0; transform: translateY(-4px) rotate(-2deg); box-shadow: 0 10px 22px rgba(232, 99, 10, .5), inset 0 1px 0 rgba(255, 255, 255, .45); animation: none; }

.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.pad button {
  position: relative; min-height: 70px; border-radius: 14px; padding-top: 6px;
  border: 1px solid var(--line-bright); background: var(--card);
  font-family: var(--font-display); font-size: 46px; line-height: 1; color: var(--text);
  box-shadow: 0 6px 14px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .06);
  transition: transform .06s;
}
.pad button::after { /* the matching die face, so a glance at the dice maps to a key */
  content: ''; position: absolute; top: 9px; right: 9px; width: 18px; height: 18px; border-radius: 4px;
  background-color: var(--die); background-repeat: no-repeat; background-size: 26% 26%;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .25);
}
.pad button[data-d="1"]::after { background-image: var(--pipdot); background-position: 50% 50%; }
.pad button[data-d="2"]::after { background-image: var(--pipdot), var(--pipdot); background-position: 15% 15%, 85% 85%; }
.pad button[data-d="3"]::after { background-image: var(--pipdot), var(--pipdot), var(--pipdot); background-position: 15% 15%, 50% 50%, 85% 85%; }
.pad button[data-d="4"]::after { background-image: var(--pipdot), var(--pipdot), var(--pipdot), var(--pipdot); background-position: 15% 15%, 85% 15%, 15% 85%, 85% 85%; }
.pad button[data-d="5"]::after { background-image: var(--pipdot), var(--pipdot), var(--pipdot), var(--pipdot), var(--pipdot); background-position: 15% 15%, 85% 15%, 50% 50%, 15% 85%, 85% 85%; }
.pad button[data-d="6"]::after { background-image: var(--pipdot), var(--pipdot), var(--pipdot), var(--pipdot), var(--pipdot), var(--pipdot); background-position: 15% 15%, 85% 15%, 15% 50%, 85% 50%, 15% 85%, 85% 85%; }
.pad button:active { background: var(--flame); color: var(--on-flame); border-color: transparent; transform: scale(.97); }
.pad .pad-back { grid-column: 1 / -1; min-height: 52px; font-family: var(--font-mono); font-size: 22px; color: var(--muted); padding-top: 0; }
.pad .pad-back::after { content: none; }
body.sheet-open .actions { visibility: hidden; }

.tu-meter { background: var(--inset); border: 1px solid var(--line); border-radius: 12px; padding: 14px 12px 10px; margin-bottom: 14px; position: relative; }
.tu-bar { position: relative; height: 18px; border-radius: 6px; background: var(--ink-2); overflow: hidden; }
.tu-bar i { position: absolute; inset: 0; background: var(--blue); transform-origin: left; transform: scaleX(0); transition: transform .08s linear; }
.tu-bar i.hot { background: var(--flame); }
.tu-bar b { position: absolute; top: 0; bottom: 0; width: 3px; margin-left: -1px; background: var(--text); box-shadow: 0 0 0 1px var(--ink-0); }
.tu-bar b#tuLow { background: var(--muted); }
.tu-read { display: flex; justify-content: space-between; gap: 8px; margin-top: 9px; font-size: 11.5px; color: var(--muted); }
.tu-read b { color: var(--text); font-weight: 400; }
.tu-shot { position: absolute; right: 12px; top: -11px; padding: 4px 9px 2px; border-radius: 6px; background: var(--flame); color: var(--on-flame); font-family: var(--font-display); font-size: 15px; letter-spacing: .08em; opacity: 0; transform: rotate(-2deg); }
.tu-shot.on { animation: fadeout 1.2s ease-out; }
.tu-fields { display: flex; flex-direction: column; gap: 12px; }
.tu-field { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 13px; color: var(--muted); }
.tu-field b { color: var(--orange-hot); font-weight: 400; font-size: 13px; }
.tu-field input { grid-column: 1 / -1; width: 100%; accent-color: var(--orange); height: 28px; }
.tu-stats { font-size: 11px; color: var(--faint); margin-top: 14px; }

.toast {
  position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom, 0px)); z-index: 950;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: all .22s cubic-bezier(.2, .9, .3, 1);
  background: var(--card); color: var(--text); border: 1px solid var(--line-bright); border-left: 3px solid var(--orange);
  padding: 11px 16px; border-radius: 12px; font-weight: 600; font-size: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .06);
  width: max-content; max-width: calc(100vw - 32px); text-align: left;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------------------------------------ seed */
.view-seed { display: flex; flex-direction: column; gap: 16px; padding-bottom: 28px; }
.seed-slate { padding-top: 4px; }
.seed-slate .stamp { position: absolute; right: 4px; top: -6px; font-size: 15px; }
.seed-slate .title { font-size: clamp(52px, 15vw, 66px); }

.words {
  list-style: none; margin: 0; padding: 0; display: grid; gap: 7px 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-flow: column; grid-template-rows: repeat(var(--half, 12), auto);
}
/* each word is a lower third: flame edge, ticket notch, mono number plate */
.word {
  position: relative; display: flex; align-items: center; gap: 9px; min-height: 48px; padding: 6px 10px 6px 9px;
  background: linear-gradient(90deg, var(--ink-3) 0%, var(--ink-2) 100%); border: 1px solid var(--line); border-radius: 10px;
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 0 100%);
  opacity: 0; transform: translateY(8px);
  animation: rise .42s cubic-bezier(.2, .9, .3, 1) forwards; animation-delay: calc(var(--i, 0) * 32ms);
}
.word::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--flame); }
.word-n {
  flex: none; min-width: 27px; height: 25px; padding: 2px 4px 0; display: grid; place-items: center; border-radius: 6px;
  font-family: var(--font-mono); font-size: 12px; color: var(--muted);
  background: var(--ink-1); border: 1px solid var(--line-bright); transform: skewX(-8deg);
}
.word-body { display: flex; flex-direction: column; min-width: 0; line-height: 1.1; }
.word-w { font-weight: 700; font-size: clamp(15px, 4.4vw, 18px); letter-spacing: .01em; color: var(--text); }
.word-l { font-family: var(--font-mono); font-size: 10px; color: var(--faint); margin-top: 2px; }
.word-last { border-color: var(--blue-line); background: linear-gradient(90deg, rgba(126, 211, 242, .14), var(--ink-2)); box-shadow: 0 0 22px rgba(126, 211, 242, .1); }
.word-last::before { background: var(--blue-fill); box-shadow: 2px 0 10px rgba(126, 211, 242, .5); }
.word-last .word-n { color: var(--ink-0); background: var(--blue-fill); border-color: transparent; }
.word-last .word-w { color: var(--blue); }
.word-last .word-l { color: var(--blue); opacity: .75; }
.word-last .word-l::after { content: ' · checksum'; }
.seed-actions { display: flex; gap: 10px; }

/* the math */
.math {
  position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--card-shadow); padding: 16px 16px 14px;
  scroll-margin-top: calc(var(--banner-h, 30px) + 12px);
}
.math-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.math-head .kicker { display: block; margin-bottom: 6px; }
.math-title { font-family: var(--font-display); font-weight: 400; font-size: 38px; letter-spacing: .04em; line-height: .95; margin: 0; text-transform: uppercase; }
.math-count { font-family: var(--font-display); font-size: 22px; letter-spacing: .04em; color: var(--faint); white-space: nowrap; padding-top: 2px; }
.math-count b { font-weight: 400; color: var(--orange); }
.math-body { min-height: 220px; }
.math-body.enter > * { animation: rise .35s ease-out backwards; }
.math-body.enter > *:nth-child(2) { animation-delay: .06s; }
.math-body.enter > *:nth-child(3) { animation-delay: .12s; }
.math-body.enter > *:nth-child(4) { animation-delay: .18s; }
.math-cap { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 10px 0 12px; }
.math-note { color: var(--faint); font-size: 12px; margin: 12px 0 0; line-height: 1.45; }
.math-note::before { content: '// '; font-family: var(--font-mono); }
.math-well { background: var(--inset); border: 1px solid var(--line); border-radius: 12px; padding: 12px; box-shadow: inset 0 2px 8px rgba(0, 0, 0, .35); }
.math-rolls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px 8px; font-family: var(--font-mono); font-size: 14.5px; color: var(--orange-hot); letter-spacing: .06em; text-align: center; }
.math-hex { display: flex; flex-direction: column; gap: 4px; font-family: var(--font-mono); font-size: clamp(14px, 4.4vw, 18px); color: var(--orange-hot); letter-spacing: .04em; text-align: center; }
.math-hex.small { font-size: 12px; color: var(--blue); text-align: left; }
.bitgrid { display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: 1px; font-family: var(--font-mono); font-size: clamp(10.5px, 3.3vw, 14px); text-align: center; line-height: 1.5; }
.bitgrid span { border-radius: 2px; }
.bitgrid span:nth-child(16n + 9) { margin-left: 3px; }
.bitgrid .b-ent { color: rgba(247, 147, 26, .4); }
.bitgrid .b-ent.one { color: var(--orange-hot); text-shadow: 0 0 8px rgba(247, 147, 26, .35); }
.bitgrid .b-cs { color: var(--blue); background: var(--blue-soft); }
.bits.inline { font-family: var(--font-mono); }
.b-ent { color: var(--orange-hot); }
.b-cs { color: var(--blue); }
.math-words { display: flex; flex-direction: column; font-family: var(--font-mono); font-size: clamp(10.5px, 3.2vw, 13px); }
.mw-row { display: grid; grid-template-columns: 2em 11.4ch 4.6ch 5.4ch 1fr; gap: 7px; align-items: baseline; padding: 4px 5px; border-radius: 5px; }
.mw-row:nth-child(even) { background: rgba(255, 255, 255, .025); }
.mw-head { color: var(--faint); font-size: 9px; letter-spacing: 0; text-transform: uppercase; border-bottom: 1px solid var(--line); border-radius: 0; margin-bottom: 2px; }
.mw-head .mw-l, .mw-head .mw-w { color: var(--faint); font-family: var(--font-mono); font-weight: 400; font-size: 9px; }
.mw-n { color: var(--faint); }
.mw-bits { letter-spacing: .02em; }
.mw-i { text-align: right; color: var(--muted); }
.mw-l { text-align: right; color: var(--blue); }
.mw-w { font-family: var(--font-body); font-weight: 700; color: var(--text); font-size: 1.08em; }
.mw-last { background: rgba(126, 211, 242, .09) !important; box-shadow: inset 0 0 0 1px var(--blue-line); }
.mw-last .mw-w { color: var(--blue); }
.math-nav { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.math-nav .btn { flex: 0 0 auto; min-width: 96px; }
.math-dots { flex: 1; display: flex; justify-content: center; gap: 7px; }
.math-dots i { width: 18px; height: 4px; border-radius: 2px; background: var(--line-bright); transition: background .2s, width .2s; }
.math-dots i.on { width: 30px; background: var(--flame); box-shadow: 0 0 10px var(--orange-glow); }

/* ------------------------------------------------------------ laptop: use the width */
@media (min-width: 1000px) and (min-height: 600px) {
  body > .app { max-width: 1180px; padding-left: 32px; padding-right: 32px; }
  .top { padding: 20px 0 18px; }
  .view-start, .view-token, .view-seed { width: 100%; max-width: 600px; margin: 0 auto; }
  .view-run {
    --stage-max-h: calc(100dvh - var(--banner-h, 30px) - 230px);
    display: grid; gap: 16px 22px; padding-bottom: 24px; align-content: start;
    grid-template-columns: minmax(0, 1.7fr) minmax(320px, 1fr);
    grid-template-areas: "frame counter" "frame phase" "frame tape" "frame entropy" "frame actions" "err err";
  }
  .view-run .counter { grid-area: counter; }
  .view-run .frame { grid-area: frame; align-self: start; }
  .view-run .phase { grid-area: phase; }
  .view-run .tape-wrap { grid-area: tape; }
  .view-run .entropy { grid-area: entropy; }
  .view-run .err-banner { grid-area: err; }
  .view-run .actions { grid-area: actions; position: static; padding: 0; background: none; max-width: none; width: 100%; margin: 0; }
  .view-run .entropy { margin-top: 0; }
  .view-run .tape { max-height: 176px; }
  .words { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(var(--quarter, 6), auto); }
  .view-seed { max-width: 820px; }
  .sheet-card { border-radius: 24px; margin-bottom: 24px; border-bottom: 1px solid var(--line-bright); }
  .toast { bottom: 32px; }
}

/* ------------------------------------------------------------ motion */
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } }
@keyframes blink { 50% { opacity: .35; } }
@keyframes onair { 0%, 100% { opacity: 1; box-shadow: 0 0 10px var(--live); } 50% { opacity: .45; box-shadow: 0 0 2px var(--live); } }
@keyframes glint { 0% { left: -40%; } 28%, 100% { left: 130%; } }
@keyframes shutter { 0% { opacity: .85; } 100% { opacity: 0; } }
@keyframes pop { to { transform: translate(-50%, var(--ty)) scale(1); } }
@keyframes pop2 { from { transform: rotate(45deg) scale(.2); } }
@keyframes rise { to { opacity: 1; transform: none; } }
@keyframes stick { 0% { opacity: 0; transform: translateY(18px) scale(.5) rotate(var(--r, 0deg)); } 100% { opacity: 1; transform: translateY(0) scale(1) rotate(var(--r, 0deg)); } }
@keyframes fade { from { opacity: 0; } }
@keyframes fadeout { 0% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes land { 0% { transform: translateY(-8px) scale(1.08); background: var(--orange); color: var(--on-flame); box-shadow: 0 0 24px var(--orange-glow); } 100% { transform: none; } }
@keyframes slam { 0% { transform: scale(1.15); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }
@keyframes sweep { from { top: -38%; } to { top: 100%; } }
@keyframes spin { to { transform: rotate(1turn); } }
@keyframes hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-7px) rotate(-8deg); } 60% { transform: translateY(0) rotate(0); } 70% { transform: translateY(-2px); } }
@keyframes tumble { 0% { transform: rotate(0) translate(0, 0); } 25% { transform: rotate(90deg) translate(2px, -2px); } 50% { transform: rotate(180deg) translate(0, 1px); } 75% { transform: rotate(270deg) translate(-2px, -1px); } 100% { transform: rotate(360deg); } }
@keyframes thunk { 0% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes ripple { 0% { transform: scale(.7); opacity: .9; } 100% { transform: scale(1.35); opacity: 0; } }
@keyframes breathe { 50% { opacity: .55; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
@keyframes wiggle { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg) scale(1.04); } }
@keyframes eq { from { height: 4px; } to { height: 16px; } }
@keyframes caret { 50% { box-shadow: 0 0 4px rgba(247, 147, 26, .1); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
