/* Burnt Match: one palette, one spacing scale (4/8/12/16/24/32/48), one radius family. */

@property --p {
  syntax: "<number>";
  inherits: true;
  initial-value: 0;
}
@property --lift {
  syntax: "<number>";
  inherits: true;
  initial-value: 0;
}

:root {
  --bg: #1b1411;
  --surface: #261d18;
  --surface-2: #33271f;
  --line: #4a3a2e;
  --text: #f6ede4;
  --muted: #b9a89a;
  --accent: #ff8a4c;
  --accent-press: #f07434;
  --on-accent: #1b1411;
  --wood: #ecc995;
  --wood-shade: #c99a5e;
  --head: #d8412f;
  --head-shine: #f0705c;
  --char: #1d1a19;
  --ember: #ff5a1f;
  --box: #8f2d22;
  --box-dark: #6f2019;
  --box-label: #f3dfc4;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --shadow: 0 8px 24px rgb(0 0 0 / 0.35);

  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --stick-h: clamp(150px, 28vh, 220px);
  --fist-h: calc(var(--stick-h) * 0.6);
  --pull: var(--fist-h);
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(120% 60% at 50% 0%, #2c1f18 0%, var(--bg) 60%) no-repeat,
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

main {
  flex: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 16px 24px;
}

[hidden] { display: none !important; }

h1, h2, h3 { line-height: 1.2; margin: 0; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}

.muted { color: var(--muted); font-weight: 400; }

/* ---------- Buttons ---------- */

.btn {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 12px 24px;
  border: 0;
  border-radius: var(--r-md);
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-press); }
.btn-secondary {
  background: transparent;
  color: var(--text);
  box-shadow: inset 0 0 0 2px var(--line);
}
.btn-secondary:hover { background: var(--surface-2); }

.btn-link {
  min-height: 44px;
  padding: 8px 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}
.btn-link:hover { color: var(--text); }

/* ---------- Setup ---------- */

.brand { text-align: center; margin: 24px 0 32px; }
.brand-mark { display: block; margin: 0 auto 12px; border-radius: var(--r-md); }
.brand h1 { font-size: 40px; font-weight: 800; letter-spacing: -0.02em; }
.tagline { margin: 8px 0 0; color: var(--muted); font-size: 17px; text-wrap: balance; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}

#setup-form { display: grid; gap: 24px; }

.field { display: grid; gap: 8px; }
.field-row { grid-template-columns: 1fr auto; align-items: center; }
.label { font-weight: 700; font-size: 17px; }

.stepper { display: flex; align-items: center; gap: 12px; }
.step {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.step:hover { background: var(--line); }
.step:disabled { opacity: 0.35; cursor: not-allowed; }
#player-count {
  min-width: 32px;
  text-align: center;
  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

input[type="text"] {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border: 2px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* 16px stops iOS from zooming in */
}
input[type="text"]::placeholder { color: #8c7b6e; }
input[type="text"]:focus { outline: none; border-color: var(--accent); }

.names summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
.names summary::-webkit-details-marker { display: none; }
.names summary::before {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.15s;
}
.names[open] summary::before { transform: rotate(45deg); }
.name-list { display: grid; gap: 8px; padding-top: 12px; }

.footnote { margin: 24px 0 0; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------- Game ---------- */

.topbar { display: flex; justify-content: space-between; align-items: center; }
.count { color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; }

.turn { text-align: center; margin: 16px 0 8px; }
.turn h2 { font-size: 32px; font-weight: 800; letter-spacing: -0.01em; outline: none; }
/* Whose turn: the name in the player's own colour, underlined */
.who {
  color: var(--c, var(--accent));
  text-decoration: underline;
  text-decoration-thickness: 4px;
  text-underline-offset: 6px;
}
.turn h2.new-turn { animation: turn-pop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1); }
.btn .who { color: inherit; text-decoration-thickness: 3px; text-underline-offset: 4px; text-decoration-color: var(--c); }
.btn-primary .who { color: var(--on-accent); }

/* "Ben — your turn!" pop-up */
.turn-splash {
  position: fixed;
  left: 50%;
  top: 38%;
  z-index: 20;
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 18px 32px;
  border: 3px solid var(--c);
  border-radius: 22px;
  background: rgb(27 20 17 / 0.94);
  box-shadow: 0 0 0 6px rgb(0 0 0 / 0.25), 0 0 48px color-mix(in srgb, var(--c) 55%, transparent);
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: splash 1.3s cubic-bezier(0.3, 1.4, 0.5, 1) forwards;
}
.splash-name { max-width: 80vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--c); font-size: 44px; font-weight: 800; line-height: 1.1; }
.splash-sub { color: var(--text); font-size: 18px; font-weight: 700; }

/* Computer: "Next up: Ben" with a bar filling until the turn starts */
.next-up {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 10px 20px;
  overflow: hidden;
  border: 2px solid var(--c);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: 20px;
  font-weight: 800;
}
.next-label { position: relative; color: var(--muted); font-size: 15px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; }
.next-up .who { position: relative; }
.next-fill {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--c) 22%, transparent);
  transform-origin: 0 50%;
  animation: next-fill linear forwards;
}
.hint { margin: 8px 0 0; min-height: 48px; color: var(--muted); font-size: 17px; }
.hint strong { color: var(--text); }
.hint.safe strong { color: #8fd18a; }
.hint.burnt strong { color: var(--ember); }

.stage { display: flex; flex-direction: column; align-items: center; padding-top: 8px; }
.stage.shake { animation: shake 0.45s ease-in-out; }

.hand {
  position: relative;
  width: min(100%, 340px);
  height: calc(var(--stick-h) * 1.7);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.matches { position: absolute; inset: 0; }

.match {
  position: absolute;
  bottom: calc(var(--fist-h) * 0.08);
  left: 50%;
  width: var(--slot, 36px);
  height: var(--stick-h);
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: none;
  transform: translateX(-50%) translateX(var(--x, 0px)) rotate(var(--angle, 0deg));
  transform-origin: 50% 100%;
  transition: transform 0.3s ease, opacity 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}
.match:focus-visible { outline-offset: 0; }
/* --p: how far it's pulled (0–1). --lift: hover pop (0–1), rises a little and grows. */
.match .stick {
  transform: translateY(calc(var(--p) * var(--pull) * -1 - var(--lift) * 10px)) scale(calc(1 + var(--lift) * 0.12));
  transform-origin: 50% 100%;
}
.match.returning { transition: transform 0.3s ease, --p 0.25s ease-out; }
.match.revealing { transition: transform 0.3s ease, --p 0.7s cubic-bezier(0.2, 0.7, 0.2, 1); }
.match.leaving { opacity: 0; }
.match[disabled] { cursor: default; }
.match .stick { transition: filter 0.2s ease, --lift 0.35s cubic-bezier(0.3, 1.6, 0.5, 1); }
/* Hover (computer only): the match pops up, grows a little and gets a thin light outline */
@media (hover: hover) {
  .match:not([disabled]):hover { z-index: 1; }
  .match:not([disabled]):hover .stick {
    --lift: 1;
    filter: drop-shadow(0 0 1px rgb(255 236 214 / 0.95)) drop-shadow(0 0 3px rgb(255 200 150 / 0.45));
  }
}
/* Pulling: the match stays popped and lights up with a warm glow */
.match.pulling { z-index: 1; }
.match.pulling .stick,
.match.pulling:hover .stick {
  --lift: 1;
  filter: drop-shadow(0 0 2px rgb(255 190 120 / 0.95)) drop-shadow(0 0 10px rgb(255 138 76 / 0.8));
}

/* One stick + head, used in the hand and in the lineup */
.stick {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 10px;
  height: 100%;
  margin-left: -5px;
  border-radius: 1.5px; /* square-cut wood, only the edges worn */
  background:
    linear-gradient(180deg, rgb(110 70 35 / 0.5) 0 3px, transparent 3px),           /* end grain on top */
    linear-gradient(90deg, transparent 0 21%, rgb(125 78 36 / 0.28) 21% 25%, transparent 25% 57%,
      rgb(125 78 36 / 0.2) 57% 60%, transparent 60% 80%, rgb(125 78 36 / 0.16) 80% 83%, transparent 83%), /* grain lines */
    repeating-linear-gradient(0deg, transparent 0 23px, rgb(90 55 25 / 0.08) 23px 26px, transparent 26px 57px), /* growth marks */
    linear-gradient(90deg, #b3844d 0%, #e3bd87 22%, #f3d8a9 45%, #e6c08b 68%, #a8783f 100%); /* round-ish shading */
  box-shadow: inset -1px 0 0 rgb(90 55 25 / 0.35);
}
.head {
  position: absolute;
  left: 50%;
  bottom: -4px;
  width: 16px;
  height: 24px;
  margin-left: -8px;
  border-radius: 50% 50% 45% 45% / 45% 45% 55% 55%;
  background: var(--wood-shade); /* unknown until pulled */
}
.is-safe .head {
  background: radial-gradient(circle at 35% 70%, var(--head-shine), var(--head) 60%);
}
.is-burnt .head {
  background: radial-gradient(circle at 40% 70%, #3a3330, var(--char) 65%);
  box-shadow: 0 0 0 2px rgb(255 90 31 / 0.35), 0 0 16px 4px rgb(255 90 31 / 0.45);
  animation: ember 1.2s ease-in-out infinite alternate;
}
.is-burnt .stick {
  background: linear-gradient(to top, #2a211c 0 12%, #6b4a33 22%, var(--wood) 40%);
}

.box {
  position: absolute;
  left: 50%;
  bottom: 0;
  z-index: 2;
  width: min(100%, 300px);
  height: var(--fist-h);
  /* Slightly crooked, like a real box someone put down */
  transform: translateX(-50%) rotate(-1.2deg);
  filter: drop-shadow(0 10px 14px rgb(0 0 0 / 0.55));
  /* Catches clicks, so only the part of a match sticking out of the box can be pulled */
}
/* The torn top-right corner: cardboard shows along the rip, the label is torn a bit further */
.box::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 3px;
  background:
    repeating-linear-gradient(80deg, rgb(120 90 55 / 0.25) 0 1px, transparent 1px 4px),
    linear-gradient(180deg, #d8c09a, #bfa37a);
  clip-path: polygon(0 0, 86% 0, 88% 2%, 90% 1%, 92% 5%, 94% 3%, 96% 8%, 98% 7%, 100% 11%, 100% 100%, 0 100%);
}
.box-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  clip-path: polygon(0 0, 83% 0, 85% 3%, 86.5% 1.5%, 88.5% 6%, 90% 4.5%, 92% 10%, 94% 8%, 95.5% 14%, 97% 13%, 98.5% 18%, 100% 19%, 100% 100%, 0 100%);
}

.after { min-height: 76px; padding-top: 24px; }

.tray-wrap { margin-top: 16px; }
.tray-title { font-size: 14px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.tray {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}
.tray li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 14px;
  animation: pop 0.25s ease-out;
}

/* A small match lying down (tray, result art) */
.match-flat {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 10px;
}
.match-flat .stick {
  left: auto;
  right: 0;
  bottom: 2px;
  width: 34px;
  height: 6px;
  margin: 0;
}
.match-flat .head {
  left: 0;
  bottom: 0;
  width: 12px;
  height: 10px;
  margin: 0;
  border-radius: 50%;
}
.match-flat.safe .head { background: radial-gradient(circle at 35% 40%, var(--head-shine), var(--head) 60%); }
.match-flat.burnt .head { background: var(--char); box-shadow: 0 0 10px 2px rgb(255 90 31 / 0.5); }

/* ---------- Game picker ---------- */

.section-title {
  margin: 32px 0 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.game-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.game-card {
  display: grid;
  align-content: start;
  justify-items: start;
  gap: 4px;
  min-height: 136px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1), border-color 0.15s, background-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.game-card.featured {
  grid-column: 1 / -1;
  grid-template-columns: auto 1fr;
  column-gap: 16px;
  align-items: center;
  min-height: 0;
  background: linear-gradient(135deg, var(--surface-2), var(--surface));
}
.game-card.featured .game-icon { grid-row: span 2; }
/* A card left alone on the last row gets the full width */
.game-card:nth-child(even):last-child { grid-column: 1 / -1; min-height: 0; }
.game-card:active { transform: scale(0.98); }
@media (hover: hover) {
  .game-card:hover { border-color: var(--accent); transform: translateY(-3px); }
}
.game-icon { display: block; }
.game-icon svg { display: block; width: 44px; height: 44px; margin-bottom: 4px; }
.game-card.featured .game-icon svg { width: 56px; height: 56px; margin: 0; }
.game-name { font-weight: 800; font-size: 17px; line-height: 1.2; }
.game-blurb { color: var(--muted); font-size: 14px; line-height: 1.35; }
.game-tag {
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

/* Shared: big tappable game pieces (dice, coin, wheel) */
.dice-roll,
.coin,
.wheel {
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.is-busy { cursor: default; }

/* ---------- Dice (3D, on a felt table) ---------- */

.dice-table {
  --die: 60px;
  position: relative;
  width: 100%;
  height: min(46vh, 340px);
  min-height: 270px;
  margin-top: 8px;
  perspective: 900px;
  perspective-origin: 50% 10%;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.dice-table.is-busy { cursor: default; }
.dice-table:focus-visible { outline-offset: 4px; }
/* The felt, tilted away from you like a real game table */
.felt {
  position: absolute;
  left: 4%;
  right: 4%;
  top: -8%;
  height: 112%;
  border: 12px solid #6b3f22;
  border-radius: 22px;
  background: radial-gradient(ellipse at 50% 45%, #2f9a5f 0%, #1f7a4a 55%, #145a36 100%);
  box-shadow: inset 0 0 0 2px rgb(255 255 255 / 0.08), inset 0 10px 30px rgb(0 0 0 / 0.45), 0 30px 40px rgb(0 0 0 / 0.5);
  transform: rotateX(34deg);
  transform-origin: 50% 60%;
  transform-style: preserve-3d;
}
.die3d,
.die-shadow {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--die);
  height: var(--die);
}
.die3d { z-index: 1; transform-style: preserve-3d; }
.die-shadow {
  border-radius: 14px;
  background: rgb(0 0 0 / 0.55);
  filter: blur(6px);
  transform-origin: 50% 50%;
}
.cube { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; }
.face {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  place-items: center;
  padding: 9px;
  border-radius: 9px;
  background: radial-gradient(circle at 30% 25%, #fffdf8, #f1e6d6 70%, #e2d2bd);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.08), inset 0 0 10px rgb(120 90 60 / 0.25);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: box-shadow 0.15s;
}
.core { position: absolute; inset: 1px; border-radius: 4px; background: #e2d2bd; }
.core.x { transform: rotateY(90deg); }
.core.y { transform: rotateX(90deg); }
.core.z { inset: 4px; }
.face.front { transform: translateZ(calc(var(--die) / 2)); }
.face.back { transform: rotateY(180deg) translateZ(calc(var(--die) / 2)); }
.face.right { transform: rotateY(90deg) translateZ(calc(var(--die) / 2)); }
.face.left { transform: rotateY(-90deg) translateZ(calc(var(--die) / 2)); }
.face.top { transform: rotateX(90deg) translateZ(calc(var(--die) / 2)); }
.face.bottom { transform: rotateX(-90deg) translateZ(calc(var(--die) / 2)); }
.pip { width: 11px; height: 11px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #3a2a22, #140c08); opacity: 0; }
.face[data-face="1"] .pip:nth-child(5) { background: radial-gradient(circle at 40% 35%, #ff5a5a, #b3131b); width: 14px; height: 14px; }
.face[data-face="1"] .pip:nth-child(5),
.face[data-face="2"] .pip:is(:nth-child(3), :nth-child(7)),
.face[data-face="3"] .pip:is(:nth-child(3), :nth-child(5), :nth-child(7)),
.face[data-face="4"] .pip:is(:nth-child(1), :nth-child(3), :nth-child(7), :nth-child(9)),
.face[data-face="5"] .pip:is(:nth-child(1), :nth-child(3), :nth-child(5), :nth-child(7), :nth-child(9)),
.face[data-face="6"] .pip:is(:nth-child(1), :nth-child(3), :nth-child(4), :nth-child(6), :nth-child(7), :nth-child(9)) {
  opacity: 1;
}
/* Computer: a glowing outline around the dice you point at */
@media (hover: hover) {
  .dice-table:not(.is-busy) .die3d:hover .face {
    box-shadow: 0 0 0 3px #ffd23f, 0 0 18px 4px rgb(255 210 63 / 0.55), inset 0 0 10px rgb(120 90 60 / 0.25);
  }
}
.scoreboard { display: grid; gap: 8px; }
.tray li.low { border-color: var(--ember); color: var(--ember); }
.tray li strong { font-variant-numeric: tabular-nums; }
#fair-detail .tray-wrap { margin-top: 16px; }
#fair-detail > .tray { margin-top: 16px; }

/* ---------- Coin flip ---------- */

.coin-wrap { display: grid; justify-items: center; gap: 24px; padding-top: 64px; perspective: 900px; }
.coin { width: 184px; height: 184px; border-radius: 50%; transition: transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1); }
.coin-inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 1.1s cubic-bezier(0.2, 0.6, 0.3, 1);
}
.coin-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 4px;
  border-radius: 50%;
  /* Polished gold with a raised rim */
  background:
    linear-gradient(135deg, rgb(255 255 255 / 0.35) 0%, transparent 35%, transparent 65%, rgb(0 0 0 / 0.12) 100%),
    radial-gradient(circle at 32% 28%, #fff2b8, #f1c24e 35%, #d99a2b 68%, #a86f14);
  box-shadow:
    inset 0 0 0 7px #c9912c,
    inset 0 0 0 9px rgb(255 240 190 / 0.55),
    inset 0 -8px 16px rgb(0 0 0 / 0.22),
    var(--shadow);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.coin-face.tails { transform: rotateX(180deg); }
/* Rules: a card at the start, a one-line reminder after the first flip */
.coin-rules {
  width: min(100%, 380px);
  margin-top: 8px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  text-align: left;
}
.coin-rules h3 { margin: 0 0 8px; font-size: 16px; }
.coin-rules ol { display: grid; gap: 6px; margin: 0; padding-left: 20px; }
.coin-rules-note { margin: 10px 0 0; color: var(--muted); font-size: 14px; }
.coin-rules.small { padding: 8px 14px; }
.coin-rules.small h3,
.coin-rules.small li:first-child,
.coin-rules.small .coin-rules-note { display: none; }
.coin-rules.small ol { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; padding: 0; list-style: none; font-size: 14px; }
.side-tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  vertical-align: 1px;
}
.side-tag.heads { background: #8fd18a; color: #0e2a0c; }
.side-tag.tails { background: #ff6b5a; color: #2a0a06; }
.coin-board { display: grid; gap: 8px; }
.coin-board li { gap: 6px; }
.coin-board li.now { border-color: var(--accent); box-shadow: 0 0 0 2px rgb(255 138 76 / 0.35); }
.coin-board li.is-safe { border-color: #4f8f4a; color: #b8e8b4; }
.coin-face svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.coin.tossing { animation: toss 1.1s cubic-bezier(0.3, 0, 0.3, 1); }
@media (hover: hover) {
  .coin:not(.is-busy):hover { transform: translateY(-6px) scale(1.04); }
}

/* ---------- Wheel (carnival) ---------- */

.wheel-wrap { position: relative; width: min(100%, 360px); margin-top: 8px; }
.wheel { display: block; width: 100%; aspect-ratio: 1; border-radius: 50%; }
.wheel-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 10px 24px rgb(0 0 0 / 0.45));
  transition: transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.wheel-label { font-family: var(--font); font-weight: 800; }
.slice { transition: filter 0.3s; }
.slice.won { filter: brightness(1.2) saturate(1.3); animation: won-flash 0.35s ease-in-out 4 alternate; }
.bulb { fill: #fff3c4; }
.bulb.odd { animation: bulb 0.9s steps(1) infinite; }
.bulb.even { animation: bulb 0.9s steps(1) 0.45s infinite; }
.wheel.spinning .bulb.odd { animation-duration: 0.3s; }
.wheel.spinning .bulb.even { animation-duration: 0.3s; animation-delay: 0.15s; }
.wheel-hub { transform-box: fill-box; transform-origin: 50% 50%; transition: transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1); }
@media (hover: hover) {
  .wheel:not(.is-busy):hover .wheel-svg { transform: scale(1.02); }
  .wheel:not(.is-busy):hover .wheel-hub { animation: none; transform: scale(1.12) rotate(-8deg); }
}
.wheel:not(.is-busy) .wheel-hub { animation: hub-pulse 1.6s ease-in-out infinite; }
.wheel.is-busy .wheel-hub { opacity: 0.9; }

/* ---------- Hot potato ---------- */

.potato-field {
  --heat: 0;
  position: relative;
  width: 100%;
  height: min(52vh, 380px);
  min-height: 300px;
  margin-top: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background:
    radial-gradient(circle at 50% 60%, rgb(255 90 31 / calc(var(--heat) * 0.4)), transparent 70%),
    var(--surface);
  touch-action: manipulation;
}
.potato {
  position: absolute;
  left: var(--x, 50%);
  top: var(--y, 50%);
  width: 124px;
  height: 114px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition: left 0.16s ease-out, top 0.16s ease-out;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.potato svg {
  display: block;
  width: 100%;
  height: 100%;
  filter:
    saturate(calc(1 + var(--heat) * 1.3))
    hue-rotate(calc(var(--heat) * -22deg))
    drop-shadow(0 0 calc(var(--heat) * 24px) rgb(255 90 31 / 0.9));
}
.potato .steam { opacity: calc(0.2 + var(--heat) * 0.8); animation: steam 1.4s ease-in-out infinite; }
.potato.hot svg { animation: jitter 0.28s linear infinite; }
.potato.very-hot svg { animation-duration: 0.12s; }
.potato-badge {
  position: absolute;
  right: 0;
  top: 8px;
  display: grid;
  place-items: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 800;
  font-size: 16px;
  box-shadow: var(--shadow);
}
.potato.tossed .potato-badge { animation: pop 0.25s ease-out; }
.potato.boom { animation: boom 0.5s ease-out forwards; }
.potato-field.boom { animation: flash 0.7s ease-out; }
.boom-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--ember);
  font-size: 64px;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-shadow: 0 0 24px rgb(255 90 31 / 0.7);
  animation: pop 0.3s ease-out;
  pointer-events: none;
}

/* ---------- Finger chooser ---------- */

.finger-field {
  position: relative;
  width: 100%;
  height: max(360px, calc(100dvh - 300px));
  overflow: hidden;
  border: 2px dashed var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.finger-prompt {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  pointer-events: none;
}
.finger-dot {
  --c: var(--accent);
  position: absolute;
  width: 96px;
  height: 96px;
  margin: -48px 0 0 -48px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--c) 30%, transparent), 0 0 32px var(--c);
  pointer-events: none;
  animation: dot-in 0.2s ease-out, breathe 1.2s ease-in-out 0.2s infinite;
  transition: transform 0.45s cubic-bezier(0.3, 1.6, 0.5, 1), opacity 0.4s;
}
.finger-field.counting .finger-dot { animation: dot-in 0.2s ease-out, breathe 0.35s ease-in-out infinite; }
.finger-dot.chosen { z-index: 1; animation: none; transform: scale(1.9); }
.finger-dot.out { animation: none; opacity: 0; transform: scale(0.3); }

/* ---------- Bomb button ---------- */

.bomb-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), 1fr);
  gap: 12px;
  width: min(100%, 360px);
  margin-top: 16px;
}
.bomb-btn {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle, #2a211c 62%, #140f0c 64%);
  box-shadow: inset 0 -3px 0 rgb(255 255 255 / 0.06);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.bomb-btn .cap {
  position: absolute;
  inset: 14%;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff8a6c, #d8412f 55%, #8f2d22);
  box-shadow: 0 6px 0 #5e1a14, 0 9px 14px rgb(0 0 0 / 0.45);
  color: var(--bg);
  font-size: 22px;
  font-weight: 800;
  transform: translateY(-5px);
  transition: transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1), box-shadow 0.15s, background 0.2s;
}
.bomb-btn .cap svg { width: 80%; height: 80%; }
@media (hover: hover) {
  .bomb-grid:not(.is-busy) .bomb-btn:not(.safe):hover .cap { transform: translateY(-9px) scale(1.06); }
}
.bomb-btn.pressing .cap {
  transform: translateY(2px);
  background: radial-gradient(circle at 35% 30%, #fff6b0, #ffd23f 55%, #c99a00);
  box-shadow: 0 1px 0 #7a5c00, 0 0 18px 4px rgb(255 210 63 / 0.6);
  transition-duration: 0.12s;
  animation: arm-blink 0.5s steps(1) infinite;
}
.bomb-btn.safe { cursor: default; }
.bomb-btn.safe .cap {
  transform: translateY(1px);
  background: radial-gradient(circle at 35% 30%, #b8e8b4, #8fd18a 55%, #4f8f4a);
  box-shadow: 0 2px 0 #2f5a2c, 0 3px 6px rgb(0 0 0 / 0.4);
}
.bomb-btn.bomb .cap {
  transform: translateY(1px);
  background: radial-gradient(circle at 40% 40%, #3a3330, var(--char) 70%);
  box-shadow: 0 0 20px 6px rgb(255 90 31 / 0.6);
}
.balloon-scene .boom-text,
.croc .boom-text { z-index: 2; }

/* Full-screen explosion (Bomb Button). --x/--y = where the bomb was. */
.explosion { position: fixed; inset: 0; z-index: 30; overflow: hidden; pointer-events: none; }
.ex-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--x) var(--y), #fff 0, #fff6c8 18%, #ffb347 40%, rgb(255 90 31 / 0.6) 65%, transparent 90%);
  animation: ex-flash 1.1s ease-out forwards;
}
.ex-fireball,
.ex-ring {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border-radius: 50%;
}
/* Real fire colours: white-hot core, yellow, orange, deep red, sooty edge */
.ex-fireball {
  background: radial-gradient(circle,
    #fffbea 0 6%, #ffe9a8 14%, #ffc15a 24%, #ff8a1e 36%, #e0520c 48%, #a8300a 58%,
    rgb(90 30 10 / 0.7) 66%, rgb(50 24 14 / 0.35) 74%, transparent 84%);
  animation: ex-fireball 2.4s cubic-bezier(0.12, 0.7, 0.3, 1) forwards;
}
.ex-bomb .ex-flash {
  background: radial-gradient(circle at var(--x) var(--y), #fffdf2 0, #fff1c4 15%, #ffb44d 35%, rgb(214 80 12 / 0.55) 60%, transparent 88%);
  animation-duration: 1.4s;
}
.ex-bomb .ex-ring {
  border-width: 3px;
  border-color: rgb(255 214 150 / 0.55);
  box-shadow: 0 0 30px rgb(255 170 80 / 0.35), inset 0 0 30px rgb(255 170 80 / 0.25);
  animation-duration: 1.4s;
}
.ex-smoke {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 34vmax;
  height: 34vmax;
  border-radius: 50%;
  background: radial-gradient(circle, rgb(58 50 44 / 0.95) 0, rgb(44 38 34 / 0.8) 35%, rgb(30 26 24 / 0.4) 55%, transparent 70%);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.2);
  animation: ex-smoke 3.8s ease-out forwards;
}
.ex-ring {
  margin: 0;
  border: 5px solid rgb(255 236 180 / 0.95);
  box-shadow: 0 0 24px rgb(255 200 120 / 0.8), inset 0 0 24px rgb(255 200 120 / 0.6);
  transform: translate(-50%, -50%);
  animation: ex-ring 0.9s ease-out forwards;
}
.ex-ring.r2 { border-color: rgb(255 140 66 / 0.8); animation-delay: 0.15s; animation-duration: 1.1s; opacity: 0; }
.ex-spark {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 4px;
  height: 14px;
  margin: -7px 0 0 -2px;
  border-radius: 2px;
  background: linear-gradient(#fff3c0, #ffa230 45%, #d9480f);
  box-shadow: 0 0 8px rgb(255 140 40 / 0.8);
  transform: rotate(var(--a));
  animation: ex-spark 0.9s cubic-bezier(0.1, 0.7, 0.3, 1) forwards;
}
/* Balloon pop: a sharp pale flash, one shockwave, rubber scraps everywhere */
.explosion.ex-balloon .ex-flash {
  background: radial-gradient(circle at var(--x) var(--y), #fff 0, #ffe3dc 20%, rgb(216 65 47 / 0.35) 50%, transparent 80%);
  animation-duration: 0.7s;
}
.explosion.ex-balloon .ex-ring { border-color: rgb(255 255 255 / 0.9); box-shadow: 0 0 18px rgb(255 200 190 / 0.7); animation-duration: 0.6s; }
.ex-shred {
  position: absolute;
  left: var(--x);
  top: var(--y);
  background: var(--head);
  box-shadow: inset -2px -2px 0 rgb(0 0 0 / 0.18), inset 2px 2px 0 rgb(255 255 255 / 0.2);
  transform: translate(-50%, -50%) scale(0.3);
  animation: ex-shred 2.4s linear forwards;
}
#app.quake { animation: quake 0.8s cubic-bezier(0.36, 0.07, 0.19, 0.97); }

/* ---------- Balloon pump ---------- */

.balloon-scene {
  position: relative;
  display: grid;
  place-items: end center;
  width: 100%;
  height: 300px;
  margin-top: 8px;
}
.balloon {
  --size: 0.45;
  width: 128px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--head);
  cursor: pointer;
  transform: scale(var(--size));
  transform-origin: 50% 100%;
  transition: transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1);
  -webkit-tap-highlight-color: transparent;
}
.balloon svg { display: block; width: 100%; height: auto; filter: drop-shadow(0 8px 16px rgb(0 0 0 / 0.35)); transition: filter 0.2s; }
.balloon:disabled { cursor: default; }
@media (hover: hover) {
  .balloon:not(:disabled):hover svg { filter: drop-shadow(0 0 2px #fff) drop-shadow(0 0 14px rgb(255 120 100 / 0.7)); }
}
.balloon.puff svg { animation: puff 0.3s ease-out; }
.balloon.big svg { animation: wobble 0.5s ease-in-out infinite alternate; }
.balloon.big.puff svg { animation: puff 0.3s ease-out, wobble 0.5s ease-in-out 0.3s infinite alternate; }
.balloon.popped { opacity: 0; transform: scale(calc(var(--size) * 1.3)); transition: transform 0.08s, opacity 0.08s; }
.balloon-controls { display: grid; gap: 12px; width: 100%; margin-top: 16px; }
.balloon-controls .btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Secret number ---------- */

.number-panel { display: grid; gap: 16px; width: min(100%, 360px); margin-top: 16px; text-align: center; }
.number-range {
  margin: 0;
  font-size: 56px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.number-panel.hit .number-range { color: var(--ember); text-shadow: 0 0 24px rgb(255 90 31 / 0.6); }
.number-bar { position: relative; height: 12px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.number-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--head));
  transition: left 0.4s ease, right 0.4s ease;
}
.number-form { display: grid; grid-template-columns: 1fr auto; gap: 12px; }
.number-last { min-height: 24px; margin: 0; color: var(--muted); }
.number-last strong { color: #8fd18a; }
.number-input {
  width: 100%;
  min-height: 52px;
  padding: 12px 16px;
  border: 2px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
}
.number-input:focus { outline: none; border-color: var(--accent); }
.number-input { -moz-appearance: textfield; appearance: textfield; }
.number-input::-webkit-inner-spin-button,
.number-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.number-form .btn { width: auto; }

/* ---------- Reaction test ---------- */

.reaction-pad {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 300px;
  margin-top: 8px;
  padding: 24px;
  border: 0;
  border-radius: var(--r-lg);
  color: var(--text);
  font: inherit;
  font-size: 32px;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.05s;
}
.reaction-pad.ready { background: var(--surface-2); box-shadow: inset 0 0 0 2px var(--line); }
.reaction-pad.wait { background: #8f2d22; }
.reaction-pad.go { background: #3f9e45; color: #0e2410; font-size: 48px; }
.reaction-pad.early { background: var(--char); color: var(--ember); }
.reaction-pad.result { background: var(--surface-2); font-variant-numeric: tabular-nums; }
@media (hover: hover) {
  .reaction-pad.ready:hover { box-shadow: inset 0 0 0 2px var(--accent); }
}

/* ---------- Crocodile teeth ---------- */

.croc { position: relative; width: min(100%, 380px); aspect-ratio: 360 / 320; margin-top: 16px; }
.croc svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.croc-back { filter: drop-shadow(0 12px 18px rgb(0 0 0 / 0.45)); }
/* The head sits above the teeth; it lets clicks through and slams down on CHOMP */
.croc-head {
  position: absolute;
  inset: 0;
  z-index: 400;
  pointer-events: none;
  transform-origin: 50% 0;
  transition: transform 0.12s cubic-bezier(0.6, 0, 1, 1);
  filter: drop-shadow(0 10px 14px rgb(0 0 0 / 0.4));
}
.croc .pupil { transition: transform 0.3s; transform-box: fill-box; transform-origin: center; }
.croc.tense .croc-head { animation: jitter 0.15s linear infinite; }
.croc.tense .pupil { transform: scaleX(2.2); }
.croc.snap .croc-head { transform: translateY(34%) scaleY(0.96); }
.croc.snap .pupil { transform: scaleX(0.6) scaleY(0.7); }
.croc .throat { transition: opacity 0.1s; }
.croc.snap .throat { opacity: 0; }
.tooth {
  position: absolute;
  width: 7.4%;
  aspect-ratio: 0.72;
  padding: 0;
  border: 0;
  border-radius: 50% 50% 40% 40% / 80% 80% 20% 20%;
  background:
    radial-gradient(ellipse at 38% 30%, rgb(255 255 255 / 0.9), transparent 45%),
    linear-gradient(90deg, #cbbba2 0%, #f3ebdd 30%, #fffaf1 50%, #eadfcc 75%, #bfae93 100%);
  box-shadow: inset 0 -5px 6px rgb(140 100 70 / 0.35), 0 3px 3px rgb(80 10 20 / 0.45);
  cursor: pointer;
  transform: translate(-50%, -100%) rotate(var(--tilt)) scale(var(--s));
  transform-origin: 50% 100%;
  transition: transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1), filter 0.2s;
  -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) {
  .croc:not(.is-busy) .tooth:not(.down):hover {
    transform: translate(-50%, -100%) rotate(var(--tilt)) scale(calc(var(--s) * 1.12)) translateY(-4px);
    filter: drop-shadow(0 0 5px rgb(255 240 200 / 0.9));
  }
}
.tooth.down {
  cursor: default;
  filter: brightness(0.82);
  transform: translate(-50%, -100%) rotate(var(--tilt)) scale(var(--s)) translateY(38%) scaleY(0.55);
  transition-duration: 0.15s;
}
.tooth.sore {
  background:
    radial-gradient(ellipse at 38% 30%, rgb(255 255 255 / 0.6), transparent 45%),
    linear-gradient(90deg, #a8281c, #ff6b5a 50%, #a8281c);
}
.croc .boom-text { z-index: 500; }

/* ---------- Don't say 21 ---------- */

.count-panel {
  --heat: 0; /* 0 at the start … 1 at 21 */
  display: grid;
  justify-items: center;
  gap: 4px;
  width: min(100%, 360px);
  margin-top: 8px;
  padding-top: 8px;
  border-radius: var(--r-lg);
  /* A red glow behind the number that grows as the count climbs */
  background: radial-gradient(ellipse 60% 45% at 50% 22%, rgb(216 30 30 / calc(var(--heat) * var(--heat) * 0.55)), transparent 75%);
  transition: background 0.6s;
}
.count-shaker { display: grid; justify-items: center; }
.count-shaker.nervous { animation: jitter var(--shake, 0.6s) linear infinite; }
.count-big {
  margin: 0;
  font-size: 96px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
/* White → warm → deep red, one shade per number */
.count-panel .count-big {
  color: color-mix(in srgb, #ff2a1f calc(var(--heat) * 100%), var(--text));
  text-shadow: 0 0 calc(var(--heat) * 28px) rgb(255 42 31 / calc(var(--heat) * 0.7));
  transition: color 0.5s, text-shadow 0.5s;
}
.count-big.bump { animation: pop 0.25s ease-out; }
.count-panel.hit .count-big { color: var(--ember); text-shadow: 0 0 24px rgb(255 90 31 / 0.6); }
.count-label { margin: 0; color: var(--muted); }
.count-options { display: grid; gap: 12px; width: 100%; margin-top: 24px; }
.count-option {
  min-height: 56px;
  padding: 12px 16px;
  border: 2px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 22px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1), border-color 0.15s;
}
.count-option.danger { border-color: var(--head); color: var(--head-shine); }
.count-option:disabled { opacity: 0.4; cursor: default; }
@media (hover: hover) {
  .count-option:not(:disabled):hover { border-color: var(--accent); transform: translateY(-3px); }
}

/* ---------- Result ---------- */

.result-art .game-icon svg { width: 96px; height: 96px; margin: 0; }

#screen-result { text-align: center; }
#screen-result > h2 { margin-top: 4px; font-size: 30px; font-weight: 800; outline: none; text-wrap: balance; }
.result-kicker {
  margin: 8px 0 0;
  color: #ffd23f;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.you-lose { display: block; color: var(--muted); font-size: 22px; font-weight: 700; }
.loser-name {
  display: inline-block;
  max-width: 100%;
  font-size: clamp(30px, 10vw, 44px);
  line-height: 1.1;
  overflow-wrap: anywhere;
  background: linear-gradient(90deg, #ff3b5c, #ffd23f, #2ec4b6, #b45cff, #ff3b5c);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: loser-shine 3s linear infinite, loser-pop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.result-sarcasm { margin: 8px 0 0; font-size: 17px; font-style: italic; color: var(--text); text-wrap: balance; }
.result-how { margin: 4px 0 0; color: var(--muted); font-size: 15px; }

.confetti { position: fixed; inset: 0; z-index: 10; overflow: hidden; pointer-events: none; }
.confetti span {
  position: absolute;
  top: -16px;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  animation: confetti-fall 3s cubic-bezier(0.25, 0.4, 0.5, 1) forwards;
}

.result-art {
  position: relative;
  height: 120px;
  display: grid;
  place-items: center;
}
.result-art .match-flat { transform: scale(3) rotate(-12deg); }
.result-art .match-flat .stick { background: linear-gradient(to left, var(--wood) 0 55%, #6b4a33 85%, #2a211c 100%); }
.smoke {
  position: absolute;
  left: calc(50% - 56px);
  top: 42px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgb(200 190 180 / 0.35);
  filter: blur(3px);
  animation: smoke 2.4s ease-out infinite;
}
.smoke.s2 { animation-delay: 0.8s; }
.smoke.s3 { animation-delay: 1.6s; }

.forfeit {
  margin: 12px 0 0;
  font-size: 20px;
}
.forfeit strong { color: var(--accent); }

/* "Was it fair?" button in the top-right corner, with a pop-up card */
#screen-result { position: relative; }
.fair-tip { position: absolute; top: 0; right: 0; z-index: 5; text-align: left; }
.fair-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 12px 6px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.fair-i {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  font-family: Georgia, serif;
  font-style: italic;
  font-weight: 700;
}
.fair-tip:hover .fair-btn,
.fair-tip.open .fair-btn { color: var(--text); border-color: var(--accent); }
.fair-pop {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(340px, calc(100vw - 32px));
  max-height: 60vh;
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
}
.fair-pop p { margin: 0; color: var(--muted); font-size: 15px; }
@media (hover: hover) {
  .fair-tip:hover .fair-pop { opacity: 1; visibility: visible; transform: none; }
}
.fair-tip.open .fair-pop { opacity: 1; visibility: visible; transform: none; }

.lineup {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 0;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
}
.lineup li {
  position: relative;
  width: 44px;
  display: grid;
  justify-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.lineup .mini {
  position: relative;
  width: 16px;
  height: 72px;
}
.lineup .mini .head { bottom: auto; top: -4px; }
.lineup .mini.is-burnt .stick { background: linear-gradient(to bottom, #2a211c 0 12%, #6b4a33 22%, var(--wood) 40%); }
.lineup .who {
  max-width: 44px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lineup .is-burnt + .who { color: var(--ember); font-weight: 700; }

.result-actions { display: grid; gap: 12px; margin-top: 32px; }

/* ---------- Footer ---------- */

.site-footer {
  padding: 16px 16px max(16px, env(safe-area-inset-bottom));
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.site-footer p { margin: 0; }
.site-footer .copy { margin-top: 4px; opacity: 0.8; }
.noscript { text-align: center; padding: 16px; }

/* ---------- Motion ---------- */

@keyframes ember {
  from { box-shadow: 0 0 0 2px rgb(255 90 31 / 0.25), 0 0 10px 2px rgb(255 90 31 / 0.35); }
  to { box-shadow: 0 0 0 2px rgb(255 90 31 / 0.45), 0 0 20px 6px rgb(255 90 31 / 0.55); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
@keyframes pop {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes toss {
  0%, 100% { transform: translateY(0) scale(1); }
  45% { transform: translateY(-58px) scale(1.12); }
}
@keyframes arm-blink {
  50% { background: radial-gradient(circle at 35% 30%, #fffbe0, #fff09a 55%, #e6c200); box-shadow: 0 1px 0 #7a5c00, 0 0 30px 10px rgb(255 230 120 / 0.85); }
}
@keyframes ex-flash {
  0% { opacity: 0; }
  8% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes ex-fireball {
  0% { transform: scale(0); opacity: 1; filter: brightness(1.5); }
  18% { transform: scale(38); opacity: 1; filter: brightness(1.2); }
  55% { transform: scale(62); opacity: 0.95; filter: brightness(0.85) saturate(0.9); }
  100% { transform: scale(80); opacity: 0; filter: brightness(0.45) saturate(0.6); }
}
@keyframes ex-smoke {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.2); }
  25% { opacity: 0.95; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--sx)), calc(-50% + var(--sy) - 28vh)) scale(calc(var(--s) * 1.7)); }
}
@keyframes ex-ring {
  0% { width: 0; height: 0; opacity: 1; }
  100% { width: 260vmax; height: 260vmax; opacity: 0; }
}
@keyframes ex-spark {
  0% { transform: rotate(var(--a)) translateY(0) scaleY(0.6); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: rotate(var(--a)) translateY(calc(var(--d) * -1)) scaleY(1.2); opacity: 0; }
}
/* Burst out fast, then flutter down slowly like torn rubber */
@keyframes ex-shred {
  0% { transform: translate(-50%, -50%) scale(0.3) rotate(0); opacity: 1; animation-timing-function: cubic-bezier(0.1, 0.8, 0.3, 1); }
  22% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1) rotate(calc(var(--r) * 0.4)); opacity: 1; animation-timing-function: ease-in; }
  60% { transform: translate(calc(-50% + var(--dx) * 1.05 + 12px), calc(-50% + var(--dy) * 1.05 + 14vh)) scale(0.95) rotate(calc(var(--r) * 0.75)); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx) * 1.1 - 10px), calc(-50% + var(--dy) * 1.1 + 45vh)) scale(0.9) rotate(var(--r)); opacity: 0; }
}
@keyframes quake {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-14px, 8px) rotate(-1deg); }
  20% { transform: translate(12px, -10px) rotate(1deg); }
  30% { transform: translate(-10px, -6px); }
  40% { transform: translate(9px, 8px) rotate(0.5deg); }
  55% { transform: translate(-6px, 4px); }
  70% { transform: translate(4px, -3px); }
  85% { transform: translate(-2px, 2px); }
}
@keyframes turn-pop {
  0% { transform: scale(0.85); }
  100% { transform: scale(1); }
}
@keyframes splash {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  25% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(0.95); }
}
@keyframes next-fill {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}
@keyframes confetti-fall {
  to { transform: translate(var(--drift), 105vh) rotate(var(--spin)); }
}
@keyframes loser-shine {
  to { background-position: 200% 0; }
}
@keyframes loser-pop {
  from { transform: scale(0.4); opacity: 0; }
}
@keyframes bulb {
  0% { fill: #fff3c4; }
  50% { fill: #ff9f1c; }
}
@keyframes hub-pulse {
  50% { transform: scale(1.06); }
}
@keyframes won-flash {
  to { filter: brightness(1.6) saturate(1.4); }
}
@keyframes steam {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
@keyframes jitter {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  25% { transform: translate(-2px, 1px) rotate(-4deg); }
  75% { transform: translate(2px, -1px) rotate(4deg); }
}
@keyframes boom {
  to { transform: translate(-50%, -50%) scale(1.9); opacity: 0; }
}
@keyframes flash {
  from { box-shadow: inset 0 0 0 999px rgb(255 160 80 / 0.8); }
  to { box-shadow: inset 0 0 0 999px rgb(255 160 80 / 0); }
}
@keyframes flash-soft {
  from { filter: brightness(1.8); }
  to { filter: brightness(1); }
}
@keyframes puff {
  0% { transform: scale(1); }
  40% { transform: scale(1.07, 0.95); }
  100% { transform: scale(1); }
}
@keyframes wobble {
  from { transform: rotate(-2deg); }
  to { transform: rotate(2deg); }
}
@keyframes dot-in {
  from { transform: scale(0); }
}
@keyframes breathe {
  50% { transform: scale(1.12); }
}
@keyframes smoke {
  0% { transform: translate(0, 0) scale(0.6); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translate(-12px, -60px) scale(2.2); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
  .match, .match.revealing, .match.returning, .coin-inner, .wheel-rot, .potato { transition-duration: 0.01ms; }
}

@media (min-width: 600px) {
  main { padding-top: 48px; }
}

/* ---------- 404 ---------- */

.notfound { text-align: center; padding-top: 96px; }
.notfound h1 { font-size: 32px; font-weight: 800; }
.notfound .brand-mark { margin: 0 auto 24px; }
.notfound .btn { margin-top: 32px; text-decoration: none; }
