/* Guerra de Eras — interfaz. Fuentes del sistema; el campo de batalla es un canvas. */
:root {
  --bg: #14161F; --bg2: #1C1F2C; --panel: rgba(16, 18, 28, .94); --borde: rgba(255, 255, 255, .13);
  --texto: #F4F1EA; --sub: #BDB8AC; --oro: #FFD23F; --oro2: #E0A800; --azul: #2F7DE1; --naranja: #E8711A;
  --ok: #3DDC84; --malo: #FF5A5F; --gloria: #C9A7FF; --neon: #00F5D4;
  --r: 12px; --sombra: 0 6px 18px rgba(0, 0, 0, .35);
  --sa-t: env(safe-area-inset-top, 0px); --sa-b: env(safe-area-inset-bottom, 0px); --sa-l: env(safe-area-inset-left, 0px); --sa-r: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--texto);
  font: 15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
#app { position: fixed; inset: 0; height: 100vh; height: 100dvh; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.vista, .pantalla { position: absolute; inset: 0; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid var(--oro); outline-offset: 2px; }
a { color: var(--oro); }
[hidden] { display: none !important; }
kbd { font: 600 10px/1 system-ui; opacity: .55; }

/* ---------- botones genéricos ---------- */
.btn { border: 1px solid var(--borde); background: #2A2E40; border-radius: var(--r); padding: 11px 16px; min-height: 44px;
  font-weight: 700; box-shadow: 0 3px 0 rgba(0, 0, 0, .35); transition: transform .06s, filter .15s; position: relative; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, .35); }
.btn:hover { filter: brightness(1.12); }
.btn.principal { background: linear-gradient(#FFDD55, #F2B705); color: #2A1A00; border-color: #FFE68A; box-shadow: 0 4px 0 #9A6D00, 0 0 24px rgba(255, 210, 63, .35); }
.btn.grande { font-size: 19px; padding: 14px 24px; min-height: 54px; }
.btn.grande small { display: block; font-size: 12px; font-weight: 600; opacity: .8; }
.btn.sec { background: transparent; box-shadow: none; }
.btn.peq { min-height: 40px; padding: 8px 12px; font-size: 14px; }
.btn.bloq { opacity: .55; }
.btn.bloq small { margin-left: 6px; font-size: 11px; }
.btn.brilla { border-color: var(--gloria); box-shadow: 0 3px 0 rgba(0,0,0,.35), 0 0 14px rgba(201, 167, 255, .45); }
.btn:disabled { opacity: .45; cursor: default; filter: none; transform: none; }
.icon { min-width: 40px; min-height: 40px; border: 1px solid var(--borde); background: rgba(0, 0, 0, .35); border-radius: 10px; font-weight: 800; }
.enlace { background: none; border: 0; color: var(--oro); text-decoration: underline; padding: 0; min-height: 0; }
.badge { position: absolute; top: -7px; right: -7px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--malo); color: #fff; font: 800 12px/22px system-ui; animation: late 1.2s infinite; }
.moneda { display: inline-block; width: 15px; height: 15px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #FFF2A8, var(--oro) 45%, var(--oro2)); border: 1px solid #8A6400; vertical-align: -2px; }
.moneda.mini { width: 11px; height: 11px; }
/* Gloria = corona de laurel violeta (la estrella se confundía con las estrellas doradas de los niveles). */
.ico-gloria { display: inline-block; width: 16px; height: 16px; vertical-align: -3px; background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cg fill='%23C9A7FF'%3E%3Cpath d='M16 29c-6-1-11-6-11-13 0-3 1-6 3-8-1 3-1 6 0 9 2 5 5 9 8 12z'/%3E%3Cpath d='M16 29c6-1 11-6 11-13 0-3-1-6-3-8 1 3 1 6 0 9-2 5-5 9-8 12z'/%3E%3Cellipse cx='6' cy='12' rx='2' ry='4' transform='rotate(-25 6 12)'/%3E%3Cellipse cx='5' cy='19' rx='2' ry='4' transform='rotate(-55 5 19)'/%3E%3Cellipse cx='9' cy='25' rx='2' ry='4' transform='rotate(-80 9 25)'/%3E%3Cellipse cx='26' cy='12' rx='2' ry='4' transform='rotate(25 26 12)'/%3E%3Cellipse cx='27' cy='19' rx='2' ry='4' transform='rotate(55 27 19)'/%3E%3Cellipse cx='23' cy='25' rx='2' ry='4' transform='rotate(80 23 25)'/%3E%3Ccircle cx='16' cy='9' r='3'/%3E%3C/g%3E%3C/svg%3E"); }
.ico-gloria.grande { width: 30px; height: 30px; }
.gloria-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 99px; background: rgba(0, 0, 0, .45); border: 1px solid rgba(201, 167, 255, .4); font-weight: 800; color: var(--gloria); }

/* ---------- partida (interfaz.md §2-4) ---------- */
.partida { display: grid; grid-template: "top top" auto "campo campo" minmax(0, 1fr) "panel lat" auto / minmax(0, 1fr) auto; background: #000; }
.hud-top { grid-area: top; } .campo-wrap { grid-area: campo; } .hud-panel { grid-area: panel; }
/* Hechizos y héroe: al final de la fila de abajo en escritorio; columna a la derecha del campo en un móvil apaisado. */
.hud-lat { grid-area: lat; display: flex; align-items: center; justify-content: center; gap: 6px; background: var(--panel); border-top: 1px solid var(--borde); padding: 5px calc(8px + var(--sa-r)) calc(5px + var(--sa-b)) 4px; z-index: 2; }
.hud-top { display: flex; align-items: center; gap: 10px; padding: calc(3px + var(--sa-t)) calc(8px + var(--sa-r)) 3px calc(8px + var(--sa-l)); background: var(--panel); border-bottom: 1px solid var(--borde); z-index: 2; min-height: 44px; }
.grupo { display: flex; align-items: center; gap: 6px; }
.reloj { font: 700 13px/1 ui-monospace, Menlo, Consolas, monospace; color: var(--sub); min-width: 38px; }
.vel { font-size: 13px; }
.ico-pausa { display: inline-block; width: 12px; height: 14px; border-left: 4px solid currentColor; border-right: 4px solid currentColor; vertical-align: middle; }
.bar { display: flex; align-items: center; gap: 6px; flex: 1 1 110px; min-width: 0; position: relative; }
.bar b { font-size: 12px; white-space: nowrap; color: var(--sub); }
.bar-in { flex: 1; height: 14px; border-radius: 7px; background: rgba(0, 0, 0, .55); overflow: hidden; border: 1px solid var(--borde); position: relative; min-width: 50px; }
.bar-in i { display: block; height: 100%; transform-origin: left; background: linear-gradient(#5EA3FF, var(--azul)); transition: transform .25s; }
.vida-i .bar-in i { background: linear-gradient(#FFA25E, var(--naranja)); transform-origin: right; }
.vida-i { flex-direction: row-reverse; }
.bar-txt { position: absolute; inset: 0; text-align: center; font: 800 12px/13px system-ui; pointer-events: none; text-shadow: 0 1px 2px #000; white-space: nowrap; overflow: hidden; }
.bar.peligro .bar-in { animation: peligro .6s infinite alternate; }
/* muescas de venganza en la barra enemiga: blancas; parpadean en el aviso; apagadas cuando ya salió */
.muesca { position: absolute; top: -1px; bottom: -1px; width: 3px; margin-right: -1px; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.6); z-index: 1; }
.muesca.aviso { background: var(--malo); animation: late .3s infinite; }
.muesca.hecha { background: rgba(255,255,255,.3); }
.ia-info { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.05; white-space: nowrap; }
.reservas { font-size: 12px; font-weight: 800; color: #FFC9A8; }
.reservas.cero { color: var(--ok); }
.atacando { font-size: 12px; font-weight: 900; color: var(--oro); }
.oro, .mana { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.oro-col { display: flex; flex-direction: column; gap: 2px; min-width: 70px; }
.oro-n { font-weight: 900; font-size: 17px; color: var(--oro); text-shadow: 0 1px 0 #000; font-variant-numeric: tabular-nums; }
.mana-n { font-weight: 900; font-size: 15px; color: #C9B6FF; font-variant-numeric: tabular-nums; }
.oro-in { font-size: 12px; color: var(--sub); font-weight: 700; }
.oro-bar { display: block; height: 4px; border-radius: 2px; background: rgba(0,0,0,.55); overflow: hidden; }
.oro-bar i { display: block; height: 100%; transform-origin: left; background: var(--oro); }
.mana-bar i { background: #9A7BFF; }
.oro.casi .oro-bar i { background: #FFA23F; animation: late .8s infinite; }
.oro.lleno .oro-n { color: var(--malo); } .oro.lleno .oro-bar i { background: var(--malo); }
.gema { display: inline-block; width: 13px; height: 13px; transform: rotate(45deg); background: linear-gradient(135deg, #E2D6FF, #8E6BFF); border: 1px solid #3A2A7A; flex: none; }
.flota-n { position: absolute; z-index: 9; font: 900 15px/1 system-ui; pointer-events: none; animation: flota 1.1s ease-out forwards; text-shadow: 0 1px 2px #000; }
.flota-n.malo { color: var(--malo); } .flota-n.bueno { color: var(--oro); }

.campo-wrap { position: relative; min-height: 0; overflow: hidden; }
/* Capas propias: sin ellas, cada fotograma del canvas obligaba a repintar el HUD entero (P8 medido: p95 33 ms → 17 ms
   en 844×390, dpr 2, CPU ×4, 120 cuerpos). */
.hud-top, .hud-panel, .hud-lat, .campo { will-change: transform; }
.campo { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.centrar { position: absolute; right: 8px; bottom: 8px; font-size: 20px; min-width: 44px; min-height: 44px; z-index: 3; }
.avisos { position: absolute; left: 0; right: 0; top: 40px; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; z-index: 4; }
.aviso { background: rgba(0, 0, 0, .75); border: 1px solid var(--borde); border-radius: 12px; padding: 7px 14px; font-weight: 800; font-size: 15px; text-align: center; animation: entra .35s cubic-bezier(.2, 1.6, .5, 1); max-width: 90%; }
.aviso.malo, .aviso.venganza, .aviso.jefe, .aviso.titanEnemigo, .aviso.asaltoFinal, .aviso.cuentaAtras { border-color: var(--malo); color: #FFD9D9; }
.aviso.bueno, .aviso.sinReservas { border-color: var(--ok); color: #D9FFE8; }
.aviso.fuera, .toast.fuera { opacity: 0; transform: translateY(-8px); transition: .4s; }
.avisos .cuenta { color: var(--oro); }
.avisos > .fuera { position: absolute; }   /* el que se va no empuja hacia abajo a los que quedan */
/* Los de la partida van en la pila de .avisos (arriba, sin tapar la melé); este contenedor es el de los menús. */
.toasts.global { position: fixed; left: 0; right: 0; bottom: calc(18px + var(--sa-b)); display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; z-index: 30; }
.toast { background: rgba(10, 10, 16, .88); border: 1px solid var(--borde); border-radius: 10px; padding: 7px 14px; font-weight: 700; font-size: 14px; animation: entra .25s; max-width: 92vw; text-align: center; }
.heroe-ret { position: absolute; left: calc(6px + var(--sa-l)); top: 18px; display: grid; grid-template-columns: 40px auto; grid-template-rows: auto auto; column-gap: 6px; align-items: center; min-height: 44px; padding: 2px 8px 2px 2px; border-radius: 12px; border: 1px solid var(--borde); background: rgba(10, 12, 20, .7); z-index: 3; text-align: left; }
.heroe-ret .retrato { grid-row: 1 / 3; width: 40px; height: 40px; }
.heroe-bar { width: 64px; height: 6px; border-radius: 3px; background: rgba(0,0,0,.6); overflow: hidden; }
.heroe-bar i { display: block; height: 100%; background: var(--ok); transform-origin: left; }
.heroe-ret small { font-size: 12px; font-weight: 700; color: var(--sub); white-space: nowrap; }
.heroe-ret.caido { opacity: .7; } .heroe-ret.caido .retrato { filter: grayscale(1); }
.buff { position: absolute; right: 6px; top: 18px; z-index: 3; font: 800 13px/1 system-ui; padding: 6px 10px; border-radius: 99px; background: rgba(0,0,0,.7); border: 1px solid var(--borde); }
.buff.b-furia { color: #FF9A7A; border-color: #FF5A3A; } .buff.b-escudo { color: #9CCBFF; border-color: #5EA3FF; }
.cola { position: absolute; left: calc(6px + var(--sa-l)); bottom: 6px; display: flex; gap: 4px; z-index: 3; }
.cola.pausada .qslot { border-color: var(--malo); }
.qslot { width: 44px; height: 44px; padding: 0; border-radius: 9px; border: 1px solid rgba(255, 255, 255, .35); background: rgba(16, 18, 28, .78); position: relative; overflow: hidden; }
.qslot .retrato { width: 100%; height: 38px; display: block; }
.qprog { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: rgba(0, 0, 0, .5); }
.qprog i { display: block; height: 100%; background: var(--oro); transform-origin: left; transform: scaleX(0); }

.hud-panel { background: var(--panel); border-top: 1px solid var(--borde); padding: 5px 6px calc(5px + var(--sa-b)) calc(6px + var(--sa-l)); display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 10px; align-items: center; z-index: 2; }
.fila-tropas { display: flex; gap: 6px; align-items: center; }
.tropas { display: flex; gap: 5px; }
.tropa { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; width: 56px; height: 62px; padding: 2px;
  border-radius: 11px; border: 1px solid var(--borde); background: linear-gradient(#323750, #23273A); box-shadow: 0 3px 0 rgba(0, 0, 0, .4); transition: transform .06s; }
.tropa:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, .4); }
.tropa .retrato { width: 40px; height: 36px; flex: none; }
.u-linea { font-weight: 900; font-size: 13px; color: var(--oro); display: flex; align-items: center; gap: 2px; line-height: 1.1; }
.u-est { position: absolute; top: 2px; left: 1px; right: 1px; font: 800 12px/1.1 system-ui; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-align: center; border-radius: 4px; pointer-events: none; z-index: 1; }
.u-est:empty { display: none; }
.u-n { position: absolute; top: 2px; right: 3px; font: 900 12px/1 system-ui; color: #fff; text-shadow: 0 1px 2px #000; }
.tropa kbd { position: absolute; bottom: 2px; right: 4px; display: none; }
.tropa.comodin { border-color: var(--gloria); }
.tropa.sin, .c-btn.sin { opacity: .5; filter: saturate(.35); }
.tropa.bloq { opacity: .6; } .tropa.bloq .retrato { filter: grayscale(1) brightness(.6); }
.tropa.bloq .u-est { background: rgba(0,0,0,.75); color: #DDD; top: 8px; padding: 2px 0; white-space: normal; line-height: 1.05; }
.tropa.lleno .u-est { background: var(--malo); color: #fff; }
.tropa.contra { border-color: var(--ok); box-shadow: 0 3px 0 rgba(0, 0, 0, .4), 0 0 0 2px rgba(61, 220, 132, .55), 0 0 16px rgba(61, 220, 132, .35); }
.tropa.contra .u-est { background: var(--ok); color: #05301A; }
.nope { animation: nope .25s; }
.accion { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 58px; height: 56px; padding: 2px 6px; border-radius: 12px; border: 1px solid var(--borde); background: #262A3C; box-shadow: 0 3px 0 rgba(0, 0, 0, .4); }
.accion .a-t { font-weight: 800; font-size: 12px; }
.accion.on { border-color: var(--oro); background: #3A3420; }
.accion.pagable::after { content: ""; position: absolute; top: 4px; right: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.accion.brilla { border-color: var(--oro); animation: late 1s infinite; }
.a-prog { position: absolute; left: 6px; right: 6px; bottom: 4px; height: 3px; border-radius: 2px; overflow: hidden; }
.a-prog i { display: block; height: 100%; background: var(--oro); transform-origin: left; transform: scaleX(0); }
.a-ico { width: 24px; height: 20px; display: block; }
.ico-castillo { background: linear-gradient(#B8B2A0, #B8B2A0) 2px 8px/20px 12px no-repeat, linear-gradient(#B8B2A0, #B8B2A0) 2px 3px/4px 5px no-repeat, linear-gradient(#B8B2A0, #B8B2A0) 10px 3px/4px 5px no-repeat, linear-gradient(#B8B2A0, #B8B2A0) 18px 3px/4px 5px no-repeat; }
.ordenes { display: flex; gap: 3px; }
.orden { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 48px; height: 50px; padding: 0 4px; border-radius: 10px; border: 1px solid var(--borde); background: #262A3C; }
.orden .o-ico { font-size: 15px; font-weight: 900; letter-spacing: -2px; line-height: 1; }
.orden .o-t { font-size: 12px; font-weight: 700; color: var(--sub); }
.orden.on { background: var(--oro); color: #2A1A00; border-color: var(--oro); } .orden.on .o-t { color: #2A1A00; }
.hechizos { display: flex; gap: 5px; }
.hech { --p: 0; --d: 42px; position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 0; border: 0; background: none; min-width: 50px; min-height: 44px; }
.hech:disabled { opacity: .45; }
.h-circ { position: relative; width: var(--d); height: var(--d); border-radius: 50%; border: 2px solid var(--borde); background: #262A3C; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.h-circ::before { content: ""; position: absolute; inset: 0; background: conic-gradient(rgba(0, 0, 0, .65) calc(var(--p) * 360deg), transparent 0); pointer-events: none; z-index: 1; }
.hech.lista .h-circ { border-color: #B9A6FF; box-shadow: 0 0 12px rgba(160, 130, 255, .55); }
.hab.lista .h-circ { border-color: var(--oro); box-shadow: 0 0 12px rgba(255, 210, 63, .5); }
.hech.activo .h-circ { border-color: var(--ok); animation: late 1s infinite; }
.h-s { position: absolute; font: 900 14px/1 system-ui; text-shadow: 0 1px 3px #000; z-index: 2; }
.h-n { font-size: 12px; font-weight: 800; color: var(--sub); line-height: 1.1; white-space: nowrap; }
.h-n b { color: #C9B6FF; }
.h-ico, .chip-ico { width: 22px; height: 22px; border-radius: 50%; display: inline-block; flex: none; }
.h-lluvia .h-ico, .chip-ico.h-lluvia { background: radial-gradient(circle at 35% 35%, #FFE08A, #FF7B1C 50%, #8A2B0B); }
.h-furia .h-ico, .chip-ico.h-furia { background: radial-gradient(circle at 40% 40%, #FFB0A0, #E63946 60%, #6A0E14); }
.h-curacion .h-ico, .chip-ico.h-curacion { background: linear-gradient(var(--ok), var(--ok)) center/7px 20px no-repeat, linear-gradient(var(--ok), var(--ok)) center/20px 7px no-repeat; border-radius: 0; }
.h-escudo .h-ico, .chip-ico.h-escudo { background: radial-gradient(circle at 50% 30%, #CFE6FF, #5EA3FF 60%, #1B4F96); border-radius: 50% 50% 50% 50% / 35% 35% 65% 65%; }
.h-congelar .h-ico, .chip-ico.h-congelar { background: radial-gradient(circle, #FFFFFF, #9CE7FF 50%, #2F7DE1); }
.h-rayo .h-ico, .chip-ico.h-rayo { background: linear-gradient(135deg, transparent 40%, #FFE14D 40% 60%, transparent 60%), #3A3F6A; }
.hab .h-ico { background: radial-gradient(circle at 40% 40%, #FFF2A8, var(--oro) 50%, var(--oro2)); }

/* bandeja del castillo: sobre el campo, sin pausar */
.bandeja { position: absolute; left: 50%; transform: translateX(-50%); bottom: var(--panel-h, 76px); width: min(760px, calc(100% - 12px)); max-height: calc(100% - var(--panel-h, 76px) - 46px); overflow: auto; z-index: 6;
  background: rgba(22, 24, 36, .97); border: 1px solid var(--borde); border-radius: 14px; padding: 8px; box-shadow: var(--sombra); }
.tray-cab { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.tray-cab b { font-size: 16px; } .tray-cab small { flex: 1; color: var(--sub); font-size: 12px; }
.cartas { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.carta { display: flex; flex-direction: column; gap: 3px; border: 1px solid var(--borde); background: #262A3C; border-radius: 10px; padding: 7px; min-width: 0; }
.carta.obra { border-color: var(--oro); } .carta.max { opacity: .7; }
.c-cab { display: flex; justify-content: space-between; align-items: center; } .c-cab b { font-size: 14px; }
.c-cab kbd { display: none; }
.c-lineas { display: flex; flex-direction: column; font-size: 12px; color: var(--sub); line-height: 1.3; }
.c-lineas b { color: var(--texto); }
.c-prog { display: block; height: 5px; border-radius: 3px; background: rgba(0,0,0,.5); overflow: hidden; }
.c-prog i { display: block; height: 100%; background: var(--oro); transform-origin: left; transform: scaleX(0); }
.c-nota { font-size: 12px; color: #FFC9A8; line-height: 1.2; }
.c-nota:empty { display: none; }
.c-btn { margin-top: auto; width: 100%; font-size: 13px; padding: 6px 4px; white-space: nowrap; }
.c-btn.principal { box-shadow: 0 3px 0 #9A6D00; }

.burbuja { position: absolute; z-index: 20; background: #FFF8E1; color: #2A1A00; border-radius: 14px; padding: 12px 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); font-weight: 700; animation: entra .3s cubic-bezier(.2, 1.5, .5, 1); }
.burbuja p { margin: 0 0 6px; font-size: 15px; }
.burbuja p:last-child { margin: 0; }
.burbuja .btn { background: #2A1A00; color: #FFF8E1; }
.flecha { position: absolute; z-index: 21; width: 0; height: 0; border: 9px solid transparent; border-top: 14px solid #FFF8E1; animation: rebota .6s infinite alternate; pointer-events: none; }
.flecha.arriba { border-top: 0; border-bottom: 14px solid #FFF8E1; }

/* ---------- modales ---------- */
.capa-modal { position: fixed; inset: 0; background: rgba(5, 6, 12, .66); display: flex; align-items: center; justify-content: center; z-index: 25; padding: calc(12px + var(--sa-t)) 12px calc(12px + var(--sa-b)); animation: aparece .2s; backdrop-filter: blur(2px); }
.modal { width: min(520px, 100%); max-height: 100%; overflow: auto; background: linear-gradient(#262A3C, #1B1E2C); border: 1px solid var(--borde); border-radius: 18px; padding: 18px; box-shadow: var(--sombra); animation: entra .3s cubic-bezier(.2, 1.4, .5, 1); user-select: text; }
.modal h2 { margin: 0 0 8px; font-size: 24px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.modal p { margin: 6px 0; color: #E3DED2; }
.kicker { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--sub) !important; font-weight: 800; }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.acciones.col { flex-direction: column; }
.acciones .principal { flex: 1 1 100%; }
.pie { font-size: 12px; color: var(--sub) !important; text-align: center; }
.nuevo { color: var(--ok) !important; font-weight: 700; }
.aviso-ia { font-size: 13px; color: #FFC9A8 !important; }
.conds { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 4px; }
.conds li { background: rgba(0, 0, 0, .25); border-radius: 8px; padding: 6px 10px; color: var(--sub); font-weight: 700; }
.conds li.ok { color: var(--oro); }
.premio { font-weight: 700; color: var(--gloria) !important; }
.fila { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid rgba(255, 255, 255, .06); min-height: 48px; }
.fila input[type=range] { width: 50%; height: 44px; margin: 0; accent-color: var(--oro); }
/* Casillas como interruptores de 52×44 (la casilla de 24 px era poco blanco para un dedo). */
.fila input[type=checkbox] { appearance: none; -webkit-appearance: none; width: 56px; height: 44px; margin: 0; padding: 8px 2px; background: #3A3F55 content-box; border-radius: 16px; position: relative; cursor: pointer; }
.fila input[type=checkbox]::after { content: ""; position: absolute; top: 11px; left: 6px; width: 22px; height: 22px; border-radius: 50%; background: #CFCAC0; transition: left .15s; }
.fila input[type=checkbox]:checked { background-color: var(--oro); }
.fila input[type=checkbox]:checked::after { left: 28px; background: #2A1A00; }
.fila .email { min-width: 0; overflow-wrap: anywhere; font-size: 13px; }
.fila .botones { display: flex; gap: 6px; }
.seg { display: inline-flex; border: 1px solid var(--borde); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 8px 12px; min-height: 40px; font-weight: 700; }
.seg button.on { background: var(--oro); color: #2A1A00; }
.refuerzos { background: rgba(61, 220, 132, .12); border: 1px solid rgba(61, 220, 132, .4); border-radius: 10px; padding: 8px 10px; margin-top: 8px; }
.n-jefe { font: 800 12px/1 system-ui; background: var(--malo); color: #fff; padding: 3px 6px; border-radius: 6px; letter-spacing: .05em; }
.creditos { font-size: 12px; color: var(--sub) !important; }
.ciclo { font-size: 13px; background: rgba(61, 220, 132, .1); border-radius: 10px; padding: 8px 10px; }

.resultado { text-align: center; }
.resultado h2 { justify-content: center; }
.res-t { font-size: 38px !important; letter-spacing: .02em; }
.res-t.gana { color: var(--oro); text-shadow: 0 0 22px rgba(255, 210, 63, .5); animation: golpe .5s cubic-bezier(.2, 1.6, .5, 1); }
.res-t.pierde { color: #FFB0B0; }
.estrellas { display: flex; justify-content: center; gap: 10px; margin: 4px 0; }
.est { font-size: 46px; color: rgba(255, 255, 255, .15); line-height: 1; transition: .2s; }
.est.on { color: var(--oro); text-shadow: 0 0 18px rgba(255, 210, 63, .8); animation: golpe .45s cubic-bezier(.2, 1.8, .5, 1); }
.res-sub { font-weight: 700; }
.g-caja { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 10px 0 4px; }
.g-total { font: 900 40px/1 system-ui; color: var(--gloria); font-variant-numeric: tabular-nums; }
.partes { list-style: none; padding: 0; margin: 4px auto; max-width: 320px; font-size: 13px; color: var(--sub); }
.partes li { display: flex; justify-content: space-between; padding: 2px 0; }
.partes b { color: var(--gloria); }
.logros-nuevos { background: rgba(201, 167, 255, .1); border: 1px solid rgba(201, 167, 255, .35); border-radius: 10px; padding: 4px 10px; margin: 8px 0; font-size: 13px; }
.hint { color: var(--gloria) !important; font-weight: 700; font-size: 13px; }

/* ---------- portada ---------- */
.portada { overflow: hidden; }
.fondo-portada { position: absolute; inset: 0; width: 100%; height: 100%; }
.portada-in { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 12px; padding: calc(16px + var(--sa-t)) 16px calc(16px + var(--sa-b));
  background: radial-gradient(ellipse at 50% 40%, rgba(10, 10, 20, .55), rgba(10, 10, 20, .2) 70%); overflow: auto; }
.portada-in > :first-child { margin-top: auto; } .portada-in > :last-child { margin-bottom: auto; }
.logo { display: flex; align-items: baseline; gap: 10px; font-weight: 900; letter-spacing: .03em; text-shadow: 0 4px 0 rgba(0, 0, 0, .5), 0 0 30px rgba(0, 0, 0, .6); animation: entra .6s cubic-bezier(.2, 1.4, .5, 1); }
.logo-a { font-size: clamp(38px, 11vw, 76px); color: #FFF3D6; }
.logo-de { font-size: clamp(18px, 4vw, 28px); color: var(--oro); font-style: italic; }
.logo-b { font-size: clamp(38px, 11vw, 76px); background: linear-gradient(90deg, #F4A259, #C9A227, #8B1E1E, #3D5A80, var(--neon)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lema { margin: 0; text-align: center; color: #F2EADB; font-weight: 600; text-shadow: 0 2px 4px #000; max-width: 420px; }
.portada .btn.principal { min-width: min(320px, 100%); }
.menu-portada { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: min(520px, 100%); }
.menu-portada .btn { background: rgba(30, 33, 50, .85); font-size: 14px; padding: 10px 8px; }
.mas-juegos { font-weight: 700; font-size: 13px; text-shadow: 0 1px 3px #000; }
.enlaces { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 8px; margin: 0; }
.cuenta-mini { margin: 0; font-size: 12px; color: var(--sub); text-shadow: 0 1px 3px #000; }

/* ---------- mapa, mejoras, retos, logros, ajustes ---------- */
.mapa, .mejoras, .retos-p, .logros-p, .ajustes-p { display: flex; flex-direction: column; overflow: auto; padding: calc(8px + var(--sa-t)) calc(12px + var(--sa-r)) calc(16px + var(--sa-b)) calc(12px + var(--sa-l)); background: var(--bg); }
.fondo-res { background: radial-gradient(ellipse at 50% 30%, #2A2440, var(--bg)); }
.cab { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.cab h1 { flex: 1; margin: 0; font-size: 22px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; flex: none; scrollbar-width: thin; }
.tabs .tab { white-space: nowrap; flex: none; }
.nodos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 8px 0; }
.nodo { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; border-radius: 14px; border: 1px solid var(--borde); padding: 12px; min-height: 92px; background: linear-gradient(160deg, rgba(255, 255, 255, .08), rgba(0, 0, 0, .25)); box-shadow: 0 3px 0 rgba(0, 0, 0, .35); }
.nodo.bloq { opacity: .4; }
.nodo.siguiente { border-color: var(--oro); box-shadow: 0 0 0 2px rgba(255, 210, 63, .4), 0 3px 0 rgba(0, 0, 0, .35); animation: late 1.6s infinite; }
.nodo.jefe { border-color: rgba(255, 90, 95, .6); }
.n-num { font: 900 22px/1 system-ui; opacity: .9; }
.n-nom { font-weight: 700; font-size: 14px; }
.n-est { color: var(--oro); letter-spacing: 2px; }
.nodo .n-jefe { position: absolute; top: 10px; right: 10px; }
.mapa.era-1 { background: linear-gradient(#3A2216, var(--bg) 60%); } .mapa.era-2 { background: linear-gradient(#1F3A2A, var(--bg) 60%); }
.mapa.era-3 { background: linear-gradient(#3A3528, var(--bg) 60%); } .mapa.era-4 { background: linear-gradient(#2E3240, var(--bg) 60%); } .mapa.era-5 { background: linear-gradient(#1A1640, var(--bg) 60%); }
.intro { color: var(--sub); font-size: 13px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 8px; }
.ramas { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.rama h3 { margin: 4px 0 8px; font-size: 15px; color: var(--oro); }
.nodo-arbol { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: rgba(255, 255, 255, .05); border: 1px solid var(--borde); border-radius: 12px; padding: 8px 10px; margin-bottom: 6px; }
.nodo-arbol b { display: block; font-size: 14px; } .nodo-arbol small { display: block; font-size: 12px; color: var(--sub); }
.nodo-arbol.max { border-color: rgba(61, 220, 132, .45); } .nodo-arbol.bloq { opacity: .5; }
.pips { display: flex; gap: 2px; margin-top: 4px; flex-wrap: wrap; }
.pips i { width: 8px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .15); }
.pips i.on { background: var(--gloria); }
.solo-movil { display: none; }
.retos, .logros { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.retos li, .logros li { display: flex; align-items: center; gap: 10px; background: rgba(255, 255, 255, .05); border: 1px solid var(--borde); border-radius: 12px; padding: 12px; }
.retos li span:nth-child(2) { flex: 1; }
.retos li.ok { border-color: rgba(61, 220, 132, .5); }
.check { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--borde); display: grid; place-items: center; color: var(--ok); font-weight: 900; flex: none; }
.logros { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.logros li { flex-direction: column; align-items: flex-start; gap: 2px; opacity: .55; }
.logros li.ok { opacity: 1; border-color: rgba(201, 167, 255, .5); }
.logros small { color: var(--sub); } .lg { font-weight: 800; color: var(--gloria); font-size: 13px; }
.tarjeta { background: rgba(255, 255, 255, .04); border: 1px solid var(--borde); border-radius: 14px; padding: 6px 14px; max-width: 560px; }

/* ---------- tamaños: todo control táctil ≥ 44 px, todo texto ≥ 12 px (P7) ---------- */
.icon, .tab, .btn.peq, .seg button, .qslot, .chip { min-height: 44px; min-width: 44px; }
.mas-juegos, .enlace, .cuenta-mini .enlace, .marca-ngv { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; }
/* La botonera de las ventanas queda siempre a la vista. */
.modal { --pad: 18px; }
.modal .acciones { position: sticky; bottom: calc(-1 * var(--pad)); margin: 14px calc(-1 * var(--pad)) calc(-1 * var(--pad)); padding: 12px var(--pad) var(--pad);
  background: linear-gradient(rgba(27, 30, 44, 0), #1B1E2C 14px); z-index: 1; }
@media (hover: hover) and (pointer: fine) { .tropa kbd, .c-cab kbd { display: block; } }

/* De pie (390×844, 360×640, 375×553): solo menús; la batalla la tapa «Gira el móvil» (interfaz.md §11). */
@media (orientation: portrait) {
  .menu-portada { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ramas { grid-template-columns: 1fr; }
  .rama { display: none; } .rama.on { display: block; }
  .solo-movil { display: flex; }
}
/* Móviles bajitos o con las barras del navegador (375×553, 360×640): se aprieta la portada. */
@media (orientation: portrait) and (max-height: 700px) {
  .portada-in { gap: 8px; } .lema { display: none; } .logo-a, .logo-b { font-size: 42px; }
  .menu-portada .btn { padding: 6px 8px; min-height: 44px; }
}
/* Apaisado bajo (667×375 a 932×430): barra fina arriba, tropas + Castillo + órdenes en una fila abajo, y hechizos y
   héroe en una columna a la derecha del campo (interfaz.md §11). */
@media (orientation: landscape) and (max-height: 500px) {
  .partida { grid-template: "top top" auto "campo lat" minmax(0, 1fr) "panel panel" auto / minmax(0, 1fr) auto; }
  .hud-lat { flex-direction: column; border-top: 0; border-left: 1px solid var(--borde); padding: 3px calc(4px + var(--sa-r)) 3px 4px; gap: 4px; }
  .hud-lat .hechizos { flex-direction: column; }
  .hud-panel { flex-wrap: nowrap; padding-right: calc(6px + var(--sa-r)); }
  .hud-top { gap: 8px; padding-top: calc(2px + var(--sa-t)); padding-bottom: 2px; min-height: 44px; }
  .bar b, .oro-in { display: none; }
  .hud-top .bar { flex: 1 1 70px; }
  .oro-col { min-width: 56px; }
  .hud-panel { padding-top: 3px; padding-bottom: calc(3px + var(--sa-b)); gap: 4px 8px; }
  .tropa { width: 52px; height: 52px; } .tropa .retrato { width: 30px; height: 28px; }
  .accion { height: 48px; min-width: 52px; } .accion .a-ico { display: none; }
  .orden { height: 46px; min-width: 46px; } .orden .o-t { display: none; } .orden .o-ico { font-size: 17px; }
  .hech { --d: 44px; min-width: 46px; } .hech .h-n { display: none; }
  .heroe-ret small { display: none; } .heroe-ret { top: 14px; }
  .bandeja { max-height: calc(100% - 8px); bottom: 4px; }
  .modal { --pad: 12px; }
  .modal h2 { font-size: 20px; } .conds li { padding: 3px 10px; }
  .res-t { font-size: 26px !important; } .est { font-size: 30px; }
  .logo-a, .logo-b { font-size: 36px; }
  .lema, .marca-ngv { display: none; }
  .portada-in { gap: 6px; padding-top: calc(6px + var(--sa-t)); padding-bottom: calc(4px + var(--sa-b)); }
  .portada .btn.grande { min-height: 48px; padding: 8px 20px; }
  .menu-portada { grid-template-columns: repeat(4, minmax(0, 1fr)); width: min(640px, 100%); gap: 6px; }
  .menu-portada .btn { padding: 6px; min-height: 44px; }
}
@media (orientation: landscape) and (max-height: 400px) {
  .fila-tropas, .tropas, .hechizos { gap: 4px; }
  .partida .modal p { margin: 3px 0; }
  .cartas { gap: 4px; } .carta { padding: 5px; }
}
@media (min-width: 1100px) and (min-height: 600px) { .tropa { width: 66px; height: 70px; } .tropa .retrato { width: 48px; height: 42px; } }
/* Pantallas grandes: el HUD crece con la pantalla (en 1920×1080 se veía diminuto). */
@media (min-width: 1500px) and (min-height: 850px) { .hud-top, .hud-panel, .hud-lat, .bandeja, .heroe-ret, .cola, .buff { zoom: 1.35; } }
/* «Gira el móvil» (interfaz.md §11): tapa la batalla de pie, con la partida en pausa; al girar, cuenta atrás 3-2-1. */
.girar { position: absolute; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center;
  padding: calc(16px + var(--sa-t)) calc(24px + var(--sa-r)) calc(16px + var(--sa-b)) calc(24px + var(--sa-l)); background: radial-gradient(ellipse at 50% 40%, #2A2440, var(--bg) 70%); }
.girar b { font-size: 28px; font-weight: 900; color: var(--oro); text-shadow: 0 3px 0 rgba(0, 0, 0, .5); }
.girar p { margin: 0; max-width: 300px; color: var(--sub); font-weight: 600; }
.girar-ilu { width: 160px; height: 160px; }
.girar-movil { transform-origin: 80px 80px; animation: girar 2.6s cubic-bezier(.6, 0, .3, 1) infinite; }
.girar-flecha { animation: aparece 2.6s infinite alternate; }
.cuenta-giro { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); z-index: 7; pointer-events: none; font: 900 72px/1 system-ui; color: var(--oro);
  text-shadow: 0 4px 0 rgba(0, 0, 0, .55), 0 0 30px rgba(255, 210, 63, .5); animation: golpe .45s cubic-bezier(.2, 1.6, .5, 1); }
@keyframes girar { 0%, 22% { transform: rotate(0); } 55%, 88% { transform: rotate(-90deg); } 100% { transform: rotate(0); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

@keyframes late { 50% { transform: scale(1.05); } }
@keyframes peligro { to { box-shadow: 0 0 10px var(--malo); border-color: var(--malo); } }
@keyframes entra { from { opacity: 0; transform: translateY(10px) scale(.96); } }
@keyframes aparece { from { opacity: 0; } }
@keyframes golpe { from { transform: scale(2.2); opacity: 0; } }
@keyframes rebota { to { transform: translateY(6px); } }
@keyframes nope { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes flota { to { transform: translateY(-34px); opacity: 0; } }

/* ---------- v2: previa, Asalto, guía, medallas, marca NGV ---------- */
.marca-ngv { font: 800 12px/1 system-ui; letter-spacing: .12em; text-transform: uppercase; color: var(--sub); text-decoration: none; text-shadow: 0 1px 3px #000; }
.enemigo { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; color: #FFC9A8; background: rgba(232, 113, 26, .1); border: 1px solid rgba(232, 113, 26, .35); border-radius: 10px; padding: 8px 10px; margin: 6px 0; }
.enemigo b { color: #fff; } .jefe-txt { color: #FFB0B0; }
.novedades { margin: 4px 0; padding-left: 18px; color: var(--ok); font-weight: 700; font-size: 14px; }
.fila.col { flex-direction: column; align-items: stretch; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--borde); background: #262A3C; border-radius: 99px; padding: 4px 12px 4px 6px; font-weight: 700; font-size: 14px; }
.chip.on { border-color: #B9A6FF; background: #3A2F66; }
.chip small { color: #C9B6FF; font-size: 12px; }
.medalla { position: absolute; bottom: 10px; right: 10px; width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(0,0,0,.4); }
.m-bronce { background: #CD7F32; } .m-plata { background: #D9D9E0; } .m-oro { background: var(--oro); }
.ejercito { display: grid; gap: 6px; margin: 8px 0; }
.ej-fila { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ej-fila .retrato { width: 40px; height: 40px; flex: none; }
.ej-fila .seg button { flex: none; min-width: 44px; padding: 8px 6px; }
.ej-n { flex: 1; min-width: 110px; display: flex; flex-direction: column; } .ej-n small { color: var(--sub); font-size: 12px; }
.guia { display: flex; flex-direction: column; overflow: auto; padding: calc(8px + var(--sa-t)) calc(12px + var(--sa-r)) calc(16px + var(--sa-b)) calc(12px + var(--sa-l)); background: var(--bg); }
.fichas { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.ficha { display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center; border: 1px solid var(--borde); background: rgba(255,255,255,.05); border-radius: 14px; padding: 10px; }
.ficha.leida { border-color: rgba(201, 167, 255, .5); }
.ficha .retrato.grande { width: 72px; height: 72px; }
.ficha small { font-size: 12px; color: var(--sub); } .f-stats { font-size: 12px; color: var(--oro); } .f-rasgo { color: #CFE !important; }
.heroe-guia { color: var(--sub); font-size: 14px; }
.consejo { background: rgba(255, 210, 63, .1); border: 1px solid rgba(255, 210, 63, .35); border-radius: 10px; padding: 8px 10px; font-weight: 700; font-size: 14px; }
.datos b.malo { color: var(--malo); }
.pips i.techo { outline: 1px dashed rgba(255,255,255,.3); }
.techo-txt { color: #FFC9A8 !important; }
.tab.bloq { opacity: .55; }
.cargando { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); z-index: 7; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 18px; border-radius: 14px; background: rgba(10, 12, 20, .85); border: 1px solid var(--borde); font-weight: 800; }
.cargando b { display: block; width: 180px; height: 8px; border-radius: 4px; background: rgba(255,255,255,.12); overflow: hidden; }
.cargando b i { display: block; height: 100%; background: var(--oro); transform-origin: left; transform: scaleX(0); transition: transform .2s; }
.seg { flex: none; } .seg button { min-height: 44px; }
.tab { border: 1px solid var(--borde); background: #262A3C; border-radius: 9px; padding: 8px 10px; min-height: 44px; font-weight: 700; font-size: 14px; }
.tab.on { background: var(--oro); color: #2A1A00; border-color: var(--oro); }
