/* Dice game — mobile-first, large center roll, no horizontal overflow */
.dice-page {
  max-width: 640px;
  margin: 0 auto;
}

.dice-page h1 {
  margin: 0.15rem 0 0.35rem;
}

.dice-stage,
.dice-stage.bezel,
#bezel.dice-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: min(70dvh, 520px);
  margin: 0.85rem 0 1rem;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line-silver);
  background: radial-gradient(ellipse at 50% 30%, #1c2545 0%, #0b1026 70%);
  box-shadow: var(--shadow-glow);
  touch-action: none;
}

.dice-stage canvas#dice-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  position: relative;
  z-index: 0;
}

.dice-fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.dice-fx[hidden] {
  display: none;
}

.dice-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem;
  z-index: 1;
  pointer-events: none;
}

.dice-fallback[hidden] {
  display: none;
}

.dice-pip {
  width: min(32vw, 120px);
  height: min(32vw, 120px);
  border-radius: 22px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 700;
  color: var(--gold);
  background: var(--texture-wood);
  border: 2px solid var(--gold-deep);
  box-shadow: var(--shadow-silver);
}

.dice-overlay {
  position: absolute;
  left: 50%;
  top: 0.55rem;
  transform: translateX(-50%);
  z-index: 3;
  pointer-events: none;
  width: min(92%, 360px);
  text-align: center;
  padding: 0.45rem 0.55rem 0.5rem;
  border-radius: 14px;
  background: rgba(8, 12, 28, 0.92);
  border: 1px solid var(--gold-deep);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(232, 197, 71, 0.28);
}

.dice-overlay[hidden] {
  display: none;
}

.dice-overlay-faces {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.28rem 0.4rem;
}

.dice-overlay-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.12rem, 5.4vw, 1.45rem);
  line-height: 1.25;
  letter-spacing: 0.01em;
  color: var(--gold);
  text-shadow: 0 1px 0 #000, 0 0 10px rgba(232, 197, 71, 0.4);
  padding: 0.12rem 0.4rem;
}

.dice-overlay-sum {
  font-size: clamp(1.2rem, 5.8vw, 1.6rem);
  color: var(--gold-soft);
}

.dice-roll {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  box-sizing: border-box;
  min-height: 80px;
  height: auto;
  width: min(82%, 300px);
  min-width: min(82%, 220px);
  padding: 0.85rem 1.1rem;
  margin: 0;
  border: 3px solid #ffd6d6;
  border-radius: 999px;
  background: linear-gradient(180deg, #ff5a5a 0%, #e11d1d 48%, #b10d0d 100%);
  color: #fff;
  font-family: var(--font-display);
  font-size: clamp(1.28rem, 5.8vw, 1.75rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.15;
  text-shadow: 0 1px 0 rgba(80, 0, 0, 0.45);
  box-shadow:
    0 10px 28px rgba(140, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.38);
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.dice-roll:hover,
.dice-roll:focus-visible {
  background: linear-gradient(180deg, #ff6e6e 0%, #ef2424 48%, #c10f0f 100%);
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.dice-roll:active {
  transform: translate(-50%, -50%) scale(0.98);
}

.dice-stage.is-rolling .dice-roll {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.dice-stage.is-revealed .dice-roll {
  top: auto;
  bottom: 0.55rem;
  transform: translateX(-50%);
  min-height: 68px;
  width: min(86%, 300px);
  font-size: clamp(1.12rem, 4.8vw, 1.4rem);
}

.dice-stage.is-revealed .dice-roll:active {
  transform: translateX(-50%) scale(0.98);
}

.dice-actions {
  display: flex;
  gap: 0.65rem;
  align-items: stretch;
  justify-content: flex-end;
}

.dice-mute {
  min-height: 44px;
  min-width: 44px;
  padding: 0 0.85rem;
}

.dice-result {
  margin-top: 1rem;
  padding: 1rem 1.05rem 1.1rem;
  border-radius: var(--radius);
  background: var(--texture-wood);
  border: 1px solid var(--line);
}

.dice-result[hidden] {
  display: none;
}

.dice-faces {
  display: flex;
  gap: 0.6rem;
  margin: 0.35rem 0 0.75rem;
  flex-wrap: wrap;
}

.dice-face-chip {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--gold-deep);
  background: rgba(11, 16, 38, 0.45);
  color: var(--gold-soft);
  font-family: var(--font-display);
  font-size: 1rem;
}

.dice-result h2 {
  margin: 0;
  font-size: 1.2rem;
}

.dice-disclaimer {
  margin: 0.75rem 0 0;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.dice-how {
  margin: 1rem 0 0;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text-muted);
}

@media (max-width: 400px) {
  .dice-overlay-chip {
    font-size: 1.18rem;
  }

  .dice-overlay-sum {
    font-size: 1.28rem;
  }

  .dice-roll {
    min-height: 84px;
    width: min(88%, 320px);
  }

  .dice-stage.is-revealed .dice-roll {
    min-height: 64px;
  }
}

@media (min-width: 600px) {
  .dice-stage {
    aspect-ratio: 5 / 4;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dice-result,
  .dice-pip,
  .dice-roll,
  .dice-overlay {
    animation: none;
    transition: none;
  }

  .anim-fade-up {
    animation: none;
  }

  .dice-fx {
    display: none;
  }
}
