:root {
  --space: #0a0e14;
  --space-raised: #101720;
  --white: #f4f7fa;
  --blue: #2e9bff;
  --line: rgba(244, 247, 250, 0.11);
  --line-strong: rgba(244, 247, 250, 0.2);
  --dim: rgba(244, 247, 250, 0.52);
  --faint: rgba(244, 247, 250, 0.29);
  --glass: rgba(15, 21, 29, 0.7);
  --die-size: clamp(104px, 15vw, 148px);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--space);
}

html {
  overflow-x: clip;
}

body {
  color: var(--white);
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Code", "Roboto Mono", monospace;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

button {
  color: inherit;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

button:not(:disabled) {
  cursor: pointer;
}

button:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

.hidden {
  display: none !important;
}

.starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(1.4px 1.4px at 7% 17%, rgba(244, 247, 250, 0.44), transparent 72%),
    radial-gradient(1px 1px at 14% 73%, rgba(46, 155, 255, 0.5), transparent 72%),
    radial-gradient(1.2px 1.2px at 22% 39%, rgba(244, 247, 250, 0.32), transparent 72%),
    radial-gradient(1.5px 1.5px at 31% 87%, rgba(244, 247, 250, 0.38), transparent 72%),
    radial-gradient(1px 1px at 39% 13%, rgba(46, 155, 255, 0.47), transparent 72%),
    radial-gradient(1.2px 1.2px at 48% 62%, rgba(244, 247, 250, 0.3), transparent 72%),
    radial-gradient(1px 1px at 57% 31%, rgba(244, 247, 250, 0.4), transparent 72%),
    radial-gradient(1.5px 1.5px at 65% 82%, rgba(46, 155, 255, 0.35), transparent 72%),
    radial-gradient(1px 1px at 73% 9%, rgba(244, 247, 250, 0.42), transparent 72%),
    radial-gradient(1.4px 1.4px at 81% 55%, rgba(244, 247, 250, 0.35), transparent 72%),
    radial-gradient(1px 1px at 91% 25%, rgba(46, 155, 255, 0.44), transparent 72%),
    radial-gradient(1.2px 1.2px at 95% 88%, rgba(244, 247, 250, 0.34), transparent 72%),
    radial-gradient(ellipse 90% 75% at 50% 45%, rgba(46, 155, 255, 0.035), transparent 66%),
    radial-gradient(ellipse 125% 110% at 50% 35%, transparent 45%, rgba(0, 0, 0, 0.56) 100%);
}

.starfield::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.38;
  background-image:
    linear-gradient(rgba(244, 247, 250, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(244, 247, 250, 0.018) 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-mask-image: radial-gradient(circle at 50% 45%, black, transparent 75%);
  mask-image: radial-gradient(circle at 50% 45%, black, transparent 75%);
}

.ambient-orbit {
  position: fixed;
  z-index: 0;
  border: 1px solid rgba(46, 155, 255, 0.055);
  border-radius: 50%;
  pointer-events: none;
}

.orbit-one {
  width: 680px;
  height: 680px;
  left: -430px;
  top: 18%;
}

.orbit-two {
  width: 900px;
  height: 900px;
  right: -650px;
  bottom: -410px;
}

.app {
  position: relative;
  z-index: 1;
  width: min(1160px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding:
    max(14px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    calc(12px + env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}

.brand > span:last-child {
  display: flex;
  flex-direction: column;
  line-height: 0.91;
}

.brand b,
.brand small {
  letter-spacing: 0.18em;
}

.brand b {
  font-size: 16px;
}

.brand small {
  margin-top: 5px;
  color: var(--blue);
  font-size: 10px;
  font-weight: 800;
}

.brand-mark {
  position: relative;
  width: 32px;
  height: 32px;
}

.brand-mark i {
  position: absolute;
  width: 19px;
  height: 19px;
  border: 1px solid rgba(244, 247, 250, 0.72);
  border-radius: 5px;
  box-shadow: inset 0 0 10px rgba(244, 247, 250, 0.09);
  transform: rotate(19deg);
}

.brand-mark i:first-child {
  left: 1px;
  top: 8px;
}

.brand-mark i:last-child {
  right: 1px;
  top: 2px;
  border-color: rgba(46, 155, 255, 0.92);
  box-shadow: 0 0 12px rgba(46, 155, 255, 0.28);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.rtp-chip,
.balance-chip {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 13px;
  background: rgba(10, 14, 20, 0.54);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.rtp-chip span,
.balance-label {
  color: var(--faint);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.rtp-chip b {
  color: var(--dim);
  font-size: 10px;
  letter-spacing: 0.07em;
}

.balance-chip b {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  transition: color 180ms ease, text-shadow 180ms ease;
}

.balance-chip b.credit {
  color: var(--blue);
  animation: balance-credit 700ms ease-out;
}

@keyframes balance-credit {
  30% {
    text-shadow: 0 0 12px rgba(46, 155, 255, 0.82), 0 0 28px rgba(46, 155, 255, 0.48);
  }
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--dim);
  background: rgba(10, 14, 20, 0.54);
  font-weight: 800;
}

.icon-button:hover {
  color: var(--white);
  border-color: var(--line-strong);
}

.game {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.ladder-rail {
  min-height: 44px;
  margin: 9px 0 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  overflow: hidden;
}

.rail-empty {
  color: rgba(244, 247, 250, 0.2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.2em;
}

.rail-node {
  height: 29px;
  min-width: 44px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(10, 14, 20, 0.5);
  color: var(--dim);
  font-size: 10px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.rail-node.current {
  color: var(--white);
  border-color: rgba(46, 155, 255, 0.46);
  box-shadow: inset 0 0 14px rgba(46, 155, 255, 0.09), 0 0 16px rgba(46, 155, 255, 0.08);
}

.rail-node.win {
  color: var(--blue);
}

.rail-node.bust {
  opacity: 0.5;
}

.rail-arrow {
  color: rgba(244, 247, 250, 0.25);
  font-size: 12px;
}

.stage {
  position: relative;
  flex: 1;
  min-height: 405px;
  padding: 8px 0 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.stage-copy {
  min-height: 105px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  text-align: center;
}

.eyebrow,
.round-readout span,
.choice-direction,
.choice-ways,
.choice-payout,
.cash-button span,
.result-summary span,
.result-summary small,
.hero-button small,
.control-hint,
.footnote,
.modal-kicker,
.rule-grid span,
.rule-grid small,
.formula > span,
.formula small,
.fairness > span {
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.eyebrow {
  min-height: 16px;
  color: var(--blue);
  font-size: 10px;
  font-weight: 800;
}

.sum-readout {
  height: 63px;
  display: flex;
  align-items: baseline;
  gap: 13px;
}

.sum-readout span {
  color: var(--dim);
  font-size: clamp(15px, 2vw, 20px);
  font-weight: 800;
  letter-spacing: 0.08em;
}

.sum-readout b {
  color: var(--white);
  font-size: clamp(49px, 7vw, 74px);
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
  text-shadow:
    0 0 10px rgba(46, 155, 255, 0.45),
    0 0 34px rgba(46, 155, 255, 0.28),
    0 0 80px rgba(46, 155, 255, 0.15);
}

.stage-copy p {
  min-height: 17px;
  margin: 7px 0 0;
  color: var(--dim);
  font-size: 11px;
}

.dice-scene {
  position: relative;
  width: min(520px, 92vw);
  height: calc(var(--die-size) + 84px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(28px, 7vw, 68px);
  perspective: 1050px;
  perspective-origin: 50% 38%;
}

.table-glow {
  position: absolute;
  z-index: 0;
  left: 50%;
  bottom: 16px;
  width: min(440px, 90vw);
  height: 72px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(46, 155, 255, 0.16), rgba(46, 155, 255, 0.035) 45%, transparent 72%);
  transform: translateX(-50%) rotateX(67deg);
  opacity: 0.58;
}

.impact-ring {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: 28px;
  width: 190px;
  height: 44px;
  border: 1px solid rgba(46, 155, 255, 0.55);
  border-radius: 50%;
  opacity: 0;
  transform: translateX(-50%) scale(0.3);
}

.dice-scene.impact .impact-ring {
  animation: impact-ring 480ms ease-out;
}

@keyframes impact-ring {
  0% {
    opacity: 0.85;
    transform: translateX(-50%) scale(0.35);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) scale(2.15);
  }
}

.die-rig {
  position: relative;
  z-index: 3;
  width: var(--die-size);
  height: var(--die-size);
  transform-style: preserve-3d;
}

.die-rig-two {
  margin-top: 19px;
}

.die-aura {
  position: absolute;
  z-index: -1;
  inset: -25%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(46, 155, 255, 0.2), rgba(46, 155, 255, 0.04) 50%, transparent 72%);
  opacity: 0.72;
  animation: aura-breathe 4.2s ease-in-out infinite;
}

.die-rig-two .die-aura {
  animation-delay: -1.8s;
  opacity: 0.48;
}

@keyframes aura-breathe {
  0%,
  100% {
    transform: scale(0.96);
    opacity: 0.48;
  }
  50% {
    transform: scale(1.08);
    opacity: 0.82;
  }
}

.die {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  will-change: transform;
}

/* The flat part of a face only: game.js insets it by the fillet radius and fills it with the
   shade that face's normal takes under the baked light. */
.die-face {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 6%;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  /* No overlay gradient or inset shadow: the face has to be the exact shade the first fillet
     ring starts from, or the seam between them reads as a recessed panel. */
}

/* One ring of the filleted shell. Sized, placed and tinted by game.js. */
.die-fillet {
  position: absolute;
  left: 50%;
  top: 50%;
}

.die-rig-one {
  --die-body: 74, 168, 250;
}

.die-rig-two {
  --die-body: 226, 237, 246;
}

.face-1 {
  transform: rotateY(0deg) translateZ(calc(var(--die-size) * 0.5));
}

.face-6 {
  transform: rotateY(180deg) translateZ(calc(var(--die-size) * 0.5));
}

.face-3 {
  transform: rotateY(90deg) translateZ(calc(var(--die-size) * 0.5));
}

.face-4 {
  transform: rotateY(-90deg) translateZ(calc(var(--die-size) * 0.5));
}

.face-2 {
  transform: rotateX(90deg) translateZ(calc(var(--die-size) * 0.5));
}

.face-5 {
  transform: rotateX(-90deg) translateZ(calc(var(--die-size) * 0.5));
}

.pip {
  width: 50%;
  aspect-ratio: 1;
  transform: translateZ(1px);
  align-self: center;
  justify-self: center;
  border-radius: 50%;
  background: var(--white);
  box-shadow:
    inset 1px 2px 3px rgba(10, 14, 20, 0.25),
    0 0 7px rgba(244, 247, 250, 0.28);
}

.die-rig-two .pip {
  background: var(--blue);
  box-shadow:
    inset 1px 2px 3px rgba(10, 14, 20, 0.3),
    0 0 5px rgba(46, 155, 255, 0.25);
}

.p1 { grid-area: 1 / 1; }
.p2 { grid-area: 1 / 2; }
.p3 { grid-area: 1 / 3; }
.p4 { grid-area: 2 / 1; }
.p5 { grid-area: 2 / 2; }
.p6 { grid-area: 2 / 3; }
.p7 { grid-area: 3 / 1; }
.p8 { grid-area: 3 / 2; }
.p9 { grid-area: 3 / 3; }

.die-shadow {
  position: absolute;
  z-index: -2;
  left: 8%;
  right: 8%;
  bottom: -41px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.67);
  box-shadow: 0 0 18px rgba(46, 155, 255, 0.2);
  transform: rotateX(68deg);
  transition: transform 160ms ease, opacity 160ms ease;
}

.stage.preparing .die-rig {
  animation: pre-roll 260ms ease-in-out infinite alternate;
}

.stage.preparing .die-rig-two {
  animation-delay: -110ms;
}

@keyframes pre-roll {
  from { transform: translateY(0) rotate(-1deg); }
  to { transform: translateY(4px) rotate(1deg); }
}

.stage.preparing .die-shadow {
  transform: rotateX(68deg) scale(1.08);
  opacity: 0.82;
}

.stage.rolling .die-shadow {
  transform: rotateX(68deg) scale(0.55);
  opacity: 0.38;
}

.stage.result-win .sum-readout b {
  animation: sum-win 620ms ease-out;
}

@keyframes sum-win {
  25% {
    color: var(--blue);
    transform: scale(1.12);
    text-shadow: 0 0 18px rgba(46, 155, 255, 0.85), 0 0 54px rgba(46, 155, 255, 0.6);
  }
}

.stage.result-loss .dice-scene {
  animation: loss-settle 440ms ease-out;
}

@keyframes loss-settle {
  35% { opacity: 0.58; transform: translateY(3px); }
}

.round-readout {
  width: min(620px, 94vw);
  min-height: 56px;
  display: grid;
  grid-template-columns: 1fr 1px 1.35fr 1px 1fr;
  align-items: center;
  gap: 14px;
  padding: 8px 18px;
  background: rgba(10, 14, 20, 0.48);
  border: 1px solid rgba(244, 247, 250, 0.08);
  border-radius: 15px;
}

.round-readout > div {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.round-readout > i {
  width: 1px;
  height: 25px;
  background: var(--line);
}

.round-readout span {
  color: var(--faint);
  font-size: 8px;
}

.round-readout b {
  color: var(--white);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

#fairBtn {
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

#fairBtn b {
  width: 100%;
  overflow: hidden;
  color: var(--dim);
  text-overflow: ellipsis;
  white-space: nowrap;
}

#fairBtn:hover b {
  color: var(--blue);
}

.controls {
  position: relative;
  width: min(780px, 100%);
  min-height: 184px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
}

.idle-controls,
.play-controls,
.result-controls {
  width: 100%;
}

.bet-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 9px;
}

.bet-chip {
  min-width: 68px;
  min-height: 38px;
  padding: 0 11px;
  color: var(--dim);
  background: rgba(10, 14, 20, 0.55);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.bet-chip:hover:not(:disabled) {
  color: var(--white);
  border-color: var(--line-strong);
}

.bet-chip.selected {
  color: var(--blue);
  border-color: rgba(46, 155, 255, 0.48);
  background: rgba(46, 155, 255, 0.08);
  box-shadow: inset 0 0 18px rgba(46, 155, 255, 0.06);
}

.bet-chip:disabled {
  opacity: 0.28;
}

.bet-input {
  text-align: center;
  color: var(--white);
  background: rgba(46, 155, 255, 0.12);
  border-color: rgba(46, 155, 255, 0.42);
  box-shadow: inset 0 0 18px rgba(46, 155, 255, 0.08);
}

.bet-input:focus {
  outline: 0;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(46, 155, 255, 0.2), inset 0 0 18px rgba(46, 155, 255, 0.1);
}

.bet-input[aria-invalid="true"] {
  border-color: rgba(46, 155, 255, 0.75);
}

.hero-button {
  width: 100%;
  min-height: 69px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 0;
  border-radius: var(--radius);
  color: var(--space);
  background: var(--blue);
  box-shadow:
    0 0 28px rgba(46, 155, 255, 0.34),
    0 0 74px rgba(46, 155, 255, 0.16),
    inset 0 1px 0 rgba(244, 247, 250, 0.42);
  transition: transform 130ms ease, box-shadow 130ms ease;
}

.hero-button:hover:not(:disabled) {
  box-shadow:
    0 0 34px rgba(46, 155, 255, 0.5),
    0 0 90px rgba(46, 155, 255, 0.24),
    inset 0 1px 0 rgba(244, 247, 250, 0.52);
}

.hero-button:active:not(:disabled) {
  transform: translateY(2px);
}

.hero-button:disabled {
  opacity: 0.45;
}

.hero-button span {
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.hero-button small {
  font-size: 8px;
  font-weight: 800;
  opacity: 0.63;
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.choice {
  position: relative;
  min-height: 102px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto auto;
  align-items: center;
  column-gap: 14px;
  padding: 15px 17px;
  overflow: hidden;
  text-align: left;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(244, 247, 250, 0.068), rgba(244, 247, 250, 0.027));
  transition: transform 130ms ease, border-color 130ms ease, background 130ms ease, box-shadow 130ms ease;
}

.choice::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  background: radial-gradient(circle at 80% 20%, rgba(46, 155, 255, 0.18), transparent 55%);
  transition: opacity 130ms ease;
}

.choice.lower::before {
  transform: scaleX(-1);
}

.choice:hover:not(:disabled) {
  z-index: 1;
  transform: translateY(-2px);
  border-color: rgba(46, 155, 255, 0.5);
  background: linear-gradient(145deg, rgba(46, 155, 255, 0.11), rgba(244, 247, 250, 0.035));
  box-shadow: 0 0 28px rgba(46, 155, 255, 0.12);
}

.choice:hover:not(:disabled)::before {
  opacity: 1;
}

.choice:active:not(:disabled) {
  transform: translateY(1px);
}

.choice:disabled {
  opacity: 0.29;
}

.choice-direction {
  position: relative;
  z-index: 1;
  color: var(--white);
  font-size: 11px;
  font-weight: 900;
}

.choice-mult {
  position: relative;
  z-index: 1;
  grid-area: 1 / 2 / 3 / 3;
  color: var(--blue);
  font-size: clamp(23px, 4vw, 34px);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.06em;
  text-shadow: 0 0 18px rgba(46, 155, 255, 0.32);
}

.choice-ways {
  position: relative;
  z-index: 1;
  margin-top: 5px;
  color: var(--dim);
  font-size: 8px;
}

.choice-payout {
  position: relative;
  z-index: 1;
  grid-column: 1 / 3;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 8px;
}

.cash-button {
  width: 100%;
  min-height: 57px;
  margin-top: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  border: 0;
  border-radius: 15px;
  color: var(--space);
  background: var(--blue);
  box-shadow: 0 0 24px rgba(46, 155, 255, 0.3), 0 0 60px rgba(46, 155, 255, 0.13);
}

.cash-button span {
  font-size: 10px;
  font-weight: 900;
}

.cash-button b {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.control-hint {
  min-height: 12px;
  margin: 8px 0 0;
  color: var(--faint);
  font-size: 7px;
  text-align: center;
}

.result-controls {
  display: grid;
  grid-template-columns: minmax(150px, 0.6fr) 1fr;
  gap: 10px;
}

.result-summary {
  grid-row: 1 / 3;
  min-height: 116px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(10, 14, 20, 0.54);
}

.result-summary span {
  color: var(--blue);
  font-size: 9px;
  font-weight: 900;
}

.result-summary b {
  margin: 7px 0 4px;
  font-size: 25px;
  font-variant-numeric: tabular-nums;
}

.result-summary small {
  color: var(--faint);
  font-size: 7px;
  line-height: 1.5;
}

.result-controls .bet-row {
  align-self: end;
  margin: 0;
}

.result-controls .hero-button {
  min-height: 64px;
}

.footnote {
  min-height: 32px;
  margin-top: 8px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  color: rgba(244, 247, 250, 0.18);
  font-size: 7px;
}

.footnote button {
  padding: 0;
  border: 0;
  color: rgba(244, 247, 250, 0.23);
  background: transparent;
  font-size: inherit;
  letter-spacing: inherit;
}

.footnote button:hover {
  color: var(--dim);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 8, 12, 0.78);
  backdrop-filter: blur(11px);
  -webkit-backdrop-filter: blur(11px);
}

.modal-card {
  position: relative;
  width: min(660px, 100%);
  max-height: min(760px, calc(100dvh - 38px));
  padding: clamp(24px, 5vw, 42px);
  overflow-y: auto;
  border: 1px solid rgba(244, 247, 250, 0.16);
  border-radius: 24px;
  background:
    radial-gradient(circle at 85% 8%, rgba(46, 155, 255, 0.13), transparent 35%),
    rgba(10, 14, 20, 0.96);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.55), 0 0 70px rgba(46, 155, 255, 0.08);
  animation: modal-in 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
}

.modal-close {
  position: absolute;
  top: 17px;
  right: 17px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--dim);
  background: transparent;
  font-size: 20px;
}

.modal-kicker {
  color: var(--blue);
  font-size: 9px;
  font-weight: 900;
}

.modal h1 {
  margin: 10px 0 14px;
  font-size: clamp(30px, 6vw, 48px);
  line-height: 1;
  letter-spacing: -0.06em;
  text-shadow: 0 0 28px rgba(46, 155, 255, 0.25);
}

.modal p {
  max-width: 570px;
  margin: 0 0 24px;
  color: var(--dim);
  font-family: system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.65;
}

.rule-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.rule-grid > div {
  min-height: 90px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(244, 247, 250, 0.025);
}

.rule-grid span,
.formula > span,
.fairness > span {
  color: var(--faint);
  font-size: 7px;
}

.rule-grid b {
  color: var(--white);
  font-size: 15px;
}

.rule-grid small {
  color: var(--dim);
  font-family: system-ui, sans-serif;
  font-size: 9px;
  line-height: 1.35;
  letter-spacing: 0.04em;
}

.formula,
.fairness {
  margin-top: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  border: 1px solid rgba(46, 155, 255, 0.22);
  border-radius: 13px;
  background: rgba(46, 155, 255, 0.045);
}

.formula code {
  color: var(--blue);
  font-size: 18px;
}

.formula small {
  color: var(--dim);
  font-family: system-ui, sans-serif;
  font-size: 8px;
  line-height: 1.45;
}

.fairness code {
  max-width: 100%;
  overflow-wrap: anywhere;
  color: var(--dim);
  font-size: 9px;
  line-height: 1.5;
}

.toast {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  max-width: calc(100vw - 32px);
  padding: 10px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--white);
  background: rgba(10, 14, 20, 0.93);
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.35);
  font-size: 10px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 700px) {
  :root {
    --die-size: clamp(88px, 26vw, 108px);
    --radius: 15px;
  }

  .app {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  .topbar {
    min-height: 46px;
  }

  .brand-mark {
    width: 27px;
    height: 27px;
  }

  .brand-mark i {
    width: 17px;
    height: 17px;
  }

  .brand b {
    font-size: 13px;
  }

  .brand small {
    margin-top: 4px;
    font-size: 8px;
  }

  .rtp-chip {
    display: none;
  }

  .balance-chip {
    min-height: 34px;
    padding: 0 11px;
  }

  .balance-label {
    display: none;
  }

  .balance-chip b {
    font-size: 12px;
  }

  .icon-button {
    width: 34px;
    height: 34px;
  }

  .ladder-rail {
    min-height: 36px;
    margin-top: 4px;
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .ladder-rail::-webkit-scrollbar {
    display: none;
  }

  .rail-empty {
    width: 100%;
    text-align: center;
    font-size: 7px;
  }

  .rail-node {
    min-width: 40px;
    height: 25px;
    padding: 0 8px;
    font-size: 9px;
  }

  .stage {
    min-height: 363px;
    padding-top: 0;
  }

  .stage-copy {
    min-height: 86px;
  }

  .eyebrow {
    font-size: 8px;
  }

  .sum-readout {
    height: 52px;
  }

  .sum-readout span {
    font-size: 13px;
  }

  .sum-readout b {
    font-size: 50px;
  }

  .stage-copy p {
    margin-top: 3px;
    font-size: 9px;
  }

  .dice-scene {
    width: 100%;
    height: calc(var(--die-size) + 63px);
    gap: 36px;
  }

  .die-rig-two {
    margin-top: 13px;
  }

  .die-shadow {
    bottom: -33px;
  }

  .round-readout {
    width: 100%;
    min-height: 50px;
    gap: 8px;
    padding: 7px 10px;
  }

  .round-readout span {
    font-size: 6px;
  }

  .round-readout b {
    font-size: 10px;
  }

  .controls {
    min-height: 180px;
  }

  .bet-row {
    gap: 5px;
  }

  .bet-chip {
    min-width: 0;
    flex: 1;
    padding: 0 4px;
    font-size: 9px;
  }

  .bet-input {
    flex: 1.5;
  }

  .hero-button {
    min-height: 62px;
  }

  .hero-button span {
    font-size: 13px;
  }

  .choice {
    min-height: 94px;
    padding: 13px 12px;
    column-gap: 7px;
  }

  .choice-direction {
    font-size: 9px;
  }

  .choice-mult {
    font-size: clamp(20px, 6vw, 27px);
  }

  .choice-ways,
  .choice-payout {
    font-size: 6px;
  }

  .cash-button {
    min-height: 52px;
  }

  .result-controls {
    grid-template-columns: 1fr;
  }

  .result-summary {
    grid-row: auto;
    min-height: 72px;
    padding: 12px 16px;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .result-summary b {
    grid-row: 1 / 3;
    grid-column: 2;
    margin: 0;
    font-size: 21px;
  }

  .result-summary small {
    margin-top: 3px;
  }

  .result-controls .hero-button {
    min-height: 58px;
  }

  .modal {
    padding: 11px;
  }

  .modal-card {
    max-height: calc(100dvh - 22px);
    border-radius: 19px;
  }
}

@media (max-height: 760px) and (max-width: 700px) {
  .stage {
    min-height: 323px;
  }

  .stage-copy {
    min-height: 72px;
  }

  .dice-scene {
    height: calc(var(--die-size) + 48px);
  }

  .controls {
    min-height: 164px;
  }

  .footnote {
    display: none;
  }
}

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