/* Fantastical Board Realms for Ludo (Alpha) */
:root,
html[data-realm="carnival"] {
  color-scheme: dark;
  --bg: #0d0a1a;
  --panel: rgba(24, 18, 46, 0.9);
  --panel-solid: #18122e;
  --tile: #1e163a;
  --tile-border: rgba(255, 255, 255, 0.12);
  --text: #fbf7ef;
  --muted: #b6abcf;
  --accent: #ffd075;
  --cta-grad: linear-gradient(120deg, #eb577e, #ff8b60 55%, #ffd075);
  --cta-ink: #140b1f;
  --aura-a: #eb577e;
  --aura-b: #02bfd2;
  --aura-c: #ffd075;
}

html[data-realm="velvet"] {
  color-scheme: dark;
  --bg: #14091a;
  --panel: rgba(34, 16, 44, 0.92);
  --panel-solid: #22102c;
  --tile: #2c1538;
  --tile-border: rgba(255, 208, 117, 0.18);
  --text: #fff7eb;
  --muted: #cbb1d9;
  --accent: #ffd075;
  --cta-grad: linear-gradient(120deg, #ffd075, #f59e0b 55%, #eb577e);
  --cta-ink: #1b0b1f;
  --aura-a: #9333ea;
  --aura-b: #f59e0b;
  --aura-c: #eb577e;
}

html[data-realm="arcade"] {
  color-scheme: dark;
  --bg: #060d1f;
  --panel: rgba(12, 24, 52, 0.92);
  --panel-solid: #0c1834;
  --tile: #112247;
  --tile-border: rgba(56, 189, 248, 0.22);
  --text: #eef7ff;
  --muted: #93b8d9;
  --accent: #38bdf8;
  --cta-grad: linear-gradient(120deg, #02bfd2, #38bdf8 55%, #a855f7);
  --cta-ink: #060d1f;
  --aura-a: #02bfd2;
  --aura-b: #6366f1;
  --aura-c: #ec4899;
}

html[data-realm="oasis"] {
  color-scheme: dark;
  --bg: #061815;
  --panel: rgba(12, 38, 33, 0.92);
  --panel-solid: #0c2621;
  --tile: #11352d;
  --tile-border: rgba(52, 211, 153, 0.2);
  --text: #f0fff9;
  --muted: #94ccb8;
  --accent: #fde047;
  --cta-grad: linear-gradient(120deg, #34d399, #a3e635 55%, #fde047);
  --cta-ink: #061815;
  --aura-a: #10b981;
  --aura-b: #f59e0b;
  --aura-c: #06b6d4;
}

html[data-realm="courtyard"] {
  color-scheme: light;
  --bg: #fdf5e6;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-solid: #ffffff;
  --tile: #fff9ef;
  --tile-border: rgba(28, 18, 41, 0.14);
  --text: #1c1229;
  --muted: #65567a;
  --accent: #d62d64;
  --cta-grad: linear-gradient(120deg, #d62d64, #eb5c3b 55%, #e59300);
  --cta-ink: #ffffff;
  --aura-a: #ffb703;
  --aura-b: #eb577e;
  --aura-c: #02bfd2;
}

html[data-realm="porcelain"] {
  color-scheme: light;
  --bg: #eef5ff;
  --panel: rgba(255, 255, 255, 0.95);
  --panel-solid: #ffffff;
  --tile: #f7faff;
  --tile-border: rgba(15, 23, 42, 0.15);
  --text: #0f172a;
  --muted: #4b5e82;
  --accent: #2563eb;
  --cta-grad: linear-gradient(120deg, #2563eb, #6366f1 55%, #9333ea);
  --cta-ink: #ffffff;
  --aura-a: #38bdf8;
  --aura-b: #a855f7;
  --aura-c: #2563eb;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  transition: background 0.35s ease, color 0.35s ease;
  overflow-x: hidden;
}

button, a, input { font: inherit; color: inherit; text-decoration: none; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.realm-bg { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.aura { position: absolute; border-radius: 50%; filter: blur(95px); opacity: 0.25; }
html[data-realm="courtyard"] .aura,
html[data-realm="porcelain"] .aura { opacity: 0.15; }
.aura-a { width: 45vw; height: 45vw; max-width: 520px; max-height: 520px; top: -14%; left: -10%; background: var(--aura-a); }
.aura-b { width: 44vw; height: 44vw; max-width: 520px; max-height: 520px; top: 8%; right: -12%; background: var(--aura-b); }
.aura-c { width: 42vw; height: 42vw; max-width: 480px; max-height: 480px; bottom: -16%; left: 32%; background: var(--aura-c); opacity: 0.18; }

.game-topbar {
  max-width: 1140px;
  margin: 0 auto;
  padding: 14px clamp(16px, 3vw, 32px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }

.back-pill, .top-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 15px;
  border-radius: 999px;
  border: 1px solid var(--tile-border);
  background: var(--panel);
  font-size: 13px;
  font-weight: 700;
  transition: transform 0.16s ease, border-color 0.16s ease;
}

.back-pill:hover, .top-pill:hover { transform: translateY(-1px); border-color: var(--accent); }
.primary-pill { border: 0; background: var(--cta-grad); color: var(--cta-ink); font-weight: 800; box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25); }

.title-cluster { display: flex; align-items: center; gap: 9px; }
.title-cluster h1 { margin: 0; font-family: "Bricolage Grotesque", system-ui, sans-serif; font-size: clamp(22px, 2.5vw, 28px); font-weight: 800; }

.alpha-badge {
  display: inline-flex;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.2px;
  background: rgba(235, 87, 126, 0.18);
  border: 1px solid #eb577e;
  color: #eb577e;
}

.top-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--tile-border);
  background: var(--panel);
  font-weight: 800;
}

#btn-mute[aria-pressed="false"] .icon-sound-off { display: none; }
#btn-mute[aria-pressed="true"] .icon-sound-on { display: none; }

/* Main Play Layout */
.play-layout {
  max-width: 1140px;
  margin: 0 auto;
  padding: 4px clamp(16px, 3vw, 32px) 36px;
  display: grid;
  grid-template-columns: minmax(0, 600px) minmax(290px, 360px);
  justify-content: center;
  align-items: start;
  gap: clamp(18px, 3vw, 30px);
}

.turn-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  margin-bottom: 12px;
  border-radius: 18px;
  border: 1px solid var(--tile-border);
  background: var(--panel);
}

.turn-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #eb577e;
  box-shadow: 0 0 12px currentColor;
  flex: none;
}

.turn-banner strong {
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-size: 16px;
  font-weight: 800;
}

.rules-tag {
  margin-left: auto;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  border: 1px solid var(--tile-border);
  color: var(--accent);
}

/* 15x15 Ludo Board */
.board-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  padding: 10px;
  border-radius: 28px;
  border: 2px solid var(--tile-border);
  background: var(--panel);
  box-shadow: 0 26px 56px rgba(0, 0, 0, 0.4);
}

.board-shell.shake {
  animation: board-shake 0.36s ease;
}

@keyframes board-shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-6px, 3px); }
  40% { transform: translate(6px, -3px); }
  60% { transform: translate(-4px, -2px); }
  80% { transform: translate(4px, 2px); }
}

.ludo-board {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(15, 1fr);
  border-radius: 18px;
  overflow: hidden;
  border: 2px solid var(--tile-border);
  background: var(--tile);
}

.b-tile {
  border: 1px solid var(--tile-border);
  display: grid;
  place-items: center;
  font-size: clamp(10px, 1.5vw, 15px);
  font-weight: 800;
  position: relative;
}

.b-tile.lane-0 { background: rgba(235, 87, 126, 0.34); }
.b-tile.lane-1 { background: rgba(2, 191, 210, 0.34); }
.b-tile.lane-2 { background: rgba(255, 208, 117, 0.34); }
.b-tile.lane-3 { background: rgba(50, 213, 131, 0.34); }

.b-tile.is-safe::after {
  content: "★";
  color: var(--accent);
  font-size: clamp(11px, 1.5vw, 16px);
  opacity: 0.9;
}

.b-tile.is-chaos {
  background: radial-gradient(circle, rgba(255, 208, 117, 0.28), transparent 72%);
}

/* Corner Yards (6x6 each) */
.yard {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 8px;
  border: 2px solid var(--tile-border);
}

.yard-0 { grid-area: 1 / 1 / 7 / 7; background: linear-gradient(135deg, rgba(235, 87, 126, 0.42), rgba(235, 87, 126, 0.14)); }
.yard-1 { grid-area: 1 / 10 / 7 / 16; background: linear-gradient(135deg, rgba(2, 191, 210, 0.42), rgba(2, 191, 210, 0.14)); }
.yard-2 { grid-area: 10 / 10 / 16 / 16; background: linear-gradient(135deg, rgba(255, 208, 117, 0.42), rgba(255, 208, 117, 0.14)); }
.yard-3 { grid-area: 10 / 1 / 16 / 7; background: linear-gradient(135deg, rgba(50, 213, 131, 0.42), rgba(50, 213, 131, 0.14)); }

.yard.is-active {
  box-shadow: inset 0 0 0 3px var(--accent);
}

.yard.is-off {
  opacity: 0.24;
  filter: grayscale(0.8);
}

.yard-label {
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(13, 10, 26, 0.72);
  color: #ffffff;
  font-size: clamp(9px, 1.2vw, 11.5px);
  font-weight: 800;
  letter-spacing: 0.4px;
  z-index: 2;
}

/* Center Crown Goal (3x3) */
.center-crown {
  grid-area: 7 / 7 / 10 / 10;
  position: relative;
  display: grid;
  place-items: center;
  background:
    conic-gradient(from -45deg, #02bfd2 0deg 90deg, #ffd075 90deg 180deg, #32d583 180deg 270deg, #eb577e 270deg 360deg);
  border: 2px solid var(--accent);
}

.center-crown span {
  width: 54%;
  height: 54%;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--panel-solid);
  border: 2px solid var(--accent);
  font-size: clamp(16px, 2.6vw, 24px);
}

/* Tokens Layer */
.tokens-layer, .callout-layer {
  position: absolute;
  inset: 12px;
  pointer-events: none;
  z-index: 5;
}

.token {
  position: absolute;
  width: 5.8%;
  height: 5.8%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2.5px solid #ffffff;
  background: var(--tok-color);
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.45), inset 0 2px 4px rgba(255, 255, 255, 0.45);
  display: grid;
  place-items: center;
  padding: 0;
  pointer-events: auto;
  transition: left 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), top 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.16s ease;
}

.token::after {
  content: "";
  width: 42%;
  height: 42%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.65);
}

.token.is-movable {
  z-index: 12;
  cursor: pointer;
  animation: token-pulse 0.9s ease-in-out infinite;
  box-shadow: 0 0 0 4px rgba(255, 208, 117, 0.85), 0 8px 18px rgba(0, 0, 0, 0.5);
}

.token.is-shielded {
  box-shadow: 0 0 0 3px #38bdf8, 0 6px 14px rgba(0, 0, 0, 0.5);
}

.token-shield {
  position: absolute;
  top: -8px;
  right: -7px;
  font-size: 11px;
  line-height: 1;
}

@keyframes token-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1.06); }
  50% { transform: translate(-50%, -58%) scale(1.22); }
}

/* Floating Callouts & Emote Bubbles */
.callout-pop {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--panel-solid);
  border: 2px solid var(--accent);
  color: var(--text);
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.5);
  animation: pop-rise 1.3s ease forwards;
}

@keyframes pop-rise {
  0% { opacity: 0; transform: translate(-50%, -20%) scale(0.6); }
  20% { opacity: 1; transform: translate(-50%, -60%) scale(1.08); }
  80% { opacity: 1; transform: translate(-50%, -95%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -130%) scale(0.95); }
}

/* Controls Dock */
.controls-column { display: grid; gap: 14px; }
.dock-card { padding: 16px; border-radius: 22px; border: 1px solid var(--tile-border); background: var(--panel); }
.dock-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.dock-eyebrow { font-size: 10.5px; font-weight: 800; letter-spacing: 1.8px; text-transform: uppercase; color: var(--muted); }
.dock-sub { font-size: 11.5px; font-weight: 700; color: var(--accent); }

/* Dice Tray */
.dice-stage { display: flex; align-items: center; gap: 16px; }

.die-btn {
  width: 76px;
  height: 76px;
  flex: none;
  border-radius: 20px;
  border: 2px solid var(--accent);
  background: #fbf7ef;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35), inset 0 -4px 0 rgba(0, 0, 0, 0.14);
  display: grid;
  place-items: center;
  padding: 12px;
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.die-btn:hover:not(:disabled) { transform: scale(1.06) rotate(-4deg); }
.die-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.die-btn.rolling { animation: die-tumble 0.36s linear infinite; }

@keyframes die-tumble {
  0% { transform: rotate(0deg) scale(1.08); }
  50% { transform: rotate(180deg) scale(0.94); }
  100% { transform: rotate(360deg) scale(1.08); }
}

.die-face {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  place-items: center;
}

.pip {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #140b1f;
}

.roll-cta { flex: 1; min-height: 54px; font-size: 15px; }

/* Emotes */
.emote-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.emote-btn {
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--tile-border);
  background: var(--tile);
  font-size: 20px;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.15s ease;
}
.emote-btn:hover { transform: translateY(-2px) scale(1.08); border-color: var(--accent); }

/* Players List */
.players-list { display: grid; gap: 8px; }
.player-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 14px;
  border: 1px solid var(--tile-border);
  background: var(--tile);
}
.player-row.is-turn { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.p-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--p-color); flex: none; }
.p-name { font-size: 13px; font-weight: 800; }
.p-meta { margin-left: auto; font-size: 11.5px; color: var(--muted); font-weight: 700; }

/* Log */
.match-log { display: grid; gap: 6px; font-size: 12px; color: var(--muted); }
.log-line:first-child { color: var(--text); font-weight: 700; }

/* Modals */
.modal {
  width: min(540px, calc(100% - 24px));
  max-height: calc(100dvh - 28px);
  padding: 0;
  border-radius: 26px;
  border: 1px solid var(--tile-border);
  background: var(--panel-solid);
  color: var(--text);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.65);
  overflow: auto;
}
.modal::backdrop { background: rgba(6, 4, 14, 0.76); backdrop-filter: blur(7px); }
.modal-inner { position: relative; padding: 24px; }
.modal-close { position: absolute; top: 16px; right: 16px; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--tile-border); background: var(--tile); font-size: 20px; }
.modal-inner h2 { margin: 6px 0 0; font-family: "Bricolage Grotesque", system-ui, sans-serif; font-size: 28px; font-weight: 800; }

.resume-banner { margin-top: 16px; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--accent); background: var(--tile); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.setup-group, .settings-section { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--tile-border); }
.setup-group h3, .settings-section h3 { margin: 0 0 10px; font-size: 13px; font-weight: 800; }
.setup-group h3 small { color: var(--muted); font-weight: 600; }
.setup-group-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.setup-group-head h3 { margin: 0; }
.text-link { border: 0; background: none; color: var(--accent); font-size: 12px; font-weight: 800; }

.seats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.seat-card { padding: 10px 12px; border-radius: 14px; border: 1px solid var(--tile-border); background: var(--tile); display: grid; gap: 8px; }
.seat-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.seat-badge { padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; border: 1px solid var(--tile-border); background: var(--panel-solid); }
.seat-name-input { width: 100%; padding: 6px 9px; border-radius: 10px; border: 1px solid var(--tile-border); background: var(--panel-solid); font-size: 12.5px; font-weight: 700; }

.choice-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.choice-btn { padding: 10px 11px; border-radius: 14px; border: 1px solid var(--tile-border); background: var(--tile); text-align: left; display: flex; flex-direction: column; gap: 3px; }
.choice-btn strong { font-size: 13px; }
.choice-btn small { font-size: 11px; color: var(--muted); line-height: 1.3; }
.choice-btn[aria-pressed="true"] { border-color: var(--accent); background: rgba(255, 208, 117, 0.14); }

.realm-cards-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.realm-card-btn { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 14px; border: 1px solid var(--tile-border); background: var(--tile); font-size: 12.5px; font-weight: 700; }
.realm-card-btn[aria-pressed="true"] { border-color: var(--accent); background: rgba(255, 208, 117, 0.14); }
.realm-dot { width: 22px; height: 22px; border-radius: 7px; background: var(--swatch); flex: none; }

.toggle-list { display: grid; gap: 8px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 12px; border-radius: 14px; border: 1px solid var(--tile-border); background: var(--tile); cursor: pointer; }
.toggle-row span { display: flex; flex-direction: column; gap: 2px; }
.toggle-row strong { font-size: 13px; }
.toggle-row small { font-size: 11px; color: var(--muted); }
.toggle-row input { width: 20px; height: 20px; accent-color: #eb577e; }

.slider-row { margin-top: 10px; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--tile-border); background: var(--tile); }
.slider-head { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 700; margin-bottom: 6px; }
.slider-row input { width: 100%; accent-color: #eb577e; }
.sub-label { margin: 12px 0 8px; font-size: 11.5px; font-weight: 700; color: var(--muted); }
.segmented-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seg-btn { min-height: 36px; border-radius: 12px; border: 1px solid var(--tile-border); background: var(--tile); font-size: 12px; font-weight: 700; }
.seg-btn[aria-pressed="true"] { background: var(--cta-grad); color: var(--cta-ink); border-color: transparent; }

.modal-actions { margin-top: 20px; display: grid; gap: 10px; }
.full-btn { width: 100%; min-height: 46px; }

.win-inner { text-align: center; }
.podium-list { margin-top: 16px; display: grid; gap: 8px; text-align: left; }
.help-body { margin-top: 14px; font-size: 13.5px; line-height: 1.65; color: var(--muted); }
.help-body ul { padding-left: 18px; display: grid; gap: 8px; }
.help-body strong { color: var(--text); }

/* Confetti */
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti-piece { position: absolute; top: -14px; width: 10px; height: 14px; border-radius: 3px; animation: confetti-fall 2s ease forwards; }
@keyframes confetti-fall { 0% { transform: translateY(0) rotate(0); opacity: 1; } 100% { transform: translateY(105vh) rotate(540deg); opacity: 0; } }

@media (max-width: 920px) {
  .play-layout { grid-template-columns: minmax(0, 580px); }
}
@media (max-width: 540px) {
  .seats-grid, .choice-grid, .realm-cards-grid { grid-template-columns: 1fr; }
}


/* === POLAR-POLYGON SVG BOARD (4P, 5P, 6P, 8P) === */
.ludo-svg {
  width: 100%;
  height: 100%;
  display: block;
  fill: var(--text);
  stroke: none;
}

.ludo-svg text,
.shape-svg text {
  stroke: none;
}

.shape-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.token.size-compact {
  width: 4.5%;
  height: 4.5%;
}

.token.size-mega {
  width: 3.6%;
  height: 3.6%;
  border-width: 2px;
}

@media (max-width: 540px) {
  .shape-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}


/* === FLUSH-SQUARE N-GON BOARD & GLOSSY 3D PAWNS === */
:root {
  --tile-surface: #231a42;
  --tile-grid: rgba(255, 255, 255, 0.22);
}

html[data-realm="velvet"] { --tile-surface: #301740; }
html[data-realm="arcade"] { --tile-surface: #132854; }
html[data-realm="oasis"] { --tile-surface: #133d33; }
html[data-realm="courtyard"],
html[data-realm="porcelain"] {
  --tile-surface: #fffdf7;
  --tile-grid: rgba(28, 18, 41, 0.22);
}
html[data-realm="porcelain"] {
  --tile-surface: #ffffff;
  --tile-grid: rgba(15, 23, 42, 0.2);
}

.shape-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.shape-icon-btn {
  padding: 6px;
  border-radius: 16px;
  border: 1.5px solid var(--tile-border);
  background: var(--tile);
  color: var(--muted);
  display: grid;
  place-items: center;
  transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.16s ease, color 0.16s ease, background 0.16s ease;
}

.shape-icon-btn:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  color: var(--text);
}

.shape-icon-btn[aria-pressed="true"] {
  border-color: var(--accent);
  background: rgba(255, 208, 117, 0.18);
  color: var(--accent);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
}

.shape-svg {
  width: 52px;
  height: 52px;
  display: block;
}

/* Glossy 3D Pawn Tokens */
.token {
  background: radial-gradient(circle at 32% 28%, #ffffff 0%, var(--tok-color) 36%, var(--tok-dark, #140b1f) 100%);
  box-shadow:
    0 6px 12px rgba(0, 0, 0, 0.52),
    inset 0 2px 3px rgba(255, 255, 255, 0.65),
    inset 0 -3px 5px rgba(0, 0, 0, 0.35);
}

.token::after {
  width: 34%;
  height: 34%;
  background: rgba(255, 255, 255, 0.8);
}

.token.is-hopping {
  transform: translate(-50%, -68%) scale(1.22);
  z-index: 15;
}

@media (max-width: 540px) {
  .shape-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
  }
  .shape-svg {
    width: 40px;
    height: 40px;
  }
}


/* === D12 EFFECT DIE & INTERACTIVE LUDO TUTORIAL === */
.effect-die-btn {
  width: 78px;
  height: 76px;
  flex: none;
  border-radius: 20px;
  border: 2px solid var(--tile-border);
  background: linear-gradient(145deg, #271a4a, #160e2c);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 4px;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.35);
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s ease, box-shadow 0.2s ease;
}

html[data-realm="courtyard"] .effect-die-btn {
  background: linear-gradient(145deg, #fff5e0, #f5e1bd);
}

.effect-die-btn.has-effect {
  border-color: var(--accent);
  box-shadow: 0 0 18px rgba(255, 208, 117, 0.42);
}

.effect-die-btn.rolling {
  animation: die-tumble 0.36s linear infinite;
}

.effect-die-btn:disabled { opacity: 0.58; cursor: not-allowed; }
.d12-tag { font-size: 9px; font-weight: 800; letter-spacing: 1.2px; color: var(--accent); }
.effect-die-btn strong { font-size: 24px; line-height: 1.05; }
.effect-die-btn small { font-size: 9px; font-weight: 700; color: var(--muted); white-space: nowrap; }

/* Interactive Tutorial */
.tut-progress { display: flex; gap: 6px; margin-bottom: 14px; }
.tut-dot { height: 5px; flex: 1; border-radius: 999px; background: var(--tile-border); }
.tut-dot.is-active { background: var(--accent); }
.tut-dot.is-done { background: #06b6d4; }
.tut-copy { margin: 10px 0 0; font-size: 13.5px; line-height: 1.6; color: var(--muted); }
.tut-sandbox { margin-top: 16px; padding: 18px; border-radius: 20px; border: 1px solid var(--tile-border); background: var(--bg); display: flex; flex-direction: column; align-items: center; gap: 14px; }
.tut-dice-pair { display: flex; gap: 14px; }
.tut-die-box { width: 92px; height: 84px; border-radius: 18px; border: 2px solid var(--tile-border); background: var(--tile); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.tut-die-box.is-d12 { border-color: var(--accent); }
.tut-die-box span { font-size: 9.5px; font-weight: 800; letter-spacing: 1px; color: var(--muted); }
.tut-die-box strong { font-family: "Bricolage Grotesque", sans-serif; font-size: 30px; }
.tut-track { display: grid; grid-template-columns: repeat(7, 42px); gap: 5px; }
.tut-sq { height: 42px; border-radius: 10px; border: 1px solid var(--tile-border); background: var(--tile); font-size: 18px; display: grid; place-items: center; }
.tut-sq.is-ladder { border-color: var(--accent); background: rgba(255, 208, 117, 0.2); }
.tut-sq.is-pawn { border: 2px solid #ffffff; }
.tut-capture-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; width: 100%; }
.tut-target { padding: 14px; border-radius: 16px; border: 1px solid var(--tile-border); background: var(--tile); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.tut-target span { font-size: 26px; }
.tut-target strong { font-size: 12.5px; }
.tut-target.is-blasted { border-color: #f43f5e; background: rgba(244, 63, 94, 0.2); }
.tut-target.is-blocked { border-color: #06b6d4; background: rgba(6, 182, 212, 0.2); }
.tut-feedback { margin: 0; font-size: 12.5px; font-weight: 700; color: var(--accent); text-align: center; }
.tut-list { margin: 0; padding-left: 18px; display: grid; gap: 8px; font-size: 13px; color: var(--muted); }
.tut-list strong { color: var(--text); }
.tut-nav { margin-top: 18px; display: flex; justify-content: space-between; gap: 10px; }


/* === TRUE DODECAHEDRON D12 & 3D TUMBLE-BOUNCE DICE ANIMATIONS === */
.dice-stage {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  perspective: 520px;
}

.die-pedestal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  position: relative;
}

.die-shadow {
  width: 54px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.55), transparent 72%);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.die-pedestal:has(.rolling) .die-shadow {
  transform: scale(0.62);
  opacity: 0.45;
}

.die-caption {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

/* Enhanced 3D-feel D6 Cube */
.die-btn {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  background: linear-gradient(145deg, #ffffff 0%, #f5eedf 65%, #e2d5be 100%);
  box-shadow:
    0 10px 22px rgba(0, 0, 0, 0.36),
    inset 0 2px 3px rgba(255, 255, 255, 0.95),
    inset 0 -5px 8px rgba(0, 0, 0, 0.16);
  transform-style: preserve-3d;
}

.die-face[data-val="1"] .pip {
  width: 16px;
  height: 16px;
  background: radial-gradient(circle at 35% 30%, #ff7a93, #e11d48);
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.35);
}

.die-face[data-val="6"] .pip {
  background: radial-gradient(circle at 35% 30%, #3b2a5a, #140b1f);
}

.die-btn.rolling {
  animation: d6-toss 0.48s cubic-bezier(0.36, 0.07, 0.19, 0.97) infinite;
}

.die-btn.landed {
  animation: die-land 0.42s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* True Faceted D12 Dodecahedron */
.d12-btn {
  position: relative;
  width: 78px;
  height: 78px;
  padding: 0;
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
  transform-style: preserve-3d;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.45));
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.2s ease;
}

.d12-btn:hover:not(:disabled) {
  transform: scale(1.07) rotate(6deg);
}

.d12-btn:disabled {
  opacity: 0.62;
  cursor: not-allowed;
}

.d12-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.d12-icon {
  position: absolute;
  font-size: 24px;
  line-height: 1;
  pointer-events: none;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
}

.d12-btn[data-effect="ladder"] { --d12-edge: #ffd075; filter: drop-shadow(0 0 16px rgba(255, 208, 117, 0.65)); }
.d12-btn[data-effect="snake"] { --d12-edge: #f43f5e; filter: drop-shadow(0 0 16px rgba(244, 63, 94, 0.65)); }
.d12-btn[data-effect="powerup"] { --d12-edge: #fb923c; filter: drop-shadow(0 0 16px rgba(251, 146, 60, 0.65)); }
.d12-btn[data-effect="swap"] { --d12-edge: #a855f7; filter: drop-shadow(0 0 16px rgba(168, 85, 247, 0.65)); }
.d12-btn[data-effect="shield"] { --d12-edge: #06b6d4; filter: drop-shadow(0 0 16px rgba(6, 182, 212, 0.65)); }
.d12-btn[data-effect="magnet"] { --d12-edge: #32d583; filter: drop-shadow(0 0 16px rgba(50, 213, 131, 0.65)); }

.d12-btn.has-effect .d12-face-poly {
  fill: rgba(255, 255, 255, 0.14);
}

.d12-btn.rolling {
  animation: d12-toss 0.52s cubic-bezier(0.36, 0.07, 0.19, 0.97) infinite;
}

.d12-btn.landed {
  animation: die-land 0.46s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes d6-toss {
  0%   { transform: translateY(0) rotateX(0deg) rotateY(0deg) rotateZ(0deg) scale(1); }
  25%  { transform: translateY(-16px) rotateX(140deg) rotateY(95deg) rotateZ(-22deg) scale(1.1); }
  50%  { transform: translateY(-20px) rotateX(260deg) rotateY(210deg) rotateZ(18deg) scale(1.12); }
  75%  { transform: translateY(-10px) rotateX(320deg) rotateY(300deg) rotateZ(-10deg) scale(1.06); }
  100% { transform: translateY(0) rotateX(360deg) rotateY(360deg) rotateZ(0deg) scale(1); }
}

@keyframes d12-toss {
  0%   { transform: translateY(0) rotateX(0deg) rotateY(0deg) rotateZ(0deg) scale(1); }
  25%  { transform: translateY(-18px) rotateX(-130deg) rotateY(120deg) rotateZ(35deg) scale(1.12); }
  50%  { transform: translateY(-22px) rotateX(-250deg) rotateY(240deg) rotateZ(-28deg) scale(1.14); }
  75%  { transform: translateY(-11px) rotateX(-330deg) rotateY(320deg) rotateZ(15deg) scale(1.07); }
  100% { transform: translateY(0) rotateX(-360deg) rotateY(360deg) rotateZ(0deg) scale(1); }
}

@keyframes die-land {
  0%   { transform: translateY(-8px) scale(1.14, 0.9); }
  35%  { transform: translateY(3px) scale(1.1, 0.88); }
  65%  { transform: translateY(-4px) scale(0.96, 1.06); }
  100% { transform: translateY(0) scale(1, 1); }
}


/* === EFFECT DIGEST BANNER & PACING === */
.effect-digest {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 24;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 18px;
  border: 2px solid var(--accent);
  background: rgba(16, 11, 32, 0.94);
  backdrop-filter: blur(8px);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.55);
  animation: digest-enter 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

html[data-realm="courtyard"] .effect-digest,
html[data-realm="porcelain"] .effect-digest {
  background: rgba(255, 252, 246, 0.96);
}

.digest-icon {
  font-size: 28px;
  line-height: 1;
  flex: none;
}

.digest-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.digest-copy strong {
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.4px;
  color: var(--accent);
}

.digest-copy span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

@keyframes digest-enter {
  0% { opacity: 0; transform: translate(-50%, -12px) scale(0.9); }
  100% { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

.pace-grid {
  grid-template-columns: repeat(3, 1fr);
}


/* === 3D CANVAS DICE BUTTONS === */
.canvas-die-btn {
  width: 88px;
  height: 88px;
  padding: 0;
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
  border-radius: 18px;
  transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.canvas-die-btn:hover:not(:disabled) {
  transform: scale(1.07);
}

.canvas-die-btn:disabled {
  opacity: 0.72;
  cursor: not-allowed;
}

.canvas-die-btn canvas {
  width: 88px;
  height: 88px;
  display: block;
}

.rule-select {
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--tile-border);
  background: var(--panel-solid);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
}


/* === LIVE-BOARD INTERACTIVE LUDO TUTORIAL === */
.tut-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 14px;
  padding-right: 34px;
}

.tut-tab {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--tile-border);
  background: var(--tile);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  transition: transform 0.14s ease, border-color 0.14s ease;
}

.tut-tab:hover { border-color: var(--accent); color: var(--text); }
.tut-tab.is-done { border-color: #32d583; color: #32d583; }
.tut-tab.is-active {
  background: var(--cta-grad);
  color: var(--cta-ink);
  border-color: transparent;
}

.tut-header-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}

.mini-replay {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--tile-border);
  background: var(--tile);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 800;
}

.mini-replay:hover { border-color: var(--accent); color: var(--text); }

.tut-live-stage {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.tut-board-shell {
  position: relative;
  width: min(100%, 340px);
  aspect-ratio: 1;
  padding: 6px;
  border-radius: 22px;
  border: 2px solid var(--tile-border);
  background: var(--panel-solid);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.45);
}

.tut-board-shell.shake {
  animation: board-shake 0.36s ease;
}

.tut-token {
  width: 6.8%;
  height: 6.8%;
}

.tut-action-bar {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.tut-feedback.is-complete {
  color: #32d583;
}


/* === BOARD-FIRST UX: HUGE BOARD, CENTER DUAL-DICE HUB, VERTICAL EMOTE RAIL & TURN CHIPS === */
.play-stage {
  max-width: 1020px;
  margin: 0 auto;
  padding: 0 clamp(12px, 2.5vw, 28px) 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* Sleek Compact Turn & Players Strip */
.turn-strip {
  width: 100%;
  max-width: 820px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.player-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.player-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--tile-border);
  background: var(--panel);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.player-chip.is-turn {
  border-color: var(--p-color);
  background: var(--panel-solid);
  color: var(--text);
  box-shadow: 0 0 14px color-mix(in srgb, var(--p-color) 40%, transparent);
  transform: translateY(-1px);
}

.player-chip.is-finished {
  opacity: 0.55;
}

.chip-name { font-weight: 800; }
.chip-score { font-size: 11px; opacity: 0.85; }

.chip-action {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--p-color);
  color: #120a1f;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

/* Board Arena + Vertical Emote Rail */
.board-arena {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
}

.board-arena .board-shell {
  width: min(86vw, calc(100dvh - 155px), 760px);
  max-width: 760px;
  flex: none;
  padding: 8px;
}

/* Center Dual-Dice Hub Inside the Board Crown! */
.center-dice-hub {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 24%;
  height: 24%;
  border-radius: 50%;
  pointer-events: auto;
}

.center-dice-hub.is-ready {
  animation: hub-pulse 1.6s ease-in-out infinite;
}

@keyframes hub-pulse {
  0%, 100% { filter: drop-shadow(0 0 6px var(--turn-color, #ffd075)); }
  50% { filter: drop-shadow(0 0 18px var(--turn-color, #ffd075)); }
}

.center-dice-pair {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
}

.center-die-btn {
  width: 48%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
  transition: transform 0.15s ease;
}

.center-die-btn:hover:not(:disabled) {
  transform: scale(1.1);
}

.center-die-btn:disabled {
  cursor: default;
}

.center-die-btn canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.center-roll-pill {
  margin-top: -6px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1.5px solid var(--turn-color, var(--accent));
  background: var(--panel-solid);
  color: var(--text);
  font-family: "Bricolage Grotesque", sans-serif;
  font-size: clamp(9px, 1.25vw, 12px);
  font-weight: 800;
  letter-spacing: 0.9px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  transition: transform 0.14s ease, background 0.14s ease;
}

.center-dice-hub.is-ready .center-roll-pill {
  background: var(--cta-grad);
  color: var(--cta-ink);
  border-color: transparent;
}

.center-roll-pill:disabled {
  opacity: 0.8;
  cursor: default;
}

/* Vertical Emote Rail Next to Board */
.emote-rail {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 8px;
  border-radius: 999px;
  border: 1px solid var(--tile-border);
  background: var(--panel);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.35);
}

.emote-rail .emote-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  font-size: 21px;
  display: grid;
  place-items: center;
}

.live-ticker {
  margin: 0;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  max-width: 760px;
}

@media (max-width: 720px) {
  .board-arena {
    flex-direction: column;
    gap: 10px;
  }
  .board-arena .board-shell {
    width: min(95vw, calc(100dvh - 205px));
  }
  .emote-rail {
    flex-direction: row;
    padding: 6px 10px;
  }
  .emote-rail .emote-btn {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }
}


/* === CAPTIVE PAWNS, TRAP TILES & RANSOM MODAL === */
.token.is-captive {
  border-style: dashed;
  border-color: #ffd075;
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.75), 0 6px 14px rgba(0, 0, 0, 0.55);
}

.token.is-retreating {
  z-index: 18;
  transform: translate(-50%, -50%) scale(0.86) rotate(-18deg);
  filter: drop-shadow(0 0 10px rgba(244, 63, 94, 0.75));
}

.token-ransom {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  padding: 1px 5px;
  border-radius: 999px;
  background: #140b1f;
  border: 1.5px solid #ffd075;
  color: #ffd075;
  font-family: "Bricolage Grotesque", sans-serif;
  font-size: 9.5px;
  font-weight: 800;
  white-space: nowrap;
  pointer-events: none;
}

.ransom-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.ransom-btn {
  min-height: 54px;
  border-radius: 16px;
  border: 2px solid var(--tile-border);
  background: var(--tile);
  font-family: "Bricolage Grotesque", sans-serif;
  font-size: 24px;
  font-weight: 800;
  color: var(--accent);
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.15s ease, background 0.15s ease;
}

.ransom-btn:hover {
  transform: translateY(-3px) scale(1.06);
  border-color: var(--accent);
  background: var(--cta-grad);
  color: var(--cta-ink);
}

.chip-bonus {
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 208, 117, 0.22);
  color: #ffd075;
  font-size: 10px;
  font-weight: 800;
}


/* === CLEANER READABLE PLAYER NAMES & SWAP PICKER === */
.player-chip {
  font-weight: 500;
}

.chip-name {
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.1px;
  color: var(--text);
}

.player-chip.is-turn .chip-name {
  font-weight: 600;
}

.player-chip:not(.is-turn) .chip-name {
  color: var(--text);
  opacity: 0.88;
}

.p-name {
  font-weight: 600;
}

.seat-name-input {
  font-weight: 500;
}

.swap-list {
  margin-top: 16px;
  display: grid;
  gap: 8px;
  text-align: left;
}

.swap-choice-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  border-radius: 14px;
  border: 1.5px solid var(--tile-border);
  background: var(--tile);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.swap-choice-btn:hover {
  transform: translateY(-2px);
  border-color: #a855f7;
  background: rgba(168, 85, 247, 0.18);
}

.swap-pct {
  margin-left: auto;
  font-size: 12px;
  color: var(--accent);
  font-weight: 700;
}

.token.is-swapping {
  z-index: 20;
  transform: translate(-50%, -50%) scale(1.25);
  box-shadow: 0 0 0 4px #a855f7, 0 0 22px rgba(168, 85, 247, 0.85);
}


/* === DIRECT ON-BOARD TAP-TO-SWAP & SHOCKWAVE EFFECT RINGS === */
.token.is-swap-target {
  z-index: 22;
  cursor: pointer;
  animation: swap-target-pulse 0.85s ease-in-out infinite;
  box-shadow: 0 0 0 4px #a855f7, 0 0 18px rgba(168, 85, 247, 0.9);
}

.token.is-swap-skip {
  z-index: 22;
  cursor: pointer;
  box-shadow: 0 0 0 4px #ffffff, 0 0 14px rgba(255, 255, 255, 0.7);
}

@keyframes swap-target-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1.08); }
  50% { transform: translate(-50%, -58%) scale(1.26); }
}

.fx-ring {
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 4px solid var(--ring-color, #ffd075);
  transform: translate(-50%, -50%) scale(0.4);
  pointer-events: none;
  animation: fx-ring-burst 0.72s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fx-ring-burst {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(0.4); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(5.2); }
}


.swap-dest-glow {
  position: absolute;
  width: 6.2%;
  height: 6.2%;
  transform: translate(-50%, -50%);
  border-radius: 10px;
  background: color-mix(in srgb, var(--glow-color) 42%, transparent);
  border: 2.5px solid var(--glow-color);
  box-shadow: 0 0 18px var(--glow-color), inset 0 0 10px var(--glow-color);
  pointer-events: none;
  animation: swap-dest-pulse 0.7s ease-in-out infinite;
}

@keyframes swap-dest-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(0.95); opacity: 0.85; }
  50% { transform: translate(-50%, -50%) scale(1.16); opacity: 1; }
}


/* === FULL-HEIGHT MAXIMIZED BOARD & OFF-BOARD SIDE ANNOUNCER RAIL === */
.game-topbar {
  max-width: 1400px;
  padding: 8px clamp(12px, 2vw, 24px);
}

.back-pill, .top-pill {
  min-height: 34px;
  padding: 0 12px;
  font-size: 12.5px;
}

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

.title-cluster h1 {
  font-size: 21px;
}

.title-sub {
  font-weight: 600;
  font-size: 0.78em;
  color: var(--accent);
  letter-spacing: 0.2px;
}

.play-stage {
  max-width: 1400px;
  padding: 0 clamp(10px, 2vw, 22px) 10px;
  gap: 0;
}

.board-arena {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
}

/* Left HUD Rail: Players + Permanent Off-Board Effect Announcer */
.hud-rail {
  width: 240px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: 22px;
  border: 1px solid var(--tile-border);
  background: var(--panel);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.34);
}

.rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.hud-rail .rules-tag {
  margin-left: 0;
  font-size: 10px;
  padding: 2px 7px;
}

.hud-rail .player-chips {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hud-rail .player-chip {
  width: 100%;
  justify-content: flex-start;
  padding: 6px 10px;
}

.hud-rail .chip-score {
  margin-left: auto;
}

/* Off-Board Announcer Slot (NEVER overlaps the board!) */
.announcer-slot {
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--tile-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 92px;
}

.hud-rail .effect-digest {
  position: static;
  transform: none;
  max-width: none;
  width: 100%;
  padding: 10px 11px;
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  animation: rail-digest-pop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes rail-digest-pop {
  0% { opacity: 0; transform: scale(0.92); }
  100% { opacity: 1; transform: scale(1); }
}

.hud-rail .digest-icon { font-size: 24px; }
.hud-rail .digest-copy strong { font-size: 13px; }
.hud-rail .digest-copy span { font-size: 11.5px; line-height: 1.35; }

.hud-rail .live-ticker {
  text-align: left;
  font-size: 11.5px;
  line-height: 1.45;
}

/* GIANT Board — fills almost the entire viewport height with a lush ornate tabletop mat! */
.board-arena .board-shell {
  width: min(calc(100vw - 340px), calc(100dvh - 64px), 920px);
  max-width: 920px;
  padding: 10px;
  border-radius: 28px;
  border: 2px solid color-mix(in srgb, var(--accent) 46%, var(--tile-border));
  background:
    radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--accent) 18%, transparent) 0%, transparent 65%),
    radial-gradient(circle at 0% 0%, color-mix(in srgb, var(--aura-a) 26%, transparent) 0%, transparent 45%),
    radial-gradient(circle at 100% 0%, color-mix(in srgb, var(--aura-b) 24%, transparent) 0%, transparent 45%),
    radial-gradient(circle at 100% 100%, color-mix(in srgb, var(--aura-c) 24%, transparent) 0%, transparent 45%),
    radial-gradient(circle at 0% 100%, color-mix(in srgb, var(--aura-a) 20%, transparent) 0%, transparent 45%),
    repeating-linear-gradient(45deg, color-mix(in srgb, var(--accent) 7%, transparent) 0 1px, transparent 1px 18px),
    repeating-linear-gradient(-45deg, color-mix(in srgb, var(--accent) 7%, transparent) 0 1px, transparent 1px 18px),
    var(--panel);
  box-shadow:
    inset 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent),
    inset 0 0 36px color-mix(in srgb, var(--accent) 12%, transparent),
    0 26px 56px rgba(0, 0, 0, 0.36);
}

html[data-realm="courtyard"] .board-arena .board-shell,
html[data-realm="porcelain"] .board-arena .board-shell {
  background:
    radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--accent) 12%, transparent) 0%, transparent 66%),
    radial-gradient(circle at 0% 0%, color-mix(in srgb, var(--aura-a) 22%, transparent) 0%, transparent 48%),
    radial-gradient(circle at 100% 0%, color-mix(in srgb, var(--aura-b) 18%, transparent) 0%, transparent 48%),
    radial-gradient(circle at 100% 100%, color-mix(in srgb, var(--aura-c) 20%, transparent) 0%, transparent 48%),
    radial-gradient(circle at 0% 100%, color-mix(in srgb, var(--aura-a) 16%, transparent) 0%, transparent 48%),
    repeating-linear-gradient(45deg, color-mix(in srgb, var(--accent) 8%, transparent) 0 1px, transparent 1px 18px),
    repeating-linear-gradient(-45deg, color-mix(in srgb, var(--accent) 8%, transparent) 0 1px, transparent 1px 18px),
    linear-gradient(145deg, var(--tile), var(--bg));
}

@media (max-width: 960px) {
  .board-arena {
    flex-direction: column;
    gap: 8px;
  }
  .hud-rail {
    width: 100%;
    max-width: 680px;
    padding: 8px 12px;
  }
  .hud-rail .player-chips {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .hud-rail .player-chip {
    width: auto;
  }
  .announcer-slot {
    min-height: 0;
    padding-top: 6px;
  }
  .board-arena .board-shell {
    width: min(96vw, calc(100dvh - 210px));
    max-width: 680px;
  }
  .emote-rail {
    flex-direction: row;
    padding: 6px 10px;
  }
}

/* Single D6 centered cleanly when 12-Face Effect Die is turned off */
.center-dice-hub.single-die .center-die-btn {
  width: 66%;
}

/* White board-marking symbol centered on pawn (replaces white dot when standing on a marked tile!) */
.token.has-mark::after {
  display: none;
}

.token-mark {
  width: 62%;
  height: 62%;
  display: grid;
  place-items: center;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.55));
}

.token-mark svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* === EXTENSIVE HOW TO PLAY (INTERACTIVE DRILLS + COMPLETE RULEBOOK) === */
.modal-wide {
  width: min(740px, calc(100% - 24px));
}

.help-mode-bar {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 14px;
  padding-right: 40px;
}

.help-mode-btn {
  padding: 9px 14px;
  border-radius: 14px;
  border: 1.5px solid var(--tile-border);
  background: var(--tile);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.help-mode-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.help-mode-btn.is-active {
  background: var(--cta-grad);
  color: var(--cta-ink);
  border-color: transparent;
  font-weight: 700;
}

.guide-main-title {
  margin: 0 0 12px;
  font-size: 24px;
}

.guide-block {
  margin-top: 12px;
  display: grid;
  gap: 12px;
}

.guide-block h3 {
  margin: 0;
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.guide-block > p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--muted);
}

.guide-block strong {
  color: var(--text);
  font-weight: 600;
}

.guide-block kbd,
.guide-block code {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--tile);
  border: 1px solid var(--tile-border);
  font-size: 11.5px;
  color: var(--accent);
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.guide-card {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--tile-border);
  background: var(--tile);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.guide-card strong {
  font-size: 13.5px;
  color: var(--text);
}

.guide-card p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}

.guide-steps {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 9px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

.guide-split {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.guide-subhead {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.guide-subhead.is-boon { color: #32d583; }
.guide-subhead.is-bane { color: #f43f5e; }

.guide-face-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 7px;
}

.guide-face-list li {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--tile-border);
  background: var(--tile);
}

.gf-icon {
  font-size: 19px;
  line-height: 1.1;
  flex: none;
}

.guide-face-list strong {
  display: block;
  font-size: 12.5px;
  color: var(--text);
}

.guide-face-list small {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--muted);
}

.guide-note {
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid var(--tile-border);
  background: var(--tile);
  font-size: 12.5px;
}

@media (max-width: 620px) {
  .guide-grid,
  .guide-split {
    grid-template-columns: 1fr;
  }
}

/* Real Clickable Pip Die Hub centered right inside the Tutorial Mini-Board */
.tut-center-hub {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 16;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.tut-dice-cluster {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.tut-pip-die {
  width: 38px;
  height: 38px;
  padding: 6px;
  border-radius: 10px;
  border: 1.5px solid rgba(20, 11, 31, 0.2);
  background: linear-gradient(145deg, #ffffff 0%, #f5eedf 68%, #e0d2b8 100%);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.45), inset 0 -2px 3px rgba(0, 0, 0, 0.14);
  display: grid;
  place-items: center;
  transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
}

.tut-center-hub.is-ready .tut-pip-die {
  cursor: pointer;
  animation: tut-die-ready 1.4s ease-in-out infinite;
  box-shadow: 0 0 0 3px var(--accent), 0 8px 18px rgba(0, 0, 0, 0.5);
}

.tut-pip-die:disabled {
  cursor: default;
}

.tut-die-face {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  place-items: center;
}

.tut-pip {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: transparent;
}

.tut-pip.on {
  background: #140b1f;
}

.tut-die-face[data-val="1"] .tut-pip.on {
  width: 8px;
  height: 8px;
  background: #e11d48;
}

.tut-d12-gem {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1.5px solid var(--accent);
  background: linear-gradient(145deg, #32215c, #190f33);
  color: #ffffff;
  font-size: 16px;
  display: grid;
  place-items: center;
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.45);
}

.tut-tap-tag {
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #140b1f;
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.9px;
  pointer-events: none;
}

.tut-center-hub:not(.is-ready) .tut-tap-tag {
  display: none;
}

.tut-pip-die.is-rolling,
.tut-d12-gem.is-rolling {
  animation: tut-die-spin 0.24s linear infinite;
}

.tut-pip-die.is-landed,
.tut-d12-gem.is-landed {
  animation: tut-die-pop 0.34s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes tut-die-ready {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

@keyframes tut-die-spin {
  0% { transform: rotate(0deg) scale(1.08); }
  50% { transform: rotate(180deg) scale(0.92); }
  100% { transform: rotate(360deg) scale(1.08); }
}

@keyframes tut-die-pop {
  0% { transform: scale(1.26); }
  100% { transform: scale(1); }
}

.tut-callout {
  font-size: 12px;
  padding: 4px 10px;
}

/* === NEW MATCH NUMBERED BASE LABELS === */
.seat-pos-cluster {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.seat-num-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--p-color);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.seat-pos-label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
}

/* Sticky Footers inside New Match & Settings Dialogs */
#setup-dialog .modal-actions,
#settings-dialog .modal-actions {
  position: sticky;
  bottom: 0;
  z-index: 10;
  margin: 20px -24px -24px;
  padding: 14px 24px 18px;
  background: var(--panel-solid);
  border-top: 1px solid var(--tile-border);
  box-shadow: 0 -10px 24px rgba(0, 0, 0, 0.32);
}

/* Unified Reference Section Directly Below Ludo Practice Board */
.tut-ref-section {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--tile-border);
  display: grid;
  gap: 18px;
}

.tut-practice-note {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
}

.ref-group {
  display: grid;
  gap: 10px;
}

.ref-group h3 {
  margin: 0;
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-size: 16.5px;
  font-weight: 700;
  color: var(--text);
}

.ref-lead {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}
