:root {
  --bg: #0b0d12;
  --bg-2: #12151d;
  --panel: #171b25;
  --panel-2: #1d2230;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e7e9f0;
  --text-dim: #97a0b2;
  --gold: #d9b26a;
  --cyan: #4ff0ff;
  --green: #6fe89a;
  --red: #ff7a6b;
  --violet: #b98cff;
  --font-display: 'Cinzel', serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'VT323', monospace;
  --tt-bosque: #58a05e;
  --tt-volcan: #d76041;
  --tt-tundra: #7fc9e3;
  --tt-desierto: #d9b26a;
  --tt-llanura: #9dbb63;
  /* v0.13.0 — HUD de vidrio flotante sobre el campo full-bleed */
  --glass-bg: rgba(11, 14, 22, 0.50);
  --glass-border: rgba(255, 255, 255, 0.14);
  --gx: 240px;   /* origen X de la rejilla (lo fija resizeBoard()) */
  --gy: 240px;   /* origen Y de la rejilla */
  --gs: 640px;   /* lado de la rejilla 8×8 */
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-body);
  overflow: hidden;  /* v0.13.0: el campo es fijo y ocupa toda la pantalla */
}
body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(79, 240, 255, 0.06), transparent 60%),
    radial-gradient(900px 500px at 100% 10%, rgba(217, 178, 106, 0.08), transparent 55%),
    var(--bg);
}
/* v0.13.0 — PÍLDORA FLOTANTE de vidrio: ◆ ELIO · turno · ☰ */
.topbar {
  position: fixed; top: 10px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 12px; align-items: center;
  padding: 8px 14px; z-index: 40;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  max-width: calc(100vw - 20px);
}
.brand {
  display: flex; align-items: baseline; gap: 10px;
  font-family: var(--font-display); font-size: 16px; letter-spacing: 0.5px;
  white-space: nowrap;
}
/* La píldora va limpia: la versión vive en el menú ☰ */
.topbar .brand em, .topbar .tag { display: none; }
.brand em { color: var(--text-dim); font-style: normal; font-family: var(--font-body); font-size: 13px; }
.brand-mark { color: var(--gold); font-size: 14px; }
.tag {
  font-family: var(--font-mono); color: var(--cyan);
  border: 1px solid var(--border-strong); padding: 2px 8px; border-radius: 999px;
  font-size: 13px; margin-left: 8px;
}
.turn-indicator {
  display: flex; gap: 8px; align-items: center;
  font-family: var(--font-mono); font-size: 14px; color: var(--cyan);
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border-strong);
  padding: 4px 10px; border-radius: 999px; white-space: nowrap;
}
.turn-indicator .dot { width: 6px; height: 6px; border-radius: 999px; background: var(--gold); }
.controls { display: flex; gap: 8px; align-items: center; }
.controls label { font-size: 12px; color: var(--text-dim); display: flex; flex-direction: column; }
.controls select, .controls button {
  background: var(--panel-2); color: #ffffff; border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 8px 10px; font-family: var(--font-body); font-size: 14px;
  min-height: 36px;
}
@media (max-width: 900px) {
  /* En móvil el font-size >= 16px evita el zoom automático de iOS al abrir el select */
  .controls select { font-size: 16px; min-height: 44px; padding: 10px 12px; }
  .controls button { font-size: 15px; min-height: 44px; padding: 10px 14px; }
}
.controls select option { background: var(--panel-2); color: #ffffff; }
.controls button { cursor: pointer; transition: 0.15s; }
.controls button:hover { border-color: var(--cyan); color: var(--cyan); }

/* v0.13.0 — EL CAMPO ES EL REY: la UI flota sobre el campo full-bleed.
   .layout ya no es una parrilla: es un plano fijo TRANSPARENTE que no
   intercepta el ratón — solo sus tarjetas flotantes son interactivas. */
.layout {
  position: fixed; inset: 0; z-index: 15;
  display: block; padding: 0; margin: 0;
  pointer-events: none;
}
.side {
  pointer-events: auto;
  position: fixed; z-index: 30;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 14px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  max-height: calc(100vh - 150px);
  max-height: calc(100dvh - 150px);
  overflow-y: auto;
  /* v0.13.1 — translúcido de verdad: el campo se ve A TRAVÉS del panel */
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
}
/* Colocación por ORIENTACIÓN (responsive a cualquier proporción) */
@media (orientation: landscape) {
  .side { width: clamp(150px, calc(var(--gx) - 16px), 260px); }
  .side.left  { left: 12px;  top: 76px; }
  .side.right { right: 12px; top: 76px; }
}
@media (orientation: portrait) {
  .side { width: min(360px, calc(50vw - 12px)); top: 62px; }
  .side.left  { left: 10px; }
  .side.right { right: 10px; }
}
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
/* v0.15.3 — CORRECCIÓN: `.panel` (opaco, definido después) pisaba el vidrio de
   `.side` desde 0.13.0 — los recuadros de bando se veían SÓLIDOS. Especificidad
   0,2,0 > 0,1,0 gana siempre: son SEMITRANSPARENTES de verdad (el campo se aprecia). */
.panel.side {
  background: rgba(11, 14, 22, 0.45);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
}
.panel h3 { margin: 0 0 12px; font-family: var(--font-display); font-size: 16px; letter-spacing: 0.5px; color: var(--gold); }
.panel h4 { margin: 12px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); }
.side .stat-row {
  display: flex; justify-content: space-between; padding: 6px 0;
  font-family: var(--font-mono); font-size: 18px; color: var(--cyan);
  border-bottom: 1px dashed var(--border);
}
.side .stat-row span { color: var(--text-dim); font-family: var(--font-body); font-size: 12px; align-self: center; }
.captured {
  min-height: 40px; display: flex; flex-wrap: wrap; gap: 4px; padding-top: 8px;
}
.captured img, .captured canvas { width: 28px; height: 28px; image-rendering: pixelated; opacity: 0.85; }
.bonus { color: var(--text-dim); font-size: 12px; line-height: 1.5; }
.bonus b { color: var(--gold); }
.bonus .plus { color: var(--green); }
.bonus .minus { color: var(--red); }

/* v0.13.0 — CAMPO DE BATALLA TOTAL: el lienzo es TODA la pantalla.
   El tamaño exacto lo fija resizeBoard() (viewport visual del navegador). */
.board-wrap { position: absolute; inset: 0; pointer-events: none; }
.board-frame {
  position: fixed; left: 0; top: 0;
  overflow: hidden;
  background: #07080c;
  z-index: 5;
}
/* v0.36.0 — CÁMARA INCLINADA (85° por defecto): el frame del campo se abisma
   en CSS 3D (GPU, coste cero por frame) — terreno, fichas, flechas y FX
   reciben la perspectiva de la cámara; el HUD (DOM flotante) permanece plano:
   es interfaz, no escena. Variables fijadas por applyCamera() en main.js:
   --cam-t inclinación · --cam-p perspectiva · --cam-s cobertura superior. */
.board-frame {
  transform: scale(var(--cam-s, 1)) perspective(var(--cam-p, 1600px)) rotateX(var(--cam-t, 0deg));
  transform-origin: 50% 50%;
  transition: transform 420ms cubic-bezier(0.33, 0, 0.15, 1);
  will-change: transform;
}
#board, #overlay {
  position: absolute; left: 0; top: 0; width: 100%; height: 100%;
  image-rendering: auto;
}
#overlay { pointer-events: auto; }
.hint {
  /* Píldora flotante sobre el campo (vive bajo la rejilla, no estorba) */
  position: fixed; left: 50%; bottom: 10px; transform: translateX(-50%);
  z-index: 30; margin: 0;
  max-width: min(92vw, 620px); text-align: center;
  background: var(--glass-bg); border: 1px solid var(--glass-border);
  border-radius: 999px; padding: 7px 18px;
  font-family: var(--font-mono); font-size: 13px; color: var(--text-dim);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}
.log-panel { margin: 0 16px 16px; }
.log { list-style: decimal inside; padding: 0; margin: 0; max-height: 200px; overflow: auto;
  font-family: var(--font-mono); font-size: 15px; color: var(--text-dim);
  columns: 2; column-gap: 24px;
}
.log li { padding: 2px 0; }
.log li b { color: var(--cyan); }
.log li em { color: var(--gold); font-style: normal; }

.rules { margin: 0 16px 24px; }
.rules-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
.rules ul { padding-left: 18px; margin: 0; color: var(--text-dim); font-size: 13px; line-height: 1.6; }
.rules b { color: var(--text); }
.rules .tt { padding: 1px 6px; border-radius: 4px; color: #0b0d12; font-weight: 700; font-size: 12px; margin-right: 4px; display: inline-block; }
.rules .tt.L { background: #6f8949; }
.rules .tt.F { background: #2f5f38; color: #e7e9f0; }
.rules .tt.M { background: #6a6a75; }
.rules .tt.P { background: #26382a; color: #e7e9f0; }
.rules .tt.S { background: #f5f6f2; }
.rules .tt.C { background: #2b2a35; color: #e7e9f0; }
.rules .tt.T { background: #a58a55; }
.rules .tt.V { background: #e6552c; color: #fff; }
.rules .tt.X { background: #7a2f8a; color: #fff; }
.rules .tt.R { background: #a99574; }

.ab-table { width: 100%; border-collapse: collapse; font-family: var(--font-mono); font-size: 13px; color: var(--text-dim); margin-top: 8px; }
.ab-table th, .ab-table td { padding: 4px 8px; text-align: left; border-bottom: 1px solid rgba(255,255,255,0.06); }
.ab-table th { color: var(--gold); font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; font-size: 11px; }
.ab-table td b { color: var(--text); }

.small { font-size: 12px; }
.muted { color: var(--text-dim); }

/* Panel de ficha */
.piece-panel { margin: 0 16px 16px; }
.pi-head { font-family: var(--font-display); font-size: 15px; color: var(--gold); margin-bottom: 8px; }
.pi-stats { display: flex; gap: 14px; font-family: var(--font-mono); font-size: 16px; color: var(--cyan); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; background: var(--panel-2); }
.pi-stats b { color: #ffffff; font-family: var(--font-mono); font-size: 20px; }
.pi-terr { margin-top: 10px; font-size: 13px; color: var(--text); }
.pi-terr b { color: var(--gold); }
.pi-costs { margin-top: 6px; }
/* v0.113.6 — min(240px, 100%): en una columna de menos de 240 px la pista ya no desborda */
.pi-abilities { margin-top: 12px; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 10px; }
.ab-item { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: var(--panel-2); }
.ab-item.active { border-color: var(--gold); box-shadow: 0 0 12px rgba(217,178,106,0.35); }
/* v0.113.6 — la cabecera puede saltar de línea ENTRE sus piezas (nombre · tipo · coste),
   pero el tipo y el coste nunca se parten por dentro (ver .ab-kind / .ab-cost). */
.ab-head { display: flex; align-items: baseline; gap: 4px 8px; flex-wrap: wrap; }
.ab-head b { color: #ffffff; font-family: var(--font-display); font-size: 13px; letter-spacing: 0.3px; }
.ab-kind { background: rgba(79,240,255,0.15); color: var(--cyan); font-size: 10px; padding: 1px 6px; border-radius: 4px; text-transform: uppercase; white-space: nowrap; /* v0.113.6 */ }
.ab-cost { margin-left: auto; color: var(--gold); font-family: var(--font-mono); font-size: 13px; white-space: nowrap; /* v0.113.6 — «30% (3 En)» en una sola línea */ }
.ab-desc { margin: 6px 0 8px; line-height: 1.4; }
.ab-btn { background: var(--panel); border: 1px solid var(--border-strong); color: var(--text); border-radius: 6px; padding: 6px 10px; font-size: 12px; font-family: var(--font-body); cursor: pointer; transition: 0.15s; }
.ab-btn:hover:not(:disabled) { border-color: var(--gold); color: var(--gold); }
.ab-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ab-btn.active { background: linear-gradient(180deg, #f6dd8a, #d4b04a); color: #0b0d12; border-color: #f6dd8a; }

.plus { color: #7cf0a1; font-weight: 600; }
.minus { color: #ff8674; font-weight: 600; }

.ab-table tr.pending td { color: var(--text-dim); font-style: italic; }

/* Modal de combate */
.combat-modal {
  /* v0.113.6 — CAPA FIJA DE PRIMER NIVEL (el nodo salió de #boardFrame: index.html). Antes
     era `absolute` dentro del frame: heredaba la inclinación 3D de la cámara, la recortaba
     su `overflow: hidden` (en móvil apaisado medía 476-520 px en una pantalla de 390 y los
     botones quedaban fuera, sin desplazamiento posible) y la pisaban la barra superior
     (z 40), la píldora de ayuda y los paneles de bando. Ahora: centrada en la PANTALLA con
     inset 0 + margin auto (sin transform: texto nítido), por encima de todo el HUD (z 60;
     bajo la ventana flotante 280 y el cajón ☰ 300) y con el alto ligado al alto visible. */
  --cm-pad-y: 18px; --cm-pad-x: 20px;
  position: fixed; inset: 0; margin: auto; z-index: 60;
  width: -moz-fit-content; width: fit-content; height: -moz-fit-content; height: fit-content;
  min-width: min(380px, calc(100vw - 16px)); max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px);
  background: rgba(13,16,24,0.78); border: 2px solid var(--gold); border-radius: 12px; padding: var(--cm-pad-y) var(--cm-pad-x); box-shadow: 0 20px 60px rgba(0,0,0,0.7); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  /* v0.19.2 — CAUSA RAÍZ del "modal muerto": .board-wrap desactiva los clics de
     todo su contenido (v0.13.0) y #overlay los re-activa PARA SÍ, pero el modal
     heredaba pointer-events: none → invisible a los clics reales: cada toque
     atravesaba el modal hasta el canvas, que retornaba temprano (botones muertos,
     tablero muerto; solo el ☰, fuera de esta capa, respondía). */
  pointer-events: auto;
}
.combat-modal h3 { margin: 0 0 10px; color: var(--gold); font-family: var(--font-display); font-size: 16px; }
.cm-row { display: grid; grid-template-columns: 1fr 40px 1fr; gap: 8px; align-items: center; margin-bottom: 10px; }
.cm-side { background: var(--panel-2); border: 1px solid var(--border-strong); border-radius: 8px; padding: 10px; font-size: 13px; color: #ffffff; }
.cm-side b { color: var(--cyan); }
.cm-vs { text-align: center; font-size: 24px; color: var(--gold); }
.cm-preview { border-top: 1px dashed var(--border); padding-top: 8px; margin-bottom: 12px; }
.cm-preview b { color: var(--gold); }
.cm-abs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
/* v0.113.6 — `> b`: solo el TÍTULO del bloque («Declara habilidad:»). Con `.cm-abs b` la
   regla atrapaba también el nombre de cada habilidad (display block, 100%) y empujaba su
   coste «30% (3 En)» a una segunda línea partida. */
.cm-abs > b { display: block; width: 100%; color: var(--gold); font-size: 12px; margin-bottom: 4px; }
/* v0.9.1: bloques de habilidad con descripción dentro del modal de combate/defensa */
.cm-abs .ab-item { flex: 1 1 260px; }
.cm-abs .ab-item .ab-btn { width: 100%; }
.cm-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.cm-actions button { background: var(--panel); border: 1px solid var(--border-strong); color: var(--text); border-radius: 6px; padding: 8px 14px; font-family: var(--font-body); font-size: 13px; cursor: pointer; }
.cm-actions #cm-confirm { background: linear-gradient(180deg, #f6dd8a, #d4b04a); color: #0b0d12; border-color: #f6dd8a; font-weight: 600; }
.cm-actions button.ghost { background: transparent; color: var(--text-dim); border-style: dashed; }
.cm-actions button.ghost:hover { color: var(--gold); border-color: var(--gold); }

/* v0.19.0 — FICHAS DE AMBOS BANDOS dentro del modal de combate (botón ℹ) */
/* v0.113.6 — la rejilla recibe por fin SUS 3 hijos (ficha atacante | ⚔ | ficha defensor:
   cada ficha es un .pi-sheet). Ya no tiene alto máximo ni desplazamiento propio (tampoco
   las habilidades): se desplaza la zona .cm-scroll de la ventana, de una sola vez. El
   resto de reglas de las fichas en combate vive al final del archivo (bloque v0.113.6). */
.cm-pieces-info {
  display: grid; grid-template-columns: minmax(0,1fr) 30px minmax(0,1fr);
  gap: 8px; align-items: start; margin: 10px 0 12px;
}
.cm-pieces-info .cm-vs { font-size: 22px; align-self: center; }
@media (max-width: 620px) {
  .cm-pieces-info { grid-template-columns: minmax(0,1fr); }
  .cm-pieces-info .cm-vs { text-align: center; padding: 0; }
}
.cm-actions button:hover { border-color: var(--cyan); }

/* (v0.13.0) La antigua parrilla responsive desaparece: el HUD flota siempre. */

/* ============ START SPLASH (pantalla inicial) ============ */
.start-splash { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; background: var(--bg); overflow: hidden; }
.start-splash-bg {
  position: absolute; inset: 0; z-index: 0;
  /* Fondo épico: El Trono Olvidado (Propuesta C) + veladura oscura para legibilidad del título */
  background:
    linear-gradient(180deg, rgba(8,9,13,0.62) 0%, rgba(8,9,13,0.28) 38%, rgba(8,9,13,0.42) 72%, rgba(8,9,13,0.72) 100%),
    radial-gradient(1200px 700px at 50% 26%, rgba(217,178,106,0.10), transparent 65%),
    radial-gradient(1000px 620px at 50% 78%, rgba(8,9,13,0.55), transparent 70%),
    url("../assets/art/title_bg.png") center/cover no-repeat,
    linear-gradient(180deg, #08090d 0%, #12151d 100%);
  background-color: #08090d;
}
.start-splash-inner { position: relative; z-index: 1; text-align: center; padding: 40px 24px; display: flex; flex-direction: column; align-items: center; gap: 18px; max-width: 720px; width: 100%; }
/* v0.25.0 — EMBLEMA OFICIAL (dualidad rúnica ámbar/turquesa con fractura violeta) */
.start-splash-logo {
  /* v0.25.3 — MASTER con llamas integradas (editImage sobre el emblema):
     protagonista ABSOLUTO del título (pedido: «que se vea grande, no tan
     pequeña como antes»). Ocupa el 55% del ancho con tope por altura (58vh)
     para no desplazar jamás los botones; piso de 240px en móvil. */
  width: max(240px, min(55vw, 58vh)); height: auto; line-height: 1;
  filter: drop-shadow(0 0 26px rgba(176, 106, 226, 0.45)) drop-shadow(0 4px 18px rgba(8, 9, 13, 0.85));
  animation: logoGlow 6s ease-in-out infinite;
}
@keyframes logoGlow {
  0%, 100% { filter: drop-shadow(0 0 22px rgba(176, 106, 226, 0.38)) drop-shadow(0 4px 18px rgba(8, 9, 13, 0.85)); }
  50% { filter: drop-shadow(0 0 34px rgba(176, 106, 226, 0.6)) drop-shadow(0 4px 18px rgba(8, 9, 13, 0.85)); }
}
.start-splash-title {
  font-family: var(--font-display);
  font-size: clamp(72px, 18vw, 140px);
  letter-spacing: clamp(4px, 1.2vw, 12px);
  color: #ffffff;
  margin: 0;
  line-height: 1;
  text-shadow: 0 0 40px rgba(217,178,106,0.45), 0 4px 24px rgba(0,0,0,0.6);
}
.start-splash-tagline {
  font-family: var(--font-display);
  font-size: clamp(16px, 3.6vw, 24px);
  color: var(--gold);
  letter-spacing: clamp(2px, 0.6vw, 5px);
  text-transform: uppercase;
  margin: 0;
}
.start-splash-sub { font-family: var(--font-mono); color: var(--cyan); font-size: clamp(12px, 2.6vw, 16px); margin: 0; }
.start-splash-btn {
  margin-top: 20px;
  background: linear-gradient(180deg, #f6dd8a, #d4b04a);
  color: #0b0d12;
  border: none;
  border-radius: 10px;
  padding: 16px 48px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 1px;
  cursor: pointer;
  min-height: 52px;
  min-width: 200px;
  box-shadow: 0 8px 32px rgba(217,178,106,0.35), inset 0 1px 0 rgba(255,255,255,0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.start-splash-btn:hover, .start-splash-btn:focus-visible { transform: translateY(-2px); box-shadow: 0 12px 40px rgba(246,221,138,0.55), inset 0 1px 0 rgba(255,255,255,0.4); outline: none; }
.start-splash-btn:active { transform: translateY(0); }
.start-splash-actions { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.start-splash-actions .start-splash-btn { margin-top: 0; }
/* v0.55.1 — SALIR del juego: botón discreto bajo Comenzar + diálogo de confirmación */
.start-splash-exit { margin-top: 18px; }
.start-splash-btn.small { padding: 8px 18px; font-size: 13px; letter-spacing: 1.5px; min-width: 0; }
.exit-confirm { position: fixed; inset: 0; z-index: 360; display: flex; align-items: center; justify-content: center;
  background: rgba(5,6,10,.78); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.exit-confirm[hidden] { display: none; }
.exit-card { width: min(430px, 92vw); text-align: center; padding: 26px 30px 22px;
  background: rgba(12,14,20,.92); border: 1px solid rgba(246,221,138,.4); border-radius: 14px;
  box-shadow: 0 24px 80px rgba(0,0,0,.8); }
.exit-title { color: #f6dd8a; font-size: 21px; letter-spacing: 2px; margin-bottom: 10px;
  font-family: 'Grenze Gotisch', 'Old English Text MT', serif; text-shadow: 0 2px 8px #000; }
.exit-msg { color: #c9bfa4; font-size: 13.5px; line-height: 1.5; margin: 0 0 18px; }
.exit-actions { display: flex; gap: 12px; justify-content: center; }
.exit-hint { color: #ff9d8f; font-size: 12.5px; margin-top: 14px; line-height: 1.5; }
.exit-hint[hidden] { display: none; }
/* ============ v0.59.0 — PANTALLA DE AJUSTES (⚙ desde el título) ============
   Las configuraciones ya no viven en el cajón ☰ de la partida. Panel de vidrio
   semitransparente (canon visual del juego) sobre velo oscuro del título. */
.settings-screen { position: fixed; inset: 0; z-index: 365; display: flex; align-items: center; justify-content: center;
  background: rgba(5,6,10,.70); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
.settings-screen[hidden] { display: none; }
.settings-card { width: min(430px, 92vw); text-align: center; padding: 26px 30px 22px;
  background: rgba(12,14,20,.88); border: 1px solid rgba(246,221,138,.4); border-radius: 14px;
  box-shadow: 0 24px 80px rgba(0,0,0,.8); }
.settings-sec { display: flex; flex-direction: column; gap: 8px; margin: 14px 0 4px; }
/* v0.73.0 — BARRAS DE VOLUMEN (⚙ Ajustes): fila etiqueta · slider · % — semitransparentes,
   coherentes con el resto del panel. */
.vol-row { display: flex; align-items: center; gap: 10px; padding: 6px 4px; }
.vol-label { font-size: 14px; color: #e8e2cf; min-width: 7.5em; }
.vol-row input[type="range"] { flex: 1; appearance: none; -webkit-appearance: none; height: 6px; border-radius: 3px;
  background: rgba(246,221,138,.22); border: 1px solid rgba(246,221,138,.30); outline: none; cursor: pointer; }
.vol-row input[type="range"]::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 16px; height: 16px;
  border-radius: 50%; background: #f6dd8e; border: 2px solid #2a2416; box-shadow: 0 0 6px rgba(246,221,138,.5); cursor: pointer; }
.vol-row input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%;
  background: #f6dd8e; border: 2px solid #2a2416; cursor: pointer; }
.vol-val { font-size: 13px; color: #cfc7ae; min-width: 3.4em; text-align: right; font-variant-numeric: tabular-nums; }
/* v0.74.0 — CARTEL DE PISTAS de la DEMOSTRACIÓN del Soldado Rúnico (M11): flotante
   arriba y centrado sobre el tablero, semitransparente e iluminado como el resto
   del UI de batalla. */
.demo-hint { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 60;
  max-width: 62%; text-align: center; font-size: 14.5px; color: #f6dd8e; text-shadow: 0 1px 3px #000;
  background: rgba(16,18,26,.82); border: 1px solid rgba(246,221,138,.55); border-radius: 10px;
  padding: 9px 16px; pointer-events: none; box-shadow: 0 6px 24px rgba(0,0,0,.55), inset 0 0 18px rgba(246,221,138,.07); }
.settings-sec button { font: inherit; font-size: 14px; color: #e8e2cf; cursor: pointer;
  padding: 11px 14px; border-radius: 8px; border: 1px solid rgba(246,221,138,.25);
  background: rgba(22,26,36,.82); transition: background .15s ease, border-color .15s ease, transform .15s ease; }
.settings-sec button:hover, .settings-sec button:focus-visible { background: rgba(246,221,138,.10);
  border-color: rgba(246,221,138,.6); transform: translateY(-1px); outline: none; }
/* ============ v0.60.0 — CUENTA DE JUGADOR ============
   Badge «nick» arriba a la DERECHA (v0.60.2; antes: nick#num arriba a la izquierda) —
   splash + lobby; oculto en batalla (la visibilidad la controla main.js).
   Cápsula de vidrio con acento dorado. */
/* ============ v0.61.1 — SELECTOR DE PRUEBAS en el mapa del capítulo ============
   Visible solo con el Modo pruebas activo (⚙ Ajustes). Cápsula de vidrio discreta
   arriba a la derecha del mapa; fija el progreso y lanza la misión elegida. */
.chmap-test { position: absolute; top: 54px; right: 14px; z-index: 305; display: flex; align-items: center; gap: 8px;
  background: rgba(12,14,20,.82); border: 1px solid rgba(246,221,138,.4); border-radius: 999px;
  padding: 6px 14px; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.chmap-test[hidden] { display: none; }
.chmap-test span { color: #f6dd8a; font-size: 12.5px; letter-spacing: 1px; }
.chmap-test button { font: inherit; font-size: 13px; color: #e8e2cf; cursor: pointer; width: 30px; height: 30px;
  border-radius: 50%; border: 1px solid rgba(246,221,138,.35); background: rgba(22,26,36,.85);
  transition: background .15s ease, border-color .15s ease; }
.chmap-test button:hover, .chmap-test button:focus-visible { background: rgba(246,221,138,.14); border-color: #f6dd8a; outline: none; }
.player-badge { position: fixed; top: 12px; right: 14px; z-index: 210; font-size: 13.5px;
  letter-spacing: 1px; color: #f6dd8a; background: rgba(12,14,20,.62);
  border: 1px solid rgba(246,221,138,.35); border-radius: 999px; padding: 6px 14px;
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  text-shadow: 0 1px 4px #000; pointer-events: none; }
.player-badge[hidden] { display: none; }
/* Fila de nick en ⚙ Ajustes: input dorado + número FIJO en turquesa */
.player-nick-row { display: flex; align-items: center; gap: 8px; text-align: left; }
.player-nick-row > span { color: #c9bfa4; font-size: 13px; white-space: nowrap; }
.player-nick-row input { flex: 1; min-width: 0; font: inherit; font-size: 13.5px; color: #f6dd8a;
  background: rgba(22,26,36,.85); border: 1px solid rgba(246,221,138,.3); border-radius: 6px;
  padding: 8px 10px; }
.player-nick-row input:focus { outline: none; border-color: rgba(246,221,138,.7); box-shadow: 0 0 12px rgba(246,221,138,.15); }
.player-num { font-weight: bold; color: #9adfd0; }
.start-splash-btn.ghost {
  background: transparent;
  color: #f6dd8a;
  border: 2px solid rgba(246,221,138,0.55);
  box-shadow: none;
  padding: 14px 36px;
  min-width: 160px;
}
.start-splash-btn.ghost:hover, .start-splash-btn.ghost:focus-visible { background: rgba(246,221,138,0.10); border-color: #f6dd8a; box-shadow: 0 0 20px rgba(246,221,138,0.25); }

/* ============ LOBBY ============ */
.lobby { position: fixed; inset: 0; z-index: 100; overflow: auto; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.lobby-bg {
  position: absolute; inset: 0; z-index: 0;
  /* v0.15.0 — La Gran Batalla del Atardecer (Nano Banana, aprobada por el propietario):
     los 6 ejércitos en combate + la nave Reina Mecánica disparando. Velo oscuro
     para que las tarjetas y la configuración floten legibles sobre la batalla. */
  background:
    linear-gradient(180deg, rgba(8,9,13,0.64) 0%, rgba(8,9,13,0.40) 38%, rgba(8,9,13,0.30) 62%, rgba(8,9,13,0.58) 100%),
    radial-gradient(1200px 600px at 50% 26%, rgba(217,178,106,0.10), transparent 65%),
    url("../assets/art/lobby_bg.png") center/cover no-repeat,
    linear-gradient(180deg, #0b0d12 0%, #12151d 100%);
  transition: background 400ms ease;
}
/* v0.15.1 — PASO 2 por modo: la propuesta A (los reinos del Mundo Fracturado)
   para VS IA y la propuesta B (dos ejércitos frente a frente tras el abismo)
   para PvP local. Mismo velo de legibilidad que el fondo general. */
.lobby-bg.ai {
  background:
    linear-gradient(180deg, rgba(8,9,13,0.62) 0%, rgba(8,9,13,0.42) 38%, rgba(8,9,13,0.34) 62%, rgba(8,9,13,0.60) 100%),
    radial-gradient(1200px 600px at 50% 26%, rgba(217,178,106,0.10), transparent 65%),
    url("../assets/art/lobby_bg_ai.png") center/cover no-repeat,
    linear-gradient(180deg, #0b0d12 0%, #12151d 100%);
}
.lobby-bg.pvp {
  background:
    linear-gradient(180deg, rgba(8,9,13,0.62) 0%, rgba(8,9,13,0.42) 38%, rgba(8,9,13,0.34) 62%, rgba(8,9,13,0.60) 100%),
    radial-gradient(1200px 600px at 50% 26%, rgba(217,178,106,0.10), transparent 65%),
    url("../assets/art/lobby_bg_pvp.png") center/cover no-repeat,
    linear-gradient(180deg, #0b0d12 0%, #12151d 100%);
}
/* v0.37.1 — VISTA DE CAMPAÑA: los reinos del continente antes de la guerra
   (fondo "Llanuras de Aureon", aprobado por el propietario) */
.lobby-bg.campaign {
  background:
    linear-gradient(180deg, rgba(8,9,13,0.64) 0%, rgba(8,9,13,0.42) 38%, rgba(8,9,13,0.34) 62%, rgba(8,9,13,0.60) 100%),
    radial-gradient(1200px 600px at 50% 26%, rgba(217,178,106,0.10), transparent 65%),
    url("../assets/art/campaign_bg.png") center/cover no-repeat,
    linear-gradient(180deg, #0b0d12 0%, #12151d 100%);
}
.lobby-inner { position: relative; z-index: 1; max-width: 1000px; width: 100%; padding: 40px 24px; display: flex; flex-direction: column; align-items: center; gap: 28px; }
.lobby-brand { text-align: center; }
.lobby-brand .brand-mark { color: var(--gold); font-size: 28px; }
.lobby-brand h1 { font-family: var(--font-display); font-size: clamp(28px, 5vw, 40px); letter-spacing: 2px; margin: 4px 0 0; color: #ffffff; text-shadow: 0 4px 20px rgba(217,178,106,0.3); }
.lobby-tagline { font-family: var(--font-display); font-size: clamp(14px, 2.4vw, 16px); color: var(--gold); letter-spacing: 1.5px; margin: 6px 0 0; text-transform: uppercase; }
.lobby-sub { font-family: var(--font-mono); color: var(--cyan); margin: 8px 0 0; font-size: 16px; }

.lobby-modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; width: 100%; }
.mode-card {
  /* v0.15.2 — vidrio translúcido: La Gran Batalla se aprecia a través de la tarjeta */
  background: linear-gradient(180deg, rgba(23,27,37,0.72) 0%, rgba(18,21,29,0.84) 100%);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 2px solid var(--border-strong); border-radius: 16px;
  padding: 28px 24px; text-align: left; cursor: pointer;
  color: var(--text); font-family: var(--font-body);
  transition: 0.2s;
  display: flex; flex-direction: column; gap: 10px;
}
.mode-card:hover { border-color: var(--cyan); transform: translateY(-3px); box-shadow: 0 10px 40px rgba(79,240,255,0.15); }
.mode-card.selected { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold), 0 10px 40px rgba(217,178,106,0.25); background: linear-gradient(180deg, rgba(45,35,15,0.6) 0%, rgba(23,27,37,0.95) 100%); }
.mode-icon { font-size: 40px; color: var(--gold); line-height: 1; }
.mode-card h2 { font-family: var(--font-display); font-size: 26px; color: #ffffff; margin: 0; letter-spacing: 1px; }
.mode-card > p { color: var(--text-dim); font-size: 14px; line-height: 1.5; margin: 0; }
.mode-feats { padding-left: 18px; margin: 8px 0 0; color: var(--text-dim); font-size: 13px; line-height: 1.7; }
.mode-feats li { color: #d5d8e0; }
.mode-feats li::marker { color: var(--gold); }

.lobby-config {
  width: 100%; max-width: 720px;
  /* v0.15.2 — vidrio: el fondo por modo (A/B) se aprecia a través de la configuración */
  background: rgba(13,16,24,0.55);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border); border-radius: 12px; padding: 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.lc-row { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.lc-field { color: #d5d8e0; font-size: 12px; display: flex; flex-direction: column; gap: 6px; flex: 1 1 220px; min-width: 200px; }
/* v0.93.2 — FACCIONES: .lc-field define display:flex, que PISA el display:none
   que el atributo hidden recibe del navegador (autor > UA, misma razón que
   .lobby-step[hidden]). Sin esta regla, el selector de facción de un bando
   NO humano seguía visible en pantalla aunque su hidden estuviera activo
   (reporte del dueño: «aparece en ambos jugadores»). */
#lobbyFactionFieldW[hidden], #lobbyFactionFieldB[hidden], #lobbyFactionRow[hidden] { display: none; }
.lc-label { color: #ffffff; font-size: 13px; font-weight: 600; letter-spacing: 0.3px; text-transform: uppercase; opacity: 0.85; }
.lc-row select, .lc-row input[type="text"] {
  background: var(--panel-2);
  color: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: var(--font-body);
  /* 16px evita el zoom automático de iOS al enfocar el select */
  font-size: 16px;
  min-height: 48px;
  width: 100%;
  box-sizing: border-box;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--gold) 50%), linear-gradient(135deg, var(--gold) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
  -webkit-tap-highlight-color: rgba(217,178,106,0.15);
}
.lc-row input[type="text"] { background-image: none; padding-right: 14px; font-family: var(--font-mono); }
.lc-row select:focus, .lc-row input[type="text"]:focus { border-color: var(--gold); outline: none; box-shadow: 0 0 0 2px rgba(217,178,106,0.25); }
.lc-row select option { background: var(--panel-2); color: #ffffff; }
.lc-actions { display: flex; justify-content: center; margin-top: 6px; }
.lc-actions button {
  background: linear-gradient(180deg, #f6dd8a, #d4b04a); color: #0b0d12;
  border: none; border-radius: 8px; padding: 12px 32px; font-weight: 700; font-size: 15px;
  font-family: var(--font-body); cursor: pointer; letter-spacing: 0.5px;
  transition: 0.15s;
}
.lc-actions button:disabled { background: var(--panel-2); color: var(--text-dim); cursor: not-allowed; }
.lc-actions button:not(:disabled):hover { box-shadow: 0 0 20px rgba(246,221,138,0.4); transform: translateY(-1px); }

.lobby-foot { text-align: center; max-width: 720px; }

/* Insignia de modo activo en la topbar */
.mode-badge {
  font-family: var(--font-mono); color: var(--gold);
  background: rgba(217,178,106,0.15); border: 1px solid var(--gold);
  padding: 3px 10px; border-radius: 999px; font-size: 13px;
  margin-left: 8px;
}
.mode-badge.ai { color: var(--cyan); border-color: var(--cyan); background: rgba(79,240,255,0.12); }

/* Indicador "IA pensando..." */
.ai-thinking {
  position: absolute; top: 12px; right: 12px; z-index: 5;
  background: rgba(11,13,18,0.55); border: 1px solid var(--cyan); color: var(--cyan);
  padding: 6px 12px; border-radius: 999px; font-family: var(--font-mono); font-size: 14px;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 0.6 } 50% { opacity: 1 } }

/* ============ v0.11.0 — INTERFAZ "EL TABLERO ES EL REY" ============ */
/* Topbar minimal: ◆ ELIO · turno · ☰. Todo lo demás vive en el menú desplegable. */
.menu-btn {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: 8px; width: 44px; height: 44px; font-size: 20px; cursor: pointer;
  margin-left: 12px; transition: 0.15s; flex: 0 0 auto;
}
.menu-btn:hover { border-color: var(--gold); color: var(--gold); }

/* Menú desplegable (cajón lateral con velo) */
.game-menu { position: fixed; inset: 0; z-index: 300; }
.game-menu[hidden] { display: none; }
.gm-scrim { position: absolute; inset: 0; background: rgba(5,6,10,0.45); opacity: 1; transition: opacity 220ms ease; }
.gm-drawer {
  position: absolute; top: 0; right: 0; height: 100%; width: min(340px, 88vw);
  /* v0.15.2 — cajón translúcido · v0.35.1 — SEMITRANSPARENTE pleno: el campo de
     batalla se aprecia a través del cajón Y de sus botones (antes opacos) */
  background: linear-gradient(180deg, rgba(20,24,33,0.58), rgba(13,16,23,0.70));
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-left: 2px solid rgba(217,178,106,0.7);
  box-shadow: -20px 0 60px rgba(0,0,0,0.6);
  padding: 16px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
  transform: translateX(0); transition: transform 220ms ease;
}
.game-menu:not(.open) .gm-drawer { transform: translateX(105%); }
.game-menu:not(.open) .gm-scrim { opacity: 0; }
.gm-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.gm-head .tag { margin-left: auto; }
.gm-section-title { color: var(--gold); font-family: var(--font-mono); font-size: 11px; letter-spacing: 2px; margin: 10px 0 0; text-transform: uppercase; }
.gm-section { display: flex; flex-direction: column; gap: 8px; }
.gm-section button { /* v0.35.1 — translúcido: deja pasar el campo detrás del cajón */
  background: rgba(29,34,48,0.55); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 12px 14px; min-height: 44px;
  font-family: var(--font-body); font-size: 15px; text-align: left; cursor: pointer; transition: 0.15s;
}
.gm-section button:hover:not(:disabled) { border-color: var(--gold); color: var(--gold); }
.gm-section button:disabled { opacity: 0.4; cursor: not-allowed; }
/* v0.49.0 — visor del REGISTRO DE PARTIDA (📜) */
.log-panel { max-width: min(760px, 92vw); }
.log-text { width: 100%; height: 46vh; background: rgba(8,9,13,.82); color: #cdd3d9;
  border: 1px solid var(--border); border-radius: 8px; font-family: var(--font-mono);
  font-size: 11.5px; line-height: 1.45; padding: 10px; resize: vertical; }
.gm-races { flex-direction: row; gap: 10px; }
.gm-races label { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-dim); }
.gm-races select { background: var(--panel-2); color: #ffffff; border: 1px solid var(--border-strong); border-radius: 8px; padding: 10px; min-height: 44px; font-size: 16px; width: 100%; }
.gm-lang { flex-direction: row; }
.gm-lang button { flex: 1; text-align: center; }
.gm-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); color: var(--text-dim); font-size: 12px; text-align: center; font-family: var(--font-display); letter-spacing: 0.5px; }

/* v0.19.0 — el menú contextual de ficha (.piece-menu, v0.11.1) se RETIRA del DOM;
   flujo de dos clics: selección directa al tocar una ficha propia. */

/* v0.11.1 — Ventana flotante (Ficha / Registro / Reglas) */
.float-win {
  position: fixed; inset: 0; z-index: 280;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(5,6,10,0.35);
  /* v0.19.1 — el velo es SOLO visual: no atrapa clics. El tablero y el HUD siguen
     jugables con la ventana abierta; cualquier toque fuera de la tarjeta la cierra. */
  pointer-events: none;
}
.float-win[hidden] { display: none; }
.fw-card {
  background: linear-gradient(180deg, rgba(20,24,33,0.74), rgba(13,16,23,0.84));
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-strong); border-radius: 14px;
  width: min(560px, 94vw); max-height: min(82vh, 82dvh);
  display: flex; flex-direction: column;
  box-shadow: 0 20px 80px rgba(0,0,0,0.7);
  pointer-events: auto;
}
.fw-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); gap: 10px; }
.fw-head h3 { margin: 0; color: var(--gold); font-family: var(--font-display); font-size: 16px; }
#fwClose { background: none; border: 1px solid var(--border); color: var(--text-dim); border-radius: 8px; width: 36px; height: 36px; min-height: 36px; cursor: pointer; font-size: 15px; transition: 0.15s; }
#fwClose:hover { border-color: var(--red); color: var(--red); }
.fw-body { padding: 14px 16px; overflow-y: auto; }
.fw-body .panel { background: none; border: none; padding: 0; margin: 0; box-shadow: none; }

/* Hogar oculto de paneles (se prestan a la ventana flotante) */
.panel-zone[hidden] { display: none; }

/* Zona de paneles con pestañas: Ficha · Registro · Reglas */
.panel-zone { max-width: 1400px; margin: 0 auto; padding: 0 16px 24px; }
.panel-tabs { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.pt-btn {
  background: var(--panel-2); color: var(--text-dim); border: 1px solid var(--border);
  border-radius: 999px; padding: 8px 16px; min-height: 40px;
  font-family: var(--font-body); font-size: 14px; cursor: pointer; transition: 0.15s;
}
.pt-btn:hover { border-color: var(--gold); color: var(--gold); }
.pt-btn.active { color: #0b0d12; background: linear-gradient(180deg, #f6dd8a, #d4b04a); border-color: #f6dd8a; font-weight: 600; }
.pt-close { margin-left: auto; background: none; border: 1px solid var(--border); color: var(--text-dim); border-radius: 8px; width: 40px; height: 40px; cursor: pointer; font-size: 16px; transition: 0.15s; }
.pt-close:hover { border-color: var(--red); color: var(--red); }
.pt-body > .panel { display: none; }
.pt-body > .panel.active { display: block; }

/* ---- Responsive: portrait, landscape y proporciones variables ---- */
/* Pantallas estrechas (<1100px): chips de bando COLAPSABLES sobre el campo */
@media (max-width: 1099px) {
  .topbar { padding: 6px 10px; gap: 8px; }
  .brand { font-size: 14px; }
  .turn-indicator { font-size: 12px; padding: 3px 8px; }
  /* Chips colapsables: solo título + energía/nº de piezas; tap despliega */
  .side { padding: 8px 10px; cursor: pointer; max-height: calc(100vh - 130px); max-height: calc(100dvh - 130px); }
  .side h3 { font-size: 13px; margin: 0; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
  .side h3::after { content: '▾'; color: var(--gold); font-size: 13px; }
  .side.open h3::after { content: '▴'; }
  .side .stat-row { display: inline-flex; gap: 4px; margin: 4px 12px 2px 0; font-size: 11px; padding: 0; border: none; }
  .side .stat-row strong { font-family: var(--font-mono); color: var(--cyan); }
  .side:not(.open) .stat-row span { display: none; }
  .side:not(.open) .captured, .side:not(.open) h4, .side:not(.open) .bonus, .side:not(.open) .formation { display: none; }
  .panel-zone { padding: 0 10px 16px; }
}
/* Landscape con poca altura: HUD aún más discreto */
@media (orientation: landscape) and (max-height: 620px) {
  .topbar { top: 6px; padding: 5px 10px; }
  .brand { font-size: 13px; }
  .turn-indicator { font-size: 11px; padding: 3px 8px; }
  .side { top: 64px; padding: 6px 10px; }
  .side .stat-row { margin: 2px 10px 0 0; }
  .hint { font-size: 11px; padding: 5px 14px; }
  .pt-btn { min-height: 34px; padding: 5px 12px; font-size: 12px; }
}

/* v0.13.0 — En VERTICAL los bandos JAMÁS invaden el campo: su altura se
   recorta a la banda superior sobre la rejilla (--gy la fija resizeBoard()).
   Va al final para ganar a los max-height de las reglas anteriores. */
@media (orientation: portrait) {
  .side { max-height: calc(var(--gy) - 74px); }
}

/* Voltear tablero (Negras abajo) — solo voltea el frame, no los paneles.
   v0.10.2: transición suave para la rotación por turno en PvP-PC. Las fichas se
   contrarrotaan en drawPieces, así que siempre quedan de pie.
   v0.37.2 — VOLTEO HORIZONTAL: el campo gira sobre su EJE HORIZONTAL (norte-sur
   se intercambian; este-oeste se conserva) en vez del giro de 180° en el plano,
   que mareaba. El final del giro equivale a scaleY(-1): el lado del oponente
   queda abajo sin barrer toda la pantalla. */
.board-frame canvas { transition: transform 480ms cubic-bezier(0.33, 0, 0.15, 1); }
.board-frame.flipped canvas { transform: scaleY(-1); }

/* ============ SPLASH FIN DE PARTIDA (Victoria / Derrota) ============ */
.end-splash {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(11,13,18,0.75) 0%, rgba(11,13,18,0.94) 60%, rgba(11,13,18,0.98) 100%);
  backdrop-filter: blur(6px);
  animation: endSplashFadeIn 260ms ease-out both;
}
@keyframes endSplashFadeIn { from { opacity: 0 } to { opacity: 1 } }

.end-splash-card {
  position: relative;
  width: min(92vw, 520px);
  padding: 40px 44px 36px;
  border-radius: 20px;
  /* v0.15.2 — vidrio: el campo de batalla queda visible tras la carta de victoria */
  background: linear-gradient(180deg, rgba(29,34,48,0.88) 0%, rgba(23,27,37,0.90) 100%);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(217,178,106,0.35);
  box-shadow:
    0 30px 80px rgba(0,0,0,0.6),
    0 0 60px rgba(217,178,106,0.15),
    inset 0 1px 0 rgba(255,255,255,0.04);
  text-align: center;
  color: var(--text);
  animation: endSplashPop 380ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes endSplashPop {
  from { opacity: 0; transform: translateY(24px) scale(0.94) }
  to   { opacity: 1; transform: translateY(0)    scale(1)     }
}

.end-splash-card[data-outcome="win"] {
  border-color: rgba(217,178,106,0.55);
  box-shadow:
    0 30px 80px rgba(0,0,0,0.6),
    0 0 80px rgba(217,178,106,0.28),
    inset 0 1px 0 rgba(255,255,255,0.06);
}
.end-splash-card[data-outcome="loss"] {
  border-color: rgba(255,122,107,0.55);
  box-shadow:
    0 30px 80px rgba(0,0,0,0.6),
    0 0 80px rgba(255,122,107,0.28),
    inset 0 1px 0 rgba(255,255,255,0.06);
}
.end-splash-card[data-outcome="draw"] {
  border-color: rgba(79,240,255,0.55);
  box-shadow:
    0 30px 80px rgba(0,0,0,0.6),
    0 0 80px rgba(79,240,255,0.25),
    inset 0 1px 0 rgba(255,255,255,0.06);
}

.end-splash-ornament {
  font-size: 24px; color: var(--gold);
  margin-bottom: 14px;
  text-shadow: 0 0 20px rgba(217,178,106,0.6);
}
.end-splash-card[data-outcome="loss"] .end-splash-ornament { color: var(--red); text-shadow: 0 0 20px rgba(255,122,107,0.6); }
.end-splash-card[data-outcome="draw"] .end-splash-ornament { color: var(--cyan); text-shadow: 0 0 20px rgba(79,240,255,0.6); }

.end-splash-eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 14px;
}

.end-splash-title {
  font-family: var(--font-display, var(--font-body));
  font-size: 48px;
  font-weight: 800;
  line-height: 1.05;
  margin: 0 0 12px;
  color: #ffffff;
  letter-spacing: 1px;
  word-break: normal;
  overflow-wrap: break-word;
}
.end-splash-title.size-md { font-size: 40px; letter-spacing: 0.6px; }
.end-splash-title.size-sm { font-size: 34px; letter-spacing: 0.4px; }
.end-splash-title.size-xs { font-size: 28px; letter-spacing: 0.3px; }
.end-splash-card[data-outcome="win"] .end-splash-title {
  color: #f6dd8a;
  text-shadow: 0 0 30px rgba(246,221,138,0.5);
}
.end-splash-card[data-outcome="loss"] .end-splash-title {
  color: #ffb0a4;
  text-shadow: 0 0 30px rgba(255,176,164,0.4);
}
.end-splash-card[data-outcome="draw"] .end-splash-title {
  color: #a8f4ff;
  text-shadow: 0 0 30px rgba(168,244,255,0.4);
}

.end-splash-sub {
  color: #ffffff;
  font-size: 16px;
  line-height: 1.5;
  margin: 0 auto 26px;
  max-width: 400px;
  opacity: 0.92;
}

.end-splash-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 28px;
  padding: 16px 20px;
  background: rgba(11,13,18,0.5);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  text-align: left;
}
.end-splash-meta-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 14px;
}
.end-splash-meta-label {
  font-family: var(--font-mono);
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-size: 11px;
}
.end-splash-meta-value {
  color: #ffffff;
  font-weight: 600;
}

.end-splash-actions {
  display: flex; gap: 12px; justify-content: center; flex-wrap: wrap;
}
.end-splash-btn {
  border: none;
  border-radius: 10px;
  padding: 13px 26px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  letter-spacing: 0.4px;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
  min-width: 180px;
}
.end-splash-btn.primary {
  background: linear-gradient(180deg, #f6dd8a 0%, #d9b26a 100%);
  color: #1a1408;
}
.end-splash-btn.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(217,178,106,0.4);
}
.end-splash-btn.ghost {
  background: transparent;
  color: #ffffff;
  border: 1px solid rgba(255,255,255,0.25);
}
.end-splash-btn.ghost:hover {
  border-color: #ffffff;
  background: rgba(255,255,255,0.06);
  transform: translateY(-1px);
}

@media (max-width: 520px) {
  .end-splash-card { padding: 32px 24px 28px; }
  .end-splash-title { font-size: 34px; }
  .end-splash-title.size-md { font-size: 30px; }
  .end-splash-title.size-sm { font-size: 26px; }
  .end-splash-title.size-xs { font-size: 22px; }
  .end-splash-btn { min-width: 100%; }
}

/* ============ FASE 1: EL ARTE ES PROTAGONISTA ============ */
/* Banner de facción en los paneles laterales */
.formation { margin-top: 12px; }
.formation img {
  width: 100%; height: 118px; object-fit: cover; display: block;
  border-radius: 10px; border: 1px solid rgba(217,178,106,0.35);
  box-shadow: 0 8px 22px rgba(0,0,0,0.5);
}

/* v0.14.2 — Lobby en DOS PASOS: elección de modo → configuración */
.lobby-step { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 24px; }
.lobby-step[hidden] { display: none; }
.lobby-step > * { animation: lobbyStepIn 240ms ease-out both; }
@keyframes lobbyStepIn { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: none } }
.lobby-config-title {
  font-family: var(--font-display);
  font-size: clamp(20px, 3.4vw, 26px);
  color: #f6dd8a; margin: 0; letter-spacing: 1px; text-align: center;
  text-shadow: 0 4px 20px rgba(217, 178, 106, 0.3);
}
.lobby-nav { display: flex; justify-content: center; }
.lobby-back-btn.ghost { padding: 10px 24px; min-width: 150px; font-size: 13px; }

/* v0.37.0 — VISTA DE CAMPAÑA: previsualización del continente de Véspera
   v0.42.0 — width 100%: el mapa global (1820×1045) ya no desborda el panel */
.campaign-preview {
  width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  background: linear-gradient(180deg, rgba(23,27,37,0.72) 0%, rgba(18,21,29,0.84) 100%);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 2px solid var(--border-strong); border-radius: 16px;
  padding: 18px;
}
.campaign-preview img {
  width: 100%; max-height: 52vh; object-fit: contain; display: block;
  border-radius: 10px; border: 1px solid rgba(246,221,138,0.25);
}
/* v0.42.2 — rótulo de la región del capítulo actual sobre el mapa de campaña */
.campaign-region {
  font-size: clamp(15px, 2.4vw, 19px); letter-spacing: 2px; text-transform: uppercase;
  color: #f6dd8a; text-shadow: 0 2px 12px rgba(217, 178, 106, 0.45); text-align: center;
}
.campaign-region[hidden] { display: none; }

/* ============ v0.43.0 — CINEMÁTICA DE CAMPAÑA (Cap. I: Reinos del Alba) ============ */
#cinematicView { position: fixed; inset: 0; background: #000; z-index: 320; }
#cinematicView[hidden] { display: none; }
#cinematicView video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity 700ms ease; }
#cinematicView video.on { opacity: 1; }
#cineSub { position: absolute; left: 50%; bottom: 7vh; transform: translateX(-50%);
  width: min(860px, 86vw); text-align: center; color: #f2e9d2;
  font-size: clamp(15px, 2.2vw, 22px); line-height: 1.5; font-style: italic;
  text-shadow: 0 2px 14px #000, 0 0 6px #000; opacity: 0; transition: opacity 600ms ease;
  pointer-events: none; }
#cineSub.on { opacity: 1; }
#cineSkip { position: absolute; top: 16px; right: 16px; background: rgba(0,0,0,.45);
  border: 1px solid rgba(246,221,138,.35); color: #c9bfa4; font-family: inherit;
  font-size: 13px; letter-spacing: 2px; padding: 8px 16px; border-radius: 4px; cursor: pointer; }
#cineSkip:hover { background: rgba(246,221,138,.12); }

/* v0.57.1 — TOAST de aviso (pase por ahogado): vidrio oscuro, borde dorado, centrado */
#gameToast { position: fixed; top: 64px; left: 50%; transform: translateX(-50%) translateY(-8px);
  z-index: 270; padding: 10px 22px; background: rgba(8,9,13,.82); color: #f2e9d2;
  border: 1px solid rgba(246,221,138,.5); border-radius: 10px; font-size: 14px; letter-spacing: 1px;
  box-shadow: 0 10px 34px rgba(0,0,0,.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none; transition: opacity .25s ease, transform .25s ease; }
#gameToast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ v0.48.0 — ESCENA DE DIÁLOGO (Misión 1: asedio del norte) ============ */
#dialogView { position: fixed; inset: 0; background: #000; z-index: 318; } /* bajo la cinemática (320) */
#dialogView[hidden] { display: none; }
#dlgBg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* FIGURAS v0.48.1 — SILUETAS RECORADAS (PNG con alfa, sin cuadro): el personaje tal cual,
   con sombra proyectada que sigue la silueta. SOLDADO (peón) a la DERECHA, HEREDERO
   (rey) a la IZQUIERDA; alternadas con fundido — la que habla aparece, la otra se desvanece. */
#dialogView img[id^='dlgFig'] { position: absolute; bottom: 23vh;
  max-height: 64vh; max-width: min(34vw, 470px); object-fit: contain;
  filter: drop-shadow(0 26px 30px rgba(0,0,0,.75)) drop-shadow(0 4px 8px rgba(0,0,0,.5));
  opacity: 0; transform: translateY(4%);
  transition: opacity 420ms ease, transform 420ms ease; pointer-events: none; }
#dlgFigA { right: 7vw; }   /* v0.48.1 — Soldado del Norte (Bren) a la DERECHA */
#dlgFigB { left: 7vw; }    /* v0.48.1 — El Heredero de la Guerra a la IZQUIERDA */
/* v0.50.0 — CUATRO VOCES (guion canónico del asedio): YSOLDE (Reina) entra desde la
   derecha, UN PASO MÁS ADENTRO que el mensajero; CORVAN (Alfil, maestre del lar)
   desde la izquierda, un paso más adentro que el Heredero. Mismo encuadre y fundido. */
#dlgFigC { right: 12vw; }  /* Ysolde · Capitana del Vado */
#dlgFigD { left: 12vw; }   /* Corvan · Maestre del Vado */
#dlgFigC, #dlgFigD { max-height: 60vh; } /* ligeramente más adentro: un escalón menos de altura */
#dlgFigE { right: 7vw; }   /* v0.51.0 — El Señor del Norte: anfitrión, lado derecho (como Bren) */
#dlgFigF { right: 12vw; max-height: 62vh; } /* v0.53.0 — El Barón del Peache: frente al Heredero, un paso adentro */
#dlgFigG { right: 7vw; max-height: 64vh; } /* v0.62.0 — EL PRETENDIENTE: frente al Heredero, lado derecho, estampa regia */
#dlgFigH { left: 12vw; max-height: 60vh; } /* v0.63.0 — EL CAPITÁN ÉLFICO: frente al Heredero, un paso adentro (como Corvan), silueta esbelta */
#dlgFigI { right: 7vw; max-height: 64vh; } /* v0.65.0 — EL REY ÉLFICO: frente al Heredero (izquierda), estampa regia ancestral */
#dlgFigJ { right: 7vw; max-height: 62vh; } /* v0.66.0 — EL MENSAJERO DEL SANTUARIO: frente al Heredero, peregrino del templo del sol */
#dialogView img[id^='dlgFig'].on { opacity: 1; transform: translateY(0); }

/* ============ v0.69.0 — INVOCACIÓN DEL PALADÍN (zoom-in + estruendo) ============
   Overlay a pantalla completa, NO interactivo (pointer-events:none): el paladín
   invocado crece hacia el centro entre un halo dorado y se desvanece solo. */
#paladinSummon { position: fixed; inset: 0; z-index: 900; display: none; align-items: center;
  justify-content: center; pointer-events: none;
  background: radial-gradient(circle at 50% 46%, rgba(255, 224, 130, 0.30) 0%,
              rgba(24, 16, 8, 0) 55%, rgba(10, 7, 4, 0.62) 100%); }
#paladinSummon.on { display: flex; animation: paladinFlash 1.6s ease-out forwards; }
#paladinSummon img { max-height: 78vh; max-width: 80vw;
  filter: drop-shadow(0 0 26px rgba(255, 216, 110, 0.85)) drop-shadow(0 0 90px rgba(255, 190, 60, 0.35));
  transform-origin: 50% 62%; }
#paladinSummon.on img { animation: paladinZoom 1.6s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
@keyframes paladinZoom {
  0%   { transform: scale(0.12); opacity: 0; }
  14%  { opacity: 1; }
  55%  { transform: scale(1.14); }
  76%  { transform: scale(1.00); opacity: 1; }
  100% { transform: scale(1.06); opacity: 0; }
}
@keyframes paladinFlash {
  0%   { opacity: 0; }
  10%  { opacity: 1; }
  70%  { opacity: 1; }
  100% { opacity: 0; }
}
/* TARJETA de texto: vidrio oscuro semitransparente (lenguaje del juego) bajo la figura */
#dlgCard { position: absolute; left: 50%; bottom: 3.5vh; transform: translateX(-50%);
  width: min(760px, 88vw); text-align: center; padding: 14px 26px 12px;
  background: rgba(8,9,13,.68); border: 1px solid rgba(246,221,138,.35); border-radius: 12px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 14px 40px rgba(0,0,0,.6); }
#dlgName { color: #f6dd8a; font-family: 'Grenze Gotisch', 'Old English Text MT', 'Palatino Linotype', serif;
  font-size: clamp(19px, 2.6vw, 26px); letter-spacing: 1px; margin-bottom: 6px;
  text-shadow: 0 1px 2px #000, 0 2px 5px #000, 0 3px 10px rgba(0,0,0,.95); }
#dlgText { color: #f2e9d2; font-size: clamp(15px, 2vw, 19.5px); line-height: 1.55;
  min-height: 3.2em; text-shadow: 0 2px 10px #000; font-style: italic; }
#dlgNext { color: #c9bfa4; font-size: 12.5px; letter-spacing: 2px; margin-top: 9px; opacity: .85; }
#dlgSkip { position: absolute; top: 16px; right: 16px; background: rgba(0,0,0,.45);
  border: 1px solid rgba(246,221,138,.35); color: #c9bfa4; font-family: inherit;
  font-size: 13px; letter-spacing: 2px; padding: 8px 16px; border-radius: 4px; cursor: pointer; }
#dlgSkip:hover { background: rgba(246,221,138,.12); }
#cineCard { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 18px; background: #000; opacity: 0; transition: opacity 1200ms ease;
  pointer-events: none; }
#cineCard.on { opacity: 1; pointer-events: auto; cursor: pointer; }
#cineCard img { width: min(220px, 36vw); filter: drop-shadow(0 0 40px rgba(217,178,106,.35)); }
#cineCard h1 { color: #f6dd8a; font-weight: normal; letter-spacing: 6px;
  font-size: clamp(22px, 4vw, 40px); margin: 0; text-align: center; }
#cineCard p { color: #c9bfa4; letter-spacing: 2px; margin: 0; font-size: clamp(12px, 1.6vw, 17px); }
.campaign-text { text-align: center; color: var(--text-dim); }
.campaign-text p { margin: 0 0 8px; line-height: 1.5; }

/* ============ v0.44.0 — MAPA DEL CAPÍTULO + MISIÓN 1 ============ */
#chapterMap { position: fixed; inset: 0; z-index: 300; background: rgba(8,9,13,.96);
  display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px; }
#chapterMap[hidden] { display: none; }
.chmap-head { width: min(1180px, 94vw); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.chmap-head h2 { margin: 0; color: #f6dd8a; font-weight: normal; letter-spacing: 4px;
  font-size: clamp(18px, 3vw, 28px); text-shadow: 0 4px 18px rgba(217,178,106,.35); }
.chmap-stage { position: relative; width: min(1180px, 94vw); }
/* v0.54.0 — SALVA DE PARTIDA: panel de continuación de la batalla a medias */
#chmapResume { width: min(1180px, 94vw); margin: 0 0 14px; display: flex; align-items: center;
  justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background: var(--glass-bg); border: 1px solid rgba(246,221,138,.4); border-radius: 12px;
  padding: 10px 18px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 10px 34px rgba(0,0,0,.55); }
#chmapResume[hidden] { display: none; }
#chmapResume .cr-txt b { color: #f6dd8a; font-size: 15px; letter-spacing: 2px; margin-right: 12px;
  font-family: 'Grenze Gotisch', 'Old English Text MT', serif; text-shadow: 0 1px 3px #000; }
#chmapResume .cr-txt span { color: #c9bfa4; font-size: 13.5px; }
#chmapResume .cr-btns { display: flex; gap: 10px; }
#chmapResume button { background: rgba(20,26,40,.85); color: #f2e9d2; border: 1px solid rgba(246,221,138,.45);
  border-radius: 8px; padding: 9px 16px; font-family: inherit; font-size: 13.5px; letter-spacing: 1px;
  cursor: pointer; transition: border-color .15s, color .15s; }
#chmapResume button:hover { border-color: var(--cyan); color: var(--cyan); }
#chmapResume #crContinue { border-color: rgba(240,199,94,.8); color: #f6dd8a;
  box-shadow: 0 0 18px rgba(240,199,94,.25); }
/* v0.54.0 — marca ⚔ en el estandarte de campaña con batalla en curso */
.camp-banner .camp-live { position: absolute; top: 8px; right: 10px; z-index: 5;
  background: radial-gradient(circle at 35% 30%, #3a2f14, #1c1608);
  border: 1px solid rgba(240,199,94,.75); border-radius: 50%; width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center; font-size: 13px; color: #f6dd8a;
  text-shadow: 0 0 8px rgba(240,199,94,.8); animation: campLivePulse 1.6s ease-in-out infinite; }
@keyframes campLivePulse { 0%, 100% { box-shadow: 0 0 6px 1px rgba(240,199,94,.35); }
  50% { box-shadow: 0 0 16px 4px rgba(240,199,94,.65); } }
.chmap-stage > img { display: block; width: 100%; border-radius: 14px;
  border: 1px solid rgba(246,221,138,.3); box-shadow: 0 18px 60px rgba(0,0,0,.7); }
#chmapMarkers { position: absolute; inset: 0; }
/* El INDICADOR DE MISIÓN: sello con el ESCUDO HUMANO (león azul y oro), aro
   dorado y resplandor — el marcador pertenece al ejército del Heredero de la Guerra. */
.chmap-marker { position: absolute; width: 54px; height: 54px; transform: translate(-50%, -50%);
  cursor: pointer; -webkit-tap-highlight-color: transparent; }
.chmap-marker .seal { position: relative; width: 54px; height: 54px; border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #dfe9ff 0%, #23407e 55%, #101c3a 100%);
  border: 3px solid #e2c06a; box-shadow: 0 0 22px 6px rgba(240,199,94,.4), 0 6px 16px rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; }
.chmap-marker .seal img { width: 42px; height: 42px; border-radius: 50%; display: block; }
.chmap-marker .sign { position: absolute; left: 50%; bottom: calc(100% + 10px); transform: translateX(-50%);
  white-space: nowrap; background: linear-gradient(180deg, #efe0bb, #d9b26a); color: #2b1f10;
  font-size: 12px; font-weight: bold; letter-spacing: 1px; padding: 6px 12px; border-radius: 14px 14px 14px 3px;
  box-shadow: 0 4px 14px rgba(0,0,0,.55); pointer-events: none; }
.chmap-marker .sign::after { content: ''; position: absolute; left: 10px; bottom: -7px;
  border: 8px solid transparent; border-top-color: #d9b26a; border-bottom: 0; }
@keyframes chmapBounce { 0%, 100% { transform: translate(-50%, -50%) translateY(0) }
  50% { transform: translate(-50%, -50%) translateY(-14px) } }
.chmap-marker.bounce { animation: chmapBounce 1.1s ease-in-out infinite; }
.chmap-marker.bounce .seal { box-shadow: 0 0 26px 9px rgba(240,199,94,.55), 0 6px 16px rgba(0,0,0,.6); }
/* v0.53.0 — PROGRESIÓN: misión COMPLETADA = sello apagado y sin cartel (memoria de la
   campaña); la misión ACTIVA es la única que rebota con cartel; las futuras no se pintan. */
.chmap-marker.done { cursor: default; opacity: .38; filter: saturate(.55); }
.chmap-marker.done .seal { border-color: #8f8a6d; box-shadow: 0 4px 10px rgba(0,0,0,.5); }
.chmap-marker.done .sign { display: none; }
.chmap-marker:hover .seal { box-shadow: 0 0 30px 12px rgba(240,199,94,.7), 0 6px 16px rgba(0,0,0,.6); }
/* v0.47.1 — FUENTE GÓTICA LEGIBLE para los títulos de los estandartes de capítulo
   (Grenze Gotisch · SIL OFL 1.1, embebida: el juego es 100% offline) */
@font-face {
  font-family: 'Grenze Gotisch';
  font-style: normal; font-weight: 500;
  src: url('../assets/fonts/grenze_gotisch_500.woff2') format('woff2');
}

/* ============ v0.45.0/v0.47.0 — HUB DE CAPÍTULOS: 4 estandartes colgantes ============
   Diseño copiado de la SELECCIÓN DE PARTIDA (estandartes de guerra · propuesta B):
   riel, argolla, tela con punta, borla — uno por CAPÍTULO/mapa de la campaña.
   v0.47.0: el fondo del panel muestra AMPLIADO el mapa del estandarte señalado. */
.chap-hub { position: relative; overflow: hidden; min-height: 520px; }
.hub-bg { position: absolute; inset: 0; z-index: 0; }
.hub-bg img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  transform: scale(1.18); opacity: 0; transition: opacity 600ms ease; }
.hub-bg img.on { opacity: 1; }
.hub-bg-veil { position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(8,9,13,.78) 0%, rgba(8,9,13,.55) 40%, rgba(8,9,13,.92) 100%); }
.chap-hub > .camp-detail-head { position: relative; z-index: 2; }
#chapterSlots { position: relative; z-index: 2; display: flex; flex-direction: column;
  align-items: center; gap: 0; margin: 18px 0 14px; }
#chapterSlots::before { /* riel del que cuelgan los estandartes (como el de la sesión) */
  content: ''; display: block; width: min(96%, 760px); height: 10px; border-radius: 5px;
  background: linear-gradient(180deg, #4a3d22, #2b2314 60%, #191408);
  border: 1px solid rgba(246,221,138,.45); box-shadow: 0 6px 18px rgba(0,0,0,.55);
  margin-bottom: -5px; }
#chapterSlots .slots-row { display: flex; gap: 22px; overflow-x: auto; padding: 26px 8px 14px;
  max-width: 100%; scrollbar-width: thin; }
.chap-slot { position: relative; flex: 0 0 auto; width: 176px; height: 328px; padding-top: 22px;
  cursor: pointer; -webkit-tap-highlight-color: transparent; }
.chap-slot .ring { position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 24px; height: 24px; border: 4px solid var(--c2, #d4b04a); border-radius: 50%;
  box-shadow: 0 3px 8px rgba(0,0,0,.6); z-index: 6; }
.chap-slot .fabric { position: relative; width: 100%; height: 300px;
  background: linear-gradient(180deg, var(--c1) 0%, color-mix(in srgb, var(--c1) 62%, #000) 100%);
  border: 2.5px solid var(--c2); border-top: none;
  clip-path: polygon(0 0, 100% 0, 100% 86%, 50% 100%, 0 86%);
  box-shadow: 0 18px 40px rgba(0,0,0,.6); overflow: hidden;
  transition: transform 200ms ease, box-shadow 200ms ease; }
.chap-slot .bg { position: absolute; inset: 0; opacity: .55; }
.chap-slot .bg img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chap-slot .veil { position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(8,9,13,.30), rgba(8,9,13,.12) 45%, rgba(8,9,13,.82)); }
.chap-slot .lbl { position: absolute; top: 44px; left: 10px; right: 10px; text-align: center; z-index: 3;
  display: flex; flex-direction: column; gap: 6px; }
/* v0.47.1 — solo el NOMBRE del mapa (sin «CAPÍTULO»), en GÓTICA legible */
.chap-slot .lbl b { color: #fff; font-family: 'Grenze Gotisch', 'Old English Text MT', 'Palatino Linotype', serif;
  font-size: 21px; font-weight: 500; letter-spacing: 1px; line-height: 1.3;
  /* v0.47.3 — sombra MÁS DENSA para legibilidad sobre zonas claras del arte: contorno
     fino + base profunda + halo ancho (antes solo 2px/10px y las letras se perdían) */
  text-shadow: 0 1px 2px #000, 0 2px 5px #000, 0 3px 10px rgba(0,0,0,.95),
               0 6px 20px rgba(0,0,0,.85), 0 0 26px rgba(0,0,0,.7); }
.chap-slot .lock-ic { position: absolute; top: 47%; left: 50%; transform: translate(-50%,-50%);
  width: 40px; height: 40px; opacity: .92; z-index: 3; }
/* v0.47.1 — la pista del candado solo aparece al SELECCIONAR el capítulo bloqueado */
.chap-slot .lock-hint { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
  width: 84%; text-align: center; color: #b9bcca; font-size: 10.5px; letter-spacing: 1px;
  line-height: 1.55; font-style: italic; z-index: 4; text-shadow: 0 2px 6px #000; display: none; }
.chap-slot .lock-hint.show { display: block; }
/* v0.47.1 — SELECCIÓN: primer click ilumina el CONTORNO con el color del capítulo
   (I dorado · II verde · III blanco · IV rojo — vía --sel inline); segundo click ENTRA. */
.chap-slot.sel .fabric { border-color: var(--sel);
  box-shadow: 0 0 52px 8px var(--sel), 0 0 18px 2px var(--sel), inset 0 0 30px rgba(0,0,0,.25), 0 18px 40px rgba(0,0,0,.6);
  filter: brightness(1.32) saturate(1.2); } /* v0.47.2 — ILUMINACIÓN FUERTE del estandarte seleccionado */
.chap-slot.sel .bg { opacity: .88; }
.chap-slot.sel .ring { border-color: var(--sel); box-shadow: 0 0 16px 3px var(--sel); }
.chap-slot.sel .lbl b { color: #fff; /* v0.47.3 — el glow del capítulo MANTIENE la base oscura densa */
  text-shadow: 0 1px 2px #000, 0 2px 5px #000, 0 3px 10px rgba(0,0,0,.95),
               0 0 16px var(--sel), 0 6px 20px rgba(0,0,0,.85); }
/* v0.47.2 — CARTEL «COMENZAR»: más pequeño, SEMITRANSPARENTE e ILUMINADO (acorde al
   estandarte), y subido para no quedar cortado por la punta de la tela */
.chap-slot .begin { position: absolute; bottom: 34px; left: 50%; transform: translateX(-50%);
  background: rgba(232,194,90,.16); color: #f6dd8a; font-size: 11px;
  letter-spacing: 2px; text-transform: uppercase; padding: 5px 12px; border-radius: 11px;
  border: 1px solid rgba(246,221,138,.65); z-index: 4; display: none; white-space: nowrap;
  text-shadow: 0 0 10px rgba(246,221,138,.85);
  box-shadow: 0 0 16px rgba(232,194,90,.4), inset 0 0 10px rgba(246,221,138,.12);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); cursor: pointer; }
.chap-slot.sel .begin.show { display: block; }
.chap-slot .tassel { position: absolute; bottom: -7px; left: 50%; transform: translateX(-50%);
  width: 0; height: 0; border-left: 9px solid transparent; border-right: 9px solid transparent;
  border-top: 15px solid var(--c2); filter: drop-shadow(0 3px 5px rgba(0,0,0,.5)); z-index: 5; }
/* v0.47.1 — TONO UNIFORME: todos los estandartes cuelgan igual (sin apagar los bloqueados);
   la identidad de cada capítulo la marca su COLOR DE SELECCIÓN al iluminarse. */
.chap-slot.unlocked:hover .fabric { transform: translateY(-4px);
  box-shadow: 0 24px 46px rgba(0,0,0,.7), 0 0 26px rgba(217,178,106,.28); }
.chap-slot.sel .fabric { transform: translateY(-2px); }
.chap-hub > .lobby-nav { position: relative; z-index: 2; }

/* Botón de acción dorado (briefs y detalle de campaña) */
.lobby-start-btn { background: linear-gradient(180deg, #e8c25a, #b68a3a); color: #211604;
  border: 1px solid rgba(246,221,138,.8); border-radius: 6px; padding: 10px 26px;
  font-family: inherit; font-size: 15px; letter-spacing: 1px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.4); }
.lobby-start-btn:hover { filter: brightness(1.08); }
.lobby-start-btn:active { transform: translateY(1px); }
#missionBrief { z-index: 310; } /* v0.45.2-fix — SOBRE el mapa del capítulo (z-300): el brief heredaba z-240 y quedaba tapado */
#missionBriefBody { min-width: min(560px, 88vw); }
#missionBriefBody h3 { margin: 0 0 6px; color: #f6dd8a; letter-spacing: 2px; font-weight: normal; }
#missionBriefBody .m-enemy { color: #e88; font-size: 13px; letter-spacing: 1px; margin: 0 0 12px; }
#missionBriefBody .m-desc { color: #c9bfa4; line-height: 1.6; margin: 0 0 8px; }

/* ============ v0.38.0 — SESIONES DE CAMPAÑA (estandartes de guerra · propuesta B) ============ */
.camp-rail {
  width: min(940px, 92vw); height: 14px; border-radius: 7px; flex: none;
  background: linear-gradient(180deg, #4a3d22, #2b2314 60%, #191408);
  border: 1px solid rgba(246,221,138,0.45);
  box-shadow: 0 6px 18px rgba(0,0,0,0.55), inset 0 1px 0 rgba(246,221,138,0.35);
  margin-bottom: -4px;
}
.camp-row { display: flex; gap: 26px; overflow-x: auto; padding: 4px 8px 14px; max-width: 94vw; scrollbar-width: thin; }
.camp-banner { position: relative; flex: 0 0 auto; width: 212px; height: 396px; padding-top: 26px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.camp-banner .ring {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 28px; height: 28px; border: 4px solid var(--gold2, #d4b04a); border-radius: 50%;
  box-shadow: 0 3px 8px rgba(0,0,0,0.6); z-index: 6;
}
.camp-banner .fabric {
  position: relative; width: 100%; height: 364px;
  background: linear-gradient(180deg, var(--c1) 0%, color-mix(in srgb, var(--c1) 68%, #000) 100%);
  border: 2.5px solid var(--c2); border-top: none;
  clip-path: polygon(0 0, 100% 0, 100% 86%, 50% 100%, 0 86%);
  box-shadow: 0 18px 40px rgba(0,0,0,0.6); overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.camp-banner .fabric::before {
  content: ''; position: absolute; inset: 0; margin: 5px;
  border: 1px solid rgba(255,255,255,0.20); pointer-events: none;
}
.camp-banner .bg { position: absolute; inset: 0; opacity: 0.5; }
.camp-banner .bg img { width: 100%; height: 100%; object-fit: cover; display: block; }
.camp-banner .veil { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(8,9,13,0.55), rgba(8,9,13,0.15) 45%, rgba(8,9,13,0.75)); }
.camp-banner .shield { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 4; }
/* v0.39.0 — escudos EXTRAÍDOS del arte de formaciones (assets/art/escudo_<raza>.png) */
.camp-escudo { display: block; height: auto; filter: drop-shadow(0 5px 12px rgba(0,0,0,0.65)); }
.camp-banner .data { position: absolute; top: 104px; left: 12px; right: 12px; text-align: center; z-index: 3; }
.camp-banner .race { font-size: 17.5px; letter-spacing: 2.5px; color: #ffffff; text-transform: uppercase; text-shadow: 0 2px 8px #000; }
.camp-banner .army { margin-top: 6px; font-size: 12px; color: var(--gold); letter-spacing: 1.5px; text-transform: uppercase; }
.camp-banner .chap { margin-top: 8px; font-size: 12.5px; font-style: italic; color: #dfe3ec; line-height: 1.5; text-shadow: 0 2px 6px #000; }
.camp-banner .prog { position: absolute; left: 16px; right: 16px; bottom: 56px; z-index: 3; }
.camp-banner .bar { height: 6px; border-radius: 3px; background: rgba(0,0,0,0.45); overflow: hidden; border: 1px solid rgba(255,255,255,0.28); }
.camp-banner .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--c2), rgba(255,255,255,0.5)); box-shadow: 0 0 8px var(--c2); }
.camp-banner .plabel { font-size: 10.5px; letter-spacing: 1.2px; color: #e6e2d5; margin-top: 5px; text-transform: uppercase; text-shadow: 0 1px 3px #000; }
.camp-banner .tassel {
  position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%);
  width: 0; height: 0; border-left: 9px solid transparent; border-right: 9px solid transparent;
  border-top: 16px solid var(--c2); filter: drop-shadow(0 3px 5px rgba(0,0,0,0.5));
}
.camp-banner:not(.camp-empty):hover .fabric {
  transform: translateY(-4px);
  box-shadow: 0 0 26px color-mix(in srgb, var(--c2) 45%, transparent), 0 20px 44px rgba(0,0,0,0.6);
}
.camp-empty .fabric {
  background: rgba(18,21,29,0.5); border-style: dashed;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
}
.camp-empty .plus { font-size: 52px; color: var(--gold); opacity: 0.85; line-height: 1; }
.camp-empty .t1 { color: var(--gold); letter-spacing: 3px; font-size: 14.5px; text-transform: uppercase; text-align: center; }
.camp-empty .t2 { color: #8a8f9c; font-size: 11.5px; font-style: italic; text-align: center; padding: 0 18px; line-height: 1.5; }
.camp-note { text-align: center; }
/* Overlays: selector de raza y detalle de sesión */
.camp-overlay {
  position: fixed; inset: 0; z-index: 240; display: flex; align-items: center; justify-content: center;
  background: rgba(5,6,9,0.74); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.camp-overlay[hidden] { display: none; }
.camp-panel {
  width: min(880px, 94vw); max-height: 88vh; overflow: auto;
  background: linear-gradient(180deg, rgba(23,27,37,0.92), rgba(18,21,29,0.96));
  border: 2px solid rgba(246,221,138,0.4); border-radius: 16px; padding: 26px;
  box-shadow: 0 24px 70px rgba(0,0,0,0.7);
}
.camp-panel h3 { margin: 0; font-family: var(--font-display); color: var(--gold); letter-spacing: 2px; text-transform: uppercase; font-size: 22px; text-align: center; }
/* v0.41.0 — SELECTOR DE RAZA DE CAMPAÑA EN CARRUSEL (diseño del propietario):
   ventana de gran formato, una raza visible a la vez con su arte de formación de
   fondo, flechas laterales de contorno luminoso y confirmación inferior. */
/* v0.41.3 — CONTROLES FUERA de la tarjeta: columnas ventana+confirmación;
   flechas flanqueando y botón de raza debajo (petición del propietario) */
.camp-race-col {
  display: flex; flex-direction: column; align-items: center; gap: clamp(10px, 1.6vh, 18px);
}
.camp-race-outer {
  display: flex; align-items: center; gap: clamp(10px, 1.4vw, 22px);
  width: min(1500px, 97vw);
}
.camp-race-full {
  position: relative; flex: 1; min-width: 0; height: min(840px, 82vh);
  display: flex; flex-direction: column; overflow: hidden;
  background: linear-gradient(180deg, rgba(23,27,37,0.9), rgba(12,14,20,0.96));
  border: 0; /* v0.41.1 — sin borde de marco (petición del propietario): la define el resplandor heráldico */
  border-radius: 18px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.75), 0 0 70px color-mix(in srgb, var(--c1, #2c4a8f) 22%, transparent);
}
.crf-stage { position: relative; flex: 1; min-height: 0; }
.crf-card {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 12px;
  padding: clamp(20px, 4vw, 44px); padding-top: clamp(42px, 8vh, 76px);
  transition: transform 260ms ease; /* entrada por deslizamiento: sin fundido de opacidad (siempre visible) */
}
.crf-card.crf-in { transform: none; }
.crf-bg { position: absolute; inset: 0; }
.crf-bg img { width: 100%; height: 100%; object-fit: cover; display: block; }
.crf-veil { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(9,11,16,0.52), rgba(9,11,16,0.88) 52%, rgba(7,9,13,0.97)); }
.crf-head { position: relative; display: flex; align-items: center; gap: 18px; }
.crf-head img { width: clamp(64px, 10vh, 96px); filter: drop-shadow(0 6px 18px rgba(0,0,0,0.65)); }
.crf-head h3 { margin: 0; font-family: var(--font-display); color: #ffffff; font-size: clamp(24px, 4.2vw, 40px); letter-spacing: 3px; text-transform: uppercase; text-shadow: 0 2px 18px rgba(0,0,0,0.85); }
.crf-desc { position: relative; margin: 0; color: #e6e9f0; font-size: clamp(13px, 1.8vh, 15.5px); line-height: 1.6; font-style: italic; max-width: 740px; text-shadow: 0 1px 8px rgba(0,0,0,0.9); }
.crf-block {
  position: relative; background: rgba(8,10,15,0.74); border: 1px solid color-mix(in srgb, var(--c2) 35%, transparent);
  border-left: 3px solid var(--c2); border-radius: 10px; padding: 10px 14px;
  max-width: 560px; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.crf-k { display: block; color: var(--c2); font-size: 11px; letter-spacing: 2.5px; text-transform: uppercase; margin-bottom: 4px; }
.crf-block p { margin: 0; color: #e2e5ec; font-size: clamp(12.5px, 1.7vh, 14.5px); line-height: 1.5; }
.crf-arrow {
  flex: none; width: clamp(46px, 4.5vw, 60px); height: clamp(64px, 8vw, 96px);
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(18px, 2.4vw, 26px); color: var(--c2); cursor: pointer;
  background: rgba(10,12,18,0.45); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  border: 2px solid var(--c2); border-radius: 12px;
  box-shadow: 0 0 22px color-mix(in srgb, var(--c2) 45%, transparent), inset 0 0 14px color-mix(in srgb, var(--c2) 16%, transparent);
  transition: 0.2s; -webkit-tap-highlight-color: transparent;
}
.crf-arrow:hover {
  background: rgba(10,12,18,0.62);
  box-shadow: 0 0 34px color-mix(in srgb, var(--c2) 70%, transparent), inset 0 0 20px color-mix(in srgb, var(--c2) 30%, transparent);
}
.crf-prev { order: 0; }
.crf-next { order: 2; }
.crf-close {
  position: absolute; top: 12px; right: 14px; z-index: 4; width: 38px; height: 38px;
  border-radius: 50%; background: rgba(10,12,18,0.55); border: 1px solid rgba(255,255,255,0.25);
  color: #d8dbe3; font-size: 16px; cursor: pointer; transition: 0.2s;
}
.crf-close:hover { border-color: #f6dd8a; color: #f6dd8a; box-shadow: 0 0 14px rgba(246,221,138,0.35); }
.crf-dots { position: relative; z-index: 2; display: flex; gap: 10px; justify-content: center; padding: 9px 0 2px; background: rgba(8,10,14,0.55); }
.crf-dot { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,0.18); transition: 0.25s; }
.crf-dot.on { background: var(--dc, #f6dd8a); box-shadow: 0 0 10px var(--dc, #f6dd8a); transform: scale(1.25); }
.crf-actions { display: flex; justify-content: center; }
.crf-actions .camp-start-btn { min-width: min(360px, 70vw); padding: 13px 22px; }
.camp-start-btn {
  margin-top: auto; padding: 12px 18px; border-radius: 10px; cursor: pointer;
  background: linear-gradient(180deg, #f6dd8a, #d4b04a); color: #0b0d12;
  border: 2px solid #f6dd8a; font-family: var(--font-display); font-weight: 700;
  font-size: 14px; letter-spacing: 2px; text-transform: uppercase; transition: 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.camp-start-btn:hover:not(:disabled) { box-shadow: 0 0 22px rgba(246,221,138,0.45); transform: translateY(-2px); }
.camp-start-btn:disabled { opacity: 0.45; cursor: default; }
@media (max-height: 560px) {
  .crf-card { gap: 8px; padding-top: 42px; }
  .crf-desc { display: none; }
}
.camp-detail-head { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }

/* v0.41.5 — basurero en la esquina del estandarte (disparador del borrado) */
.camp-del-mini {
  position: absolute; top: 6px; right: 6px; z-index: 7;
  width: 30px; height: 30px; border-radius: 8px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(12,14,19,0.6); border: 1px solid rgba(255,255,255,0.22);
  color: #c9cdd6; cursor: pointer; transition: 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.camp-del-mini:hover {
  background: rgba(122,26,22,0.78); border-color: #b0524a; color: #f2d7d0;
  box-shadow: 0 0 14px rgba(176,82,74,0.5);
}

/* v0.41.4 — BORRADO DE CAMPAÑA con confirmación obligatoria */
.camp-del-nav { gap: 12px; }
.camp-del-btn {
  padding: 10px 20px; border-radius: 10px; cursor: pointer;
  background: linear-gradient(180deg, rgba(122,26,22,0.85), rgba(82,14,12,0.92));
  border: 2px solid #b0524a; color: #f2d7d0;
  font-family: var(--font-display); font-weight: 700; font-size: 13px;
  letter-spacing: 2px; text-transform: uppercase; transition: 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.camp-del-btn:hover { box-shadow: 0 0 22px rgba(176,82,74,0.45); transform: translateY(-2px); }
.camp-del-panel { width: min(540px, 92vw); text-align: center; }
.camp-del-msg { max-width: 420px; margin: 14px auto 18px; line-height: 1.6; }

/* Previsualización de raza en el lobby */
.lobby-form {
  width: 100%; height: 88px; object-fit: cover; display: block; margin-top: 6px;
  border-radius: 8px; border: 1px solid rgba(217,178,106,0.3);
  background: var(--panel-2);
}

/* Ficha de unidad (concept art) en el panel de pieza */
.pi-art { margin-bottom: 12px; display: flex; justify-content: center; }
.pi-card {
  width: 100%; max-width: 360px; height: auto; display: block;
  border-radius: 12px;
  border: 1px solid rgba(217,178,106,0.45);
  box-shadow: 0 12px 34px rgba(0,0,0,0.55), 0 0 26px rgba(217,178,106,0.10);
}
.pi-card.fallback {
  width: 96px; height: 96px; border-radius: 50%;
  border: 2px solid rgba(246,221,138,0.6);
  box-shadow: 0 8px 20px rgba(0,0,0,0.5);
}

/* Retratos tácticos en el modal de combate */
.cm-portrait {
  width: 56px; height: 56px; display: block; margin-bottom: 8px;
  border-radius: 50%; border: 2px solid rgba(217,178,106,0.5);
  box-shadow: 0 4px 14px rgba(0,0,0,0.5);
  background: var(--panel);
}

/* ============ v0.113.6 — VENTANAS DE COMBATE / DEFENSA Y FICHA DE UNIDAD ============ */

/* --- 1 · La ventana SIEMPRE cabe: título y botones fijos, contenido con desplazamiento propio.
   .cm-panel es una columna flex limitada al alto visible (menos el relleno y el borde de
   .combat-modal). En combate/defensa (.cm-duel) el contenido va dentro de .cm-scroll, que
   es lo único que encoge y se desplaza; coronación/tablas/registro no tienen .cm-scroll y,
   si no cupieran, se desplaza el propio panel. */
.cm-panel {
  display: flex; flex-direction: column; min-height: 0;
  max-height: calc(100vh - 20px - 2 * var(--cm-pad-y, 18px));
  max-height: calc(100dvh - 20px - 2 * var(--cm-pad-y, 18px));
  overflow-y: auto; overscroll-behavior: contain;
}
.cm-panel > * { flex: 0 0 auto; }
/* coronación / tablas: la ventana se ciñe a su texto, sin estirarse a una sola línea larga
   (el visor del registro conserva su propio ancho: .log-panel) */
.cm-panel:not(.cm-duel):not(.log-panel) { max-width: 560px; }
.cm-panel.cm-duel { width: min(600px, calc(100vw - 20px - 2 * var(--cm-pad-x, 20px))); }
.cm-panel.cm-duel.cm-panel-info { width: min(900px, calc(100vw - 20px - 2 * var(--cm-pad-x, 20px))); }
.cm-panel > .cm-scroll {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y;
  padding-right: 6px;
}
.cm-panel.cm-duel > .cm-actions { padding-top: 10px; border-top: 1px solid var(--border); }
.cm-scroll > :last-child { margin-bottom: 10px; }

/* Barra de desplazamiento oscura (antes salía la nativa blanca) en las ventanas de partida */
.cm-panel, .cm-scroll, .fw-body, .float-win.fw-ficha .pi-data {
  scrollbar-width: thin; scrollbar-color: rgba(217,178,106,0.45) rgba(255,255,255,0.04);
}
.cm-panel::-webkit-scrollbar, .cm-scroll::-webkit-scrollbar, .fw-body::-webkit-scrollbar,
.float-win.fw-ficha .pi-data::-webkit-scrollbar { width: 8px; height: 8px; }
.cm-panel::-webkit-scrollbar-track, .cm-scroll::-webkit-scrollbar-track, .fw-body::-webkit-scrollbar-track,
.float-win.fw-ficha .pi-data::-webkit-scrollbar-track { background: rgba(255,255,255,0.04); border-radius: 8px; }
.cm-panel::-webkit-scrollbar-thumb, .cm-scroll::-webkit-scrollbar-thumb, .fw-body::-webkit-scrollbar-thumb,
.float-win.fw-ficha .pi-data::-webkit-scrollbar-thumb { background: rgba(217,178,106,0.45); border-radius: 8px; }

/* --- 2 · Ficha de cada bando en combate/defensa (ℹ): RETRATO | datos, habilidades debajo.
   EL RETRATO SE VE ENTERO: ancho y alto `auto` dentro de un máximo (la imagen conserva su
   proporción sea cual sea), `object-fit: contain` de respaldo, y NINGÚN contenedor de tamaño
   fijo ni `overflow: hidden` alrededor (.pi-art y .pi-zoom se ciñen a la imagen). */
.pi-sheet { min-width: 0; }
.pi-data { min-width: 0; }
.pi-abilities:empty { display: none; }
.pi-sheet-combat {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px 12px; align-items: start;
  background: rgba(29,34,48,0.55); border: 1px solid var(--border-strong); border-radius: 10px; padding: 10px;
}
.pi-sheet-combat .pi-art { margin: 0; display: block; line-height: 0; }
/* El retrato es un WebP con ALFA: su esquina inferior derecha es TRANSPARENTE (en la tarjeta
   la tapa el panel de habilidades). Por eso NO lleva fondo, borde, esquinas redondeadas ni
   sombra de caja (dibujarían el rectángulo y delatarían la esquina vacía, y el redondeo
   mordería las esquinas de la imagen): solo `drop-shadow`, que sigue la silueta real. */
.pi-sheet-combat .pi-card.pi-portrait {
  display: block; width: auto; height: auto; max-width: 170px; max-height: 230px;
  object-fit: contain; background: none; border: 0; border-radius: 0; box-shadow: none;
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.55));
}
.pi-sheet-combat .pi-zoom:hover > .pi-card.pi-portrait,
.pi-sheet-combat .pi-zoom:active > .pi-card.pi-portrait {
  box-shadow: none; filter: drop-shadow(0 0 6px rgba(246,221,138,0.75)) drop-shadow(0 6px 12px rgba(0,0,0,0.55));
}
/* sin retrato: la miniatura redonda de siempre (con su aro dorado) */
.pi-sheet-combat .pi-card.pi-portrait.fallback,
.pi-sheet-combat .pi-zoom:hover > .pi-card.pi-portrait.fallback {
  width: 96px; height: 96px; border-radius: 50%; border: 2px solid rgba(246,221,138,0.6);
  box-shadow: 0 8px 20px rgba(0,0,0,0.5); filter: none;
}
.pi-sheet-combat .pi-head { margin-bottom: 6px; }
.pi-sheet-combat .pi-stats { flex-wrap: wrap; gap: 2px 12px; padding: 6px 10px; font-size: 15px; }
.pi-sheet-combat .pi-stats span { white-space: nowrap; }
.pi-sheet-combat .pi-stats b { font-size: 18px; }
.pi-sheet-combat .pi-terr { margin-top: 8px; }
.pi-sheet-combat .pi-abilities { grid-column: 1 / -1; margin-top: 0; grid-template-columns: minmax(0, 1fr); gap: 8px; }

/* Imagen AMPLIABLE (tarjeta de la ficha flotante y retrato de combate): cursor de lupa,
   insignia en la esquina y realce al pasar el cursor. El envoltorio se ciñe a la imagen. */
.pi-zoom { position: relative; display: inline-block; line-height: 0; cursor: zoom-in; -webkit-tap-highlight-color: transparent; }
.pi-zoom::after {
  content: '🔍'; position: absolute; right: 5px; bottom: 5px; width: 22px; height: 22px;
  border-radius: 50%; background: rgba(8,10,16,0.80); border: 1px solid rgba(246,221,138,0.65);
  font-size: 11px; line-height: 20px; text-align: center; pointer-events: none;
}
.pi-zoom:hover > .pi-card, .pi-zoom:active > .pi-card { border-color: #f6dd8a; box-shadow: 0 0 0 2px rgba(246,221,138,0.30), 0 12px 34px rgba(0,0,0,0.55); }

/* --- 3 · Ficha flotante de unidad (.fw-ficha, SOLO esa ventana): TARJETA COMPLETA a la
   izquierda ajustada al alto disponible (entera) y los datos reales a la derecha, con
   desplazamiento propio si no cupieran. 96 px = cabecera + rellenos + bordes de la ventana. */
.float-win.fw-ficha .fw-card { width: min(900px, 94vw); }
.float-win.fw-ficha .pi-sheet { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 18px; align-items: start; }
.float-win.fw-ficha .pi-art { margin: 0; display: block; line-height: 0; }
.float-win.fw-ficha .pi-card:not(.fallback) {
  display: block; width: auto; height: auto; max-width: min(430px, 44vw); object-fit: contain;
  max-height: calc(82vh - 96px); max-height: calc(min(82vh, 82dvh) - 96px);
}
.float-win.fw-ficha .pi-data {
  max-height: calc(82vh - 96px); max-height: calc(min(82vh, 82dvh) - 96px);
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding-right: 6px;
}
.float-win.fw-ficha .pi-abilities { grid-template-columns: minmax(0, 1fr); }

/* --- 4 · Visor de tarjeta ampliada: pantalla completa sobre fondo oscuro, la tarjeta
   ENTERA ajustada a la pantalla. Por encima de todo (incluido el fin de partida, 9999). */
.card-zoom {
  position: fixed; inset: 0; z-index: 10050; display: flex; align-items: center; justify-content: center;
  background: rgba(4,5,9,0.93); cursor: zoom-out; -webkit-tap-highlight-color: transparent;
}
.card-zoom[hidden] { display: none; }
#cardZoomImg {
  flex: 0 0 auto; display: block; width: auto; height: auto; object-fit: contain; cursor: default;
  max-width: calc(100vw - 24px); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px);
  border-radius: 12px; border: 1px solid rgba(217,178,106,0.55); box-shadow: 0 20px 80px rgba(0,0,0,0.8);
}
#cardZoomClose {
  position: absolute; top: 10px; right: 12px; z-index: 1; width: 40px; height: 40px; border-radius: 50%;
  background: rgba(13,16,24,0.85); border: 1px solid rgba(246,221,138,0.6); color: #f6dd8a;
  font-size: 17px; line-height: 1; cursor: pointer; transition: 0.15s;
}
#cardZoomClose:hover { border-color: var(--red); color: var(--red); }

/* --- 5 · Pantallas BAJAS (móvil apaisado, 844×390 · 667×375): todo más compacto para que
   el contenido útil no se quede en una rendija entre el título y los botones. */
@media (max-height: 480px) {
  .combat-modal { --cm-pad-y: 10px; --cm-pad-x: 12px; }
  .combat-modal h3 { margin: 0 0 6px; font-size: 14px; }
  .cm-row { margin-bottom: 6px; }
  .cm-side { padding: 6px 8px; font-size: 12px; display: flow-root; }
  .cm-portrait { float: left; width: 42px; height: 42px; margin: 0 8px 0 0; }
  .cm-preview { padding-top: 6px; margin-bottom: 8px; }
  .cm-panel.cm-duel > .cm-actions { padding-top: 7px; }
  .cm-actions button { padding: 7px 12px; }
  .pi-sheet-combat { padding: 8px; gap: 8px 10px; }
  .pi-sheet-combat .pi-card.pi-portrait { max-width: 110px; max-height: 132px; }
  .pi-sheet-combat .pi-card.pi-portrait.fallback { width: 72px; height: 72px; }
  .pi-sheet-combat .pi-head { font-size: 13px; margin-bottom: 4px; }
  .pi-sheet-combat .pi-terr { margin-top: 6px; font-size: 12px; }
  .float-win.fw-ficha { padding: 8px; }
  .float-win.fw-ficha .fw-card { max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); }
  .float-win.fw-ficha .fw-head { padding: 6px 12px; }
  .float-win.fw-ficha #fwClose { width: 30px; height: 30px; min-height: 30px; }
  .float-win.fw-ficha .fw-body { padding: 10px 12px; }
  .float-win.fw-ficha .pi-sheet { column-gap: 14px; }
  .float-win.fw-ficha .pi-terr { margin-top: 8px; }
  .float-win.fw-ficha .pi-abilities { margin-top: 8px; gap: 8px; }
  .float-win.fw-ficha .ab-item { padding: 7px 10px; }
  .float-win.fw-ficha .ab-desc { margin: 4px 0 6px; }
  .pi-zoom::after { width: 18px; height: 18px; font-size: 9px; line-height: 16px; right: 3px; bottom: 3px; }
  .float-win.fw-ficha .pi-card:not(.fallback),
  .float-win.fw-ficha .pi-data { max-height: calc(100vh - 86px); max-height: calc(100dvh - 86px); }
}
/* --- 6 · VERTICAL estrecho: la ficha flotante en UNA columna (tarjeta arriba, datos debajo;
   se desplaza el cuerpo de la ventana, como siempre). */
@media (orientation: portrait) and (max-width: 700px) {
  .float-win.fw-ficha .pi-sheet { display: block; }
  .float-win.fw-ficha .pi-art { text-align: center; margin-bottom: 12px; }
  .float-win.fw-ficha .pi-card:not(.fallback) {
    display: inline-block; max-width: min(360px, calc(94vw - 36px));
    max-height: 56vh; max-height: 56dvh;
  }
  .float-win.fw-ficha .pi-data { max-height: none; overflow: visible; padding-right: 0; }
}

/* Volver al título desde el lobby */
.lobby-back { display: flex; justify-content: center; margin-top: 4px; }
.lobby-back-btn {
  background: transparent; color: #f6dd8a;
  border: 2px solid rgba(246,221,138,0.45);
  border-radius: 10px; padding: 12px 32px;
  font-family: var(--font-body); font-weight: 600; font-size: 14px;
  letter-spacing: 0.5px; cursor: pointer; transition: 0.15s;
  min-width: 180px;
  -webkit-tap-highlight-color: transparent;
}
.lobby-back-btn:hover, .lobby-back-btn:focus-visible {
  background: rgba(246,221,138,0.10); border-color: #f6dd8a;
  box-shadow: 0 0 20px rgba(246,221,138,0.25); outline: none;
}
