: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 - 12rem) * 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; }

@media (prefers-reduced-motion: reduce) {
  .caret, .prompt.on, .dice.waiting .die { animation: none; }
  .fade, .hype.show, .captcha { transition: none; animation: none; }
}
