/*
  Desert Night Ludo — UI v4
  Ref: Ludo King board structure (yard inner pad, cone tokens, wood texture, star safe cells).
  ui-ux-pro-max: dark premium + gold #CA8A04, DM Sans.
*/
:root {
  --bg-deep:    #06080f;
  --bg-mid:     #0c1220;
  --panel-edge: rgba(202,138,4,0.32);
  --text:       #f2ebe0;
  --muted:      rgba(242,235,224,0.52);

  /* Player colours */
  --red:    #e03540;
  --blue:   #2f6de0;
  --green:  #22b060;
  --yellow: #d4920a;

  /* Board quadrant fills — rich saturated like Ludo King */
  --board-red:    #c8232a;
  --board-blue:   #1e4fbf;
  --board-green:  #187840;
  --board-yellow: #b87008;

  /* Yard inner white pad */
  --yard-inner: #f5f0e4;

  /* Track cells */
  --track-bg: #f0ece0;
  --track-border: rgba(0,0,0,0.14);

  --cta:        #ca8a04;
  --cta-bright: #f0c14d;

  --shadow-card: 0 16px 48px rgba(0,0,0,0.55);
  --r-lg: 18px;
  --r-md: 12px;
  --font-ui:   "DM Sans","Outfit",system-ui,sans-serif;
  --font-mono: "Share Tech Mono",ui-monospace,monospace;
  --ease:      cubic-bezier(0.4,0,0.2,1);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--font-ui);
  font-size: 15px;
  color: var(--text);
  touch-action: manipulation;
  overscroll-behavior-y: contain;
  background:
    radial-gradient(ellipse 140% 55% at 50% -5%, rgba(202,138,4,0.1), transparent 52%),
    radial-gradient(circle at 8% 92%, rgba(47,109,224,0.1), transparent 40%),
    linear-gradient(165deg, #0e1628 0%, #06080f 60%, #02030a 100%);
  min-height: 100dvh;
}

/* ── App shell ─────────────────────────────────────────────── */
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 14px;
  background: rgba(12,18,32,0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--panel-edge);
  border-radius: var(--r-lg);
  flex-shrink: 0;
}

.topbar__left { display: flex; align-items: center; gap: 10px; }

.brand { display: flex; align-items: center; gap: 7px; }
.brand__mark {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: conic-gradient(from 200deg, var(--cta-bright), #7a5209, var(--cta-bright));
  box-shadow: 0 0 10px rgba(240,193,77,0.5);
}
.brand__text {
  font-weight: 700; font-size: 0.74rem;
  letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--cta-bright);
}

.topbar__actions { display: flex; gap: 6px; }

.icon-btn {
  min-height: 36px; padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  font-family: var(--font-ui); font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: background 0.18s var(--ease);
}
.icon-btn:hover { background: rgba(255,255,255,0.1); }

.topbar__stats { display: flex; align-items: center; }
.topbar__turn {
  font-size: 13px; font-weight: 700;
  color: var(--cta-bright);
  white-space: nowrap;
}
/* hidden stat elements — keep for JS compatibility */
.stat { display: flex; flex-direction: column; }
.stat__label, .stat__value, .stat--wide { display: none; }

/* ── Player rail ────────────────────────────────────────────── */
.player-rail {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  flex-shrink: 0;
}

.player-card {
  display: flex; flex-direction: column; gap: 4px;
  padding: 7px 8px 8px;
  border-radius: var(--r-md);
  background: rgba(255,255,255,0.04);
  border: 1.5px solid rgba(255,255,255,0.07);
  transition: border-color 0.2s, box-shadow 0.2s;
  position: relative; overflow: visible;
}
.player-card::before {
  content: ""; position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  border-radius: 3px 3px 0 0;
}
.player-card--red::before    { background: var(--red); }
.player-card--blue::before   { background: var(--blue); }
.player-card--green::before  { background: var(--green); }
.player-card--yellow::before { background: var(--yellow); }

.player-card--active {
  border-color: var(--cta);
  box-shadow: 0 0 0 1px rgba(202,138,4,0.18), 0 4px 16px rgba(0,0,0,0.4);
}

/* ── Action bubble ─────────────────────────────────────────── */
.player-card__bubble {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%; transform: translateX(-50%);
  background: rgba(20,16,10,0.92);
  border: 1px solid rgba(202,138,4,0.4);
  border-radius: 8px;
  padding: 4px 9px;
  font-size: 10px; font-weight: 600; color: var(--text);
  white-space: nowrap;
  pointer-events: none;
  z-index: 20;
  backdrop-filter: blur(6px);
  animation: bubble-pop 0.18s cubic-bezier(0.34,1.56,0.64,1);
}
.player-card__bubble[hidden] { display: none; }
.player-card__bubble::after {
  content: "";
  position: absolute;
  top: 100%; left: 50%; transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(202,138,4,0.4);
}
@keyframes bubble-pop {
  from { transform: translateX(-50%) scale(0.8); opacity: 0; }
  to   { transform: translateX(-50%) scale(1); opacity: 1; }
}

.player-card__row { display: flex; align-items: center; gap: 5px; }

.player-card__avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-ui); font-weight: 700; font-size: 9px;
  color: #fff; flex-shrink: 0;
  overflow: hidden;
}
.player-card--red .player-card__avatar { background: linear-gradient(145deg,#ff8c94,var(--red)); }
/* SVG avatar fills the circle */
.player-card__avatar--svg { padding: 0; background: transparent; }
.player-card__avatar--svg svg { width: 100%; height: 100%; display: block; border-radius: 50%; }

.player-card__name {
  font-size: 10px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.player-card__meta {
  font-size: 9px; color: var(--muted); font-family: var(--font-mono);
}
.player-card__pips { display: flex; gap: 3px; }
.home-pip {
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
}
.home-pip--on {
  background: var(--cta-bright);
  border-color: var(--cta);
  box-shadow: 0 0 5px rgba(240,193,77,0.55);
}

/* ── Mode bar ───────────────────────────────────────────────── */
.mode-bar {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; padding: 5px 10px;
  border-radius: var(--r-md);
  background: rgba(12,18,32,0.5);
  border: 1px solid rgba(202,138,4,0.18);
  flex-shrink: 0;
}
.mode-bar__label {
  font-size: 9px; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--muted); margin-right: 2px;
}
.mode-chip {
  min-height: 30px; padding: 0 12px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: var(--muted); font-family: var(--font-ui);
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: background 0.18s, border-color 0.18s, color 0.18s;
}
.mode-chip:hover { border-color: rgba(202,138,4,0.3); color: var(--text); }
.mode-chip--active { border-color: rgba(202,138,4,0.55); background: rgba(202,138,4,0.14); color: var(--cta-bright); }
.mode-chip:focus-visible { outline: 2px solid var(--cta-bright); outline-offset: 2px; }

/* ── Stage ──────────────────────────────────────────────────── */
.stage {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 6px; min-height: 0;
}
.stage__glow { display: none; }
.board-wrap { width: 100%; display: flex; justify-content: center; flex-shrink: 1; }

/* ── Board ──────────────────────────────────────────────────── */
.board {
  position: relative;
  width: min(96vw, 400px);
  aspect-ratio: 1;
  border-radius: 14px;
  border: 2px solid rgba(202,138,4,0.45);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.05),
    0 20px 56px rgba(0,0,0,0.6);
  overflow: hidden;
  /* wood-grain style background */
  background:
    repeating-linear-gradient(
      92deg,
      rgba(255,255,255,0) 0px, rgba(255,255,255,0) 18px,
      rgba(255,255,255,0.018) 18px, rgba(255,255,255,0.018) 19px
    ),
    repeating-linear-gradient(
      178deg,
      rgba(0,0,0,0) 0px, rgba(0,0,0,0) 24px,
      rgba(0,0,0,0.04) 24px, rgba(0,0,0,0.04) 25px
    ),
    linear-gradient(170deg, #2a1a08 0%, #1a1008 50%, #100c04 100%);
}

/* ── 15×15 grid ─────────────────────────────────────────────── */
.board__grid {
  position: absolute; inset: 0;
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(15, 1fr);
}

.board__cell { min-width: 0; min-height: 0; position: relative; }

/* Outer track — warm ivory + subtle border */
.board__cell--track {
  background: var(--track-bg);
  box-shadow: inset 0 0 0 0.5px var(--track-border);
}

/* Safe cells — pure white + star */
.board__cell--safe {
  background: #fff;
  box-shadow: inset 0 0 0 0.5px rgba(0,0,0,0.12);
}
.board__cell--safe::after {
  content: "★";
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(6px,1.4vw,10px);
  color: rgba(0,0,0,0.22);
  pointer-events: none;
}

/* Yard quadrant base colour */
.board__cell--yard-red    { background: var(--board-red); }
.board__cell--yard-blue   { background: var(--board-blue); }
.board__cell--yard-green  { background: var(--board-green); }
.board__cell--yard-yellow { background: var(--board-yellow); }

/* Yard inner white pad — rows 1-4 cols 1-4 within each quadrant.
   Achieved by targeting cells via data attributes in JS (class: board__cell--yard-inner). */
.board__cell--yard-inner {
  background: var(--yard-inner) !important;
  border-radius: 3px;
}

/* Home column strips */
.board__cell--home         { background: var(--track-bg); }
.board__cell--home-red     { background: rgba(200,35,42,0.82); }
.board__cell--home-blue    { background: rgba(30,79,191,0.82); }
.board__cell--home-green   { background: rgba(24,120,64,0.82); }
.board__cell--home-yellow  { background: rgba(184,112,8,0.82); }

/* Neutral (wood background shows through) */
.board__cell--neutral { background: rgba(0,0,0,0.12); }

/* Centre — 4-colour pinwheel */
.board__cell--centre {
  background: conic-gradient(
    from 45deg,
    var(--board-red)    0deg  90deg,
    var(--board-blue)   90deg 180deg,
    var(--board-green)  180deg 270deg,
    var(--board-yellow) 270deg 360deg
  );
  z-index: 2;
}
/* Centre star */
.board__cell--centre::after {
  content: "★";
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(10px, 2.5vw, 16px);
  color: rgba(255,255,255,0.75);
  pointer-events: none;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

/* ── Tokens: cone shape (wider bottom, narrower top) ─────────── */
.token {
  position: absolute;
  /* cone proportions: wider base, tapered top */
  width:  clamp(20px, 5.5vw, 28px);
  height: clamp(24px, 6.5vw, 34px);
  border-radius: 50% 50% 46% 46% / 30% 30% 70% 70%;
  border: none;
  cursor: pointer;
  z-index: 24;
  transform: translate(-50%, -50%);
  transition: transform 0.14s var(--ease), filter 0.14s var(--ease);
  box-shadow:
    0 5px 0 rgba(0,0,0,0.5),
    0 7px 14px rgba(0,0,0,0.5);
}

/* Cone gradient: bright top highlight fading to rich base colour at bottom */
.token--red {
  background: radial-gradient(ellipse 65% 55% at 38% 22%,
    #ffb0b5 0%, var(--red) 48%, #7a1018 100%);
}
.token--blue {
  background: radial-gradient(ellipse 65% 55% at 38% 22%,
    #a8caff 0%, var(--blue) 48%, #102270 100%);
}
.token--green {
  background: radial-gradient(ellipse 65% 55% at 38% 22%,
    #90f5be 0%, var(--green) 48%, #083c22 100%);
}
.token--yellow {
  background: radial-gradient(ellipse 65% 55% at 38% 22%,
    #ffeaa0 0%, var(--yellow) 48%, #6a4000 100%);
}

/* Specular highlight (small bright oval top-left) */
.token::before {
  content: "";
  position: absolute;
  top: 8%; left: 18%;
  width: 36%; height: 22%;
  border-radius: 50%;
  background: rgba(255,255,255,0.6);
  pointer-events: none;
}

/* Ground shadow ellipse */
.token::after {
  content: "";
  position: absolute;
  bottom: -6px; left: 8%;
  width: 84%; height: 6px;
  border-radius: 50%;
  background: rgba(0,0,0,0.38);
  pointer-events: none;
}

.token:active {
  transform: translate(-50%, -56%) scale(0.91);
  filter: brightness(1.12);
}

/* Selectable pulse ring */
.token--selectable {
  outline: 2.5px solid var(--cta-bright);
  outline-offset: 2px;
  animation: pulse-ring 1.1s ease-in-out infinite;
}
@keyframes pulse-ring {
  0%,100% { box-shadow: 0 5px 0 rgba(0,0,0,0.5), 0 0 0 0   rgba(240,193,77,0.65); }
  50%      { box-shadow: 0 5px 0 rgba(0,0,0,0.5), 0 0 0 10px rgba(240,193,77,0);   }
}

/* Capture flash */
.token--captured {
  animation: captured-flash 0.4s ease-out forwards;
}
@keyframes captured-flash {
  0%   { filter: brightness(2.5) saturate(0); transform: translate(-50%,-50%) scale(1.25); }
  100% { filter: brightness(1)   saturate(1); transform: translate(-50%,-50%) scale(0); opacity: 0; }
}

/* ── HUD message ────────────────────────────────────────────── */
.hud-msg { width: 100%; text-align: center; padding: 0 8px; min-height: 18px; }
.hud-msg__text { margin: 0; font-size: 13px; color: var(--muted); }

/* ── Action bar ─────────────────────────────────────────────── */
.action-bar {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; width: 100%; flex-shrink: 0;
}

/* ── Dice Overlay ───────────────────────────────────────────────
   Full-board overlay that shows a large spinning CSS 3D die.
   Position: absolute over .board-wrap (which is position:relative).
   The die is 120×120 px, centered. After animation it fades out.
 ───────────────────────────────────────────────────────────────── */
.board-wrap { position: relative; }

.dice-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  z-index: 50;
  pointer-events: none;
  background: radial-gradient(ellipse 65% 55% at 50% 44%, rgba(0,0,0,0.32) 0%, transparent 100%);
}
.dice-overlay[hidden] { display: none; }

/* fade-out */
.dice-overlay--fadeout {
  animation: dice-overlay-fade 0.3s ease forwards;
}
@keyframes dice-overlay-fade {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* perspective container — shadow here keeps preserve-3d intact on the cube */
.dice-overlay__scene {
  position: relative;
  width: 96px;
  /* extra height below cube for result number (96px cube + 44px badge) */
  height: 140px;
  perspective: 480px;
  perspective-origin: 50% 34%;
  flex-shrink: 0;
  filter: drop-shadow(0 12px 24px rgba(0,0,0,0.75));
}

/* the cube — NO filter, preserve-3d must be intact */
.dice-overlay__cube {
  width: 96px;
  height: 96px;
  position: relative;
  transform-style: preserve-3d;
  transform: rotateX(-20deg) rotateY(0deg);
}

/* 6 faces — size=96px, translateZ=48px */
.dice-overlay__face {
  position: absolute;
  width: 96px;
  height: 96px;
  border-radius: 14px;
  border: 2px solid rgba(40,20,0,0.18);
  display: grid;
  grid-template-columns: repeat(3, 20px);
  grid-template-rows: repeat(3, 20px);
  gap: 4px;
  place-content: center;
  place-items: center;
  padding: 8px;
  box-sizing: border-box;
}
.dice-overlay__face--front  {
  background: linear-gradient(160deg, #f5edd8 0%, #dcc89a 100%);
  box-shadow: inset 0 2px 6px rgba(255,255,255,0.5), inset 0 -2px 4px rgba(0,0,0,0.12);
  transform: translateZ(48px);
}
.dice-overlay__face--top    {
  background: linear-gradient(160deg, #f8f0da 0%, #cfc0a0 100%);
  transform: rotateX( 90deg) translateZ(48px);
}
.dice-overlay__face--back   { background: linear-gradient(145deg, #b87830, #6a3c08); transform: rotateY(180deg) translateZ(48px); }
.dice-overlay__face--right  { background: linear-gradient(145deg, #a06820, #5a3008); transform: rotateY( 90deg) translateZ(48px); }
.dice-overlay__face--left   { background: linear-gradient(145deg, #a06820, #5a3008); transform: rotateY(-90deg) translateZ(48px); }
.dice-overlay__face--bottom { background: linear-gradient(145deg, #8a5018, #4a2204); transform: rotateX(-90deg) translateZ(48px); }

/* pip dots */
.dice-overlay__pip {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #5a2c0c, #180802);
  box-shadow: 0 1px 4px rgba(0,0,0,0.55);
  opacity: 0;
}
.dice-overlay__pip--on { opacity: 1; }

/* spin animation — pops in small, tumbles, lands front-face forward */
.dice-overlay__cube--spin {
  animation: dice-spin 0.7s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}
@keyframes dice-spin {
  0%   { transform: rotateX(-20deg) rotateY(0deg)   scale(0.45); }
  15%  { transform: rotateX(80deg)  rotateY(120deg)  scale(1.18); }
  35%  { transform: rotateX(200deg) rotateY(270deg)  scale(0.9); }
  55%  { transform: rotateX(320deg) rotateY(400deg)  scale(1.1); }
  78%  { transform: rotateX(460deg) rotateY(540deg)  scale(0.96); }
  90%  { transform: rotateX(520deg) rotateY(660deg)  scale(1.03); }
  100% { transform: rotateX(540deg) rotateY(720deg)  scale(1); }
}

/* result number — sits directly below the cube inside scene */
.dice-overlay__result {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) scale(0.6);
  font-family: var(--font-ui);
  font-size: 30px;
  font-weight: 900;
  color: #fff;
  text-shadow:
    0 0 14px rgba(240,193,77,1),
    0 0 28px rgba(240,193,77,0.5),
    0 2px 4px rgba(0,0,0,0.9);
  letter-spacing: 0.04em;
  opacity: 0;
  transition: opacity 0.16s ease, transform 0.16s cubic-bezier(0.34,1.56,0.64,1);
}
.dice-overlay__result--show {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* ── Roll button (replaces old dice widget) ─────────────────── */
.roll-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 24px;
  height: 52px;
  border-radius: 16px;
  border: none;
  background: linear-gradient(160deg, #f0c84a 0%, #c88c14 60%, #a06808 100%);
  box-shadow: 0 4px 0 #7a4c04, 0 8px 24px rgba(200,140,20,0.4);
  color: #1a0e02;
  font-family: var(--font-ui);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  text-transform: uppercase;
}
.roll-btn:hover  { transform: translateY(-2px); box-shadow: 0 6px 0 #7a4c04, 0 12px 28px rgba(200,140,20,0.45); }
.roll-btn:active { transform: translateY(2px);  box-shadow: 0 2px 0 #7a4c04, 0 4px 12px rgba(200,140,20,0.3); }
.roll-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
.roll-btn:focus-visible { outline: 2px solid var(--cta-bright); outline-offset: 3px; }
.roll-btn__icon  { font-size: 22px; line-height: 1; }
.roll-btn__label { line-height: 1; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  font-family: var(--font-ui); font-size: 13px; font-weight: 600;
  min-height: 40px; padding: 0 18px;
  border-radius: 12px; border: 1px solid transparent;
  cursor: pointer; transition: background 0.18s, transform 0.12s;
}
.btn--gold {
  background: linear-gradient(180deg, #eece7c, #b88828);
  color: #1a1206; border-color: rgba(255,255,255,0.22);
}
.btn--gold:hover { transform: translateY(-1px); }
.btn--ghost {
  background: rgba(255,255,255,0.06); color: var(--text);
  border-color: rgba(255,255,255,0.1);
}

/* ── Dice history panel ─────────────────────────────────────── */
.dice-history-btn {
  min-height: 36px; padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  color: var(--muted); font-family: var(--font-ui);
  font-size: 11px; font-weight: 600; cursor: pointer;
  transition: background 0.18s, color 0.18s;
}
.dice-history-btn:hover { background: rgba(255,255,255,0.09); color: var(--text); }

.dice-history-panel {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: rgba(12,18,32,0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(202,138,4,0.2);
  flex-shrink: 0;
}
.dice-history-panel[hidden] { display: none; }

.dice-history__title {
  font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--muted);
  margin: 0 0 8px;
  display: flex; align-items: center; justify-content: space-between;
}
.dice-history__title span { color: var(--cta-bright); }

.dice-dist {
  display: flex; gap: 4px; align-items: flex-end;
  height: 40px; margin-bottom: 6px;
}
.dice-dist__bar-wrap {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 2px;
}
.dice-dist__bar {
  width: 100%; border-radius: 3px 3px 0 0;
  background: rgba(202,138,4,0.55);
  min-height: 3px;
  transition: height 0.3s var(--ease);
}
.dice-dist__label {
  font-size: 9px; color: var(--muted); font-family: var(--font-mono);
}

.dice-history__rolls {
  display: flex; flex-wrap: wrap; gap: 3px;
  max-height: 42px; overflow: hidden;
  font-family: var(--font-mono); font-size: 11px;
}
.dice-roll-pill {
  padding: 1px 5px; border-radius: 5px;
  background: rgba(255,255,255,0.07);
  color: var(--muted);
}
.dice-roll-pill--six { background: rgba(202,138,4,0.22); color: var(--cta-bright); }
.dice-roll-pill--one { background: rgba(224,53,64,0.18); color: #ff7882; }

/* Fair dice note */
.dice-history__fair {
  margin-top: 6px;
  font-size: 10px; color: var(--muted);
  line-height: 1.4;
}
.dice-history__fair strong { color: var(--cta-bright); }

/* ── Ads slot ───────────────────────────────────────────────── */
.ads-slot {
  width: 100%; min-height: 50px;
  border-radius: var(--r-md);
  border: 1px dashed rgba(255,255,255,0.09);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--muted);
}

/* ── Toast ──────────────────────────────────────────────────── */
.toast-stack {
  position: fixed; left: 50%; bottom: 88px;
  transform: translateX(-50%);
  width: min(400px, calc(100% - 24px));
  display: flex; flex-direction: column; gap: 6px;
  pointer-events: none; z-index: 50;
}
.toast {
  padding: 9px 13px; border-radius: 10px;
  background: rgba(10,14,26,0.96);
  border: 1px solid rgba(202,138,4,0.22);
  color: var(--text); font-size: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.5);
  animation: toast-in 0.22s var(--ease) forwards;
}
@keyframes toast-in {
  from { opacity:0; transform:translateY(8px); }
  to   { opacity:1; transform:translateY(0); }
}

/* ── Footer ─────────────────────────────────────────────────── */
.legal-foot {
  text-align: center; font-size: 11px; color: var(--muted);
  padding: 4px 0 2px; flex-shrink: 0;
}
.legal-foot a { color: var(--cta-bright); text-decoration: none; }
.legal-foot a:hover { text-decoration: underline; }

/* ── Rules sheet ────────────────────────────────────────────── */
.sheet[hidden] { display: none !important; }
.sheet { position: fixed; inset: 0; z-index: 80; }
.sheet__backdrop {
  position: absolute; inset: 0;
  background: rgba(2,4,10,0.6);
  backdrop-filter: blur(4px);
}
.sheet__panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: min(88vh,620px); overflow: auto;
  background: rgba(10,16,28,0.97);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-radius: 22px 22px 0 0;
  border: 1px solid var(--panel-edge);
  box-shadow: 0 -18px 50px rgba(0,0,0,0.5);
  padding: 18px 18px 32px;
}
.sheet__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet__title { margin:0; font-size:1.2rem; color:var(--cta-bright); }
.sheet__close {
  width:40px; height:40px; border-radius:10px;
  border:1px solid rgba(255,255,255,0.1);
  background:rgba(255,255,255,0.05);
  color:var(--text); font-size:20px; line-height:1; cursor:pointer;
}
.sheet__body { color:var(--muted); font-size:13px; line-height:1.65; }
.sheet__body ul { padding-left:1.1rem; }
.sheet__body li + li { margin-top:5px; }
.sheet__note { margin-top:12px; font-size:11px; opacity:.8; }
.sheet__note code { font-family:var(--font-mono); font-size:10px; }

/* ── Modal ──────────────────────────────────────────────────── */
.modal {
  position:fixed; inset:0; z-index:100;
  display:flex; align-items:center; justify-content:center;
  padding:20px;
  background:rgba(2,4,12,0.82);
  backdrop-filter:blur(10px);
}
.modal--hidden,.modal.hidden { display:none; }
.modal__confetti { position:absolute; inset:0; pointer-events:none; overflow:hidden; }

.modal--victory .modal__confetti::before,
.modal--victory .modal__confetti::after {
  content:""; position:absolute;
  width:10px; height:22px;
  left:50%; top:12%;
  animation:confetti-fall 1.8s ease-in forwards;
  transform:translateX(-50%) rotate(14deg);
}
.modal--victory .modal__confetti::before { background:var(--cta-bright); }
.modal--victory .modal__confetti::after  { background:var(--red); left:44%; animation-delay:0.12s; }
@keyframes confetti-fall {
  to { transform:translate(-30vw,70vh) rotate(240deg); opacity:0; }
}

.modal__panel {
  position:relative; width:min(360px,100%);
  padding:26px 22px; border-radius:var(--r-lg);
  background:rgba(10,16,28,0.98);
  backdrop-filter:blur(20px); -webkit-backdrop-filter:blur(20px);
  border:1px solid var(--panel-edge);
  box-shadow:0 24px 64px rgba(0,0,0,0.65);
  text-align:center;
}
.modal__title {
  margin:0 0 8px;
  font-family:var(--font-mono); font-size:1.6rem;
  color:var(--cta-bright);
}
.modal__body { margin:0 0 20px; color:var(--muted); line-height:1.55; }
.modal__actions { display:flex; flex-direction:column; gap:8px; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (min-height:820px) {
  .board { width: min(96vw, 440px); }
}
