:root { color-scheme: dark; --gold: #ffd54a; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #e9f1fb;
  background: radial-gradient(ellipse at 50% 35%, #263a55 0%, #121b2a 55%, #0a0f18 100%) fixed;
}
main {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(.8rem, 2.5vh, 1.6rem);
  padding: 3vh 2vw 4.5rem;
  text-align: center;
}

.headline {
  margin: 0;
  min-height: 1.15em;
  font: italic 800 clamp(2rem, 5.5vw, 4rem) / 1.1 Georgia, "Times New Roman", serif;
  color: #fff;
  text-shadow: 0 0 28px #7fb4ff55, 0 3px 0 #0007;
}
.caret { display: inline-block; width: .06em; height: .85em; margin-left: .06em; vertical-align: -.06em; background: var(--gold); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* Everything on the stage is placed in board units (584 × 408), like the game. */
.board {
  position: relative;
  width: min(1100px, 96vw, calc((100vh - 19rem) * 584 / 408));
  min-width: 300px;
  aspect-ratio: 584 / 408;
  container-type: inline-size;
}
.art, .dim { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 12px; }
.art { display: block; background: #000; box-shadow: 0 30px 80px #000c, 0 0 0 1px #ffffff14; }
.dim { background: #000; }
.fade { opacity: 0; transition: opacity .9s ease, transform 1.1s cubic-bezier(.2, .8, .2, 1); pointer-events: none; }
.art.fade { transform: scale(.94); }
.fade.on { opacity: 1; transform: none; }
.dim.fade.on { opacity: .55; }
.fade.out { opacity: 0 !important; transition-duration: .8s; }

/* The intro logo (scale 0.9 of 572 × 316, m.intro.scale), dropped in by script. */
.clip { position: absolute; inset: 0; overflow: hidden; border-radius: 12px; pointer-events: none; }
.logo { position: absolute; left: 5.84%; width: 88.15%; height: auto; top: -70%; pointer-events: none; filter: drop-shadow(0 12px 18px #000a); }
.tagline {
  position: absolute;
  left: 0;
  right: 0;
  top: 86%;
  margin: 0;
  font: italic 700 clamp(1rem, 3.6cqw, 2.1rem) / 1.2 Georgia, serif;
  color: #fff;
  text-shadow: 0 2px 10px #000, 0 0 24px #ffd54a66;
}

.prompt {
  position: absolute;
  left: 0;
  right: 0;
  top: 64%;
  margin: 0;
  font-size: clamp(.95rem, 1.8vw, 1.2rem);
  font-weight: 600;
  letter-spacing: .04em;
  color: #cfe3f3;
  opacity: 0;
  transition: opacity .6s ease;
  pointer-events: none;
}
.prompt.on { opacity: 1; animation: breathe 2.2s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .45; } }
.prompt.gone { opacity: 0 !important; animation: none; }

/* The dice: frames from the original strips (board units: rolling 40 × 38, resting 60 × 38, shadow 40 × 31). */
.dice { position: absolute; inset: 0; padding: 0; margin: 0; border: 0; background: none; pointer-events: none; transition: opacity .8s ease; }
.dice:focus-visible { outline: none; }
.dice.out { opacity: 0; }
.die, .shadow { position: absolute; left: 0; top: 0; background-repeat: no-repeat; pointer-events: none; will-change: transform; }
.die { transform-origin: 50% 50%; width: calc(40 / 584 * 100%); height: calc(38 / 408 * 100%); background-image: url(/assets/dicerollingall.webp); background-size: 1500% 100%; }
.die.rest { width: calc(60 / 584 * 100%); background-size: 600% 100%; }
.die.rest.d0 { background-image: url(/assets/sixdieresting01.webp); }
.die.rest.d1 { background-image: url(/assets/sixdieresting02.webp); }
.die.hidden { visibility: hidden; }
.shadow { width: calc(40 / 584 * 100%); height: calc(31 / 408 * 100%); background-image: url(/assets/diceshadowrollingloop.webp); background-size: 500% 100%; opacity: .6; visibility: hidden; }
.die.hit { pointer-events: auto; cursor: pointer; }
.dice.out .die.hit { pointer-events: none; }
.dice.waiting .die { animation: bob 1.6s ease-in-out infinite; filter: drop-shadow(0 0 10px #ffd54a99) drop-shadow(0 8px 10px #000a); }
.dice.waiting .die + .die { animation-delay: -.8s; }
@keyframes bob { 50% { margin-top: -1.2%; } }
.dice:not(.waiting) .die.hit:hover { filter: drop-shadow(0 0 6px #fff8) brightness(1.08); }

/* The hype vote: the board's ROLL button, the live count and "what did you roll?". */
.hype { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; padding-top: 36%; gap: .55rem; }
.hype.show { animation: pop .5s cubic-bezier(.2, 1.4, .4, 1) both; }
.hype.gone { opacity: 0; transition: opacity .5s ease; }
.count.below { margin: 0; animation: pop .5s ease-out both; }
@keyframes pop { from { opacity: 0; transform: scale(.85); } }
.roll {
  width: calc(92 * 2.2 / 584 * 100%);
  aspect-ratio: 92 / 37;
  padding: 0;
  border: 0;
  background: url(/assets/roll-normal.webp) center bottom / 100% auto no-repeat;
  cursor: pointer;
  filter: drop-shadow(0 10px 18px #000b);
}
/* The over / down frames are 94 × 43 (a touch larger, standing on the same bottom edge). */
.roll:hover:not(:disabled) { background-image: url(/assets/roll-over.webp); background-size: 102.2% auto; }
.roll:active:not(:disabled) { background-image: url(/assets/roll-down.webp); background-size: 102.2% auto; }
.roll:disabled { background-image: url(/assets/roll-disabled.webp); cursor: default; }
.roll:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; border-radius: 10px; }
.count { margin: .2rem 0 0; font-size: clamp(1rem, 2.4cqw, 1.5rem); color: #cfe3f3; }
.count b { color: var(--gold); font-size: 1.35em; font-variant-numeric: tabular-nums; }
.captcha { display: flex; flex-direction: column; align-items: center; gap: .4rem; animation: pop .35s ease-out both; }
.captcha label { font-weight: 700; color: #fff; font-size: clamp(.95rem, 2cqw, 1.2rem); }
.captcha .row { display: flex; gap: .4rem; }
.captcha input {
  width: 4.5rem;
  padding: .4rem .5rem;
  font: 700 1.1rem/1 "Segoe UI", system-ui, sans-serif;
  text-align: center;
  color: #fff;
  background: #0f1822;
  border: 1px solid #4f677c;
  border-radius: 8px;
}
.captcha button {
  padding: .45rem 1.1rem;
  font: 700 1rem/1 "Segoe UI", system-ui, sans-serif;
  color: #0d2a40;
  border: 1px solid #2f6f9c;
  border-radius: 8px;
  background: linear-gradient(180deg, #d9f2ff 0%, #8fd0f7 45%, #4fb0ea 100%);
  box-shadow: inset 0 1px 0 #fff8, 0 2px 6px #0008;
  cursor: pointer;
}
.note { min-height: 1.3em; margin: 0; font-size: clamp(.85rem, 1.8cqw, 1.05rem); color: #ffd9a0; }

.fan { position: fixed; right: .9rem; bottom: .7rem; max-width: 26rem; font-size: .7rem; line-height: 1.4; color: #7d90a7; text-align: right; }

/* ---- the countdown: a red digital alarm clock ------------------------------------------------------ */
.clock {
  --lit: #ff2b17;
  --unlit: #3d0907;
  position: relative;
  font-size: clamp(1.7rem, 5.2vw, 3.6rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  filter: drop-shadow(0 .35em .4em #000a);
  transform-origin: 50% 100%;
}
.clock.in { animation: clock-in .7s cubic-bezier(.2, 1.4, .4, 1) both, wobble .5s ease-in-out .55s 2; }
@keyframes clock-in { from { opacity: 0; transform: translateY(-.6em) scale(.8); } }
@keyframes wobble { 25% { transform: rotate(-3deg); } 75% { transform: rotate(3deg); } }
/* The snooze bar on top, and two little feet. */
.snooze {
  width: 38%;
  height: .2em;
  margin-bottom: -.04em;
  border-radius: .12em .12em 0 0;
  background: linear-gradient(180deg, #ff6a5c, #b8160e);
  box-shadow: inset 0 .03em 0 #ffffff80;
}
.feet { display: flex; justify-content: space-between; width: 78%; height: .14em; }
.feet span { width: .5em; border-radius: 0 0 .1em .1em; background: linear-gradient(180deg, #5c0a06, #2a0402); }
.case {
  padding: .22em .3em .14em;
  border-radius: .42em;
  background:
    radial-gradient(ellipse 70% 40% at 35% 8%, #ffffff55, transparent 70%),
    linear-gradient(180deg, #ee3326 0%, #c81d13 45%, #8d0f09 100%);
  box-shadow: inset 0 .04em 0 #ffffff70, inset 0 -.06em .08em #0006, 0 0 0 .02em #5a0804;
}
.screen {
  padding: .12em .22em;
  border-radius: .18em;
  background: radial-gradient(ellipse at 50% 40%, #1b0503 0%, #080101 75%);
  box-shadow: inset 0 .05em .12em #000, 0 .02em 0 #ffffff40;
}
.readout { display: flex; align-items: center; gap: .08em; transform: skewX(-7deg); filter: drop-shadow(0 0 .07em #ff2b17cc); }
.units { display: flex; justify-content: space-around; margin-top: .1em; font: 800 .2em/1 "Segoe UI", system-ui, sans-serif; letter-spacing: .12em; color: #ffe7df; text-shadow: 0 .06em 0 #6a0b06; }
.units span { flex: 1; text-align: center; }
/* One 7-segment digit (segments a-g, hexagonal like an LED clock's), 0.56em × 1em. */
.digit { position: relative; width: .56em; height: 1em; }
.seg { position: absolute; background: var(--unlit); }
.seg.on { background: var(--lit); }
.seg.a, .seg.g, .seg.d { left: .055em; width: .45em; height: .1em; clip-path: polygon(11% 0, 89% 0, 100% 50%, 89% 100%, 11% 100%, 0 50%); }
.seg.a { top: 0; }
.seg.g { top: .45em; }
.seg.d { top: .9em; }
.seg.b, .seg.c, .seg.e, .seg.f { width: .1em; height: .44em; clip-path: polygon(50% 0, 100% 11%, 100% 89%, 50% 100%, 0 89%, 0 11%); }
.seg.f { left: 0; top: .03em; }
.seg.b { right: 0; top: .03em; }
.seg.e { left: 0; top: .53em; }
.seg.c { right: 0; top: .53em; }
.pair { display: flex; gap: .09em; }
.colon { display: flex; flex-direction: column; justify-content: center; gap: .26em; width: .14em; height: 1em; align-items: center; }
.colon i { width: .1em; height: .1em; border-radius: 50%; background: var(--unlit); }
.colon.on i { background: var(--lit); }
/* Zero: the alarm goes off. */
.clock.ring .readout { animation: flash .5s steps(1) infinite; }
.clock.ring { animation: wobble .18s ease-in-out infinite; }
@keyframes flash { 50% { opacity: .15; } }

@media (prefers-reduced-motion: reduce) {
  .caret, .prompt.on, .dice.waiting .die { animation: none; }
  .fade, .hype.show, .captcha { transition: none; animation: none; }
  .clock.in, .clock.ring, .clock.ring .readout { animation: none; }
}
