/* Dice Roller — tray, 3D dice, live panel, and stats extras. Shared page,
   button, and stats styles live in /assets/site.css. The orange stays orange
   in dark mode. White text on orange is lower contrast, so text on the
   background is kept large or bold; small text sits on white cards. */

body.game-dice {
  --game-bg: #F26B0F;
  --game-deep: #B84A06;
  --game-accent: #C2410C;
  --card-line: #FDE7D8;
  --felt: #B84A06;
  --die: min(22vw, 90px);
}

/* Desktop and wide: tray up to 640px, dice up to 120px (the site-wide size table). */
@media (min-width: 900px) {
  body.game-dice { --die: 120px; }
}

/* ── Layout ────────────────────────────────────────────── */

.dice-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.dice-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 472px;
  padding: 8px 16px 0;
}

.dice-side {
  width: 100%;
  max-width: 472px;
  padding: 20px 16px 0;
}

/* Phones and tablets: only the live curve, under the button. */
.dice-facts, .dice-recent, .dice-side-link { display: none; }

@media (min-width: 900px) {
  .dice-layout {
    display: grid;
    grid-template-columns: minmax(0, 640px) 340px;
    justify-content: center;
    align-items: start;
    column-gap: 40px;
    max-width: calc(var(--ws-container) + 2 * var(--ws-gutter));
    margin: 0 auto;
    padding: 0 var(--ws-gutter);
  }
  .dice-main { max-width: none; padding: 8px 0 0; }
  .dice-side { max-width: none; padding: 8px 0 0; display: flex; flex-direction: column; gap: 16px; }
  .dice-facts, .dice-recent { display: block; }
  .dice-side-link { display: inline-block; font-weight: 700; font-size: 16px; }
  .dice-stats-link { display: none; }
}

/* ── Tray ──────────────────────────────────────────────── */

.tray {
  position: relative;
  display: flex;
  width: 100%;
  height: calc(var(--die) * 2.4);
  overflow: hidden;
  border: 6px solid #8F3A05;
  border-radius: 24px;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.10), transparent 60%),
    repeating-radial-gradient(circle at 17% 32%, rgba(0, 0, 0, 0.05) 0 1px, transparent 1px 3px),
    repeating-radial-gradient(circle at 71% 64%, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 4px),
    var(--felt);
  box-shadow: inset 0 5px 16px rgba(0, 0, 0, 0.4), 0 6px 0 #7A2F03, 0 12px 26px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

@media (min-width: 900px) {
  .tray { height: 320px; }
}

.die-slot { position: relative; flex: 1; }

.die-pos {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--die);
  height: var(--die);
  margin: calc(var(--die) / -2) 0 0 calc(var(--die) / -2);
  perspective: calc(var(--die) * 7);
  will-change: transform;
}

.die-shadow {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -14%;
  height: 26%;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.45), transparent 70%);
  filter: blur(3px);
}

.die {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
}

.face {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  place-items: center;
  padding: 14%;
  border-radius: 16%;
  background: radial-gradient(circle at 35% 30%, #FFFFFF, #F1F1EE 70%, #E2E1DC);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08), inset 0 -3px 6px rgba(0, 0, 0, 0.08);
  backface-visibility: hidden;
}

.face i { display: block; width: 72%; height: 72%; border-radius: 50%; }
.face i.on { background: radial-gradient(circle at 40% 35%, #3A3A3A, #0E0E0E); }

.f1 { transform: rotateY(0deg) translateZ(calc(var(--die) / 2)); }
.f6 { transform: rotateY(180deg) translateZ(calc(var(--die) / 2)); }
.f3 { transform: rotateY(90deg) translateZ(calc(var(--die) / 2)); }
.f4 { transform: rotateY(-90deg) translateZ(calc(var(--die) / 2)); }
.f2 { transform: rotateX(90deg) translateZ(calc(var(--die) / 2)); }
.f5 { transform: rotateX(-90deg) translateZ(calc(var(--die) / 2)); }

/* ── Result ────────────────────────────────────────────── */

.dice-result { margin: 14px 0 12px; text-align: center; }

.dice-total {
  min-height: 1em;
  margin: 0;
  font-size: clamp(56px, 16vw, 76px);
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: opacity 150ms ease;
}

.dice-special {
  min-height: 1.3em;
  margin: 4px 0 0;
  color: var(--game-yellow);
  font-size: 22px;
  font-weight: 800;
}

body.game-dice .big-button { min-width: 200px; }
body.game-dice .site-footer { color: #FFFFFF; font-weight: 600; }

/* ── Live panel ────────────────────────────────────────── */

.dice-side .card h2 { margin-bottom: 8px; }
.dice-curve .detail { margin-top: 4px; }

.dice-recent-list { margin: 0; padding: 0; list-style: none; }

.dice-recent-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  border-bottom: 1px solid var(--card-line);
  font-variant-numeric: tabular-nums;
}

.dice-recent-list li:last-child { border-bottom: 0; }
.dice-recent-list b { min-width: 2ch; margin-left: 6px; font-size: 17px; }
.dice-dbl { margin-left: auto; padding: 1px 8px; border-radius: 999px; background: #FFF1D6; color: var(--game-accent); font-size: 12px; font-weight: 700; }
.dice-none { color: var(--card-muted); }

.mini-die {
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 3px;
  border: 1px solid #D5D2CC;
  border-radius: 5px;
  background: #FFFFFF;
  vertical-align: middle;
}

.mini-die i { display: block; width: 4px; height: 4px; border-radius: 50%; }
.mini-die i.on { background: #111111; }

/* ── Stats page extras ─────────────────────────────────── */

.dice-strip { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.dice-strip li { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 6px 4px; border-radius: 10px; background: #FFF6EF; }
.dice-strip li.is-double { background: #FFE9C2; }
.dice-strip .pair { display: flex; gap: 3px; }
.dice-strip b { font-size: 14px; }

.dice-doubles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin-top: 12px; text-align: center; }
.dice-doubles div { padding: 6px 0; border-radius: 10px; background: #FFF6EF; }
.dice-doubles .pair { display: flex; justify-content: center; gap: 2px; }
.dice-doubles .mini-die { width: 18px; height: 18px; padding: 2px; }
.dice-doubles .mini-die i { width: 3px; height: 3px; }
.dice-doubles small { display: block; margin-top: 3px; font-size: 12px; color: var(--card-muted); }
.dice-doubles .is-named { background: #FFE9C2; }

.dice-droughts { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.dice-records { margin-top: 12px; }
.dice-droughts li { padding: 8px; border-radius: 10px; background: #FFF6EF; text-align: center; }
.dice-droughts b { display: block; font-size: 22px; color: var(--game-accent); }
.dice-droughts span { font-size: 13px; color: var(--card-muted); }

@media (hover: hover) and (pointer: fine) {
  .tray:hover { filter: brightness(1.04); }
}

@media (prefers-reduced-motion: reduce) {
  .dice-total { transition: none; }
}
