:root {
  --papel: #fdf6e3;
  --tinta: #1a1033;
  --bg: #f6ead1;
  --morado: #4c1d95;
  --morado-2: #7c3aed;
  --cempasuchil: #ea580c;
  --rosa: #db2777;
  --jade: #047857;
  --oro: #d97706;
  --celeste: #0891b2;
  --hueso: #fef3c7;
  --celda: #fff8e1;
  --celda-alt: #fdecc8;
  --sombra: 0 1px 2px rgba(26, 16, 51, 0.08), 0 10px 30px rgba(26, 16, 51, 0.1);
  --borde: 1px solid rgba(76, 29, 149, 0.18);
}
:root:not([data-theme="light"]) {
  @media (prefers-color-scheme: dark) {
    --papel: #1b1430;
    --tinta: #f8e9c7;
    --bg: #0f0820;
    --hueso: #2a1f4a;
    --celda: #241a3f;
    --celda-alt: #2d2250;
    --morado: #c4b5fd;
  }
}
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--tinta);
  font-family: "Noto Sans", "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body {
  min-height: 100vh;
}
.wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 40px 0 0 0;
}
@media (max-width: 720px) {
  .wrap {
    padding-top: 24px;
  }
}
.hidden {
  display: none !important;
}

header {
  text-align: center;
  padding: 12px 8px 20px;
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--morado);
  font-weight: 600;
}
h1 {
  font-family: "Noto Sans", system-ui, sans-serif;
  font-weight: 800;
  font-size: clamp(26px, 5vw, 46px);
  margin: 4px 0 6px;
  line-height: 1.1;
  letter-spacing: -0.01em;
}
h1 em {
  font-style: normal;
  color: var(--cempasuchil);
  font-weight: 700;
}
.sub {
  font-size: 14px;
  line-height: 1.5;
  color: color-mix(in oklab, var(--tinta) 70%, transparent);
  max-width: 680px;
  margin: 0 auto;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 22px;
  align-items: start;
}
@media (max-width: 940px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 14px;
  }
}
.panel {
  background: var(--papel);
  border: var(--borde);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--sombra);
}

/* ====== SETUP: pantalla centrada con tarjetas verticales ====== */
.setup-wrap {
  min-height: calc(100vh - 180px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px 0;
  position: relative;
}
/* Decoración de fondo removida — queda limpio */

/* ====== MONOS CALAVERA (decoración a los lados, solo en computadoras) ====== */
.setup-mono {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: clamp(180px, 17vw, 260px);
  height: auto;
  pointer-events: none;
  user-select: none;
  z-index: 0;
  display: none; /* oculto por defecto, se muestra en pantallas grandes */
  animation: monoFloat 6s ease-in-out infinite;
}
.setup-mono-izq {
  left: clamp(40px, 7vw, 140px);
  transform: translateY(-50%) rotate(-5deg);
  animation-delay: 0s;
}
.setup-mono-der {
  right: clamp(40px, 7vw, 140px);
  transform: translateY(-50%) rotate(5deg) scaleX(-1); /* espejo si solo tienes una imagen */
  animation-delay: -3s;
}
@keyframes monoFloat {
  0%,
  100% {
    margin-top: 0;
  }
  50% {
    margin-top: -14px;
  }
}

/* Breakpoint progresivo: cuanto más ancha la pantalla, más adentro quedan */
@media (min-width: 1100px) {
  .setup-mono {
    display: block;
  }
}
@media (min-width: 1400px) {
  .setup-mono-izq {
    left: clamp(80px, 9vw, 200px);
  }
  .setup-mono-der {
    right: clamp(80px, 9vw, 200px);
  }
}
@media (min-width: 1700px) {
  .setup-mono-izq {
    left: clamp(140px, 12vw, 280px);
  }
  .setup-mono-der {
    right: clamp(140px, 12vw, 280px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .setup-mono {
    animation: none;
  }
}

.setup {
  position: relative;
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  background: var(--papel);
  border-radius: 32px;
  padding: 0;
  box-shadow:
    0 40px 80px rgba(76, 29, 149, 0.25),
    0 10px 30px rgba(26, 16, 51, 0.12),
    0 0 0 1px rgba(76, 29, 149, 0.15);
  overflow: hidden;
  z-index: 1;
}

/* Franja superior con esquinas redondeadas */
.setup::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 8px;
  background: linear-gradient(
    90deg,
    var(--cempasuchil),
    var(--rosa),
    var(--morado),
    var(--jade),
    var(--oro),
    var(--cempasuchil)
  );
}

/* ====== HEADER ====== */
.setup-head {
  text-align: center;
  padding: 36px 24px 24px;
  background: radial-gradient(
    circle at 50% 0%,
    color-mix(in oklab, var(--cempasuchil) 18%, var(--papel)),
    color-mix(in oklab, var(--morado) 8%, var(--papel)) 100%
  );
  position: relative;
}
.setup-eyebrow {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--cempasuchil);
  font-weight: 800;
  padding: 4px 12px;
  background: color-mix(in oklab, var(--cempasuchil) 10%, transparent);
  border-radius: 999px;
  margin-bottom: 12px;
}
.setup h2 {
  font-family: "Noto Sans", system-ui, sans-serif;
  margin: 0 0 8px;
  font-size: 32px;
  color: var(--morado);
  font-weight: 700;
  line-height: 1.1;
}
.setup-sub {
  font-size: 14px;
  color: color-mix(in oklab, var(--tinta) 70%, transparent);
  margin: 0 auto;
  max-width: 420px;
  line-height: 1.55;
}

/* ====== SECCIÓN JUGADORES ====== */
.setup-section {
  padding: 24px;
}
.setup-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px dashed color-mix(in oklab, var(--morado) 20%, transparent);
}
.setup-section-head h3 {
  font-family: "Noto Sans", system-ui, sans-serif;
  font-size: 17px;
  margin: 0;
  color: var(--tinta);
  display: flex;
  align-items: center;
  gap: 10px;
}
.setup-section-head h3 .ico-h3 {
  width: 30px;
  height: 30px;
  background: #fff8e1;
  border: 2px solid var(--morado);
  color: var(--morado);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: 0 2px 6px rgba(76, 29, 149, 0.18);
}
.setup-counter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: linear-gradient(135deg, var(--cempasuchil), var(--rosa));
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  box-shadow: 0 4px 10px rgba(234, 88, 12, 0.3);
}
.setup-counter .n {
  font-size: 14px;
  font-weight: 900;
}

/* ====== GRID DE TARJETAS VERTICALES ====== */
.jugadores-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.jugador-row {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: linear-gradient(
    180deg,
    color-mix(in oklab, var(--morado) 8%, var(--papel)),
    color-mix(in oklab, var(--cempasuchil) 6%, var(--papel))
  );
  padding: 18px 16px 16px;
  border-radius: 18px;
  border: 2px solid color-mix(in oklab, var(--morado) 18%, transparent);
  box-shadow: 0 3px 10px rgba(26, 16, 51, 0.1);
  transition: all 0.25s;
}
.jugador-row:hover {
  box-shadow: 0 12px 28px rgba(76, 29, 149, 0.22);
  transform: translateY(-3px);
  border-color: color-mix(in oklab, var(--morado) 35%, transparent);
}

/* Número en esquina superior izquierda */
.jug-num {
  position: absolute;
  top: 10px;
  left: 12px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.15em;
  color: var(--morado);
  text-transform: uppercase;
  background: color-mix(in oklab, var(--morado) 15%, transparent);
  padding: 2px 8px;
  border-radius: 999px;
}

/* Botón eliminar en esquina sup. derecha */
.jug-eliminar {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: color-mix(in oklab, var(--rosa) 15%, transparent);
  color: var(--rosa);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.jug-eliminar:hover:not(:disabled) {
  background: var(--rosa);
  color: #fff;
  transform: rotate(90deg);
}
.jug-eliminar:disabled {
  opacity: 0.2;
  cursor: not-allowed;
}

/* Avatar circular GRANDE (visual, ya no interactivo) */
.jug-icono-badge {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 4px solid #fff;
  font-size: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow:
    0 6px 16px rgba(0, 0, 0, 0.2),
    0 0 0 3px color-mix(in oklab, var(--morado) 15%, transparent);
  margin-top: 12px;
  user-select: none;
  pointer-events: none;
}

/* Etiqueta de nombre debajo del avatar (no editable) */
.jug-info {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}
.jug-nombre {
  font-family: "Noto Sans", system-ui, sans-serif;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-align: center;
  padding: 4px 2px;
  user-select: none;
}

/* Botón agregar: tarjeta con guión */
.btn-agregar-wrap {
  display: flex;
  justify-content: center;
}
button.ghost {
  background: transparent;
  border: 2px dashed color-mix(in oklab, var(--morado) 35%, transparent);
  color: var(--morado);
  width: 100%;
  margin: 0;
  padding: 14px 20px;
  font-size: 14px;
  letter-spacing: 0.05em;
  font-weight: 700;
  border-radius: 14px;
  transition: all 0.2s;
}
button.ghost:hover:not(:disabled) {
  border-color: var(--morado);
  background: color-mix(in oklab, var(--morado) 8%, transparent);
  transform: translateY(-1px);
}

/* Reglas rápidas */
.reglas {
  background: linear-gradient(
    135deg,
    color-mix(in oklab, var(--morado) 10%, var(--papel)),
    color-mix(in oklab, var(--cempasuchil) 8%, var(--papel))
  );
  margin: 0 24px 20px;
  padding: 18px 20px;
  border-radius: 16px;
  border: 1.5px dashed color-mix(in oklab, var(--morado) 30%, transparent);
}
.reglas-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: "Noto Sans", system-ui, sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--tinta);
  margin-bottom: 14px;
}
.reglas-title .ico-h3 {
  width: 26px;
  height: 26px;
  background: linear-gradient(135deg, var(--oro), var(--cempasuchil));
  color: #fff;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}
.reglas-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  font-size: 13px;
}
.regla {
  display: flex;
  align-items: center;
  gap: 10px;
  color: color-mix(in oklab, var(--tinta) 85%, transparent);
  line-height: 1.3;
}
.regla-ico {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  font-weight: 800;
}
.regla-ico.a {
  background: color-mix(in oklab, var(--cempasuchil) 18%, transparent);
  color: var(--cempasuchil);
}
.regla-ico.b {
  background: color-mix(in oklab, var(--morado-2) 18%, transparent);
  color: var(--morado-2);
}
.regla-ico.c {
  background: color-mix(in oklab, var(--oro) 18%, transparent);
  color: var(--oro);
}
.regla-ico.d {
  background: color-mix(in oklab, var(--jade) 18%, transparent);
  color: var(--jade);
}

/* Footer: botón grande */
/* ====== BOTÓN COMENZAR PARTIDA (rediseñado) ====== */
.setup-footer {
  padding: 0 24px 28px;
}
.setup-footer button.primary.big {
  width: 100%;
  font-family: "Noto Sans", system-ui, sans-serif;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 20px 24px;
  color: #fff8e1;
  background: #1a1033;
  border: 2px solid #d97706;
  border-radius: 14px;
  box-shadow:
    0 0 0 4px rgba(217, 119, 6, 0.15),
    0 10px 28px rgba(26, 16, 51, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.25s ease;
}
.setup-footer button.primary.big::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(234, 88, 12, 0.25) 50%,
    transparent 100%
  );
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}
.setup-footer button.primary.big:hover {
  color: #fff;
  background: #2d1a4f;
  border-color: #ea580c;
  box-shadow:
    0 0 0 4px rgba(234, 88, 12, 0.25),
    0 14px 36px rgba(234, 88, 12, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
}
.setup-footer button.primary.big:hover::before {
  transform: translateX(100%);
}
.setup-footer button.primary.big:active {
  transform: translateY(0);
}

/* TABLERO */
.board-stage {
  position: relative;
  aspect-ratio: 1/1;
  width: 100%;
}
.board {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);
  gap: 0;
  background: color-mix(in oklab, var(--morado) 20%, transparent);
  border: 3px solid var(--morado);
  border-radius: 10px;
  overflow: hidden;
}
.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px 4px;
  font-size: clamp(10px, 1.4vw, 14px);
  font-weight: 800;
  color: color-mix(in oklab, var(--tinta) 70%, transparent);
  border: 1px solid color-mix(in oklab, var(--morado) 20%, transparent);
  background: var(--celda);
}
.cell.alt {
  background: var(--celda-alt);
}
.cell.start {
  background: linear-gradient(135deg, #fecaca, #fca5a5);
}
.cell.goal {
  background: linear-gradient(135deg, #1e1b4b, #4c1d95);
  color: #fef3c7;
}
.cell.info {
  background: linear-gradient(135deg, #fde68a, #fbbf24);
  color: #422006;
  box-shadow: inset 0 0 0 2px #d97706;
}
.cell.info::before {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d97706;
  box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.25);
}
.cell .n {
  display: block;
  line-height: 1;
  letter-spacing: 0.5px;
}
.cell.goal .n {
  color: #fef3c7;
}
.overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.tokens {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.token {
  position: absolute;
  width: 7%;
  height: 7%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(10px, 1.6vw, 16px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  border: 2px solid #fff;
  transition:
    left 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    top 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 5;
  color: #fff;
}
.token.ganador {
  animation: tokenGanador 1s ease-in-out infinite;
}
@keyframes tokenGanador {
  0%,
  100% {
    transform: scale(1) rotate(0);
  }
  50% {
    transform: scale(1.4) rotate(10deg);
  }
}

.confeti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 20;
}
.confeti-piece {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 14px;
  animation: caerConfeti var(--dur, 3s) linear var(--delay, 0s) infinite;
  opacity: 0;
}
.confeti.activo .confeti-piece {
  opacity: 1;
}
@keyframes caerConfeti {
  0% {
    transform: translateY(-20px) rotate(0);
    opacity: 1;
  }
  100% {
    transform: translateY(110vh) rotate(720deg);
    opacity: 0;
  }
}

/* DADO 3D */
h2,
h3 {
  font-family: "Noto Sans", system-ui, sans-serif;
  margin: 0 0 10px;
}
h2 {
  font-size: 20px;
}
h3 {
  font-size: 14px;
}
.dado-wrap {
  display: flex;
  justify-content: center;
  perspective: 600px;
  padding: 16px 0 8px;
}
.dice-scene {
  width: 100px;
  height: 100px;
  perspective: 600px;
}
.dice {
  width: 100px;
  height: 100px;
  position: relative;
  transform-style: preserve-3d;
  transform: rotateX(-15deg) rotateY(15deg);
  transition: transform 1s cubic-bezier(0.3, 0.6, 0.3, 1);
}
.dice.rodando {
  animation: rodarDado 1s ease-out;
}
@keyframes rodarDado {
  0% {
    transform: rotateX(0) rotateY(0);
  }
  25% {
    transform: rotateX(360deg) rotateY(180deg);
  }
  50% {
    transform: rotateX(720deg) rotateY(540deg);
  }
  75% {
    transform: rotateX(1080deg) rotateY(900deg);
  }
  100% {
    transform: rotateX(1440deg) rotateY(1260deg);
  }
}
.face {
  position: absolute;
  width: 100px;
  height: 100px;
  background: linear-gradient(135deg, #fff, #f3e8d2);
  border: 3px solid var(--morado);
  border-radius: 14px;
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  padding: 12px;
  gap: 4px;
  box-shadow: inset 0 0 20px rgba(76, 29, 149, 0.08);
}
.pip {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #7c3aed, #1e1b4b);
  box-shadow:
    inset -1px -1px 2px rgba(0, 0, 0, 0.3),
    0 1px 1px rgba(0, 0, 0, 0.2);
  align-self: center;
  justify-self: center;
}
.pip.tl {
  grid-area: 1/1;
}
.pip.tc {
  grid-area: 1/2;
}
.pip.tr {
  grid-area: 1/3;
}
.pip.ml {
  grid-area: 2/1;
}
.pip.c {
  grid-area: 2/2;
}
.pip.mr {
  grid-area: 2/3;
}
.pip.bl {
  grid-area: 3/1;
}
.pip.bc {
  grid-area: 3/2;
}
.pip.br {
  grid-area: 3/3;
}
.face.f1 {
  transform: translateZ(50px);
}
.face.f6 {
  transform: rotateY(180deg) translateZ(50px);
}
.face.f2 {
  transform: rotateY(90deg) translateZ(50px);
}
.face.f5 {
  transform: rotateY(-90deg) translateZ(50px);
}
.face.f3 {
  transform: rotateX(90deg) translateZ(50px);
}
.face.f4 {
  transform: rotateX(-90deg) translateZ(50px);
}
.dice[data-show="1"] {
  transform: rotateX(360deg) rotateY(720deg);
}
.dice[data-show="2"] {
  transform: rotateX(360deg) rotateY(630deg);
}
.dice[data-show="3"] {
  transform: rotateX(270deg) rotateY(720deg);
}
.dice[data-show="4"] {
  transform: rotateX(450deg) rotateY(720deg);
}
.dice[data-show="5"] {
  transform: rotateX(360deg) rotateY(810deg);
}
.dice[data-show="6"] {
  transform: rotateX(360deg) rotateY(900deg);
}

.turno {
  text-align: center;
  font-weight: 600;
  margin: 14px 0 10px;
  font-size: 14px;
}
.turno .pill {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 999px;
  color: #fff;
  background: var(--morado);
  margin-left: 4px;
}

.players {
  display: grid;
  gap: 6px;
  margin: 8px 0 14px;
  font-size: 13px;
}
.player {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: color-mix(in oklab, var(--morado) 6%, transparent);
  border-radius: 10px;
  border: 2px solid transparent;
  transition: all 0.2s;
}
.player.activo {
  border-color: var(--morado);
  background: color-mix(in oklab, var(--morado) 12%, transparent);
}
.player .icono-circle {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.player .nombre {
  flex: 1;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player .score {
  font-size: 12px;
  color: color-mix(in oklab, var(--tinta) 65%, transparent);
  font-weight: 500;
}

.controls {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}
button {
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid color-mix(in oklab, var(--morado) 30%, transparent);
  background: var(--papel);
  color: var(--tinta);
  cursor: pointer;
  transition:
    transform 0.08s,
    background 0.2s;
  min-height: 44px;
}
button:hover {
  background: color-mix(in oklab, var(--morado) 10%, var(--papel));
}
button:active {
  transform: translateY(1px);
}
button.primary {
  background: var(--morado);
  color: #fff;
  border-color: var(--morado);
}
button.primary:hover {
  background: var(--morado-2);
}
button.primary.big {
  padding: 14px 20px;
  font-size: 16px;
}
button.ghost {
  background: transparent;
  border: 1.5px dashed var(--morado);
  color: var(--morado);
  width: 100%;
  margin-bottom: 8px;
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.historia-wrap {
  margin-top: 14px;
}
.historia {
  font-size: 12px;
  line-height: 1.45;
  max-height: 140px;
  overflow-y: auto;
  background: color-mix(in oklab, var(--morado) 6%, transparent);
  border-radius: 8px;
  padding: 10px;
}
.historia .ev {
  margin: 4px 0;
  padding-left: 8px;
  border-left: 2px solid var(--morado);
}

.leyenda {
  font-size: 12px;
  line-height: 1.5;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed color-mix(in oklab, var(--morado) 25%, transparent);
}
.leyenda .row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
}
.leyenda .dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}
.leyenda .dot.orange {
  background: var(--cempasuchil);
}
.leyenda .dot.purple {
  background: #047857;
}
.leyenda .dot.gold {
  background: var(--oro);
}

dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  border: none;
  border-radius: 18px;
  padding: 26px;
  max-width: 460px;
  width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: linear-gradient(
    180deg,
    var(--papel),
    color-mix(in oklab, var(--morado) 5%, var(--papel))
  );
  color: var(--tinta);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  text-align: center;
  border: 2px solid color-mix(in oklab, var(--morado) 15%, transparent);
}
dialog[open] {
  display: block;
}
dialog::backdrop {
  background: rgba(26, 16, 51, 0.65);
  backdrop-filter: blur(4px);
}
.dlg-ico {
  display: none;
} /* iconos del modal de datos ocultos */
.dlg-tag {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--morado);
}
.dlg-tag.serpiente {
  color: var(--morado-2);
}
.dlg-tag.escalera {
  color: var(--cempasuchil);
}
.dlg-tag.info {
  color: var(--oro);
}
dialog h3 {
  font-family: "Noto Sans", system-ui, sans-serif;
  margin: 0 0 10px;
  font-size: 26px;
  color: var(--tinta);
}
dialog p {
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 16px;
}
dialog p b {
  color: var(--morado);
}
dialog button {
  margin-top: 4px;
  min-width: 140px;
}

/* ═══════════════════════════════════════════════════════════════════
   MODAL DE GANADOR
   Fondo amarillo claro FIJO → se fuerzan colores oscuros locales
   para que el texto se vea tanto en modo claro como en modo oscuro.
   ═══════════════════════════════════════════════════════════════════ */
.dlg-win {
  /* Reasignamos las variables SOLO dentro de este modal */
  --tinta: #1a1033;
  --papel: #fdf6e3;
  --morado: #4c1d95;
  --morado-2: #7c3aed;
  --cempasuchil: #ea580c;

  background: linear-gradient(145deg, #fef3c7, #fcd34d);
  border: 3px solid var(--morado);
  color: var(--tinta);
}
.dlg-win .win-ico {
  font-size: 84px;
  line-height: 1;
  margin: 0 0 10px;
  animation: winBounce 1s ease-in-out infinite;
}
.dlg-win .win-tag {
  font-size: 12px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--cempasuchil);
  margin-bottom: 6px;
}
.dlg-win h3 {
  font-size: 40px;
  font-family: "Noto Sans", system-ui, sans-serif;
  font-style: italic;
  color: var(--morado);
  margin: 0 0 12px;
}
.dlg-win p {
  color: var(--tinta);
}
.dlg-win p b {
  color: var(--morado);
}
.dlg-win button {
  background: var(--morado);
  color: #fff8e1;
  border-color: var(--morado);
}
.dlg-win button:hover {
  background: var(--morado-2);
  color: #fff;
  border-color: var(--morado-2);
}
.dlg-win button.ghost {
  background: transparent;
  color: var(--morado);
  border: 2px dashed var(--morado);
}
.dlg-win button.ghost:hover {
  background: color-mix(in oklab, var(--morado) 10%, transparent);
  color: var(--morado);
}
@keyframes winBounce {
  0%,
  100% {
    transform: translateY(0) scale(1) rotate(-5deg);
  }
  50% {
    transform: translateY(-12px) scale(1.1) rotate(5deg);
  }
}

/* Modal de iconos eliminado: los iconos se asignan automáticamente */

@media (max-width: 640px) {
 
  header {
    padding: 8px 4px 14px;
  }
  .panel {
    padding: 12px;
    border-radius: 14px;
  }
  .board-panel {
    padding: 8px;
  }
  .layout {
    gap: 10px;
  }
  .setup-wrap {
    min-height: auto;
    padding: 10px 0 20px;
  }
  .setup {
    border-radius: 24px;
  }
  .setup-head {
    padding: 26px 16px 18px;
  }
  .setup h2 {
    font-size: 24px;
  }
  .setup-sub {
    font-size: 13px;
  }
  .setup-eyebrow {
    font-size: 9px;
  }
  .setup-section {
    padding: 18px 14px;
  }
  .setup-section-head h3 {
    font-size: 15px;
  }

  /* En móvil: 2 columnas aún, pero más compactas */
  .jugadores-list {
    gap: 10px;
  }
  .jugador-row {
    padding: 14px 12px 12px;
    border-radius: 14px;
  }
  .jug-icono-badge {
    width: 62px;
    height: 62px;
    font-size: 32px;
    border-width: 3px;
    margin-top: 10px;
  }
  .jug-nombre {
    font-size: 13.5px;
    padding: 4px 2px;
  }
  .jug-num {
    font-size: 9px;
  }

  .reglas {
    margin: 0 14px 16px;
    padding: 14px 14px;
  }
  .reglas-list {
    grid-template-columns: 1fr;
    gap: 10px;
    font-size: 12.5px;
  }
  .setup-footer {
    padding: 0 14px 20px;
  }
  .setup-footer button.primary.big {
    font-size: 15px;
    padding: 15px;
  }
  .dice-scene,
  .dice {
    width: 80px;
    height: 80px;
  }
  .face {
    width: 80px;
    height: 80px;
    padding: 8px;
    border-radius: 10px;
    border-width: 2px;
  }
  .pip {
    width: 14px;
    height: 14px;
  }
  .face.f1 {
    transform: translateZ(40px);
  }
  .face.f6 {
    transform: rotateY(180deg) translateZ(40px);
  }
  .face.f2 {
    transform: rotateY(90deg) translateZ(40px);
  }
  .face.f5 {
    transform: rotateY(-90deg) translateZ(40px);
  }
  .face.f3 {
    transform: rotateX(90deg) translateZ(40px);
  }
  .face.f4 {
    transform: rotateX(-90deg) translateZ(40px);
  }
  .cell {
    font-size: 10px;
    padding: 2px 3px;
  }
  .cell.info::before {
    width: 5px;
    height: 5px;
    top: 2px;
    right: 2px;
  }
  .token {
    width: 8%;
    height: 8%;
    font-size: 10px;
    border-width: 1.5px;
  }
  button.primary.big {
    padding: 16px;
    font-size: 16px;
  }
  .historia {
    max-height: 110px;
  }
  .icono-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .icono-opt {
    width: 48px;
    height: 48px;
    font-size: 24px;
  }
  dialog {
    padding: 20px;
  }
  .dlg-win .win-ico {
    font-size: 64px;
  }
  .dlg-win h3 {
    font-size: 30px;
  }
}
@media (max-width: 380px) {
  .cell {
    font-size: 9px;
  }
  .cell.info::before {
    width: 4px;
    height: 4px;
  }
  .dice-scene,
  .dice {
    width: 70px;
    height: 70px;
  }
  .face {
    width: 70px;
    height: 70px;
    padding: 6px;
  }
  .pip {
    width: 11px;
    height: 11px;
  }
  .face.f1 {
    transform: translateZ(35px);
  }
  .face.f6 {
    transform: rotateY(180deg) translateZ(35px);
  }
  .face.f2 {
    transform: rotateY(90deg) translateZ(35px);
  }
  .face.f5 {
    transform: rotateY(-90deg) translateZ(35px);
  }
  .face.f3 {
    transform: rotateX(90deg) translateZ(35px);
  }
  .face.f4 {
    transform: rotateX(-90deg) translateZ(35px);
  }
  /* En pantallas muy chicas, 1 columna de jugadores */
  .jugadores-list {
    grid-template-columns: 1fr;
  }
}