:root{
  --active-color:#7c5cff;
  --active-dark:#34207b;
  --active-glow:rgba(124,92,255,.34);
  --luna-color:#1388e5;
  --luna-dark:#07579d;
  --luna-glow:rgba(19,136,229,.34);
  --bg0:#070b12;
  --bg1:#101a28;
  --panel:rgba(18,25,37,.78);
  --panelSolid:rgba(18,25,37,.96);
  --line:rgba(255,255,255,.15);
  --line2:rgba(255,255,255,.28);
  --text:#f7f3e8;
  --muted:#b9b4aa;
  --shadow:0 28px 88px rgba(0,0,0,.42);
  --red:#ef2f2a;
  --blue:#1388e5;
  --yellow:#f5bd12;
  --green:#55ad32;
  color-scheme:dark;
}
[data-theme="light"]{
  --bg0:#f5f7fb;
  --bg1:#e3edf7;
  --panel:rgba(255,255,255,.80);
  --panelSolid:rgba(255,255,255,.96);
  --line:rgba(15,23,42,.14);
  --line2:rgba(15,23,42,.26);
  --text:#172033;
  --muted:#667085;
  --shadow:0 28px 74px rgba(65,84,113,.18);
  color-scheme:light;
}
*{box-sizing:border-box}
html,body{margin:0;min-height:100%}
body{
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  color:var(--text);
  background:
    radial-gradient(circle at 15% 12%, rgba(19,136,229,.33), transparent 30%),
    radial-gradient(circle at 86% 16%, rgba(239,47,42,.24), transparent 28%),
    radial-gradient(circle at 50% 115%, rgba(245,189,18,.18), transparent 42%),
    linear-gradient(135deg,var(--bg0),var(--bg1));
  overflow:hidden;
}
body::before{
  content:"";
  position:fixed;
  inset:0;
  pointer-events:none;
  background:
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size:42px 42px;
  mask-image:radial-gradient(circle at 50% 50%,#000 44%,transparent 90%);
}
button{font:inherit}
.panel{
  border:1px solid var(--line);
  background:var(--panel);
  box-shadow:var(--shadow);
  backdrop-filter:blur(18px) saturate(1.18);
  border-radius:24px;
}
.app{
  height:100dvh;
  display:grid;
  grid-template-rows:auto minmax(0,1fr);
  gap:16px;
  padding:16px;
}
.top{
  min-height:82px;
  padding:14px 16px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
}
.brand{display:flex;align-items:center;gap:13px;min-width:0}
.brand-mark{
  width:54px;height:54px;border-radius:16px;
  background:
    radial-gradient(circle at 34% 28%, #fff, transparent 15%),
    conic-gradient(from 40deg,var(--red),var(--yellow),var(--green),var(--blue),var(--red));
  box-shadow:0 0 34px rgba(19,136,229,.28),0 0 28px rgba(239,47,42,.18);
  transform:rotate(-8deg);
}
h1{
  margin:0;
  font-family:"Trebuchet MS","Arial Black",system-ui,sans-serif;
  font-size:clamp(24px,2.4vw,38px);
  line-height:.95;
  text-transform:uppercase;
  letter-spacing:.04em;
}
.brand p{margin:6px 0 0;color:var(--muted);font-size:13px}
.top-actions{display:flex;gap:10px;flex-wrap:wrap;justify-content:flex-end}
.layout{
  min-height:0;
  display:grid;
  grid-template-columns:minmax(255px,330px) minmax(520px,1fr) minmax(260px,330px);
  gap:16px;
}
.side,.score{
  min-height:0;
  padding:14px;
  display:flex;
  flex-direction:column;
  gap:14px;
  overflow:hidden;
}
.board-stage{
  position:relative;
  min-height:0;
  display:grid;
  place-items:center;
  padding:12px;
  overflow:hidden;
}
#boardCanvas{
  width:min(100%,calc(100dvh - 130px));
  height:min(100%,calc(100dvh - 130px));
  max-width:100%;
  max-height:100%;
  aspect-ratio:1;
  cursor:pointer;
  touch-action:manipulation;
}
.btn{
  border:0;
  min-height:44px;
  padding:11px 15px;
  border-radius:16px;
  color:white;
  font-weight:900;
  letter-spacing:.025em;
  text-transform:uppercase;
  cursor:pointer;
  transition:transform .12s ease,filter .12s ease,opacity .12s ease;
}
.btn:hover{transform:translateY(-1px);filter:brightness(1.05) saturate(1.08)}
.btn:active{transform:translateY(1px) scale(.99)}
.btn:disabled{opacity:.45;cursor:not-allowed;transform:none;filter:grayscale(.2)}
.primary{background:linear-gradient(135deg,#ff3d7f,#7c5cff);box-shadow:0 14px 30px rgba(255,61,127,.20),inset 0 1px 0 rgba(255,255,255,.30)}
.roll{width:100%;background:linear-gradient(135deg,#f97316,#ef4444);box-shadow:0 14px 30px rgba(249,115,22,.18),inset 0 1px 0 rgba(255,255,255,.30)}
.ghost{color:var(--text);background:rgba(255,255,255,.07);border:1px solid var(--line);box-shadow:none}
.announcer{
  display:grid;
  grid-template-columns:84px 1fr;
  gap:13px;
  align-items:center;
  padding:13px;
  border-radius:20px;
  border:1px solid var(--line);
  background:linear-gradient(135deg,rgba(19,136,229,.14),rgba(239,47,42,.10)),rgba(255,255,255,.07);
}
.announcer h2,.validation-card h2,.section-title{
  margin:0 0 9px;
  font-family:"Trebuchet MS","Arial Black",system-ui,sans-serif;
  text-transform:uppercase;
  letter-spacing:.04em;
  font-size:16px;
}
.announcer p{margin:0;color:var(--muted);font-size:12.5px;line-height:1.38}
.announcer-avatar{
  width:84px;
  height:112px;
  border-radius:26px;
  object-fit:cover;
  object-position:center top;
  border:1px solid rgba(255,255,255,.28);
  background:#15263d;
  box-shadow:0 0 20px rgba(46,233,255,.22),0 14px 24px rgba(0,0,0,.20);
}
.turn-card,.validation-card{
  display:grid;
  gap:12px;
  padding:14px;
  border-radius:20px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.07);
}
.turn-row{display:flex;justify-content:space-between;gap:10px;color:var(--muted)}
.turn-row strong{color:var(--text)}
.dice{
  width:94px;height:94px;margin:0 auto;
  display:grid;place-items:center;
  border-radius:26px;
  border:2px solid var(--line2);
  background:radial-gradient(circle at 30% 26%,rgba(255,255,255,.36),transparent 23%),linear-gradient(135deg,rgba(255,255,255,.16),rgba(255,255,255,.04));
  box-shadow:inset 0 0 24px rgba(255,255,255,.08),0 0 34px rgba(19,136,229,.16);
  font:1000 46px/1 "Trebuchet MS","Arial Black",system-ui,sans-serif;
}
.dice.rolling{animation:diceShake .08s linear infinite alternate}
@keyframes diceShake{from{transform:rotate(-6deg) scale(1.01)}to{transform:rotate(6deg) scale(.99)}}
.hint{min-height:38px;margin:0;color:var(--muted);font-size:13px;line-height:1.38;text-align:center}
.token-buttons{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:9px}
.token-buttons .btn{min-height:42px;padding-inline:8px;border-radius:14px;font-size:12px}
.players-list{display:grid;gap:10px}
.player-card{
  border-radius:18px;
  padding:12px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.07);
  position:relative;
  overflow:hidden;
}
.player-card.active{outline:2px solid currentColor}
.player-card::after{
  content:"";
  position:absolute;right:-28px;top:-28px;width:82px;height:82px;border-radius:50%;
  background:currentColor;opacity:.15;
}
.player-head{display:flex;justify-content:space-between;gap:10px;font-size:13px;font-weight:1000;text-transform:uppercase}
.progress{height:8px;margin-top:10px;border-radius:999px;background:rgba(255,255,255,.12);overflow:hidden}
.progress span{display:block;height:100%;width:var(--pct,0%);background:currentColor;box-shadow:0 0 14px currentColor;transition:width .25s ease}
.meta{margin-top:8px;color:var(--muted);font-size:12px;line-height:1.35}
.log-section{min-height:0;display:flex;flex-direction:column;flex:1}
.log{
  min-height:140px;flex:1;overflow:auto;
  padding:11px;border-radius:18px;border:1px solid var(--line);
  background:rgba(0,0,0,.16);
}
.log p{margin:0 0 8px;color:var(--muted);font-size:12px;line-height:1.36}
.log b{color:var(--text)}
.validation-ok,.validation-fail{font-size:12px;line-height:1.35;margin:0 0 5px}
.validation-ok{color:#67e8a3}
.validation-fail{color:#fb7185}
.toast{
  position:absolute;left:20px;right:20px;bottom:20px;
  pointer-events:none;
  display:flex;gap:12px;justify-content:space-between;align-items:center;
  padding:13px 15px;border-radius:18px;color:#fff;
  border:1px solid rgba(255,255,255,.18);
  background:rgba(0,0,0,.36);backdrop-filter:blur(10px);
  transform:translateY(130%);opacity:0;transition:.24s ease;
}
.toast.visible{transform:translateY(0);opacity:1}
.toast strong{font-family:"Trebuchet MS","Arial Black",system-ui,sans-serif;text-transform:uppercase;letter-spacing:.04em}
.modal{
  position:fixed;inset:0;display:none;place-items:center;
  padding:20px;background:rgba(3,7,18,.72);backdrop-filter:blur(12px);
  z-index:20;
}
.modal.show{display:grid}
.modal-panel{
  width:min(640px,100%);
  padding:24px;
  text-align:center;
  background:var(--panelSolid);
}
.modal-panel h2{
  margin:0 0 8px;
  font-family:"Trebuchet MS","Arial Black",system-ui,sans-serif;
  text-transform:uppercase;
  font-size:clamp(28px,4vw,46px);
  line-height:.96;
}
.modal-panel p{margin:0;color:var(--muted);line-height:1.45}
.small-note{margin-top:15px!important;font-size:12px}
.color-picker{display:grid;grid-template-columns:repeat(4,1fr);gap:12px;margin:20px 0 10px}
.color-choice{
  border:1px solid var(--line);
  min-height:132px;
  border-radius:22px;
  background:linear-gradient(135deg,rgba(255,255,255,.18),rgba(255,255,255,.035)),var(--choice);
  color:white;
  font-weight:1000;
  cursor:pointer;
  position:relative;
  overflow:hidden;
  display:grid;
  place-items:end center;
  padding:12px;
  text-transform:uppercase;
  text-shadow:0 1px 2px rgba(0,0,0,.48);
}
.color-choice::before{
  content:"";
  position:absolute;top:24px;left:50%;transform:translateX(-50%);
  width:64px;height:64px;border-radius:50%;
  background:radial-gradient(circle at 32% 24%,#fff,transparent 20%),var(--choice);
  border:8px solid rgba(255,255,255,.28);
  box-shadow:0 8px 18px rgba(0,0,0,.30),inset 0 -8px 0 rgba(0,0,0,.18);
}
.color-choice span{position:relative;z-index:1}
@media(max-width:1180px){
  body{overflow:auto}
  .app{height:auto;min-height:100dvh;padding:12px;gap:12px}
  .top{flex-direction:column;align-items:stretch}
  .layout{grid-template-columns:1fr;gap:12px}
  .board-stage{order:-1;min-height:72dvh}
  #boardCanvas{width:min(100%,96dvw);height:auto;max-height:78dvh}
  .side,.score{overflow:visible}
  .score{min-height:340px}
}
@media(max-width:620px){
  .app{padding:8px;gap:10px}
  .panel{border-radius:18px}
  .top-actions{display:grid;grid-template-columns:1fr;width:100%}
  .announcer{grid-template-columns:64px 1fr}
  .announcer-avatar{width:64px;height:86px}
  .color-picker{grid-template-columns:repeat(2,1fr)}
  .color-choice{min-height:112px}
}


/* v6: modo tablero para jugar/revisar con máximo espacio sin perder producción. */
body.board-focus .layout{
  grid-template-columns:minmax(0,1fr);
}
body.board-focus .side,
body.board-focus .score{
  display:none;
}
body.board-focus .board-stage{
  min-height:calc(100dvh - 122px);
}
body.board-focus #boardCanvas{
  width:min(100%,calc(100dvh - 130px));
  height:min(100%,calc(100dvh - 130px));
}
.validation-card{
  max-height:240px;
  overflow:auto;
}
.token-buttons .btn.exit-enabled{
  outline:2px solid rgba(255,255,255,.88);
  box-shadow:0 0 24px currentColor, inset 0 1px 0 rgba(255,255,255,.35);
}
@media(max-width:620px){
  .announcer-avatar{
    width:64px;
    height:86px;
    border-radius:20px;
  }
}


/* v8: salida con 5 reforzada y UX de producción */
.exit-chooser{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:9px;
  padding:10px;
  border-radius:18px;
  border:1px solid rgba(255,255,255,.24);
  background:
    radial-gradient(circle at 30% 0%, rgba(255,255,255,.20), transparent 42%),
    linear-gradient(135deg, rgba(245,189,18,.22), rgba(255,61,127,.14));
  box-shadow:0 0 24px rgba(245,189,18,.16), inset 0 1px 0 rgba(255,255,255,.22);
}
.exit-chooser[hidden]{display:none}
.exit-chooser__title{
  grid-column:1/-1;
  margin:0 0 2px;
  color:var(--text);
  font:900 12px/1.2 "Trebuchet MS","Arial Black",system-ui,sans-serif;
  text-transform:uppercase;
  letter-spacing:.04em;
}
.exit-chooser .btn{
  min-height:42px;
  padding:9px 10px;
  border-radius:14px;
  background:linear-gradient(135deg,#f5bd12,#ff3d7f);
  box-shadow:0 0 18px rgba(245,189,18,.20), inset 0 1px 0 rgba(255,255,255,.38);
}
.token-buttons .btn.exit-enabled{
  outline:2px solid rgba(255,255,255,.92);
  box-shadow:0 0 24px currentColor, inset 0 1px 0 rgba(255,255,255,.35);
}
.pulse-strong{
  animation:pulseStrong .78s ease-in-out infinite alternate;
}
@keyframes pulseStrong{
  from{filter:brightness(1) saturate(1)}
  to{filter:brightness(1.18) saturate(1.25)}
}


/* v9: Luna Arcade sprite + tablero más ancho/real */
.luna-sprite-dock{
  position:fixed;
  right:clamp(10px,2vw,26px);
  bottom:clamp(10px,2vw,26px);
  width:min(430px,calc(100vw - 20px));
  display:grid;
  grid-template-columns:124px 1fr;
  align-items:end;
  gap:12px;
  padding:12px 14px;
  border-radius:26px;
  border:1px solid rgba(76,238,255,.58);
  color:#fff;
  background:
    radial-gradient(circle at 20% 0%, rgba(255,255,255,.18), transparent 42%),
    linear-gradient(135deg, rgba(9,11,28,.90), rgba(22,28,52,.82));
  box-shadow:0 0 28px rgba(34,231,255,.24),0 0 52px rgba(255,79,227,.18);
  backdrop-filter:blur(16px);
  z-index:80;
  transform:translateY(130%);
  opacity:0;
  pointer-events:none;
  transition:transform .34s cubic-bezier(.2,.85,.2,1.15),opacity .24s ease;
}
.luna-sprite-dock.is-visible{
  transform:translateY(0);
  opacity:1;
}
.luna-sprite-dock[data-priority="epic"],
.luna-sprite-dock[data-priority="high"]{
  animation:lunaPop .68s ease both;
}
.luna-sprite-wrap{
  width:124px;
  height:150px;
  display:grid;
  align-items:end;
  justify-items:center;
  overflow:visible;
  filter:drop-shadow(0 12px 16px rgba(0,0,0,.45));
}
.luna-sprite-canvas{
  width:124px;
  height:150px;
  object-fit:contain;
}
.luna-speech{
  min-width:0;
  position:relative;
  padding:14px 15px;
  border-radius:20px;
  border:1px solid rgba(255,255,255,.18);
  background:
    linear-gradient(135deg, rgba(255,255,255,.13), rgba(255,255,255,.04)),
    rgba(0,0,0,.24);
}
.luna-speech::before{
  content:"";
  position:absolute;
  left:-9px;
  bottom:28px;
  width:18px;
  height:18px;
  transform:rotate(45deg);
  background:rgba(255,255,255,.08);
  border-left:1px solid rgba(255,255,255,.16);
  border-bottom:1px solid rgba(255,255,255,.16);
}
.luna-kicker{
  margin-bottom:5px;
  color:rgba(255,255,255,.76);
  font:900 11px/1.1 system-ui,sans-serif;
  letter-spacing:.16em;
  text-transform:uppercase;
}
.luna-text{
  font:1000 clamp(15px,2vw,20px)/1.14 system-ui,sans-serif;
  text-shadow:0 2px 0 rgba(0,0,0,.35);
}
@keyframes lunaPop{
  0%{filter:saturate(1);transform:translateY(0) scale(.98)}
  45%{filter:saturate(1.35);transform:translateY(0) scale(1.035)}
  100%{filter:saturate(1);transform:translateY(0) scale(1)}
}
@media(max-width:720px){
  .luna-sprite-dock{
    left:8px;
    right:8px;
    bottom:8px;
    width:auto;
    grid-template-columns:82px 1fr;
    padding:9px 10px;
    border-radius:20px;
  }
  .luna-sprite-wrap{
    width:82px;
    height:104px;
  }
  .luna-sprite-canvas{
    width:82px;
    height:104px;
  }
  .luna-speech{
    padding:11px 12px;
    border-radius:16px;
  }
  .luna-text{
    font-size:14px;
  }
}
@media(prefers-reduced-motion:reduce){
  .luna-sprite-dock,
  .luna-sprite-dock[data-priority="epic"],
  .luna-sprite-dock[data-priority="high"]{
    transition:opacity .1s linear;
    animation:none;
  }
}


/* v11 PRO: no duplicidad entre selector de salida y botones generales */
.token-buttons.is-hidden{
  display:none;
}
.exit-chooser{
  border-color:rgba(255,255,255,.16);
  background:
    radial-gradient(circle at 20% 0%, rgba(255,255,255,.18), transparent 40%),
    linear-gradient(135deg, rgba(249,115,22,.16), rgba(255,61,127,.18)),
    rgba(255,255,255,.04);
}
.exit-chooser__title{
  color:var(--text);
  opacity:.94;
}
.exit-chooser .btn{
  font-size:13px;
  letter-spacing:.03em;
}
.board-stage::before{
  content:"";
  position:absolute;
  inset:10px;
  border-radius:28px;
  pointer-events:none;
  background:
    radial-gradient(circle at 50% 50%, rgba(255,255,255,.05), transparent 52%),
    linear-gradient(135deg, rgba(255,255,255,.05), rgba(0,0,0,.10));
  box-shadow:inset 0 0 0 1px rgba(255,255,255,.10);
}


/* ============================================================
   v20: Modo selector, pips, estadísticas de victoria, sonido
   ============================================================ */

/* Mode selector in color picker */
.mode-selector {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  justify-content: center;
}

.mode-btn {
  flex: 1;
  max-width: 220px;
  font-size: 14px;
}

.mode-btn.active {
  background: linear-gradient(135deg, #7c5cff, #ff3d7f);
  box-shadow: 0 8px 20px rgba(124,92,255,.28);
}

/* Color grid */
.color-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.color-choice.sel {
  outline: 3px solid #fff;
  outline-offset: 2px;
  filter: brightness(1.10) saturate(1.18);
  transform: scale(1.04);
}

/* Start game button */
.start-game-btn {
  width: 100%;
  margin-top: 4px;
  font-size: 16px;
  padding: 14px 24px;
}

.start-game-btn:disabled {
  opacity: .42;
  cursor: not-allowed;
  transform: none;
  filter: grayscale(.3);
}

/* Round badge */
.round-badge {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  transition: color .2s;
}

/* Token pip display */
.player-pips {
  display: flex;
  gap: 6px;
  margin: 6px 0 4px;
}

.pip {
  font-size: 16px;
  line-height: 1;
  transition: transform .15s;
}

.pip-goal {
  color: gold;
  text-shadow: 0 0 8px rgba(255,200,0,.6);
}

.pip-home {
  opacity: .38;
}

.pip-track {
  filter: drop-shadow(0 0 4px currentColor);
}

/* Log color dots */
.log-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
  flex-shrink: 0;
}

/* Winner stats grid */
.winner-subtitle {
  display: block;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 16px;
}

.winner-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 14px 0;
}

.wstat {
  background: rgba(255,255,255,.07);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.wstat-v {
  font: 900 28px/1 "Trebuchet MS", "Arial Black", system-ui, sans-serif;
  color: var(--text);
}

.wstat-l {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}

.winner-board {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  text-align: left;
}

.wplayer {
  background: rgba(255,255,255,.05);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px;
  color: var(--c, var(--text));
}

.wp-label {
  font: 900 13px/1 system-ui, sans-serif;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.wp-meta {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 4px 0 6px;
}

.wbar {
  height: 6px;
  border-radius: 99px;
  background: rgba(255,255,255,.12);
  overflow: hidden;
}

.wbar span {
  display: block;
  height: 100%;
  background: var(--c, #fff);
  box-shadow: 0 0 8px var(--c, #fff);
  transition: width .4s ease;
}

/* Modal panel scrollable for longer stats */
.modal-panel {
  max-height: 90dvh;
  overflow-y: auto;
}

@media (max-width: 620px) {
  .winner-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .color-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .mode-selector {
    flex-direction: column;
    align-items: stretch;
  }
}


/* v21 UX clarity: active player color drives the HUD + Luna feedback */
.turn-card{
  position:relative;
  overflow:hidden;
  border-color:var(--active-color);
  background:
    radial-gradient(circle at 50% 0%, var(--active-glow), transparent 56%),
    linear-gradient(135deg, color-mix(in srgb, var(--active-color) 22%, transparent), rgba(255,255,255,.055)),
    rgba(255,255,255,.07);
  box-shadow:0 0 28px var(--active-glow), inset 0 1px 0 rgba(255,255,255,.18);
}
.turn-card::before{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  background:
    linear-gradient(90deg, transparent, color-mix(in srgb, var(--active-color) 26%, transparent), transparent);
  opacity:.32;
  transform:translateX(-100%);
  animation:activePanelSweep 4.2s ease-in-out infinite;
}
.turn-card > *{position:relative;z-index:1}
.turn-row strong{
  color:#fff;
  text-shadow:0 0 12px var(--active-color),0 1px 0 rgba(0,0,0,.5);
}
.dice{
  border-color:color-mix(in srgb, var(--active-color) 60%, white 20%);
  box-shadow:inset 0 0 24px rgba(255,255,255,.08),0 0 34px var(--active-glow);
}
.announcer{
  border-color:color-mix(in srgb, var(--active-color) 65%, white 18%);
  background:
    radial-gradient(circle at 10% 5%, var(--active-glow), transparent 48%),
    linear-gradient(135deg, color-mix(in srgb, var(--active-color) 18%, transparent), rgba(255,255,255,.06)),
    rgba(255,255,255,.07);
  box-shadow:0 0 22px var(--active-glow), inset 0 1px 0 rgba(255,255,255,.14);
}
.announcer-avatar{
  border-color:color-mix(in srgb, var(--active-color) 65%, white 24%);
  box-shadow:0 0 24px var(--active-glow),0 14px 24px rgba(0,0,0,.20);
}
.luna-sprite-dock{
  border-color:color-mix(in srgb, var(--luna-color) 68%, white 20%);
  background:
    radial-gradient(circle at 20% 0%, var(--luna-glow), transparent 42%),
    linear-gradient(135deg, color-mix(in srgb, var(--luna-dark) 56%, rgba(9,11,28,.90)), rgba(22,28,52,.82));
  box-shadow:0 0 28px var(--luna-glow),0 0 52px color-mix(in srgb, var(--luna-color) 38%, transparent);
}
.luna-speech{
  border-color:color-mix(in srgb, var(--luna-color) 42%, white 18%);
  background:
    radial-gradient(circle at 5% 0%, color-mix(in srgb, var(--luna-color) 22%, transparent), transparent 48%),
    linear-gradient(135deg, rgba(255,255,255,.13), rgba(255,255,255,.04)),
    rgba(0,0,0,.24);
}
@keyframes activePanelSweep{
  0%,72%{transform:translateX(-120%);opacity:0}
  82%{opacity:.34}
  100%{transform:translateX(120%);opacity:0}
}
@supports not (background: color-mix(in srgb, red 50%, transparent)){
  .turn-card,.announcer{border-color:var(--active-color)}
  .luna-sprite-dock{border-color:var(--luna-color)}
  .turn-card{background:linear-gradient(135deg, var(--active-glow), rgba(255,255,255,.07))}
  .announcer{background:linear-gradient(135deg, var(--active-glow), rgba(255,255,255,.07))}
}


/* v23 feedback policy: Luna has its own message color; HUD can advance turn without repainting old messages */
.luna-sprite-dock{
  --luna-color:#1388e5;
  --luna-dark:#07579d;
  --luna-glow:rgba(19,136,229,.34);
}
.luna-sprite-dock[data-color="red"]{
  --luna-color:#ef2f2a;
  --luna-dark:#9c1116;
  --luna-glow:rgba(239,47,42,.34);
}
.luna-sprite-dock[data-color="blue"]{
  --luna-color:#1388e5;
  --luna-dark:#07579d;
  --luna-glow:rgba(19,136,229,.34);
}
.luna-sprite-dock[data-color="yellow"]{
  --luna-color:#f5bd12;
  --luna-dark:#9f6b00;
  --luna-glow:rgba(245,189,18,.32);
}
.luna-sprite-dock[data-color="green"]{
  --luna-color:#55ad32;
  --luna-dark:#2f741d;
  --luna-glow:rgba(85,173,50,.34);
}


/* v24 bonus buttons */
.btn.bonus-enabled{
  position:relative;
  border:1px solid rgba(255,255,255,.35);
  box-shadow:0 0 18px var(--active-glow), inset 0 1px 0 rgba(255,255,255,.25);
}
.btn.bonus-enabled::after{
  content:"BONUS";
  position:absolute;
  right:8px;
  top:5px;
  font-size:8px;
  letter-spacing:.08em;
  opacity:.82;
}


/* v27: anime KO spotlight for human captures */
.luna-capture-spotlight{
  position:fixed;
  inset:0;
  display:grid;
  place-items:center;
  padding:max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  background:radial-gradient(circle at center, color-mix(in srgb, var(--luna-glow, rgba(19,136,229,.38)) 55%, transparent) 0%, rgba(6,10,18,.18) 25%, rgba(6,10,18,.74) 100%);
  opacity:0;
  visibility:hidden;
  pointer-events:none;
  transition:opacity .18s ease, visibility .18s ease;
  z-index:70;
}
.luna-capture-spotlight.show{opacity:1;visibility:visible}
.luna-capture-spotlight__panel{
  width:min(92vw, 900px);
  min-height:min(82vh, 640px);
  border-radius:28px;
  border:2px solid var(--luna-color, #1388e5);
  box-shadow:0 24px 60px rgba(0,0,0,.38), 0 0 0 1px rgba(255,255,255,.06) inset, 0 0 44px var(--luna-glow, rgba(19,136,229,.34));
  background:linear-gradient(180deg, color-mix(in srgb, var(--luna-glow, rgba(19,136,229,.34)) 24%, rgba(8,12,22,.96)) 0%, rgba(8,12,22,.94) 46%, rgba(8,12,22,.9) 100%);
  display:grid;
  grid-template-columns:minmax(220px, 1fr) minmax(280px, 1.1fr);
  align-items:end;
  gap:16px;
  padding:22px 22px 10px;
  transform:translateY(20px) scale(.96);
  transition:transform .18s ease;
  overflow:hidden;
}
.luna-capture-spotlight.show .luna-capture-spotlight__panel{transform:translateY(0) scale(1)}
.luna-capture-spotlight__copy{
  align-self:center;
  display:grid;
  gap:10px;
  padding:8px 6px 22px 6px;
}
.luna-capture-spotlight__kicker{
  font-weight:900;
  font-size:clamp(18px, 2.2vw, 30px);
  letter-spacing:.14em;
  text-transform:uppercase;
  color:var(--luna-color, #1388e5);
  text-shadow:0 0 18px var(--luna-glow, rgba(19,136,229,.34));
}
.luna-capture-spotlight__text{
  font-weight:900;
  line-height:1.05;
  font-size:clamp(28px, 4.3vw, 54px);
  color:#fff6ea;
  text-shadow:0 3px 14px rgba(0,0,0,.34);
}
.luna-capture-spotlight__canvas{
  width:min(100%, 420px);
  max-height:min(72vh, 520px);
  justify-self:end;
  align-self:end;
  filter:drop-shadow(0 18px 30px rgba(0,0,0,.4));
}
.luna-capture-spotlight[data-color="red"]{--luna-color:#ef2f2a;--luna-dark:#9c1116;--luna-glow:rgba(239,47,42,.36)}
.luna-capture-spotlight[data-color="blue"]{--luna-color:#1388e5;--luna-dark:#07579d;--luna-glow:rgba(19,136,229,.36)}
.luna-capture-spotlight[data-color="yellow"]{--luna-color:#f5bd12;--luna-dark:#9f6b00;--luna-glow:rgba(245,189,18,.34)}
.luna-capture-spotlight[data-color="green"]{--luna-color:#55ad32;--luna-dark:#2f741d;--luna-glow:rgba(85,173,50,.36)}
@media (max-width: 780px){
  .luna-capture-spotlight__panel{
    width:min(94vw, 560px);
    min-height:auto;
    grid-template-columns:1fr;
    justify-items:center;
    gap:8px;
    padding:18px 16px 8px;
  }
  .luna-capture-spotlight__copy{padding:6px 2px 0;text-align:center}
  .luna-capture-spotlight__canvas{justify-self:center;width:min(100%, 340px);max-height:42vh}
}


/* v30: four character announcers */
.announcer-avatar{
  border-color:var(--active-color);
  box-shadow:0 0 0 2px rgba(255,255,255,.08), 0 0 24px var(--active-glow);
  background:radial-gradient(circle at 50% 35%, rgba(255,255,255,.18), rgba(255,255,255,.02));
}
.announcer h2{
  color:var(--active-color);
  text-shadow:0 0 16px var(--active-glow);
}


/* v31: mobile-first production branding + PWA */
.visually-hidden{
  position:absolute!important;
  width:1px!important;
  height:1px!important;
  padding:0!important;
  margin:-1px!important;
  overflow:hidden!important;
  clip:rect(0,0,0,0)!important;
  white-space:nowrap!important;
  border:0!important;
}
.brand-logo{
  display:block;
  width:clamp(148px, 24vw, 260px);
  height:auto;
  max-height:72px;
  object-fit:contain;
  filter:drop-shadow(0 0 18px rgba(0,204,255,.25)) drop-shadow(0 0 20px rgba(255,59,166,.18));
}
.brand-copy{
  min-width:0;
  display:grid;
  align-content:center;
}
.install-btn[hidden]{display:none!important}
.noscript-warning{
  position:fixed;
  inset:auto 16px 16px;
  z-index:99;
  padding:12px 14px;
  border-radius:14px;
  background:#1b2233;
  color:#fff;
  border:1px solid rgba(255,255,255,.2);
}
@media (max-width: 760px){
  .app{
    gap:10px;
    padding:10px;
  }
  .top{
    min-height:64px;
    padding:8px 10px;
    border-radius:18px;
    gap:8px;
  }
  .brand{
    gap:8px;
    flex:1 1 auto;
  }
  .brand-logo{
    width:min(48vw, 190px);
    max-height:58px;
  }
  .round-badge{
    font-size:11px;
    max-width:34vw;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
  }
  .top-actions{
    gap:6px;
    flex-wrap:wrap;
    justify-content:flex-end;
  }
  .top-actions .btn{
    min-height:36px;
    padding:8px 10px;
    font-size:11px;
    border-radius:12px;
  }
  .top-actions #soundBtn,
  .top-actions #themeBtn{
    display:none;
  }
}
@media (max-width: 460px){
  .brand-logo{
    width:min(54vw, 170px);
    max-height:52px;
  }
  .round-badge{
    display:none;
  }
  .top-actions #focusBoardBtn{
    display:none;
  }
}


/* ==========================================================
   v33 · ARCADE MOTION PASS
   Dinamismo visual sin tocar las reglas del juego.
   ========================================================== */

body{
  position:relative;
}
body::after{
  content:"";
  position:fixed;
  inset:-22vmax;
  z-index:0;
  pointer-events:none;
  opacity:.16;
  background:
    radial-gradient(circle at 28% 38%, rgba(19,136,229,.72), transparent 18%),
    radial-gradient(circle at 70% 30%, rgba(239,47,42,.58), transparent 17%),
    radial-gradient(circle at 62% 72%, rgba(85,173,50,.44), transparent 18%),
    radial-gradient(circle at 36% 74%, rgba(245,189,18,.50), transparent 17%);
  filter:blur(72px) saturate(1.18);
  animation:arcadeAmbientOrbit 22s linear infinite;
}
.app{
  position:relative;
  z-index:1;
}

@keyframes arcadeAmbientOrbit{
  0%{transform:rotate(0deg) scale(1)}
  50%{transform:rotate(180deg) scale(1.08)}
  100%{transform:rotate(360deg) scale(1)}
}

/* Header feels alive but remains quiet enough for long sessions. */
.top{
  overflow:hidden;
  position:relative;
}
.top::after{
  content:"";
  position:absolute;
  top:-40%;
  bottom:-40%;
  width:28%;
  left:-35%;
  pointer-events:none;
  transform:skewX(-18deg);
  background:linear-gradient(90deg,transparent,rgba(255,255,255,.12),transparent);
  animation:headerScan 8.5s ease-in-out infinite;
}
@keyframes headerScan{
  0%,65%{left:-38%;opacity:0}
  72%{opacity:.7}
  88%{left:118%;opacity:.35}
  100%{left:118%;opacity:0}
}

/* Turn transition. */
.board-stage{
  position:relative;
  isolation:isolate;
}
.board-stage::after{
  content:"";
  position:absolute;
  inset:8px;
  border-radius:inherit;
  pointer-events:none;
  z-index:4;
  opacity:0;
  transform:scale(.92);
  background:
    radial-gradient(circle at 50% 50%, var(--active-glow), transparent 58%);
  box-shadow:
    inset 0 0 0 2px color-mix(in srgb, var(--active-color) 56%, transparent),
    inset 0 0 64px var(--active-glow);
}
body.turn-fx .board-stage::after{
  animation:boardTurnFlash .78s cubic-bezier(.2,.8,.2,1);
}
body.turn-fx .turn-card{
  animation:turnCardArrival .72s cubic-bezier(.16,1,.3,1);
}
body.turn-fx .announcer{
  animation:announcerTurnNudge .66s cubic-bezier(.16,1,.3,1);
}
@keyframes boardTurnFlash{
  0%{opacity:0;transform:scale(.93)}
  30%{opacity:.78}
  100%{opacity:0;transform:scale(1.015)}
}
@keyframes turnCardArrival{
  0%{transform:translateY(8px) scale(.98);box-shadow:0 0 0 transparent}
  42%{transform:translateY(-2px) scale(1.018);box-shadow:0 0 34px var(--active-glow)}
  100%{transform:none;box-shadow:0 0 0 transparent}
}
@keyframes announcerTurnNudge{
  0%{transform:translateX(-5px);filter:brightness(.9)}
  48%{transform:translateX(3px);filter:brightness(1.16)}
  100%{transform:none;filter:none}
}

/* Active character and player feel present. */
.announcer-avatar{
  animation:characterIdleFloat 4.2s ease-in-out infinite;
  transition:border-color .28s ease, box-shadow .28s ease, transform .28s ease;
}
@keyframes characterIdleFloat{
  0%,100%{transform:translateY(0)}
  50%{transform:translateY(-4px)}
}

.player-card.active{
  animation:activePlayerBreath 2.1s ease-in-out infinite;
}
@keyframes activePlayerBreath{
  0%,100%{box-shadow:0 0 0 rgba(0,0,0,0)}
  50%{box-shadow:0 0 24px color-mix(in srgb,currentColor 34%,transparent)}
}
body.ai-turn .player-card.active::after{
  animation:aiThinkingOrb 1.35s ease-in-out infinite;
}
@keyframes aiThinkingOrb{
  0%,100%{transform:scale(.92);opacity:.10}
  50%{transform:scale(1.16);opacity:.25}
}

/* Dice: shake while rolling + satisfying landing pop. */
.dice{
  transition:
    border-color .22s ease,
    box-shadow .22s ease,
    transform .18s ease;
}
.dice.result-pop{
  animation:diceResultPop .58s cubic-bezier(.18,.9,.22,1.25);
  border-color:var(--active-color);
  box-shadow:
    inset 0 0 28px rgba(255,255,255,.12),
    0 0 18px var(--active-glow),
    0 0 42px var(--active-glow);
}
@keyframes diceResultPop{
  0%{transform:scale(.76) rotate(-8deg);filter:brightness(1.55)}
  38%{transform:scale(1.16) rotate(4deg)}
  68%{transform:scale(.97) rotate(-1deg)}
  100%{transform:scale(1) rotate(0);filter:none}
}

/* Legal actions subtly invite interaction. */
.token-buttons .btn:not(:disabled),
.exit-chooser .btn:not(:disabled),
.btn.roll:not(:disabled){
  position:relative;
  overflow:hidden;
}
.token-buttons .btn:not(:disabled)::after,
.exit-chooser .btn:not(:disabled)::after,
.btn.roll:not(:disabled)::after{
  content:"";
  position:absolute;
  inset:-2px;
  pointer-events:none;
  background:linear-gradient(110deg,transparent 25%,rgba(255,255,255,.18) 48%,transparent 70%);
  transform:translateX(-125%);
  animation:actionSheen 3.1s ease-in-out infinite;
}
@keyframes actionSheen{
  0%,62%{transform:translateX(-125%)}
  82%,100%{transform:translateX(125%)}
}
.btn:not(:disabled):active{
  transform:translateY(1px) scale(.975);
}

/* Toast now lands with a little arcade spring. */
.toast.visible{
  animation:toastArcadeIn .38s cubic-bezier(.16,1,.3,1);
}
@keyframes toastArcadeIn{
  0%{transform:translateY(135%) scale(.96);opacity:0}
  72%{transform:translateY(-4px) scale(1.01);opacity:1}
  100%{transform:translateY(0) scale(1);opacity:1}
}

/* More energetic capture spotlight, but only for existing human KO flow. */
.luna-capture-spotlight.show .luna-capture-spotlight__panel{
  animation:koPanelPunch .42s cubic-bezier(.16,1,.3,1);
}
@keyframes koPanelPunch{
  0%{transform:scale(.82) rotate(-1deg);filter:brightness(1.35)}
  58%{transform:scale(1.035) rotate(.25deg)}
  100%{transform:scale(1);filter:none}
}

/* Mobile: motion remains visible without stealing board space. */
@media (max-width:760px){
  body::after{
    opacity:.12;
    filter:blur(58px);
  }
  .announcer-avatar{
    animation-duration:5.2s;
  }
  body.turn-fx .turn-card{
    animation-duration:.58s;
  }
}

/* Accessibility: honor reduced-motion preference everywhere. */
@media (prefers-reduced-motion: reduce){
  *,
  *::before,
  *::after{
    animation-duration:.001ms!important;
    animation-iteration-count:1!important;
    scroll-behavior:auto!important;
  }
  body::after{
    display:none;
  }
}


/* ==========================================================
   v34 · Board action button + center girls overlay
   ========================================================== */
.board-stage{
  isolation:isolate;
}

.board-action-btn{
  position:absolute;
  z-index:6;
  width:min(18.5%, 132px);
  aspect-ratio:1 / 1;
  border-radius:24px;
  border:2px solid rgba(255,255,255,.28);
  color:#fffdf5;
  background:
    linear-gradient(180deg, rgba(255,255,255,.18), rgba(255,255,255,.04)),
    radial-gradient(circle at 30% 25%, rgba(255,255,255,.26), transparent 28%),
    linear-gradient(160deg, rgba(9,14,23,.84), rgba(18,22,33,.96));
  box-shadow:
    0 16px 34px rgba(0,0,0,.30),
    inset 0 1px 0 rgba(255,255,255,.18),
    0 0 0 1px rgba(255,255,255,.08);
  display:grid;
  place-items:center;
  gap:2px;
  padding:10px;
  text-align:center;
  text-transform:uppercase;
  backdrop-filter:blur(7px);
  cursor:pointer;
  overflow:hidden;
  transition:transform .16s ease, box-shadow .22s ease, filter .22s ease;
}
.board-action-btn::before{
  content:"";
  position:absolute;
  inset:0;
  background:
    linear-gradient(120deg, transparent 12%, rgba(255,255,255,.18) 48%, transparent 82%);
  transform:translateX(-120%);
  animation:boardActionScan 3.2s ease-in-out infinite;
}
.board-action-btn::after{
  content:"";
  position:absolute;
  inset:-12%;
  border-radius:inherit;
  border:1px solid rgba(255,255,255,.14);
  opacity:.7;
}
.board-action-btn:hover{
  transform:translateY(-2px) scale(1.02);
  filter:brightness(1.04);
}
.board-action-btn:active{
  transform:translateY(1px) scale(.98);
}
.board-action-btn__eyebrow{
  position:relative;
  z-index:1;
  font-size:clamp(11px,1.15vw,13px);
  letter-spacing:.12em;
  opacity:.84;
}
.board-action-btn__main{
  position:relative;
  z-index:1;
  font-size:clamp(16px,1.7vw,24px);
  line-height:1;
  letter-spacing:.06em;
  text-shadow:0 2px 8px rgba(0,0,0,.35);
}
.board-action-btn__sub{
  position:relative;
  z-index:1;
  font-size:clamp(11px,1.1vw,13px);
  letter-spacing:.22em;
  opacity:.92;
}
.board-action-btn--red{
  left:5%;
  top:7%;
  box-shadow:
    0 16px 34px rgba(0,0,0,.30),
    0 0 26px rgba(239,47,42,.26),
    inset 0 1px 0 rgba(255,255,255,.18);
}
.board-action-btn--blue{
  right:5%;
  top:7%;
  box-shadow:
    0 16px 34px rgba(0,0,0,.30),
    0 0 26px rgba(19,136,229,.26),
    inset 0 1px 0 rgba(255,255,255,.18);
}
.board-action-btn--yellow{
  right:5%;
  bottom:7%;
  box-shadow:
    0 16px 34px rgba(0,0,0,.30),
    0 0 26px rgba(245,189,18,.28),
    inset 0 1px 0 rgba(255,255,255,.18);
}
.board-action-btn--green{
  left:5%;
  bottom:7%;
  box-shadow:
    0 16px 34px rgba(0,0,0,.30),
    0 0 26px rgba(85,173,50,.26),
    inset 0 1px 0 rgba(255,255,255,.18);
}
@keyframes boardActionScan{
  0%,62%{transform:translateX(-120%)}
  82%,100%{transform:translateX(130%)}
}

/* Center board character cameo */
.board-hero-overlay{
  position:absolute;
  inset:0;
  z-index:5;
  display:grid;
  place-items:center;
  pointer-events:none;
  opacity:0;
  transform:scale(.92);
  transition:opacity .18s ease, transform .18s ease;
}
.board-hero-overlay.show{
  opacity:1;
  transform:scale(1);
}
.board-hero-overlay__panel{
  width:min(54%, 420px);
  min-width:min(50%, 260px);
  padding:16px 18px 14px;
  border-radius:28px;
  border:1px solid rgba(255,255,255,.16);
  background:
    linear-gradient(180deg, rgba(7,11,18,.25), rgba(7,11,18,.70)),
    radial-gradient(circle at 20% 18%, rgba(255,255,255,.18), transparent 24%);
  backdrop-filter: blur(8px);
  box-shadow:
    0 24px 48px rgba(0,0,0,.36),
    inset 0 1px 0 rgba(255,255,255,.12);
  display:grid;
  grid-template-columns:minmax(124px, 0.95fr) 1fr;
  align-items:end;
  gap:8px 16px;
  overflow:hidden;
}
.board-hero-overlay__panel::before{
  content:"";
  position:absolute;
  inset:0;
  background:
    linear-gradient(110deg, transparent 0%, rgba(255,255,255,.12) 45%, transparent 76%);
  transform:translateX(-120%);
  animation:boardHeroScan 4.6s ease-in-out infinite;
  opacity:.65;
}
.board-hero-overlay__canvas,
.board-hero-overlay__copy{
  position:relative;
  z-index:1;
}
.board-hero-overlay__canvas{
  width:100%;
  max-width:180px;
  justify-self:center;
  align-self:end;
  filter:drop-shadow(0 12px 20px rgba(0,0,0,.25));
}
.board-hero-overlay__copy{
  align-self:center;
  padding-right:8px;
}
.board-hero-overlay__kicker{
  font-size:clamp(11px,1vw,13px);
  font-weight:800;
  letter-spacing:.18em;
  text-transform:uppercase;
  color:var(--board-hero-color, #9ad4ff);
  text-shadow:0 0 12px rgba(255,255,255,.16);
  margin-bottom:8px;
}
.board-hero-overlay__text{
  font-size:clamp(15px,1.2vw,22px);
  line-height:1.1;
  font-weight:900;
  color:#fffdf7;
  text-wrap:balance;
  text-shadow:0 3px 12px rgba(0,0,0,.36);
}
.board-hero-overlay[data-color="red"]{ --board-hero-color:#ff827d; }
.board-hero-overlay[data-color="blue"]{ --board-hero-color:#7eceff; }
.board-hero-overlay[data-color="yellow"]{ --board-hero-color:#ffe075; }
.board-hero-overlay[data-color="green"]{ --board-hero-color:#93ef79; }

@keyframes boardHeroScan{
  0%,66%{transform:translateX(-120%); opacity:0}
  76%{opacity:.65}
  100%{transform:translateX(125%); opacity:0}
}

/* Keep the board hero clean over the board; toast still sits above bottom. */
.toast{
  z-index:7;
}

@media (max-width: 980px){
  .board-action-btn{
    width:min(22%, 112px);
    border-radius:20px;
  }
  .board-hero-overlay__panel{
    width:min(68%, 390px);
    min-width:210px;
    grid-template-columns: 110px 1fr;
    padding:14px 14px 12px;
  }
  .board-hero-overlay__canvas{
    max-width:132px;
  }
}

@media (max-width: 760px){
  .board-action-btn{
    width:min(24%, 92px);
    padding:7px 6px;
    border-radius:18px;
  }
  .board-action-btn__main{ font-size:clamp(14px,4vw,18px); }
  .board-action-btn__sub,
  .board-action-btn__eyebrow{ letter-spacing:.08em; }

  .board-hero-overlay{
    place-items:end center;
    padding-bottom:12%;
  }
  .board-hero-overlay__panel{
    width:min(82%, 360px);
    grid-template-columns: 88px 1fr;
    gap:4px 12px;
    border-radius:24px;
    padding:10px 12px;
  }
  .board-hero-overlay__canvas{
    max-width:98px;
  }
  .board-hero-overlay__text{
    font-size:clamp(14px,3.8vw,18px);
  }
}

@media (max-width: 520px){
  .board-action-btn{
    width:min(25%, 80px);
    border-radius:16px;
  }
  .board-action-btn--red{ left:4%; top:5%; }
  .board-action-btn--blue{ right:4%; top:5%; }
  .board-action-btn--yellow{ right:4%; bottom:5%; }
  .board-action-btn--green{ left:4%; bottom:5%; }

  .board-hero-overlay{
    padding-bottom:14%;
  }
  .board-hero-overlay__panel{
    width:min(88%, 320px);
    grid-template-columns: 76px 1fr;
    min-width:0;
    padding:9px 10px;
  }
  .board-hero-overlay__canvas{
    max-width:84px;
  }
  .board-hero-overlay__kicker{
    margin-bottom:4px;
    font-size:10px;
  }
  .board-hero-overlay__text{
    font-size:14px;
    line-height:1.05;
  }
}

@media (prefers-reduced-motion: reduce){
  .board-action-btn::before,
  .board-hero-overlay__panel::before{
    animation:none!important;
  }
}


/* ==========================================================
   v36 · Start/modal production fixes
   Fix cascade regressions introduced by arcade motion pass.
   ========================================================== */

/* HTML hidden must always win over component display rules. */
.board-action-btn[hidden]{
  display:none!important;
}

/* Modals must remain viewport overlays. */
.modal{
  position:fixed!important;
  inset:0!important;
  z-index:200!important;
}
.modal.show{
  display:grid!important;
}

/* Floating announcers must remain true overlays, not flow content. */
.luna-sprite-dock{
  position:fixed!important;
  z-index:180!important;
}
.luna-capture-spotlight{
  position:fixed!important;
  inset:0!important;
  z-index:220!important;
}

/* The center-board hero belongs above the board but below modal UI. */
.board-hero-overlay{
  z-index:5;
}

/* No interactive board action is visible while setup modal is open. */
body:has(#colorModal.show) .board-action-btn,
body:has(#winnerModal.show) .board-action-btn{
  display:none!important;
}


/* ==========================================================
   v37 · BOARD-FIRST UX
   The board is now the primary controller.
   ========================================================== */

/* Side card becomes informational: no competing action buttons. */
.turn-card--secondary{
  gap:8px;
  padding:12px;
}
.turn-card--secondary > .dice,
.turn-card--secondary > .exit-chooser,
.turn-card--secondary > .roll,
.turn-card--secondary > .token-buttons{
  display:none!important;
}
.turn-card--secondary .hint{
  min-height:0;
  margin:2px 0 0;
  font-size:12px;
  text-align:left;
}

/* The integrated board HUD sits in the empty center of the current home yard. */
.board-action-btn{
  width:clamp(86px, 11.2%, 118px);
  aspect-ratio:1;
  border-radius:24px;
  transform:translate(-50%,-50%);
  padding:8px 7px;
  grid-template-rows:auto 1fr auto auto;
  gap:0;
  border-width:2px;
  background:
    radial-gradient(circle at 30% 18%, rgba(255,255,255,.30), transparent 26%),
    linear-gradient(155deg, color-mix(in srgb, var(--board-action-color) 78%, #fff 8%), color-mix(in srgb, var(--board-action-color) 68%, #05070d 32%));
  box-shadow:
    0 13px 26px rgba(0,0,0,.32),
    inset 0 1px 0 rgba(255,255,255,.36),
    inset 0 -8px 18px rgba(0,0,0,.16),
    0 0 24px color-mix(in srgb, var(--board-action-color) 48%, transparent);
}
.board-action-btn:hover{
  transform:translate(-50%,-50%) scale(1.035);
}
.board-action-btn:active{
  transform:translate(-50%,-50%) scale(.975);
}
.board-action-btn:disabled{
  opacity:.96;
  cursor:default;
  filter:none;
}
.board-action-btn--red{
  --board-action-color:#ef2f2a;
  left:24.5%;
  top:24.5%;
  right:auto;
  bottom:auto;
}
.board-action-btn--blue{
  --board-action-color:#1388e5;
  left:75.5%;
  top:24.5%;
  right:auto;
  bottom:auto;
}
.board-action-btn--green{
  --board-action-color:#55ad32;
  left:24.5%;
  top:75.5%;
  right:auto;
  bottom:auto;
}
.board-action-btn--yellow{
  --board-action-color:#f5bd12;
  left:75.5%;
  top:75.5%;
  right:auto;
  bottom:auto;
}

.board-action-btn__eyebrow{
  font-size:9px;
  letter-spacing:.08em;
  opacity:.90;
  max-width:100%;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.board-action-btn__die{
  position:relative;
  z-index:1;
  display:grid;
  place-items:center;
  width:40px;
  height:40px;
  margin:2px auto 1px;
  border-radius:12px;
  color:#111827;
  background:#fff8e8;
  border:1px solid rgba(255,255,255,.75);
  box-shadow:
    0 5px 12px rgba(0,0,0,.24),
    inset 0 1px 0 #fff;
  font:1000 23px/1 system-ui,sans-serif;
}
.board-action-btn__main{
  font-size:15px;
  line-height:1;
}
.board-action-btn__sub{
  font-size:8.5px;
  line-height:1.05;
  letter-spacing:.10em;
  min-height:9px;
}
.board-action-btn.is-actionable{
  cursor:pointer;
  animation:boardActionReady 1.25s ease-in-out infinite;
}
.board-action-btn.is-status::before{
  animation:none;
  opacity:.12;
}
.board-action-btn.is-rolling .board-action-btn__die{
  animation:boardDieShake .095s linear infinite alternate;
}
.board-action-btn.is-rolling{
  filter:brightness(1.12) saturate(1.15);
}
@keyframes boardActionReady{
  0%,100%{
    box-shadow:
      0 13px 26px rgba(0,0,0,.32),
      inset 0 1px 0 rgba(255,255,255,.36),
      0 0 18px color-mix(in srgb, var(--board-action-color) 44%, transparent);
  }
  50%{
    box-shadow:
      0 13px 26px rgba(0,0,0,.32),
      inset 0 1px 0 rgba(255,255,255,.40),
      0 0 34px color-mix(in srgb, var(--board-action-color) 72%, transparent);
  }
}
@keyframes boardDieShake{
  from{transform:rotate(-5deg) scale(.98)}
  to{transform:rotate(5deg) scale(1.04)}
}

/* Avoid the old color-position rules fighting the new centered-home layout. */
.board-action-btn--red,
.board-action-btn--blue,
.board-action-btn--green,
.board-action-btn--yellow{
  right:auto!important;
  bottom:auto!important;
}

/* Center cameo is lighter/shorter so it does not steal attention from legal pieces. */
.board-hero-overlay__panel{
  width:min(46%, 350px);
  background:
    linear-gradient(180deg, rgba(7,11,18,.12), rgba(7,11,18,.58)),
    radial-gradient(circle at 20% 18%, rgba(255,255,255,.14), transparent 24%);
}
.board-hero-overlay__canvas{
  max-width:142px;
}

/* Touch: keep integrated control large enough and board dominant. */
@media (max-width:760px){
  .board-action-btn{
    width:clamp(70px, 18%, 88px);
    border-radius:18px;
    padding:5px;
  }
  .board-action-btn__die{
    width:32px;
    height:32px;
    border-radius:9px;
    font-size:18px;
  }
  .board-action-btn__main{font-size:12px}
  .board-action-btn__sub{font-size:7px}
  .board-action-btn__eyebrow{font-size:7.5px}

  .turn-card--secondary{
    padding:10px;
  }
}

@media (max-width:520px){
  .board-action-btn{
    width:clamp(64px, 19%, 78px);
    border-radius:16px;
  }
  .board-action-btn--red{left:24.5%!important;top:24.5%!important}
  .board-action-btn--blue{left:75.5%!important;top:24.5%!important}
  .board-action-btn--green{left:24.5%!important;top:75.5%!important}
  .board-action-btn--yellow{left:75.5%!important;top:75.5%!important}
}

/* Keyboard fallback remains available even though side buttons are not visual. */
.turn-card--secondary .roll:focus-visible,
.turn-card--secondary .token-buttons .btn:focus-visible,
.turn-card--secondary .exit-chooser .btn:focus-visible{
  outline:3px solid var(--active-color);
}

@media (prefers-reduced-motion:reduce){
  .board-action-btn.is-actionable,
  .board-action-btn.is-rolling .board-action-btn__die{
    animation:none!important;
  }
}

/* ===== v38 MOBILE DICE STUDIO ===== */
/* Recalculate center from BoardRenderer yard geometry, not screen percentages. */
.board-action-btn--red,.board-action-btn--blue,.board-action-btn--green,.board-action-btn--yellow {
  left:var(--yard-left,50%)!important;
  top:var(--yard-top,50%)!important;
  right:auto!important;
  bottom:auto!important;
}
.board-action-btn[hidden],.board-action-sprite[hidden] { display:none!important; }
.board-action-btn:disabled { pointer-events:none; }
.board-stage { touch-action:manipulation; }
.board-action-sprite {
  position:relative;
  z-index:2;
  display:none;
  width:100%;
  height:auto;
  max-height:230px;
  object-fit:contain;
  filter:drop-shadow(0 10px 14px rgba(0,0,0,.30));
  transform-origin:bottom center;
  will-change:transform,opacity;
}
.board-hero-overlay.is-dice-action .board-hero-overlay__panel {
  width:min(39%,300px);
  min-width:0;
  padding:5px 8px;
  display:grid;
  grid-template-columns: 55% 1fr;
  border:1px solid rgba(255,255,255,.26);
  background:linear-gradient(160deg, rgba(10,15,31,.76),rgba(8,11,22,.66));
}
.board-hero-overlay.is-dice-action .board-hero-overlay__canvas { display:none; }
.board-hero-overlay.is-dice-action .board-action-sprite { display:block; }
.board-hero-overlay.is-dice-action .board-hero-overlay__kicker { margin-bottom:3px; font-size:10px; }
.board-hero-overlay.is-dice-action .board-hero-overlay__text { font-size:clamp(10px,1.1vw,15px); }
.board-hero-overlay.is-dice-action[data-action="shake"] .board-action-sprite { animation:diceCharacterShake .20s ease-in-out 2 alternate; }
.board-hero-overlay.is-dice-action[data-action="throw"] .board-action-sprite { animation:diceCharacterThrow .19s ease-out 1; }
.board-action-sprite.dice-action-enter { animation:diceCharacterBeat .17s ease both; }
@keyframes diceCharacterBeat { from{transform:translateY(9px) scale(.93);opacity:.6} to{transform:none;opacity:1} }
@keyframes diceCharacterShake { from{transform:translateX(-4px) rotate(-2deg)} to{transform:translateX(4px) rotate(2deg)} }
@keyframes diceCharacterThrow { from{transform:translateX(-18px) scale(.95);opacity:.7} to{transform:none;opacity:1} }
.board-action-btn:focus-visible, #boardCanvas:focus-visible {
  outline:3px solid #fff;
  outline-offset:3px;
}

@media(max-width:780px) {
  body{overflow-y:auto;overscroll-behavior-y:contain}
  .app{height:auto;min-height:100dvh;padding:max(7px,env(safe-area-inset-top)) 6px max(10px,env(safe-area-inset-bottom));gap:7px}
  .top{min-height:54px;padding:6px 9px;flex-direction:row;align-items:center;gap:5px}
  .brand-logo{width:clamp(100px,30vw,165px);max-height:42px}
  .top-actions{width:auto;grid-template-columns:repeat(2,auto);display:flex;gap:5px}
  .top-actions .btn{font-size:10px;min-height:39px;padding:7px 9px}
  .top-actions #soundBtn,.top-actions #themeBtn,.top-actions #focusBoardBtn{display:none}
  .board-stage{order:-1;aspect-ratio:1/1;min-height:0;padding:3px;max-height:none;overflow:hidden}
  #boardCanvas{width:100%;height:auto;max-height:none;max-width:100%;aspect-ratio:1/1}
  .layout{grid-template-columns:minmax(0,1fr);gap:8px}
  .side{padding:8px;gap:6px;display:grid;grid-template-columns:1fr;}
  .turn-card--secondary{padding:8px 12px}
  .announcer{grid-template-columns:50px 1fr;padding:7px;gap:9px}
  .announcer-avatar{width:50px;height:55px}
  .announcer h2{font-size:13px;margin-bottom:4px}
  .announcer p{font-size:11px}
  .turn-card--secondary .hint{font-size:11px}
  .score{min-height:0;padding:10px}
  .board-action-btn { width:clamp(53px,16%,77px);border-radius:14px;padding:4px }
  .board-action-btn__die{width:26px;height:26px;font-size:16px;border-radius:7px}
  .board-action-btn__main{font-size:11px;line-height:1}
  .board-action-btn__sub{font-size:7px}
  .board-action-btn__eyebrow{font-size:7px}
  .board-hero-overlay.is-dice-action {place-items:center;padding:0}
  .board-hero-overlay.is-dice-action .board-hero-overlay__panel{width:min(52%,230px);grid-template-columns:55% 45%;padding:3px 5px;border-radius:13px;gap:4px}
  .board-hero-overlay.is-dice-action .board-action-sprite{max-height:110px}
  .board-hero-overlay.is-dice-action .board-hero-overlay__kicker{font-size:8px}
  .board-hero-overlay.is-dice-action .board-hero-overlay__text{font-size:10px;line-height:1.1}
  .luna-sprite-dock{width:min(275px,calc(100vw - 12px));grid-template-columns:60px 1fr;padding:7px;right:6px;bottom:max(8px,env(safe-area-inset-bottom))}
  .luna-sprite-wrap,.luna-sprite-canvas{width:60px;height:72px}
  .luna-speech{font-size:11px}
}
@media(max-width:370px){
  .top-actions #installBtn{display:none}
  .board-action-btn{width:49px;padding:3px;border-radius:12px}
  .board-action-btn__die{width:21px;height:21px;font-size:13px}
  .board-action-btn__main{font-size:9px}
  .board-action-btn__sub{font-size:6px}
}
@media(prefers-reduced-motion:reduce){
 .board-action-sprite,.board-action-sprite.dice-action-enter{animation:none!important;will-change:auto!important}
}
