/* Math Range: a hand-painted range sign. Limestone card, dusk sky, Rye lettering. */
:root {
  --limestone: #e8dcc3; --caliche: #d9c9a3; --cedar: #3f5a3a; --oak: #4b5e2e;
  --bluebonnet: #3a4fb0; --sky: #8fb8e8; --dusk: #f7b267; --ink: #2a211b;
  --p1: #e8590c; --p2: #1c7ed6;
  --display: "Rye", "Rockwell", "Clarendon", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
/* The hidden attribute wins over any display an element sets for itself. */
[hidden] { display: none !important; }

html { min-height: 100%; background: var(--ink); }

body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  font: 500 1rem/1.4 var(--sans); color: var(--ink);
  background:
    linear-gradient(180deg, var(--sky) 0%, var(--dusk) 38%, var(--caliche) 72%, var(--limestone) 100%) fixed;
}

h1, h2, legend { font-family: var(--display); font-weight: 400; }
:focus-visible { outline: 3px solid var(--bluebonnet); outline-offset: 3px; }

.flash {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 10;
  margin: 0; padding: 10px 18px; border-radius: 999px; font-weight: 700;
  background: #a61e1e; color: var(--limestone); box-shadow: 0 8px 24px rgba(0,0,0,.35);
}

/* Buttons: painted tin, pressed down on :active */
.btn {
  appearance: none; display: inline-block; cursor: pointer; text-decoration: none;
  font: 700 1.1rem/1 var(--sans); letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink); background: var(--limestone);
  border: 3px solid var(--ink); border-radius: 12px; padding: 14px 24px;
  box-shadow: 0 5px 0 var(--ink); transition: transform .08s, box-shadow .08s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 0 var(--ink); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn-primary { background: var(--p1); color: #fff7ea; font-size: 1.4rem; padding: 18px 40px; text-shadow: 0 2px 0 rgba(0,0,0,.25); }

/* Landing */
.landing {
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 20px; padding: 32px 16px; text-align: center;
}
.landing .logo { width: clamp(88px, 22vw, 128px); height: auto; border-radius: 22%; box-shadow: 0 10px 24px rgba(42,33,27,.35); transform: rotate(-3deg); }
.landing h1 {
  margin: 0; font-size: clamp(3.2rem, 14vw, 7rem); line-height: .95; color: var(--ink);
  text-shadow: 0 3px 0 var(--limestone), 0 7px 0 rgba(42,33,27,.25);
  transform: rotate(-2deg);
}
.tagline { margin: 0 0 12px; max-width: 24ch; font-size: 1.2rem; font-weight: 600; }
.join {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center;
  margin-top: 28px; padding: 14px 18px; background: var(--limestone);
  border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 10px 24px rgba(42,33,27,.25);
}
.join label { font-weight: 700; }
.join input[type=text] {
  width: 8.5ch; font: 400 1.5rem/1.2 var(--display); letter-spacing: .08em; text-transform: uppercase;
  text-align: center; padding: 8px 10px; border: 3px solid var(--ink); border-radius: 10px; background: #fff9ec;
  box-sizing: content-box;
}
.join .btn { padding: 12px 20px; font-size: 1rem; }

/* Lobby */
.lobby { max-width: 920px; margin: 0 auto; padding: 24px 16px 48px; display: grid; gap: 22px; }
.lobby-head { text-align: center; display: grid; justify-items: center; gap: 6px; }
.lobby-head h1 { margin: 0; font-size: 1.6rem; letter-spacing: .06em; color: var(--ink); }
.code-label { margin: 0; font-weight: 700; font-size: .85rem; letter-spacing: .12em; text-transform: uppercase; }

/* The game code is the sign: nailed-up limestone board, cedar frame */
.code {
  position: relative; margin: 6px 0 0; padding: .18em .5em .12em;
  font: 400 clamp(2.6rem, 13vw, 4.5rem)/1.1 var(--display); letter-spacing: .14em; text-indent: .14em;
  color: var(--ink); background: var(--limestone);
  border: 8px solid var(--cedar); border-radius: 10px;
  box-shadow: inset 0 0 0 3px var(--limestone), inset 0 0 0 5px var(--ink), 0 14px 0 -4px rgba(42,33,27,.35), 0 20px 36px rgba(42,33,27,.35);
  transform: rotate(-1deg); user-select: all;
}
.code::before, .code::after {
  content: ""; position: absolute; top: 50%; width: 10px; height: 10px; margin-top: -5px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #8a7f70, var(--ink) 70%);
}
.code::before { left: 10px; } .code::after { right: 10px; }

/* Share the range: a small pill under the code sign; in the HUD, a chip beside the speaker */
.share {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; padding: 6px 14px; cursor: pointer;
  font-family: inherit; font-weight: 800; font-size: .8rem; line-height: 1; letter-spacing: .08em; text-transform: uppercase;
  color: var(--limestone); background: var(--ink); border: 0; border-radius: 999px;
}
.share.copied .share-label { font-size: 0; }
.share.copied .share-label::after { content: "Link copied"; font-size: .8rem; }

.badge {
  display: inline-block; padding: 4px 14px; border-radius: 999px; font-weight: 800; font-size: .8rem;
  letter-spacing: .06em; background: var(--ink); color: var(--limestone);
}
/* Status lines: the lobby's background load and the loading card's step */
.preload, .phase .step { font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; opacity: .7; }
.preload { margin: 4px 0 0; }

.panel {
  background: var(--limestone); border: 3px solid var(--ink); border-radius: 14px;
  padding: 18px 20px 20px; box-shadow: 0 10px 24px rgba(42,33,27,.22); margin: 0; min-inline-size: 0;
}
fieldset { border: 0; padding: 0; margin: 0; min-inline-size: 0; }
fieldset[disabled] { opacity: .6; pointer-events: none; }
fieldset legend { float: left; width: 100%; padding: 0; margin-bottom: 12px; font-size: 1.3rem; }
fieldset legend + * { clear: both; }
legend small { font: 700 .7rem/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; opacity: .7; margin-left: 8px; }

.host-panel fieldset { display: grid; gap: 14px; }
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.mode {
  position: relative; display: grid; gap: 2px; padding: 14px 16px 14px 48px; cursor: pointer;
  background: #fff9ec; border: 3px solid var(--caliche); border-radius: 12px; transition: border-color .12s, background .12s;
}
.mode input { position: absolute; left: 14px; top: 16px; width: 22px; height: 22px; margin: 0; accent-color: var(--cedar); }
.mode strong { font-size: 1.1rem; }
.mode span { font-size: .9rem; opacity: .8; }
.mode.selected { border-color: var(--cedar); background: #f3ecd6; box-shadow: inset 0 0 0 2px var(--cedar); }

.field { display: flex; align-items: center; gap: 10px; font-weight: 700; flex-wrap: wrap; }
.field input[type=number] {
  width: 5.5ch; font: 700 1.2rem/1.2 var(--sans); text-align: center; padding: 6px;
  border: 3px solid var(--ink); border-radius: 10px; background: #fff9ec; box-sizing: content-box;
}
.handicaps { display: grid; gap: 10px; }

.players { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.player-panel { border-left: 6px solid var(--player-color, var(--ink)); }
.player-name {
  width: 100%; margin-bottom: 14px; font: 400 1.7rem/1.2 var(--display); color: var(--player-color, var(--ink));
  background: transparent; border: 0; border-bottom: 3px dashed var(--caliche); padding: 2px 0; border-radius: 0;
}
.player-name:focus { border-bottom-color: var(--player-color, var(--ink)); outline: 0; }
.player-panel.waiting {
  display: grid; place-content: center; text-align: center; border-left-color: var(--caliche);
  border-style: dashed; border-left-style: dashed; box-shadow: none; background: transparent; min-height: 200px;
}
.waiting p { margin: 0; font-weight: 700; }
.waiting .hint { margin-top: 8px; font-weight: 500; font-size: .9rem; }

/* Operation chips: tin cans on the fence post. On = painted in the player's
   colour, standing up, shimmering, with a check in the corner. Off = knocked
   over: gray, tilted, dented, no shine. The set-up and topple animations are
   played by lobby_controller (Web Animations), so they run on a toggle only,
   never on page load or a reconnect. */
.ops { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 6px 0 16px; }
.op { position: relative; display: block; }
.op input {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; appearance: none;
  background: transparent; border: 0; cursor: pointer; z-index: 1;
}
.op span {
  position: relative; overflow: hidden; display: grid; place-items: center; min-height: 64px; font: 800 2.2rem/1 var(--sans);
  color: #5a544b; background: #c6bfb1; border: 3px dashed #7d766b; border-radius: 14px; box-shadow: none;
  transform: translateY(4px) rotate(-7deg) scale(.94); filter: grayscale(1);
  transition: transform .18s cubic-bezier(.3,1.6,.5,1), box-shadow .18s, background .18s, color .18s, border-color .18s, filter .18s;
}
/* A dent across the fallen can */
.op span::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(118deg, transparent 46%, rgba(42,33,27,.22) 47%, rgba(42,33,27,.22) 52%, transparent 53%);
}
.op input:checked + span {
  color: #fff7ea; background: var(--player-color); text-shadow: 0 2px 0 rgba(0,0,0,.3);
  border-style: solid; border-color: var(--ink); box-shadow: 0 4px 0 var(--ink), 0 0 18px rgba(255,209,102,.45);
  transform: none; filter: none;
}
/* The shine sweeping across the painted tin */
.op input:checked + span::before {
  inset: -40% -60%;
  background: linear-gradient(115deg, transparent 42%, rgba(255,255,255,.55) 50%, transparent 58%);
  animation: op-shimmer 2.8s ease-in-out 3;
}
/* The check in the corner */
.op input:checked + span::after {
  content: "✓"; position: absolute; top: 5px; right: 6px; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; font: 900 .8rem/1 var(--sans); color: var(--ink); background: #fff7ea;
  border: 2px solid var(--ink); text-shadow: none;
}
/* Pressing a standing can pushes it down; a fallen one just sinks a little */
.op input:active:checked + span { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.op input:active:not(:checked) + span { transform: translateY(6px) rotate(-7deg) scale(.92); }
.op input:focus-visible + span { outline: 3px solid var(--bluebonnet); outline-offset: 3px; }
/* The sparks that fly when a can is set back up: a dot whose shadows scatter (lobby_controller animates it) */
.op .sparks {
  position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%;
  pointer-events: none; z-index: 2; opacity: 0;
}
@keyframes op-shimmer { 0%, 60% { transform: translateX(-60%); } 100% { transform: translateX(60%); } }

.player-panel .field { margin-bottom: 18px; }
/* Under the slider: what the chosen grades deal */
.player-panel .field:has(input[type=range]) { margin-bottom: 6px; }
.difficulty-note { margin: 0 0 18px; font-size: .88rem; line-height: 1.35; color: rgba(42,33,27,.78); }
.difficulty-note .grade { font: 400 .95rem/1.2 var(--display); letter-spacing: .02em; color: var(--player-color, var(--ink)); }
.field output { font: 400 1.5rem/1 var(--display); min-width: 1ch; color: var(--player-color); display: inline-block; }

/* The grade slider is a fuse with two handles, lowest and highest grade: lit in
   the player's colour between them, plain rope elsewhere. --lo and --hi are the
   grades the handles sit on (set inline, kept live by lobby_controller) and
   --grade-min/--grade-max, set once on the lobby, are the ends of the scale. The
   handles are two stacked range inputs whose own tracks are invisible and
   which take no pointer events; the .handles box takes the pointer instead
   (lobby_controller#grab). The rope runs the whole width; the .track inside it
   is inset by half a thumb, so it spans exactly the thumbs' centres: the lit
   stretch is painted on it, the controller measures it, and the notches below
   (one thumb wide each, spread out) line up with it. */
.fuse {
  --thumb: 30px;
  --thumb-face: radial-gradient(circle at 35% 30%, #fff7ea, var(--player-color) 62%);
  --thumb-glow: 0 3px 0 var(--ink), 0 0 0 5px rgba(255,209,102,.45), 0 0 14px 3px rgba(255,160,60,.35);
  --lo-at: calc((var(--lo, 0) - var(--grade-min, 0)) / (var(--grade-max, 1) - var(--grade-min, 0)) * 100%);
  --hi-at: calc((var(--hi, 0) - var(--grade-min, 0)) / (var(--grade-max, 1) - var(--grade-min, 0)) * 100%);
}
.fuse .field-label { font-weight: 700; display: flex; align-items: center; gap: 10px; }
.fuse .handles { position: relative; flex: 1 1 100%; height: 36px; touch-action: none; cursor: pointer; }
.fuse .handles::before {
  content: ""; position: absolute; left: 0; right: 0; top: 10px; height: 16px; box-sizing: border-box;
  border-radius: 999px; border: 3px solid var(--ink);
  background: repeating-linear-gradient(-55deg, #b9b1a2 0 5px, #a39b8d 5px 10px);
}
.fuse .track {
  position: absolute; left: calc(var(--thumb) / 2); right: calc(var(--thumb) / 2); top: 13px; height: 10px;
  background: linear-gradient(90deg, transparent var(--lo-at), var(--player-color) var(--lo-at), var(--player-color) var(--hi-at), transparent var(--hi-at));
}
.fuse .handles input[type=range] {
  position: absolute; inset: 0; width: 100%; height: 36px; margin: 0; appearance: none; -webkit-appearance: none;
  background: transparent; pointer-events: none;
}
.fuse .handles input[type=range]::-webkit-slider-runnable-track { height: 16px; background: transparent; }
.fuse .handles input[type=range]::-moz-range-track { height: 16px; background: transparent; }
.fuse .handles input.hi { z-index: 2; }
.fuse .handles input:focus-visible { z-index: 3; outline: 0; }
/* The thumbs: lit tin can lids with an ember halo; they grow while the fuse is being dragged */
.fuse input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: var(--thumb); height: var(--thumb); margin-top: -7px; border-radius: 50%;
  background: var(--thumb-face); border: 3px solid var(--ink); box-shadow: var(--thumb-glow);
  transition: transform .15s cubic-bezier(.3,1.6,.5,1);
}
.fuse input[type=range]::-moz-range-thumb {
  box-sizing: border-box; width: var(--thumb); height: var(--thumb); border-radius: 50%;
  background: var(--thumb-face); border: 3px solid var(--ink); box-shadow: var(--thumb-glow);
  transition: transform .15s cubic-bezier(.3,1.6,.5,1);
}
.fuse .handles:hover input[type=range]::-webkit-slider-thumb, .fuse .handles:active input[type=range]::-webkit-slider-thumb { transform: scale(1.18); }
.fuse .handles:hover input[type=range]::-moz-range-thumb, .fuse .handles:active input[type=range]::-moz-range-thumb { transform: scale(1.18); }
.fuse input[type=range]:focus-visible::-webkit-slider-thumb { outline: 3px solid var(--bluebonnet); outline-offset: 3px; }
.fuse input[type=range]:focus-visible::-moz-range-thumb { outline: 3px solid var(--bluebonnet); outline-offset: 3px; }
.fuse .ticks { flex: 1 1 100%; display: flex; justify-content: space-between; margin-top: -6px; }
.fuse .ticks i {
  width: var(--thumb); text-align: center; font: 700 .8rem/1 var(--sans); font-style: normal; color: #8f877a;
  transition: color .15s, transform .15s;
}
.fuse .ticks i::before { content: ""; display: block; width: 3px; height: 7px; margin: 0 auto 3px; border-radius: 2px; background: #a39b8d; }
.fuse .ticks i.lit { color: var(--player-color); }
.fuse .ticks i.lit::before { background: var(--player-color); }
/* The notches the handles sit on */
.fuse .ticks i.end { color: var(--ink); transform: scale(1.25); }

/* Ready: a stamp that goes solid */
.ready { position: relative; display: block; }
.ready input {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; appearance: none;
  background: transparent; border: 0; cursor: pointer; z-index: 1;
}
.ready span {
  display: grid; place-items: center; min-height: 64px; font: 400 1.7rem/1 var(--display); letter-spacing: .08em; text-transform: uppercase;
  color: var(--player-color); background: transparent; border: 4px dashed var(--player-color); border-radius: 14px;
  transition: transform .15s cubic-bezier(.3,1.6,.5,1), background .15s, color .15s;
}
.ready:hover span { background: rgba(42,33,27,.05); }
.ready.is-ready span {
  background: var(--player-color); color: #fff7ea; border-style: solid; border-color: var(--ink);
  box-shadow: 0 5px 0 var(--ink); transform: rotate(-1.5deg) scale(1.02); text-shadow: 0 2px 0 rgba(0,0,0,.3);
}
.ready input:focus-visible + span { outline: 3px solid var(--bluebonnet); outline-offset: 3px; }

@media (max-width: 480px) {
  .ops { gap: 8px; }
  .op span { min-height: 58px; }
}

/* Range / HUD (Tasks 7-12 depend on these) */
/* Entrance animations pop by scale and never start from opacity 0: on a software rasteriser (headless Chrome,
   a GPU-less VM) the compositor can stall for seconds, which would leave a card, callout or sheet unreadable
   until it caught up. Exits may fade: a stalled fade just lingers. */
main.range { position: fixed; inset: 0; overflow: hidden; background: #2a211b; }
.range-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: manipulation; }
.range-overlay { position: absolute; inset: 0; pointer-events: none; }
.range-overlay > * { pointer-events: auto; }
.card { position: absolute; left: 0; top: 0; will-change: transform;
        background: var(--limestone); color: var(--ink); border: 4px solid var(--ink); border-radius: 14px;
        padding: 14px 18px; min-width: 220px; box-shadow: 0 18px 40px rgba(0,0,0,.45); }
.card > * { animation: card-in .22s ease-out; }
/* Tail: a notch in the sign pointing at the can, wherever the clamp put the card */
.card::before, .card::after { content: ""; position: absolute; left: var(--tail-x, 50%); width: 0; height: 0; translate: -50% 0;
        border: 14px solid transparent; }
.card::before { top: 100%; border-top-color: var(--ink); border-bottom: 0; }
.card::after { top: calc(100% - 6px); border-width: 10px; border-top-color: var(--limestone); border-bottom: 0; }
.card.below::before { top: auto; bottom: 100%; border: 14px solid transparent; border-bottom-color: var(--ink); border-top: 0; }
.card.below::after { top: auto; bottom: calc(100% - 6px); border: 10px solid transparent; border-bottom-color: var(--limestone); border-top: 0; }
.card .prompt { font: 700 2.4rem/1 "Rye", serif; text-align: center; margin-bottom: 10px; }
.card input { width: 100%; font: 600 2rem/1.2 system-ui, sans-serif; text-align: center; border: 3px solid var(--ink); border-radius: 10px; padding: 6px;
        background: #fff9ec; caret-color: var(--p1); }
.card input:focus { outline: 0; border-color: var(--bluebonnet); box-shadow: 0 0 0 4px rgba(58,79,176,.35); }
.card button { display: none; }
/* Some numeric keypads have no return key: give touch players a Fire button */
@media (pointer: coarse) {
  .card button { display: block; width: 100%; margin-top: 10px; min-height: 56px; cursor: pointer;
                 font: 400 1.6rem/1 var(--display); letter-spacing: .06em; text-transform: uppercase;
                 color: #fff7ea; background: var(--player-color, var(--p1)); border: 3px solid var(--ink); border-radius: 12px;
                 box-shadow: 0 5px 0 var(--ink); text-shadow: 0 2px 0 rgba(0,0,0,.3); }
  .card button:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
}
@keyframes card-in { from { transform: scale(.6) } }

/* Callouts: painted tags in Rye that pop in over the can, hold, then float off */
.callout { position: absolute; transform: translate(-50%, -100%); padding: 6px 16px 4px; border-radius: 10px;
           font: 400 1.65rem/1.1 var(--display); letter-spacing: .02em; white-space: nowrap; pointer-events: none;
           background: var(--callout-color, var(--ink)); color: #fff7ea; border: 3px solid var(--ink);
           box-shadow: 0 4px 0 var(--ink), 0 10px 22px rgba(0,0,0,.35); text-shadow: 0 2px 0 rgba(0,0,0,.3);
           animation: callout 2.4s cubic-bezier(.2,1.4,.4,1) forwards; }
.callout.miss { --callout-color: #b3261e; }
.callout.late { --callout-color: #c98a12; }
.callout.late::before { content: "✓ "; }
.callout.notice { --callout-color: #5c5148; font-size: 1.25rem; }
@keyframes callout {
  0% { scale: .3; translate: 0 8px }
  9% { scale: 1.12; translate: 0 0 }
  15% { scale: 1 }
  84% { opacity: 1; translate: 0 0 }
  100% { opacity: 0; translate: 0 -24px }
}
/* HIT! a comic starburst */
.callout.hit { padding: 30px 34px; border: 0; border-radius: 0; box-shadow: none; background: #f2c14e; color: var(--ink);
               font-size: 2.1rem; text-shadow: 0 2px 0 #fff7ea; letter-spacing: .04em;
               clip-path: polygon(50% 0, 61% 26%, 90% 10%, 77% 38%, 100% 50%, 77% 62%, 90% 90%, 61% 74%, 50% 100%, 39% 74%, 10% 90%, 23% 62%, 0 50%, 23% 38%, 10% 10%, 39% 26%);
               filter: drop-shadow(0 4px 0 var(--ink)); animation: hit-burst 1.3s cubic-bezier(.2,1.6,.4,1) forwards; }
@keyframes hit-burst { 0% { scale: .2; rotate: -20deg } 18% { scale: 1.15; rotate: 6deg } 30% { scale: 1; rotate: 0deg } 75% { opacity: 1 } 100% { opacity: 0; scale: 1.25; translate: 0 -18px } }

/* The far board's name, on a little nailed-up plaque */
.plaque { position: absolute; left: 0; top: 0; pointer-events: none; white-space: nowrap; will-change: transform;
          padding: 3px 14px 2px; font: 400 1rem/1.2 var(--display); letter-spacing: .08em; text-transform: uppercase;
          color: var(--player-color); background: var(--limestone); border: 3px solid var(--ink); border-radius: 6px;
          box-shadow: 0 3px 0 rgba(42,33,27,.45); }
.plaque::before, .plaque::after { content: ""; position: absolute; top: 50%; width: 5px; height: 5px; margin-top: -2.5px; border-radius: 50%; background: var(--ink); }
.plaque::before { left: 4px; } .plaque::after { right: 4px; }
.hud { position: absolute; z-index: 5; top: 12px; left: 12px; right: 12px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-player { background: rgba(42,33,27,.8); color: var(--limestone); border-left: 6px solid var(--player-color); padding: 8px 14px; border-radius: 8px; }
.hud-player .count { font: 700 1.3rem/1 "Rye", serif; margin-left: 10px; }
@media (max-width: 600px) {
  .hud { gap: 6px; top: 8px; left: 8px; right: 8px; }
  .hud-player { padding: 6px 10px; }
  .hud-player .count { margin-left: 6px; }
}
.hud .mute { margin-left: auto; font-size: 1.4rem; background: rgba(42,33,27,.8); border: 0; border-radius: 8px; padding: 6px 10px; cursor: pointer; }
.hud .share { margin: 0 0 0 auto; padding: 8px 12px; border-radius: 8px; background: rgba(42,33,27,.8); }
.hud .share + .mute { margin-left: 0; }
@media (max-width: 600px) { .hud .share .share-label { display: none; } }
/* Start screens, in the overlay: loading progress, who we're waiting on, then the countdown. Never in the way of a click. */
.range-overlay > .phase { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.phase:empty { display: none; }
.phase.loading, .phase.waiting { background: rgba(42,33,27,.35); }
/* One limestone sheet for the start screens and the results; --sheet-trim is the stripe along its top */
.sheet { background: var(--limestone); color: var(--ink); border: 6px solid var(--ink); border-radius: 16px; text-align: center;
         box-shadow: inset 0 10px 0 var(--sheet-trim, var(--ink)), 0 24px 60px rgba(0,0,0,.5); animation: sheet-in .5s cubic-bezier(.2,1.4,.4,1); }
.phase .sheet { --sheet-trim: var(--cedar); padding: 26px 36px 24px; min-width: 340px; max-width: min(90vw, 520px); }
.phase h2 { margin: 6px 0 14px; font: 400 2rem/1.15 var(--display); }
.phase .step { margin: 12px 0 0; }
.phase .bar { height: 16px; border: 3px solid var(--ink); border-radius: 999px; background: #fff9ec; overflow: hidden; }
.phase .bar i { display: block; height: 100%; background: var(--p1); transition: width .3s ease-out; }
.phase.waiting h2 { animation: breathe 1.6s ease-in-out infinite; }
.phase .countdown { font: 700 12rem/1 var(--display); color: var(--limestone); text-shadow: 0 10px 30px rgba(0,0,0,.6); animation: count-pop .45s cubic-bezier(.2,1.6,.4,1); }
.phase.ready .countdown { font-size: 5rem; letter-spacing: .06em; }
.phase.go .countdown { font-size: 16rem; color: #f2c14e; text-shadow: 0 6px 0 var(--ink), 0 14px 40px rgba(0,0,0,.6); animation: go-pop .6s cubic-bezier(.2,1.6,.4,1); }
@keyframes count-pop { from { scale: 1.7 } }
@keyframes breathe { 50% { opacity: .55 } }
@keyframes go-pop { 0% { scale: .4; rotate: -8deg } 45% { scale: 1.15; rotate: 2deg } 100% { scale: 1; rotate: 0deg } }
@media (max-width: 600px) {
  .phase .countdown { font-size: 8rem; }
  .phase.ready .countdown { font-size: 3.2rem; }
  .phase.go .countdown { font-size: 10rem; }
  .phase .sheet { min-width: 0; width: calc(100vw - 32px); padding: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .phase.waiting h2, .phase .countdown, .phase.go .countdown { animation: none; }
  .phase .bar i { transition: none; }
}
.results { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(42,33,27,.55); }
.results[hidden] { display: none; }
.results { overflow: hidden; }
.results .sheet { --sheet-trim: var(--winner-color, var(--ink)); position: relative; z-index: 1; padding: 32px 40px; min-width: 360px; }
.results h2 { font: 700 3rem/1.1 "Rye", serif; margin: 6px 0 16px; color: var(--ink); text-shadow: 0 3px 0 var(--winner-color, transparent); }
/* A draw: the trim splits between both seats' colours and the heading wears both. */
.results.draw .sheet { background: linear-gradient(90deg, var(--p1) 50%, var(--p2) 50%) top / 100% 10px no-repeat, var(--limestone);
                       box-shadow: 0 24px 60px rgba(0,0,0,.5); }
.results.draw h2 { margin-bottom: 4px; text-shadow: -3px 3px 0 var(--p1), 3px 3px 0 var(--p2); }
.results .tagline { margin: 0 0 16px; font-style: italic; }
.results table { margin: 0 auto 20px; border-collapse: collapse; }
.results td { padding: 6px 12px; text-align: left; }
.results td:first-child { border-left: 6px solid var(--player-color); font-weight: 800; color: var(--player-color); }
.results .sheet .btn { margin: 4px; }
@keyframes sheet-in { from { scale: .7 } }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i { position: absolute; left: 50%; top: 32%; width: 10px; height: 16px; border-radius: 2px; opacity: 0;
              animation: confetti var(--d) cubic-bezier(.15,.6,.4,1) var(--delay) forwards; }
@keyframes confetti {
  0% { opacity: 1; transform: translate(0, 0) rotate(0) }
  25% { opacity: 1; transform: translate(calc(var(--x) * .6), calc(var(--y) * -.35)) rotate(calc(var(--r) * .3)) }
  100% { opacity: 0; transform: translate(var(--x), var(--y)) rotate(var(--r)) }
}
@media (prefers-reduced-motion: reduce) { .card > *, .sheet { animation-duration: .01s; } }
/* Reduced motion: callouts still have to be read, so they keep their timing, appear in full and only fade out — no pop, float or spin. */
@media (prefers-reduced-motion: reduce) {
  .callout { animation: callout-still 2.4s linear forwards; }
  .callout.hit { animation: hit-still 1.3s linear forwards; }
}
@keyframes callout-still { 0%, 84% { opacity: 1 } 100% { opacity: 0 } }
@keyframes hit-still { 0%, 75% { opacity: 1 } 100% { opacity: 0 } }
@media (prefers-reduced-motion: reduce) {
  .btn, .op span, .ready span, .mode, .fuse .ticks i { transition: none; }
  .op input:checked + span::before { animation: none; }
}

.hud .badge { background: var(--limestone); color: var(--ink); padding: 6px 12px; border-radius: 999px; font-weight: 800; }
main.range[data-game-player-id-value="0"] .range-canvas { cursor: default; }
main.range .range-canvas { cursor: crosshair; }

/* Landing menu: pick 1 or 2 players, Nintendo-style, then start. The cursor sits on the chosen row. */
.landing .start { display: grid; justify-items: center; gap: 18px; }
.pick {
  display: grid; gap: 4px; min-width: min(340px, 100%); padding: 14px 18px; text-align: left;
  background: rgba(42,33,27,.88); color: var(--limestone); border: 3px solid var(--ink); border-radius: 14px;
  box-shadow: inset 0 0 0 2px var(--caliche), 0 10px 24px rgba(42,33,27,.35);
}
.pick-option {
  position: relative; display: grid; grid-template-columns: 1.1em 1fr; column-gap: 12px; align-items: baseline;
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
}
/* Transparent, not opacity 0: an invisible radio is one a driver (and a test) can't click. */
.pick-option input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; appearance: none; background: transparent; border: 0; cursor: pointer; z-index: 1; }
.pick-option .cursor { visibility: hidden; color: var(--dusk); font-size: 1.1rem; animation: blink 1s steps(2, start) infinite; }
.pick-option input:checked ~ .cursor { visibility: visible; }
.pick-option .choice { font: 400 1.7rem/1.1 var(--display); letter-spacing: .06em; text-transform: uppercase; }
.pick-option input:checked ~ .choice { color: var(--dusk); }
.pick-option small { grid-column: 2; font-size: .85rem; opacity: .75; }
.pick-option input:focus-visible ~ .choice { outline: 3px solid var(--sky); outline-offset: 4px; border-radius: 4px; }
.pick-option:hover { background: rgba(232,220,195,.08); }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .pick-option .cursor { animation: none; } }

/* Leaderboard: an arcade high-score table on a limestone panel */
.leaderboard { width: 100%; max-width: 860px; margin-top: 32px; text-align: left; }
.leaderboard-head { display: grid; gap: 8px; margin-bottom: 12px; }
.leaderboard-head h2 { margin: 0; font-size: 1.8rem; letter-spacing: .06em; }
.leaderboard-view { margin: 0; font-weight: 700; font-size: .85rem; letter-spacing: .12em; text-transform: uppercase; opacity: .8; min-height: 1.2em; }
.leaderboard .tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.leaderboard .tabs button {
  font: 700 .8rem/1 var(--sans); letter-spacing: .06em; text-transform: uppercase; padding: 8px 12px; cursor: pointer;
  color: var(--ink); background: #fff9ec; border: 2px solid var(--ink); border-radius: 999px;
}
.leaderboard .tabs button[aria-pressed=true] { background: var(--ink); color: var(--limestone); }
.runs { width: 100%; border-collapse: collapse; font-size: .95rem; }
.runs th { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; text-align: left; padding: 6px 8px; opacity: .7; border-bottom: 2px solid var(--caliche); }
.runs td { padding: 8px; border-bottom: 1px solid var(--caliche); vertical-align: baseline; }
.runs .rank { font: 400 1.3rem/1 var(--display); width: 2.5ch; }
.runs tr:nth-child(1) .rank { color: #c98a12; }
.runs tr:nth-child(2) .rank { color: #8a7f70; }
.runs tr:nth-child(3) .rank { color: #a0522d; }
.runs .name { font-weight: 800; }
.runs .score { font: 400 1.2rem/1 var(--display); color: var(--p1); font-variant-numeric: tabular-nums; }
.runs .time, .runs .hits { font-variant-numeric: tabular-nums; font-weight: 600; }
.runs .hits small { font-weight: 500; opacity: .7; }
.runs .loadout { white-space: nowrap; }
/* Chips on the rows are .badge in smaller sizes */
.runs .grades { padding: 2px 7px; border-radius: 6px; font-size: .75rem; letter-spacing: 0; }
.runs .ops-chips { font-weight: 800; letter-spacing: .12em; margin: 0 4px; }
.runs .cans { font-size: .85rem; opacity: .8; }
.runs .when { font-size: .85rem; opacity: .75; white-space: nowrap; }
.runs tr.latest td { background: rgba(247,178,103,.3); }
.leaderboard .medal { padding: 2px 8px; font-size: .68rem; letter-spacing: .04em; white-space: nowrap; vertical-align: middle; }
.leaderboard .medal.fastest { background: #c98a12; }
.leaderboard .medal.sharpest { background: var(--cedar); }
.leaderboard .medal.latest { background: var(--p1); }
.leaderboard .empty { margin: 0; font-weight: 600; }
.leaderboard-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 12px; }
.leaderboard .legend { margin: 0; font-size: .8rem; opacity: .7; }
button.link { background: none; border: 0; padding: 0; color: var(--bluebonnet); text-decoration: underline; cursor: pointer; font: inherit; font-size: .8rem; }
@media (max-width: 640px) {
  .runs { font-size: .85rem; }
  .runs td, .runs th { padding: 6px 4px; }
  .runs .when, .runs th:last-child { display: none; }
  .runs .loadout { white-space: normal; }
}

/* Solo HUD clock and results: the time is the headline */
.hud-clock { font: 700 1.5rem/1 var(--display); color: var(--limestone); background: rgba(42,33,27,.8); padding: 8px 14px; border-radius: 8px;
             font-variant-numeric: tabular-nums; min-width: 6.5ch; text-align: center; }
.results.solo .time { margin: 0 0 14px; font: 400 4.2rem/1 var(--display); color: var(--ink); text-shadow: 0 3px 0 var(--winner-color, var(--caliche)); font-variant-numeric: tabular-nums; }
.scorecard { display: grid; justify-items: center; gap: 2px; margin: 0 0 20px; }
.scorecard:empty { display: none; }
.scorecard .score-label { margin: 0; font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; opacity: .75; }
.scorecard .score { margin: 0; font: 400 2.6rem/1 var(--display); color: var(--winner-color, var(--ink)); font-variant-numeric: tabular-nums; }
.scorecard .place { margin: 6px 0 0; font-weight: 600; }
.scorecard .stamp { display: inline-block; margin-top: 12px; padding: 7px 16px 5px; font: 400 1.15rem/1 var(--display); letter-spacing: .08em; text-transform: uppercase;
                    color: #fff7ea; background: var(--winner-color, var(--p1)); border: 3px solid var(--ink); border-radius: 10px;
                    box-shadow: 0 4px 0 var(--ink); text-shadow: 0 2px 0 rgba(0,0,0,.3); transform: rotate(-3deg); }
