/**
 * ============================================================================
 * ARCHIVO: css/styles.css
 * DESCRIPCIÓN:
 * Hoja de estilos principal de El Juego de la Oca.
 * Implementa el sistema de tokens con 4 Mundos Visuales intercambiables:
 *   1. "tertulia"  -> Tertulia de Café Histórico (Tapete verde, marfil y latón)
 *   2. "fournier"  -> Pliego Litográfico Clásico (Pergamino, azul de Prusia y bermellón)
 *   3. "atlas"     -> Atlas Enciclopédico y Cobre (Papel verjurado, sepia y verde herbario)
 *   4. "crouwel"   -> Espécimen Reticular Geométrico (Matriz modular suizo-neerlandesa)
 *
 * Incluye la retícula en espiral de 9 columnas × 7 filas (63 escaques),
 * conectores vectoriales SVG de saltos, cartela mecánica de refranes,
 * dados animados y adaptación responsiva completa.
 * ============================================================================
 */

/* --------------------------------------------------------------------------
   1. TOKENS POR MUNDO VISUAL
   -------------------------------------------------------------------------- */
:root,
[data-world="tertulia"] {
  --font-display: 'Spectral', Georgia, serif;
  --font-sans: 'Source Sans 3', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Superficies del mundo Tertulia de Café Histórico */
  --bg-page: #11291d;
  --bg-header: #1d1410;
  --bg-panel: #193828;
  --bg-panel-elevated: #204532;
  --bg-board-frame: #241812;
  --bg-board-mat: #143323;

  /* Escaques del tablero (marfil grabado sobre tapete) */
  --sq-bg: #f6f1e5;
  --sq-bg-ring1: #efe7d6;
  --sq-bg-ring2: #f8f4ea;
  --sq-text: #1c1612;
  --sq-muted: #5a4b3c;
  --sq-border: #c9ba9b;

  /* Colores de texto del shell */
  --text-primary: #f7f2e7;
  --text-secondary: #d7ccb6;
  --text-on-accent: #18120c;

  /* Acentos y herrajes de latón */
  --accent-primary: #dfb053;
  --accent-primary-hover: #ecc36b;
  --accent-secondary: #c83e2b;
  --border-subtle: rgba(223, 176, 83, 0.28);
  --border-strong: #dfb053;

  /* Casillas especiales sobre el tablero */
  --sp-goose-bg: #fdf3d7;
  --sp-goose-ink: #8a5200;
  --sp-goose-border: #d99b26;

  --sp-bridge-bg: #e3f0fb;
  --sp-bridge-ink: #124578;
  --sp-bridge-border: #2b6cb0;

  --sp-inn-bg: #f9e8dc;
  --sp-inn-ink: #7c2d12;
  --sp-inn-border: #c05621;

  --sp-dice-bg: #ede6fb;
  --sp-dice-ink: #4c1d95;
  --sp-dice-border: #6d28d9;

  --sp-well-bg: #dde8eb;
  --sp-well-ink: #164e63;
  --sp-well-border: #0e7490;

  --sp-labyrinth-bg: #e5f2e8;
  --sp-labyrinth-ink: #14532d;
  --sp-labyrinth-border: #15803d;

  --sp-prison-bg: #ece7e1;
  --sp-prison-ink: #3b2f26;
  --sp-prison-border: #685648;

  --sp-skull-bg: #fbe2e0;
  --sp-skull-ink: #881313;
  --sp-skull-border: #b91c1c;

  --sp-garden-bg: #f6e09e;
  --sp-garden-ink: #4a2c00;
  --sp-garden-border: #b7791f;

  --shadow-soft: 0 8px 24px rgba(7, 18, 12, 0.38);
  --shadow-card: 0 4px 12px rgba(7, 18, 12, 0.26);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

/* MUNDO 2: Pliego Litográfico Clásico Fournier */
[data-world="fournier"] {
  --bg-page: #efe6d4;
  --bg-header: #162f4c;
  --bg-panel: #f8f3e8;
  --bg-panel-elevated: #efe7d6;
  --bg-board-frame: #162f4c;
  --bg-board-mat: #e6dac2;

  --sq-bg: #fcf9f2;
  --sq-bg-ring1: #f4ecdc;
  --sq-bg-ring2: #fbf7ee;
  --sq-text: #16293e;
  --sq-muted: #4b5d73;
  --sq-border: #b8a686;

  --text-primary: #16293e;
  --text-secondary: #3f5269;
  --text-on-accent: #fdfaf3;

  --accent-primary: #c83e2b;
  --accent-primary-hover: #b0301e;
  --accent-secondary: #162f4c;
  --border-subtle: rgba(22, 47, 76, 0.22);
  --border-strong: #162f4c;

  --shadow-soft: 0 8px 24px rgba(22, 47, 76, 0.14);
  --shadow-card: 0 4px 12px rgba(22, 47, 76, 0.1);
}

/* MUNDO 3: Atlas Enciclopédico y Lámina de Cobre */
[data-world="atlas"] {
  --bg-page: #f3eee3;
  --bg-header: #231e1a;
  --bg-panel: #faf6ee;
  --bg-panel-elevated: #efe9dc;
  --bg-board-frame: #3a2b22;
  --bg-board-mat: #e7dfd0;

  --sq-bg: #fdfbf6;
  --sq-bg-ring1: #f3ede0;
  --sq-bg-ring2: #faf6ed;
  --sq-text: #211c18;
  --sq-muted: #5c4f45;
  --sq-border: #bfb19c;

  --text-primary: #211c18;
  --text-secondary: #53463c;
  --text-on-accent: #fcf9f4;

  --accent-primary: #9e3b24;
  --accent-primary-hover: #832d19;
  --accent-secondary: #2e5a44;
  --border-subtle: rgba(58, 43, 34, 0.22);
  --border-strong: #9e3b24;

  --shadow-soft: 0 8px 22px rgba(35, 30, 26, 0.13);
  --shadow-card: 0 4px 10px rgba(35, 30, 26, 0.09);
}

/* MUNDO 4: Espécimen Reticular Geométrico Crouwel */
[data-world="crouwel"] {
  --font-display: 'Source Sans 3', system-ui, sans-serif;
  --bg-page: #eceae2;
  --bg-header: #111315;
  --bg-panel: #f7f6f1;
  --bg-panel-elevated: #eae8df;
  --bg-board-frame: #111315;
  --bg-board-mat: #111315;

  --sq-bg: #faf9f5;
  --sq-bg-ring1: #f0eee6;
  --sq-bg-ring2: #ffffff;
  --sq-text: #111315;
  --sq-muted: #454950;
  --sq-border: #22252a;

  --text-primary: #111315;
  --text-secondary: #3c4047;
  --text-on-accent: #ffffff;

  --accent-primary: #e63926;
  --accent-primary-hover: #c82917;
  --accent-secondary: #1d4ed8;
  --border-subtle: rgba(17, 19, 21, 0.22);
  --border-strong: #111315;

  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-lg: 6px;
  --shadow-soft: 0 6px 18px rgba(17, 19, 21, 0.14);
  --shadow-card: 0 3px 8px rgba(17, 19, 21, 0.08);
}

/* --------------------------------------------------------------------------
   2. RESET Y SUPERFICIES DEL NAVEGADOR (CRAFT FLOOR)
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  scrollbar-color: var(--accent-primary) var(--bg-page);
  scrollbar-width: thin;
}

body {
  min-height: 100vh;
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.45;
  caret-color: var(--accent-primary);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

::selection {
  background-color: var(--accent-primary);
  color: var(--text-on-accent);
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-page);
}

::-webkit-scrollbar-thumb {
  background: var(--accent-primary);
  border-radius: 4px;
}

:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

a {
  color: var(--accent-primary);
  text-underline-offset: 3px;
}

/* --------------------------------------------------------------------------
   3. CABECERA Y CARTELA MECÁNICA DE REFRANES
   -------------------------------------------------------------------------- */
.app-header {
  background-color: var(--bg-header);
  color: #f7f2e7;
  padding: 0.65rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(300px, 1.4fr) auto;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-card);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-emblem {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: var(--radius-md);
  background-color: rgba(223, 176, 83, 0.16);
  border: 1px solid rgba(223, 176, 83, 0.45);
  color: #f3c86b;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-emblem svg {
  width: 1.55rem;
  height: 1.55rem;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: #fbf7ef;
}

.brand-subtitle {
  font-size: 0.8rem;
  color: #d6c8b2;
}

/* Cartela mecánica (inspirada en tablón de láminas abatibles) */
.proverb-banner {
  background-color: #14110f;
  border: 1px solid rgba(223, 176, 83, 0.4);
  border-radius: var(--radius-md);
  padding: 0.42rem 0.9rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 3.1rem;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.55);
  transform-origin: center top;
}

.proverb-banner.is-flipping {
  animation: splitFlapFlip 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes splitFlapFlip {
  0% {
    transform: perspective(400px) rotateX(-35deg);
    opacity: 0.55;
  }
  100% {
    transform: perspective(400px) rotateX(0deg);
    opacity: 1;
  }
}

.proverb-banner-title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #f3c86b;
}

.proverb-banner-saying {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.92rem;
  line-height: 1.25;
  color: #faf5ea;
}

/* Controles de la cabecera */
.header-controls {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  min-width: 0;
}

.world-selector-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  color: #dfd3be;
  min-width: 0;
}

.world-selector-text {
  font-weight: 600;
  white-space: nowrap;
}

.control-select {
  background-color: #261e19;
  color: #faf5ea;
  border: 1px solid rgba(223, 176, 83, 0.42);
  border-radius: var(--radius-sm);
  padding: 0.38rem 0.6rem;
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  max-width: 100%;
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.08);
  color: #faf5ea;
  border: 1px solid rgba(223, 176, 83, 0.36);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.7rem;
  font-family: var(--font-sans);
  font-size: 0.83rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.btn-secondary svg {
  width: 1rem;
  height: 1rem;
}

.btn-secondary:hover {
  background-color: rgba(223, 176, 83, 0.2);
  border-color: #f3c86b;
}

.btn-secondary[aria-pressed="true"] {
  background-color: rgba(223, 176, 83, 0.24);
  border-color: #f3c86b;
  color: #ffe29a;
}

/* --------------------------------------------------------------------------
   4. DISTRIBUCIÓN PRINCIPAL: TABLERO (IZQUIERDA) + CONSOLA (DERECHA)
   -------------------------------------------------------------------------- */
.game-workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.95fr) minmax(320px, 0.95fr);
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  max-width: 1680px;
  width: 100%;
  margin: 0 auto;
  align-items: start;
}

.app-header > *,
.game-workspace > * {
  min-width: 0;
}

/* --------------------------------------------------------------------------
   5. TABLERO EN ESPIRAL DE 63 CASILLAS (MATRIZ 9×7)
   -------------------------------------------------------------------------- */
.board-stage {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.board-frame {
  position: relative;
  background-color: var(--bg-board-frame);
  padding: 0.65rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-soft);
}

.board-grid {
  --spiral-channel: 24px;
  --spiral-wall: #c6973f;
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  grid-template-rows: repeat(7, minmax(58px, 1fr));
  gap: var(--spiral-channel);
  background-color: #0b1c13;
  padding: 12px;
  border-radius: var(--radius-md);
  box-shadow: inset 0 3px 12px rgba(0, 0, 0, 0.65);
}

[data-world="fournier"] .board-grid {
  --spiral-wall: #162f4c;
  background-color: #12243b;
}

[data-world="atlas"] .board-grid {
  --spiral-wall: #6b3421;
  background-color: #211914;
}

[data-world="crouwel"] .board-grid {
  --spiral-wall: #111315;
  background-color: #111315;
}

/* Cada una de las 63 casillas dentro del carril en espiral */
.board-square {
  position: relative;
  background-color: var(--sq-bg);
  color: var(--sq-text);
  border: 1px dashed var(--sq-border);
  border-radius: 0;
  padding: 0.2rem 0.3rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: left;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
  overflow: visible;
  min-height: 58px;
  min-width: 0;
  z-index: 1;
}

/* Muros exteriores de cada vuelta de la espiral (separan un anillo del siguiente) */
.board-square.wall-top {
  border-top: 3px solid var(--spiral-wall);
}

.board-square.wall-right {
  border-right: 3px solid var(--spiral-wall);
}

.board-square.wall-bottom {
  border-bottom: 3px solid var(--spiral-wall);
}

.board-square.wall-left {
  border-left: 3px solid var(--spiral-wall);
}

/* Curvas exteriores en los giros de 90 grados de la espiral */
.board-square.wall-top.wall-left {
  border-top-left-radius: 14px;
}

.board-square.wall-top.wall-right {
  border-top-right-radius: 14px;
}

.board-square.wall-bottom.wall-left {
  border-bottom-left-radius: 14px;
}

.board-square.wall-bottom.wall-right {
  border-bottom-right-radius: 14px;
}

/* Puente de calzada que une físicamente la casilla n con la casilla n+1,
   manteniendo despejado el canal de 24px entre los carriles paralelos de la espiral */
.spiral-connector {
  position: absolute;
  background-color: var(--sq-bg);
  color: var(--sq-muted);
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 2;
}

.ring-1 .spiral-connector {
  background-color: var(--sq-bg-ring1);
}

.ring-2 .spiral-connector {
  background-color: var(--sq-bg-ring2);
}

.spiral-connector svg {
  width: 0.78rem;
  height: 0.78rem;
  opacity: 0.78;
}

/* Conector hacia la derecha (ej. casillas 1->9, 28->35, 48->53, 60->63) */
.spiral-connector.conn-right {
  top: -3px;
  bottom: -3px;
  right: calc(-1 * var(--spiral-channel));
  width: var(--spiral-channel);
  border-top: 3px solid var(--spiral-wall);
  border-bottom: 3px solid var(--spiral-wall);
  border-left: 1px dashed var(--sq-border);
  border-right: 1px dashed var(--sq-border);
}

/* Conector hacia arriba (ej. casillas 9->15, 35->39, 53->55) */
.spiral-connector.conn-up {
  left: -3px;
  right: -3px;
  top: calc(-1 * var(--spiral-channel));
  height: var(--spiral-channel);
  border-left: 3px solid var(--spiral-wall);
  border-right: 3px solid var(--spiral-wall);
  border-top: 1px dashed var(--sq-border);
  border-bottom: 1px dashed var(--sq-border);
}

/* Conector hacia la izquierda (ej. casillas 15->23, 39->45, 55->59) */
.spiral-connector.conn-left {
  top: -3px;
  bottom: -3px;
  left: calc(-1 * var(--spiral-channel));
  width: var(--spiral-channel);
  border-top: 3px solid var(--spiral-wall);
  border-bottom: 3px solid var(--spiral-wall);
  border-left: 1px dashed var(--sq-border);
  border-right: 1px dashed var(--sq-border);
}

/* Conector hacia abajo (ej. casillas 23->28, 45->48, 59->60) */
.spiral-connector.conn-down {
  left: -3px;
  right: -3px;
  bottom: calc(-1 * var(--spiral-channel));
  height: var(--spiral-channel);
  border-left: 3px solid var(--spiral-wall);
  border-right: 3px solid var(--spiral-wall);
  border-top: 1px dashed var(--sq-border);
  border-bottom: 1px dashed var(--sq-border);
}

.board-square.ring-1 {
  background-color: var(--sq-bg-ring1);
}

.board-square.ring-2 {
  background-color: var(--sq-bg-ring2);
}

.board-square:hover {
  border-color: var(--accent-primary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
  z-index: 6;
}

.board-square.is-inspected {
  outline: 2px solid var(--accent-primary);
  outline-offset: -3px;
}

/* Efecto de resaltado y parpadeo (blink) en TODAS las casillas donde hay jugadores */
.board-square.has-player {
  z-index: 4;
  animation: occupiedSquareBlink 1.35s ease-in-out infinite;
}

.board-square.has-player::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 2.5px solid var(--occupant-color, #1d4ed8);
  background-color: var(--occupant-color, #1d4ed8);
  opacity: 0.14;
  pointer-events: none;
  animation: occupiedOverlayFlash 1.35s ease-in-out infinite;
}

/* Efecto de parpadeo intenso y baliza luminosa en la casilla del jugador con el turno activo */
.board-square.has-active-player {
  z-index: 5;
  animation: activePlayerSquareBlink 0.95s ease-in-out infinite;
}

.board-square.has-active-player::before {
  content: '';
  position: absolute;
  inset: -3px;
  border: 3px solid var(--occupant-color, var(--accent-secondary));
  border-radius: inherit;
  box-shadow: 0 0 14px var(--occupant-color, var(--accent-secondary));
  pointer-events: none;
  z-index: 5;
  animation: activeBeaconRing 0.95s ease-in-out infinite;
}

@keyframes occupiedSquareBlink {
  0%,
  100% {
    box-shadow:
      inset 0 0 0 2px var(--occupant-color, #1d4ed8),
      0 0 4px rgba(0, 0, 0, 0.2);
  }
  50% {
    box-shadow:
      inset 0 0 0 3.5px var(--occupant-color, #1d4ed8),
      inset 0 0 16px rgba(223, 176, 83, 0.45),
      0 0 14px var(--occupant-color, #1d4ed8);
  }
}

@keyframes occupiedOverlayFlash {
  0%,
  100% {
    opacity: 0.06;
  }
  50% {
    opacity: 0.24;
  }
}

@keyframes activePlayerSquareBlink {
  0%,
  100% {
    box-shadow:
      inset 0 0 0 2.5px var(--occupant-color, #c83e2b),
      0 0 6px rgba(223, 176, 83, 0.35);
    transform: scale(1);
  }
  50% {
    box-shadow:
      inset 0 0 0 4px var(--occupant-color, #c83e2b),
      inset 0 0 22px rgba(255, 215, 110, 0.65),
      0 0 20px rgba(245, 196, 81, 0.95);
    transform: scale(1.02);
  }
}

@keyframes activeBeaconRing {
  0%,
  100% {
    opacity: 0.3;
  }
  50% {
    opacity: 1;
  }
}

.board-square.is-step-flash {
  animation: squareStepFlash 240ms ease-out;
}

.board-square.is-special-trigger {
  animation: squareSpecialPulse 450ms ease-in-out infinite alternate;
  z-index: 7;
}

@keyframes squareStepFlash {
  0% {
    transform: scale(1.05);
    filter: brightness(1.18);
  }
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

@keyframes squareSpecialPulse {
  0% {
    transform: scale(1);
  }
  100% {
    transform: scale(1.05);
  }
}

/* Cabecera interna de la casilla: Número y destino */
.square-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.15rem;
  width: 100%;
}

.square-number {
  font-family: var(--font-mono);
  font-size: 0.77rem;
  font-weight: 700;
  line-height: 1;
}

.square-dest-badge {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  padding: 0.05rem 0.22rem;
  border-radius: 3px;
  background-color: rgba(0, 0, 0, 0.09);
}

/* Cuerpo central: icono SVG y etiqueta corta */
.square-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.06rem;
  margin: auto 0;
}

.square-icon {
  width: 1.38rem;
  height: 1.38rem;
  display: inline-flex;
}

.square-icon svg {
  width: 100%;
  height: 100%;
}

.square-label {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.05;
  text-align: center;
}

/* Variantes cromáticas de las casillas especiales */
.board-square.square-type-start {
  background-color: #f3ebd9;
  color: #3d2c10;
}

.board-square.square-type-goose {
  background-color: var(--sp-goose-bg);
  color: var(--sp-goose-ink);
}

.board-square.square-type-bridge {
  background-color: var(--sp-bridge-bg);
  color: var(--sp-bridge-ink);
}

.board-square.square-type-inn {
  background-color: var(--sp-inn-bg);
  color: var(--sp-inn-ink);
}

.board-square.square-type-dice {
  background-color: var(--sp-dice-bg);
  color: var(--sp-dice-ink);
}

.board-square.square-type-well {
  background-color: var(--sp-well-bg);
  color: var(--sp-well-ink);
}

.board-square.square-type-labyrinth {
  background-color: var(--sp-labyrinth-bg);
  color: var(--sp-labyrinth-ink);
}

.board-square.square-type-prison {
  background-color: var(--sp-prison-bg);
  color: var(--sp-prison-ink);
}

.board-square.square-type-skull {
  background-color: var(--sp-skull-bg);
  color: var(--sp-skull-ink);
}

.board-square.square-type-garden {
  background-color: var(--sp-garden-bg);
  color: var(--sp-garden-ink);
  box-shadow: inset 0 0 0 2px var(--sp-garden-border);
}

/* Reafirmar muros continuos de la espiral por encima de cualquier tipo de casilla */
.board-square.wall-top {
  border-top: 3px solid var(--spiral-wall);
}

.board-square.wall-right {
  border-right: 3px solid var(--spiral-wall);
}

.board-square.wall-bottom {
  border-bottom: 3px solid var(--spiral-wall);
}

.board-square.wall-left {
  border-left: 3px solid var(--spiral-wall);
}

/* Contenedor de fichas dentro de cada casilla */
.square-tokens {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.22rem;
  min-height: 1.25rem;
  flex-wrap: wrap;
  z-index: 3;
}

.board-token {
  width: 1.22rem;
  height: 1.22rem;
  border-radius: 50%;
  background-color: var(--token-color);
  color: #ffffff;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.45);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
  transition: transform 180ms ease;
  animation: tokenSubtlePulse 1.8s ease-in-out infinite;
}

.board-token.is-active-token {
  animation: activeTokenBlink 1.15s ease-in-out infinite;
  box-shadow: 0 0 0 2px var(--token-stroke), 0 0 10px var(--token-color);
}

@keyframes tokenSubtlePulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
}

@keyframes activeTokenBlink {
  0%,
  100% {
    transform: scale(1.12);
    box-shadow: 0 0 0 2px var(--token-stroke), 0 2px 6px rgba(0, 0, 0, 0.5);
  }
  50% {
    transform: scale(1.26);
    box-shadow: 0 0 0 3px #ffffff, 0 0 12px var(--token-color);
  }
}

.board-token.is-penalized-token {
  opacity: 0.78;
  border-style: dashed;
}

/* --------------------------------------------------------------------------
   6. CAPA VECTORIAL SVG DE ESPIRAL Y ARCOS DE SALTO
   -------------------------------------------------------------------------- */
.board-svg-overlay {
  position: absolute;
  inset: 0.65rem;
  width: calc(100% - 1.3rem);
  height: calc(100% - 1.3rem);
  pointer-events: none;
  z-index: 2;
  transition: opacity 180ms ease;
}

.board-svg-overlay.is-hidden {
  opacity: 0;
}

.spiral-guide-line {
  fill: none;
  stroke: rgba(140, 115, 75, 0.18);
  stroke-width: 2;
  stroke-dasharray: 4 5;
}

.jump-arc {
  fill: none;
  stroke-width: 2.2;
  stroke-dasharray: 5 4;
  opacity: 0.52;
  transition: opacity 160ms ease, stroke-width 160ms ease;
}

.jump-arc.arc-bridge {
  stroke: #1d4ed8;
}

.jump-arc.arc-dice {
  stroke: #6d28d9;
}

.jump-arc.arc-labyrinth {
  stroke: #15803d;
}

.jump-arc.arc-skull {
  stroke: #b91c1c;
}

.jump-arc.arc-active-jump {
  stroke: #d97706;
  opacity: 0.95;
  stroke-width: 3.2;
}

.jump-arc.is-highlighted {
  opacity: 0.96;
  stroke-width: 3.4;
}

/* Leyenda inferior del tablero */
.board-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.legend-chip {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.24rem 0.55rem;
  border-radius: var(--radius-sm);
  background-color: var(--bg-panel);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  display: inline-block;
}

.legend-goose .legend-dot { background-color: var(--sp-goose-border); }
.legend-bridge .legend-dot { background-color: var(--sp-bridge-border); }
.legend-inn .legend-dot { background-color: var(--sp-inn-border); }
.legend-dice .legend-dot { background-color: var(--sp-dice-border); }
.legend-well .legend-dot { background-color: var(--sp-well-border); }
.legend-labyrinth .legend-dot { background-color: var(--sp-labyrinth-border); }
.legend-prison .legend-dot { background-color: var(--sp-prison-border); }
.legend-skull .legend-dot { background-color: var(--sp-skull-border); }

/* --------------------------------------------------------------------------
   7. BARRA LATERAL OPERATIVA: DADOS, JUGADORES, INSPECTOR Y CRÓNICA
   -------------------------------------------------------------------------- */
.control-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.panel-block {
  background-color: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.8rem 0.95rem;
  box-shadow: var(--shadow-card);
}

.panel-heading {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.55rem;
  color: var(--text-primary);
}

/* Consola de turno y dados */
.turn-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.active-player-pill {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.active-player-badge {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  color: #ffffff;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
  display: grid;
  place-items: center;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.active-player-name {
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.15;
}

.active-player-square {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.dice-result-sum {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-sm);
  background-color: var(--bg-panel-elevated);
  border: 1px solid var(--border-subtle);
}

.dice-action-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.dice-stage {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 3.4rem;
}

.die-cube {
  width: 3.25rem;
  height: 3.25rem;
  flex-shrink: 0;
}

.die-cube.is-rolling {
  animation: dieRollSpin 360ms cubic-bezier(0.22, 1, 0.36, 1) infinite;
}

@keyframes dieRollSpin {
  0% {
    transform: rotate(0deg) scale(1);
  }
  50% {
    transform: rotate(16deg) scale(1.08);
  }
  100% {
    transform: rotate(-12deg) scale(1);
  }
}

.die-body {
  fill: #fbf8f1;
  stroke: #3d3124;
  stroke-width: 4;
}

.die-pip {
  fill: #1d1611;
}

.dice-cta-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.btn-primary-roll {
  background-color: var(--accent-primary);
  color: var(--text-on-accent);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.62rem 1rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 150ms ease, transform 120ms ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.btn-primary-roll:hover:not(:disabled) {
  background-color: var(--accent-primary-hover);
  transform: translateY(-1px);
}

.btn-primary-roll:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.turn-rule-hint {
  font-size: 0.76rem;
  color: var(--text-secondary);
}

/* Tarjetas de jugadores */
.players-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.player-card {
  background-color: var(--bg-panel-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.player-card.is-current-turn {
  border-color: var(--accent-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
}

.player-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.player-identity {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.player-token-dot {
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 50%;
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  border: 1.5px solid #ffffff;
}

.player-name {
  font-size: 0.88rem;
  margin-right: 0.35rem;
}

.player-role-tag {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

/* Insignias de estado semántico */
.status-pill {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.14rem 0.45rem;
  border-radius: 4px;
  border: 1px solid transparent;
}

.status-ready {
  background-color: rgba(34, 197, 94, 0.16);
  color: #4ade80;
  border-color: rgba(34, 197, 94, 0.35);
}

[data-world="fournier"] .status-ready,
[data-world="atlas"] .status-ready,
[data-world="crouwel"] .status-ready {
  background-color: #dcfce7;
  color: #166534;
  border-color: #86efac;
}

.status-penalty {
  background-color: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
}

.status-well {
  background-color: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}

.status-winner {
  background-color: #fef08a;
  color: #713f12;
  border-color: #eab308;
}

.player-card-metrics {
  display: flex;
  justify-content: space-between;
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.player-progress-track {
  height: 4px;
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 2px;
  overflow: hidden;
}

.player-progress-fill {
  height: 100%;
  transition: width 240ms ease;
}

/* Inspector de casilla y reglas activas */
.square-inspector {
  background-color: var(--bg-panel-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.7rem;
  margin-bottom: 0.5rem;
}

.inspector-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.3rem;
}

.inspector-icon {
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-sm);
  background-color: rgba(223, 176, 83, 0.18);
  color: var(--accent-primary);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.inspector-icon svg {
  width: 1.35rem;
  height: 1.35rem;
}

.inspector-title-row {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.inspector-number {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.12rem 0.42rem;
  border-radius: 4px;
  background-color: rgba(0, 0, 0, 0.15);
  color: var(--text-secondary);
}

.inspector-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.15;
}

.inspector-saying {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.84rem;
  color: var(--accent-primary);
  margin-bottom: 0.2rem;
}

.inspector-rule {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.active-rules-summary {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem 0.6rem;
  font-size: 0.74rem;
  color: var(--text-secondary);
}

.active-rules-summary strong {
  color: var(--text-primary);
}

/* Crónica de la partida */
.history-list {
  list-style: none;
  max-height: 170px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding-right: 0.25rem;
}

.history-item {
  background-color: var(--bg-panel-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.6rem;
  font-size: 0.78rem;
}

.history-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.15rem;
}

.history-turn {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  background-color: rgba(0, 0, 0, 0.18);
}

.history-msg {
  color: var(--text-primary);
}

.history-saying {
  display: block;
  margin-top: 0.15rem;
  font-family: var(--font-display);
  color: var(--accent-primary);
}

/* --------------------------------------------------------------------------
   8. DIÁLOGOS MODALES (CONFIGURACIÓN Y VICTORIA)
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(10, 14, 12, 0.76);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 50;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-sheet {
  background-color: var(--bg-panel);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 760px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 1.25rem 1.4rem;
  box-shadow: var(--shadow-soft);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
}

.btn-icon-close {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.btn-icon-close svg {
  width: 1.1rem;
  height: 1.1rem;
}

.config-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.config-fieldset {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
}

.config-legend {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0 0.4rem;
}

/* Tarjetas de selección de Mundo Visual */
.world-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 0.4rem;
}

.world-choice-card {
  display: block;
  cursor: pointer;
}

.world-choice-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.world-choice-body {
  background-color: var(--bg-panel-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.world-choice-card input:checked + .world-choice-body {
  border-color: var(--accent-primary);
  box-shadow: inset 0 0 0 1px var(--accent-primary);
}

.world-choice-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.world-choice-title {
  font-size: 0.88rem;
}

.world-swatches {
  display: flex;
  gap: 0.2rem;
}

.world-swatch {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.world-choice-desc {
  font-size: 0.76rem;
  color: var(--text-secondary);
}

/* Cuadrícula de reglas y jugadores */
.rules-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 0.4rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  font-size: 0.82rem;
  font-weight: 600;
}

.players-setup-rows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.player-setup-row {
  display: grid;
  grid-template-columns: 2rem 1fr 150px;
  gap: 0.6rem;
  align-items: center;
}

.player-setup-row[hidden] {
  display: none;
}

.setup-token-badge {
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  color: #ffffff;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.8rem;
  display: grid;
  place-items: center;
}

.player-setup-row input,
.player-setup-row select {
  background-color: var(--bg-panel-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.42rem 0.6rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  margin-top: 0.5rem;
}

.modal-victory {
  max-width: 480px;
  text-align: center;
}

.victory-proverb {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--accent-primary);
  margin: 0.6rem 0;
}

.victory-summary {
  font-size: 0.92rem;
  color: var(--text-secondary);
  margin-bottom: 1.1rem;
}

/* --------------------------------------------------------------------------
   9. DISEÑO RESPONSIVO (TABLETAS Y MÓVILES)
   -------------------------------------------------------------------------- */
@media (max-width: 1180px) {
  .app-header {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

  .game-workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .app-header {
    padding: 0.55rem 0.65rem;
  }

  .brand-title {
    font-size: 1.1rem;
  }

  .brand-subtitle {
    font-size: 0.74rem;
  }

  .world-selector-label {
    width: 100%;
    justify-content: space-between;
  }

  .world-selector-label .control-select {
    flex: 1;
    min-width: 0;
  }

  .game-workspace {
    padding: 0.55rem 0.6rem;
    gap: 0.75rem;
  }

  .board-frame {
    padding: 0.3rem;
  }

  .board-grid {
    --spiral-channel: 8px;
    gap: var(--spiral-channel);
    padding: 4px;
    grid-template-rows: repeat(7, minmax(46px, 1fr));
  }

  .board-square {
    min-height: 46px;
    padding: 0.12rem 0.15rem;
  }

  .spiral-connector svg {
    width: 0.5rem;
    height: 0.5rem;
  }

  .square-number {
    font-size: 0.6rem;
  }

  .square-dest-badge,
  .square-flow-arrow,
  .square-label {
    display: none;
  }

  .square-icon {
    width: 0.98rem;
    height: 0.98rem;
  }

  .board-token {
    width: 0.72rem;
    height: 0.72rem;
    font-size: 0.48rem;
    border-width: 1px;
  }

  .legend-chip {
    font-size: 0.68rem;
    padding: 0.2rem 0.42rem;
  }

  .active-rules-summary,
  .world-cards-grid,
  .rules-grid {
    grid-template-columns: 1fr;
  }

  .player-setup-row {
    grid-template-columns: 1.8rem 1fr 110px;
  }
}
