/* Fichas D&D en el formato de la app de Kael: pantalla 16:9 (base 640x360), estilo GBA retro con marcos dorados.
   Todo se mide en píxeles de esa base y se escala entero con el tamaño de la ventana. */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { font-size: 8px; -webkit-text-size-adjust: 100%; }
html, body { width: 100%; height: 100%; background: #000; overflow: hidden; overscroll-behavior: none; touch-action: manipulation; }
:root { --oro: #d8bd6e; --tinta: #2a2018; --papel: #f4ecd0; --papel2: #e9dfb8; --linea: #b8aa80; --marron: #7a4a10; --verde: #4dff7a; --rojo: #b83a3a; --azul: #2a78c8; --panel: #16342a; --suave: #6a5a3a; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; text-align: inherit; }
canvas { image-rendering: pixelated; }
a { color: #1f5a9a; }

#marco { position: absolute; left: 0; top: 0; width: 640px; height: 360px; transform-origin: 0 0; }
#app { position: relative; width: 640px; height: 360px; overflow: hidden; font-family: 'Press Start 2P', monospace; font-size: 8px; color: var(--tinta); line-height: 1.5; background: var(--panel); image-rendering: pixelated; }
#seguro { position: fixed; left: 0; top: 0; width: 0; height: 0; visibility: hidden; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
#girar { display: none; position: fixed; inset: 0; z-index: 99; background: #16342a; color: var(--papel); font-family: 'Press Start 2P', monospace; font-size: 12px; text-align: center; padding: 30px; align-items: center; justify-content: center; line-height: 2; }
#girar { display: none !important; }      /* ya no hace falta girar el móvil: hay versión vertical */
.cargando { text-align: center; padding: 140px 20px; color: var(--papel); }
.salto { position: absolute; left: -999px; }
:focus-visible { outline: 3px solid #e04838; outline-offset: -3px; }

/* marcos dorados */
.caja, .tarjeta, .modal { background: var(--papel); border: 3px solid var(--tinta); border-radius: 3px; position: relative; box-shadow: inset 0 0 0 2px var(--oro), inset 0 0 0 3px var(--tinta); }
.caja::before, .caja::after, .tarjeta::before, .tarjeta::after, .modal::before, .modal::after { content: ''; position: absolute; width: 5px; height: 5px; background: var(--oro); border: 1px solid var(--tinta); pointer-events: none; z-index: 2; }
.caja::before, .tarjeta::before, .modal::before { top: -4px; left: -4px; } .caja::after, .tarjeta::after, .modal::after { bottom: -4px; right: -4px; }

/* ---------- pantalla principal (el personaje) ---------- */
.principal { position: absolute; inset: 0; display: grid; grid-template-columns: 84px minmax(0, 1fr) 172px; grid-template-rows: 34px minmax(0, 1fr) 62px; gap: 4px; padding: 4px; background: #16342a; }
.principal > * { min-height: 0; min-width: 0; position: relative; z-index: 2; }
.sup { grid-column: 1 / 4; display: flex; gap: 6px; }
.sup .caja { display: flex; align-items: center; padding: 0 8px; white-space: nowrap; }
.sup .nombre { flex: 1; font-size: 9px; overflow: hidden; } .sup .nombre span { overflow: hidden; text-overflow: ellipsis; } .sup b { color: var(--marron); margin-left: 5px; }
.mas { background: var(--rojo); color: #fff; padding: 2px 5px; margin-left: 8px; border: 2px solid var(--tinta); }
.izq { display: flex; flex-direction: column; gap: 6px; padding-top: 2px; }
.attr { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; width: 100%; line-height: 1.25; }
.attr > button { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; height: 100%; padding-top: 5px; padding-bottom: 1px; gap: 2px; }
.attr small { font-size: 7px; } .attr b { font-size: 12px; }
.escena { position: relative; }
.plataforma { position: absolute; left: 50%; bottom: 2px; width: 250px; height: 40px; transform: translateX(-50%); border-radius: 50%; background: #dcebe6; border: 4px solid #a8c4be; box-shadow: 0 5px 0 #7fa39b; }
.escena.mar .plataforma { background: #3f8fb0; border-color: #7cc7dc; box-shadow: 0 5px 0 #2a6a88; }
.escena.cielo .plataforma { background: #f2f7fb; border-color: #c4dcec; box-shadow: 0 5px 0 #98b8cc; }
.heroe { position: absolute; left: 50%; transform: translateX(-50%); bottom: 14px; }
.heroe canvas { display: block; }
.etiqueta-forma { position: absolute; z-index: 4; left: 6px; top: 4px; background: var(--panel); color: var(--papel); border: 2px solid var(--oro); padding: 5px 8px; }
.der { display: flex; flex-direction: column; gap: 6px; }
.menu { flex: 1; min-height: 0; padding: 8px 6px; display: flex; flex-direction: column; }
.menu h3 { font-size: 8px; margin: 0 0 6px 4px; color: var(--marron); }
.menu ul { list-style: none; flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: none; }
.menu li button { display: block; width: 100%; padding: 5px 4px 5px 16px; position: relative; white-space: nowrap; }
html:not([lang="es"]):not([lang="en"]) .menu li button { white-space: normal; line-height: 1.15; }   /* alemán, francés, italiano… son más largos: el rótulo baja de línea en vez de cortarse */
.menu li.sel button, .menu li button:hover { background: var(--oro); } .menu li.sel button::before { content: '▶'; position: absolute; left: 3px; color: var(--rojo); }
.acciones { display: flex; gap: 6px; height: 34px; flex: none; }
.acciones .caja { flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; line-height: 1.4; font-size: 6px; padding: 0 2px; }
.acciones .caja > button { width: 100%; height: 100%; text-align: center; }
.acciones .grande { flex: 1.7; font-size: 7px; }
.caja.verde { background: #7ee89c; } .caja.rojo { background: #f0b0a0; }
.estado { grid-column: 1 / 3; padding: 5px 10px; display: grid; grid-template-rows: 1fr 1fr 1fr; row-gap: 2px; align-items: center; }
.fila { display: flex; align-items: center; gap: 10px; }
.pgtxt { color: #d86a10; } .barra { flex: 1; height: 9px; background: #7a746a; border: 2px solid var(--tinta); } .barra i { display: block; height: 100%; background: repeating-linear-gradient(90deg, #40d060 0 6px, #30b050 6px 8px); }
.barra.baja i { background: repeating-linear-gradient(90deg, #e05040 0 6px, #c04030 6px 8px); }
.barra i.temp { background: repeating-linear-gradient(90deg, #58a8f0 0 6px, #4890d8 6px 8px); } .barra.corta { flex: none; width: 60px; }
.datos { display: flex; justify-content: space-between; } .datos button { display: flex; gap: 5px; } .datos small { opacity: .7; }
.dot { display: inline-block; width: 7px; height: 7px; border: 2px solid var(--tinta); margin-left: 2px; } .dot.ok { background: #40c060; } .dot.ko { background: #d84838; }
.insp { color: #b07a10; margin-left: auto; } .insp.apagada { opacity: .35; }

/* ---------- pantallas con ventana: lista, creador, reglas, pestañas de la ficha ---------- */
.panel { position: absolute; inset: 0; background: var(--panel); padding: 6px; display: flex; flex-direction: column; gap: 5px; }
.panel-cab { display: flex; gap: 6px; height: 28px; flex: none; }
.panel-cab .titulo { flex: 1; display: flex; align-items: center; padding: 0 10px; font-size: 9px; white-space: nowrap; overflow: hidden; }
.panel-cab .btn-cab { padding: 0 10px; display: flex; align-items: center; justify-content: center; font-size: 8px; text-align: center; }
.panel-cab .btn-cab:hover { background: var(--oro); }
.pestanas { display: flex; gap: 4px; flex: none; flex-wrap: wrap; }
.pestanas a { flex: 1; padding: 5px 2px; background: #cdbf98; border: 3px solid var(--tinta); text-align: center; font-size: 8.5px; color: var(--tinta); text-decoration: none; white-space: nowrap; }
.pestanas a.activo { background: var(--oro); }
.contenido { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 8px 10px; line-height: 1.7; scrollbar-width: thin; scrollbar-color: var(--marron) var(--papel2); overflow-wrap: anywhere; }
.contenido::-webkit-scrollbar, .modal::-webkit-scrollbar { width: 6px; } .contenido::-webkit-scrollbar-thumb, .modal::-webkit-scrollbar-thumb { background: var(--marron); }
.pie { flex: none; color: #9fb8a8; font-size: 6.5px; line-height: 1.35; text-align: center; padding: 0 4px; } .pie a { color: #d8e8b0; }
.pie select.idioma { width: auto; max-width: 120px; min-height: 24px; font: inherit; font-size: 7px; color: #d8e8b0; background: rgba(22, 52, 42, .85); border: 2px solid #7d9d8a; border-radius: 3px; padding: 1px 4px; cursor: pointer; }

h1, h2, h3, h4, h5, h6 { font-weight: normal; line-height: 1.4; }
h1 { font-size: 10px; color: var(--marron); margin-bottom: 6px; } h2 { font-size: 9px; color: var(--marron); margin: 0 0 6px; } h3 { font-size: 8px; color: var(--marron); margin: 0 0 5px; } h4 { font-size: 8px; color: var(--marron); margin: 6px 0 4px; }
.contenido > div > h1:first-child, .contenido h2:first-child { margin-top: 0; }
p { margin: 3px 0; }
.suave { color: var(--suave); font-size: 7px; line-height: 1.7; }
label { display: block; font-size: 7px; color: var(--marron); margin: 7px 0 3px; }
.clave { color: #a02010; font-weight: bold; text-shadow: .5px 0 0 currentColor; }

/* botones y campos */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 6px 9px; background: var(--papel2); border: 3px solid var(--tinta); box-shadow: inset 0 0 0 2px var(--oro); text-align: center; text-decoration: none; color: var(--tinta); font-size: 7px; line-height: 1.4; min-height: 0; }
.btn:hover { background: #f0e6c0; }
.btn.verde { background: #7ee89c; } .btn.rojo { background: #f0b0a0; } .btn.chico { padding: 4px 6px; font-size: 6px; } .btn.mini { padding: 2px 5px; font-size: 7px; min-width: 0; }
.btn[disabled], .btn-cab[disabled] { opacity: .45; cursor: not-allowed; }
.botones { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
input[type=text], input[type=number], input[type=password], input[type=email], select, textarea { width: 100%; background: #fff8e0; border: 2px solid var(--tinta); padding: 4px 6px; font-size: 8px; max-width: 100%; border-radius: 0; }
textarea { min-height: 60px; resize: vertical; line-height: 1.6; }
input[type=checkbox] { width: 12px !important; height: 12px !important; accent-color: var(--marron); flex: none; }
@media (pointer: coarse) { input[type=text], input[type=number], input[type=password], input[type=email], select, textarea { font-size: 16px; } }
.fila-pg { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; } .fila-pg input { width: 44px; text-align: center; }
.etq { display: inline-block; padding: 1px 4px; background: #cdbf98; border: 2px solid var(--tinta); font-size: 6px; }
.etq.oro { background: var(--oro); } .etq.roja { background: #f0b0a0; } .etq.verde { background: #7ee89c; }
.aviso-caja { border-left: 4px solid var(--oro); background: #f4ecc8; padding: 4px 8px; margin: 6px 0; font-size: 7px; line-height: 1.7; }

/* tarjetas */
.tarjeta { padding: 8px 10px; margin: 0 0 9px; }
.tarjeta > h3:first-child, .tarjeta > h2:first-child { margin-top: 0; }
.rejilla { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.lista-pj { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin: 8px 0; }
.pj { text-align: left; display: block; width: 100%; cursor: pointer; text-decoration: none; color: inherit; } .pj h3 { margin: 0 0 2px; } .pj .suave { margin: 0; }
.pj:hover { background: #f4e8b8; }
.hero { text-align: center; padding: 4px 0; } .hero p { margin: 4px auto; }
.hero h1 { font-size: 12px; }

/* ficha: cifras y bloques */
.cabecera-pj { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-bottom: 5px; } .cabecera-pj h1 { margin: 0; }
.vida { display: grid; grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); gap: 5px; }
.cifra { text-align: center; background: var(--papel2); border: 2px solid var(--tinta); padding: 4px 2px; font-family: inherit; }
.cifra b { display: block; font-size: 11px; line-height: 1.3; font-weight: normal; } .cifra span { font-size: 6px; text-transform: uppercase; color: var(--marron); }
.cifra.grande b { font-size: 13px; }
button.cifra:hover { background: var(--oro); }
.barra-pg { height: 9px; background: #7a746a; border: 2px solid var(--tinta); margin: 5px 0; } .barra-pg i { display: block; height: 100%; background: repeating-linear-gradient(90deg, #40d060 0 6px, #30b050 6px 8px); }
.barra-pg.bajo i { background: repeating-linear-gradient(90deg, #e05040 0 6px, #c04030 6px 8px); }
.atributos { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.atributo { text-align: center; background: var(--papel2); border: 2px solid var(--tinta); padding: 4px 1px; cursor: pointer; font-family: inherit; }
.atributo:hover { background: var(--oro); } .atributo small { display: block; font-size: 5px; text-transform: uppercase; color: var(--marron); }
.atributo .m { display: block; font-size: 12px; line-height: 1.3; } .atributo .v { display: inline-block; border: 2px solid var(--tinta); background: var(--papel); padding: 0 4px; font-size: 6px; }
.dos-col { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; }
.filas > div { display: flex; align-items: center; gap: 5px; padding: 2px 0; border-bottom: 1px dashed var(--linea); font-size: 7px; }
.filas > div:last-child { border-bottom: 0; } .filas .nombre { flex: 1; } .filas .bono { min-width: 20px; text-align: right; color: var(--marron); }
.punto { width: 12px; height: 12px; border: 2px solid var(--tinta); background: transparent; padding: 0; flex: none; position: relative; } .punto::after { content: ''; position: absolute; inset: -7px; }
.punto.on { background: var(--oro); } .punto.doble { background: var(--rojo); }
.tirar { cursor: pointer; background: none; border: 0; text-align: left; padding: 0; font: inherit; color: inherit; } .tirar:hover .nombre { background: var(--oro); }
.espacios { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 3px 0 6px; }
.pastilla { width: 12px; height: 12px; border: 2px solid var(--tinta); background: var(--azul); padding: 0; } .pastilla.gastado { background: transparent; }
.pastilla.verde { background: #43a65d; } .pastilla.verde.gastado { background: transparent; }
.fila-espacio { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; border-bottom: 1px dashed var(--linea); padding: 3px 0; } .fila-espacio strong { min-width: 70px; font-weight: normal; color: var(--marron); }
.conjuro { display: flex; align-items: center; gap: 6px; padding: 4px 2px; border-bottom: 1px dashed var(--linea); }
.conjuro .nombre { flex: 1; text-align: left; background: none; border: 0; cursor: pointer; padding: 2px 0; font: inherit; color: inherit; }
.conjuro .nombre:hover { background: var(--oro); }
.conjuro .sub { display: block; font-size: 6px; color: var(--suave); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; } .chip { border: 3px solid var(--tinta); background: #cdbf98; padding: 4px 6px; font-size: 7px; cursor: pointer; } .chip.on { background: var(--oro); } .chip[disabled] { pointer-events: none; opacity: .4; }
details.rasgo { border-left: 4px solid var(--oro); background: #f4ecc8; margin: 4px 0 8px; } details.rasgo > summary { cursor: pointer; padding: 4px 8px; list-style: none; display: flex; gap: 6px; align-items: center; }
details.rasgo > summary::-webkit-details-marker { display: none; } details.rasgo > summary::before { content: '▸'; color: var(--rojo); } details.rasgo[open] > summary::before { content: '▾'; }
details.rasgo > div { padding: 0 8px 6px; }
.nivel-tag { background: var(--oro); border: 2px solid var(--tinta); font-size: 6px; padding: 0 3px; }

/* texto de reglas */
.reglas p { margin: 0 0 8px; } .reglas h5.opcion { font-size: 7px; color: var(--marron); margin: 10px 0 4px; padding: 3px 5px; background: #e6d9a0; border-left: 4px solid var(--oro); }
.reglas h6 { font-size: 6px; color: var(--marron); margin: 8px 0 3px; text-transform: uppercase; }
.reglas ul, .perfil ul { list-style: none; margin: 2px 0 9px; } .reglas li, .perfil li { position: relative; padding-left: 12px; margin-bottom: 6px; }
.reglas li::before, .perfil li::before { content: '◆'; position: absolute; left: 0; color: #a02010; font-size: 6px; }
.superior { border-left: 4px solid var(--oro); background: #f4ecc8; padding: 4px 8px; margin: 6px 0 9px; } .superior h5 { font-size: 6px; color: var(--marron); margin-bottom: 4px; } .superior p { margin: 0; }
.ficha-datos { border: 2px solid var(--tinta); background: #f4ecc8; margin: 6px 0 8px; }
.dato { display: flex; gap: 8px; padding: 4px 6px; border-bottom: 1px dashed var(--linea); align-items: baseline; } .dato:last-child { border-bottom: 0; }
.dato-n { flex: none; width: 92px; font-size: 6px; color: var(--marron); }
.tabla { margin: 8px 0 12px; } .tabla h5 { font-size: 7px; color: var(--marron); margin-bottom: 3px; }
.tabla-scroll { overflow-x: auto; } .tabla table { border-collapse: collapse; width: 100%; background: #f4ecc8; border: 2px solid var(--tinta); }
.tabla th { font-size: 6px; text-align: left; padding: 3px 5px; background: #d8c98e; color: #5a3a08; font-weight: normal; } .tabla td { padding: 3px 5px; border-top: 1px dashed var(--linea); vertical-align: top; } .tabla td.num { white-space: nowrap; color: var(--marron); }
.perfil { border: 3px solid var(--tinta); background: #f7f0d6; padding: 6px 8px 4px; margin: 10px 0 8px; box-shadow: inset 0 0 0 2px var(--oro); }
.perfil > h5 { font-size: 8px; color: #a02010; } .perfil-tipo { color: var(--marron); margin-bottom: 4px; }
.perfil-car { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 4px 0 6px; } .perfil-car > div { display: flex; flex-direction: column; align-items: center; padding: 3px 2px; background: #f4ecc8; border: 2px solid var(--tinta); line-height: 1.5; }
.perfil-car b { font-size: 6px; color: var(--marron); font-weight: normal; } .perfil-car .val { font-size: 11px; } .perfil-car small { font-size: 5px; color: #5a4a30; }
.perfil h5.grupo, h5.grupo { font-size: 6px; color: var(--marron); margin: 8px 0 4px; padding: 3px 4px; background: #d8c98e; border-left: 4px solid var(--oro); }
.rasgo { border-left: 4px solid var(--oro); background: #f4ecc8; padding: 4px 8px; margin: 4px 0 10px; } .rasgo h5 { font-size: 7px; color: var(--marron); margin-bottom: 4px; } .rasgo p { margin: 0; }
.caja-regla { border: 3px solid var(--tinta); background: #f4ecc8; padding: 5px 8px; margin: 8px 0; box-shadow: inset 0 0 0 2px var(--oro); } .caja-regla h5 { font-size: 7px; color: var(--marron); margin-bottom: 3px; } .caja-regla p { margin: 0; }

/* ventanas emergentes y avisos */
.modal-fondo { position: absolute; inset: 0; z-index: 40; background: rgba(0, 0, 0, .62); display: flex; align-items: center; justify-content: center; font-family: 'Press Start 2P', monospace; font-size: 8px; color: var(--tinta); }
.modal { width: 100%; padding: 10px 12px; max-height: 340px; overflow-y: auto; overflow-x: hidden; line-height: 1.8; overflow-wrap: anywhere; scrollbar-width: thin; scrollbar-color: var(--marron) var(--papel2); }
.modal .cerrar { position: sticky; float: right; top: 0; z-index: 3; width: 18px; height: 18px; background: var(--rojo); color: #fff; border: 2px solid var(--tinta); text-align: center; line-height: 14px; font-size: 10px; margin: 0 0 4px 6px; }
.modal h2 { color: var(--marron); } .modal .sub { color: var(--marron); margin-bottom: 6px; }
.toast-zona { position: absolute; left: 8px; right: 8px; bottom: 70px; z-index: 60; display: flex; flex-direction: column; gap: 3px; pointer-events: none; align-items: flex-start; }
.toast { background: var(--panel); color: var(--papel); border: 2px solid var(--oro); padding: 5px 8px; font-family: 'Press Start 2P', monospace; font-size: 7px; line-height: 1.6; max-width: 520px; }
.toast.aviso { background: #6a4a10; border-color: #f0c040; }
.tirada { font-size: 9px; } .tirada b { font-size: 11px; }
.pasos { display: flex; gap: 3px; margin: 0 0 8px; flex-wrap: nowrap; } .pasos span { flex: 1; min-width: 0; text-align: center; font-size: 5px; padding: 4px 0; overflow: hidden; background: #cdbf98; border: 2px solid var(--tinta); white-space: nowrap; } .pasos span.activo { background: var(--oro); } .pasos span.hecho { background: #7ee89c; }
.opcion-carta { text-align: left; width: 100%; cursor: pointer; background: var(--papel2); border: 3px solid var(--tinta); padding: 5px 7px; } .opcion-carta:hover { background: #f4e8b8; } .opcion-carta.sel { background: var(--oro); box-shadow: inset 0 0 0 2px #fff8d0; }
.opcion-carta b { display: block; font-weight: normal; } .opcion-carta span { font-size: 6px; color: var(--suave); display: block; }
.compra { display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); gap: 5px; } .compra > div { background: var(--papel2); border: 2px solid var(--tinta); padding: 4px; text-align: center; } .compra b { display: block; font-size: 11px; font-weight: normal; }
.buscador { display: grid; gap: 4px; grid-template-columns: 2fr 1fr 1fr 1fr; margin-bottom: 6px; }
.legal p { max-width: none; } blockquote.atrib { margin: 8px 0; padding: 5px 8px; border-left: 4px solid var(--oro); background: #f4ecc8; font-size: 7px; line-height: 1.7; }
.teclado { display: grid; grid-template-columns: repeat(3, 44px); gap: 4px; margin: 6px 0; } .teclado button { height: 26px; background: var(--papel2); border: 3px solid var(--tinta); text-align: center; }
.pantallita { background: #1c2b25; color: #7cff5a; border: 3px solid var(--tinta); padding: 6px 8px; margin-bottom: 4px; text-align: right; font-size: 12px; min-height: 26px; }

/* formas salvajes: todo en verde */
.tarjeta.forma { background: linear-gradient(180deg, #d9f3dd, var(--papel) 75%); } .tarjeta.forma.activa { box-shadow: inset 0 0 0 2px #43a65d, inset 0 0 0 3px var(--tinta), 0 0 0 2px #43a65d; }
.tarjeta.forma h3 { color: #2f7d45; } .bestia-arte { display: inline-block; line-height: 0; } .bestia-arte svg { max-width: 100%; height: auto; }
.rejilla-formas { display: grid; gap: 5px; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); margin: 6px 0; }
.forma-carta { display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center; background: var(--papel2); border: 3px solid #43a65d; padding: 4px; font-size: 6px; }
.forma-arte { background: none; border: 0; padding: 0; cursor: pointer; text-align: center; } .forma-arte svg { width: 70px; height: auto; }
.banner-forma { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: #d9f3dd; border: 3px solid #2f7d45; padding: 3px 7px; margin: 0 0 6px; color: #123d22; font-size: 7px; }
.banner-forma .bestia-arte svg { width: 40px; height: auto; } .banner-forma .btn { margin-left: auto; }
.forma-perfil > h5 { color: #2f7d45; }
.retrato { display: inline-block; line-height: 0; } .retrato svg { width: 32px; height: auto; }
.aspecto { display: grid; gap: 8px; grid-template-columns: 170px 1fr; align-items: start; }
.aspecto-vista { text-align: center; position: sticky; top: 0; } .aspecto-vista svg { width: 110px; height: auto; max-width: 100%; }
.muestras { display: flex; flex-wrap: wrap; gap: 4px; } .muestra { width: 16px; height: 16px; border: 2px solid var(--tinta); cursor: pointer; padding: 0; } .muestra.on { box-shadow: 0 0 0 2px var(--oro), 0 0 0 4px var(--tinta); }
.sprite-vista canvas { display: block; margin: 0 auto; }
.subir { cursor: pointer; }
@media print { .panel-cab, .pestanas, .botones, .toast-zona, .pie { display: none !important; } }

/* tarjetas dentro de una ventana: marco sencillo para no apilar marcos dorados */
.contenido .tarjeta { border-width: 2px; box-shadow: none; background: #f8f1d8; } .contenido .tarjeta::before, .contenido .tarjeta::after { display: none; }
.contenido .tarjeta.forma { background: linear-gradient(180deg, #d9f3dd, #f8f1d8 75%); } .contenido .tarjeta.forma.activa { box-shadow: 0 0 0 2px #43a65d; }
.contenido .pasos { position: sticky; top: -8px; z-index: 5; background: var(--papel); padding: 6px 0 4px; margin-top: -8px; }
.menu li.bloq { opacity: .5; } .menu ul { scrollbar-width: thin; scrollbar-color: var(--marron) var(--papel2); }
.conjuro.prep { background: #efe3b0; }

/* menú de creación del aspecto: cada pieza con flechas */
.ciclo { display: grid; grid-template-columns: 78px 22px 1fr 22px; gap: 4px; align-items: center; margin: 4px 0; }
.ciclo-t { font-size: 7px; color: var(--marron); } .ciclo-v { text-align: center; background: #fff8e0; border: 2px solid var(--tinta); padding: 3px 2px; font-size: 7px; }
.ciclo .btn.mini { padding: 3px 0; width: 28px; min-height: 26px; }
.muestras-fila { grid-template-columns: 78px 1fr; } .muestra { width: 18px; height: 18px; }

/* portada */
.portada { text-align: center; padding: 14px 6px; } .portada-titulo .logo-titulo { display: block; margin: 0 auto; width: min(100%, 440px); height: auto; image-rendering: pixelated; }
.portada-titulo h1 { font-size: 26px; color: var(--marron); letter-spacing: 4px; margin: 6px 0 4px; text-shadow: 2px 2px 0 var(--oro); }
.portada-botones { justify-content: center; margin: 14px 0; } .btn.grande { padding: 10px 16px; font-size: 9px; }
.enlace { background: none; border: 0; color: #1f5a9a; text-decoration: underline; font: inherit; cursor: pointer; text-align: center; }

/* panel de administrador */
.barras { display: flex; gap: 4px; align-items: flex-end; height: 92px; } .barra-dia { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 2px; min-width: 0; }
.barra-dia i { display: block; width: 100%; background: var(--oro); border: 2px solid var(--tinta); min-height: 2px; } .barra-dia small { font-size: 5px; color: var(--suave); } .barra-dia b { font-size: 7px; font-weight: normal; }

/* Recursos de clase y especie, modos activos y auras */
.recursos { display: flex; flex-direction: column; gap: 6px; }
.recurso { border: 3px solid var(--linea); background: var(--papel2); padding: 6px 8px; } .recurso.activo { border-color: var(--rojo); background: #f4d9cc; }
.recurso-cab { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.pips { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; } .pip { width: 14px; height: 14px; border: 3px solid var(--tinta); background: transparent; padding: 0; cursor: pointer; } .pip.on { background: var(--oro); }
.reserva { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; } .cifra-recurso { font-size: 11px; } .pequeno { font-size: 6px; }
.banner-modos { margin: 0 0 6px; } .banner-modo { border: 3px solid var(--rojo); background: #f4d9cc; padding: 4px 7px; margin-bottom: 4px; font-size: 7px; color: #4a1410; } .banner-modo ul { margin: 3px 0 4px 12px; padding: 0; }
.etiqueta-modo { position: absolute; z-index: 4; right: 6px; top: 4px; background: var(--rojo); color: #fff; border: 2px solid var(--oro); padding: 5px 8px; }
.heroe[class*="aura-"] canvas { animation: aura-pulso 1.1s ease-in-out infinite alternate; }
.heroe.aura-furia canvas { --a1: #ff2a1a; --a2: #d40000; } .heroe.aura-innata canvas { --a1: #c58bff; --a2: #7a2cff; } .heroe.aura-marca canvas { --a1: #7dff9a; --a2: #19b34a; }
.heroe.aura-alas canvas { --a1: #9fe6ff; --a2: #3aa7ff; } .heroe.aura-grande canvas { --a1: #ffe07a; --a2: #d8a21a; transform: scale(1.18); transform-origin: 50% 100%; }
@keyframes aura-pulso { from { filter: drop-shadow(0 0 3px var(--a1)) drop-shadow(0 0 8px var(--a2)); } to { filter: drop-shadow(0 0 7px var(--a1)) drop-shadow(0 0 16px var(--a2)) brightness(1.08); } }
@media (prefers-reduced-motion: reduce) { .heroe[class*="aura-"] canvas { animation: none; filter: drop-shadow(0 0 6px var(--a1)); } }

.btn.marca { background: var(--oro); } .opcion-carta.sin-requisito { opacity: .85; border-style: dashed; }

/* Arte de IA de las bestias */
img.fondo-ia { position: absolute; left: 0; top: 0; width: 640px; height: 360px; z-index: 0; object-fit: cover; }
.escena.arte .plataforma { background: rgba(0, 0, 0, .22); border: 0; box-shadow: none; height: 26px; width: 220px; }
img.bestia-sprite { display: block; object-fit: contain; object-position: 50% 100%; image-rendering: pixelated; }
.bestia-arte img.bestia-sprite { max-width: 100%; }
.heroe img.bestia-sprite { margin: 0 auto; }

/* Selector de escenario: flechitas y candado, casi invisibles hasta que se tocan */
.sel-escena { position: absolute; top: 4px; left: 50%; transform: translateX(-50%); z-index: 5; display: flex; gap: 4px; align-items: center; opacity: .5; transition: opacity .15s; }
.sel-escena:hover, .sel-escena:focus-within { opacity: 1; }
.sel-escena button { width: 22px; height: 22px; padding: 0; line-height: 20px; font-size: 11px; background: rgba(22, 52, 42, .72); color: var(--papel); border: 1px solid var(--oro); text-align: center; cursor: pointer; }
.sel-escena button[disabled] { opacity: .35; cursor: default; } .sel-escena .candado { font-size: 8px; } .sel-escena.fijo { opacity: .28; }
.lista-contenido-propio { list-style: none; margin: 4px 0 0; padding: 0; }
.lista-contenido-propio li { margin: 5px 0; }
.conjuro.elegido { background: #e6f1c8; border-radius: 3px; }

/* ---------- inicio: vitrina de héroes, botón principal grande, tarjetas con dibujo y «Más opciones» ---------- */
.vitrina { display: flex; justify-content: center; align-items: flex-end; gap: 4px; height: 92px; margin: -2px 0 4px; }
.vitrina img { height: 100%; width: auto; image-rendering: pixelated; filter: drop-shadow(0 3px 0 rgba(0,0,0,.25)); }
.btn.grande { font-size: 10px; padding: 8px 18px; }
.tarjeta.pj { display: flex; align-items: center; gap: 10px; }
.tarjeta.pj canvas { background: #dbeee6; border: 2px solid var(--tinta); border-radius: 3px; }
.tarjeta.pj > a > div { min-width: 0; }
details.mas-opciones { margin: 8px 0; } details.mas-opciones > summary { cursor: pointer; color: var(--suave); padding: 4px 0; }

/* ---------- telón de fondo del escenario del personaje detrás de las pantallas de la ficha ---------- */
.panel.con-fondo > * { position: relative; z-index: 1; }
.panel.con-fondo > .panel-fondo { position: absolute; z-index: 0; left: 0; top: 0; width: 100%; height: 100%; object-fit: cover; filter: brightness(.55) saturate(1.1); image-rendering: pixelated; pointer-events: none; }
.panel.con-fondo > .panel-fondo + .panel-cab { margin-top: 0; }

.escena-vista { position: relative; background-size: cover; background-position: center; border: 3px solid var(--tinta); border-radius: 3px; box-shadow: inset 0 0 0 2px var(--oro); display: flex; align-items: flex-end; justify-content: center; padding: 10px 4px 12px; align-self: flex-start; image-rendering: pixelated; }
.escena-vista canvas { position: relative; z-index: 1; }
.plataforma-mini { position: absolute; left: 50%; bottom: 6px; width: 70%; height: 22px; transform: translateX(-50%); border-radius: 50%; background: #dcebe6; border: 3px solid #a8c4be; box-shadow: 0 3px 0 #7fa39b; z-index: 0; }

/* ---------- arte de los monstruos y del DM ---------- */
.arte-criatura { image-rendering: pixelated; flex: none; }
.arte-criatura.centrada { display: block; margin: 0 auto 6px; }
.arte-criatura.dm-avatar { float: right; margin: -4px 0 4px 8px; filter: drop-shadow(0 3px 0 rgba(0,0,0,.25)); }
.conjuro > .arte-criatura { margin-right: 8px; width: 64px !important; object-fit: contain; }   /* ancho fijo: el texto de todas las filas empieza en el mismo sitio */


/* ---------- versión vertical (móvil en vertical): escenario de 360x640 ---------- */
body.vertical #marco, body.vertical #app { width: var(--wv, 360px); height: var(--hv, 640px); }
body.vertical img.fondo-ia { width: var(--wv, 360px); height: var(--hv, 640px); object-fit: cover; }
body.vertical .principal { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) clamp(150px, calc(var(--hv, 640px) * .3), 230px) auto; }
body.vertical .principal > .sup, body.vertical .principal > .izq, body.vertical .principal > .escena, body.vertical .principal > .der, body.vertical .principal > .estado { grid-column: 1; }
body.vertical .sup { grid-row: 1; } body.vertical .izq { grid-row: 2; flex-direction: row; padding-top: 0; gap: 4px; }
body.vertical .escena { grid-row: 3; } body.vertical .der { grid-row: 4; } body.vertical .estado { grid-row: 5; }
body.vertical .sup .caja { padding: 0 5px; } body.vertical .sup { gap: 4px; }
body.vertical .sup { flex-wrap: wrap; } body.vertical .sup .caja { min-height: 28px; } body.vertical .sup .nombre { flex: 1 1 100%; min-height: 32px; font-size: 9px; }
body.vertical .sup .caja:not(.nombre) { flex: 1 1 0; justify-content: center; font-size: 8px; }
body.vertical .estado { grid-template-rows: auto auto auto; row-gap: 6px; padding: 6px 8px; }
body.vertical .estado .datos { flex-wrap: wrap; justify-content: flex-start; gap: 4px 12px; } body.vertical .estado .fila { flex-wrap: wrap; row-gap: 4px; gap: 6px 10px; }
body.vertical .estado .insp { margin-left: auto; }
body.vertical .vida { grid-template-columns: repeat(3, minmax(0, 1fr)); } body.vertical .cifra span { word-break: normal; overflow-wrap: normal; hyphens: none; font-size: 5.5px; }
body.vertical .panel-cab .titulo { white-space: normal; line-height: 1.3; min-height: 32px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; overflow: hidden; }
body.vertical .titulo .t-sep { display: none; } body.vertical .titulo .t-n { font-size: 6px; color: var(--marron); } body.vertical .titulo .t-s { font-size: 8px; }
body.vertical .menu ul { display: grid; grid-template-columns: 1fr 1fr; align-content: start; }
body.vertical .menu li button { padding: 5px 2px 5px 14px; font-size: 7px; white-space: normal; }
body.vertical .atributos { grid-template-columns: repeat(3, 1fr); }
body.vertical .aspecto, body.vertical .dos-col { grid-template-columns: 1fr; }
body.vertical .buscador { grid-template-columns: 1fr 1fr; }
body.vertical .modal { max-width: calc(var(--wv, 360px) - 16px) !important; max-height: 570px; }
body.vertical .toast { max-width: calc(var(--wv, 360px) - 30px); }
body.vertical .toast-zona { bottom: 80px; }
body.vertical .panel-cab .titulo { font-size: 8px; } body.vertical .pestanas a { padding: 5px 1px; }
body.vertical .lista-pj, body.vertical .rejilla { grid-template-columns: 1fr 1fr; }
.bloqueadas { margin-top: 8px; } .bloqueadas summary { cursor: pointer; font-weight: bold; color: #7a6a4a; }
.fila-bloq { opacity: .75; border-top: 1px dashed #b9a97f; padding: 4px 0; } .fila-bloq p { margin: 2px 0; }

/* aviso de que el menú sigue hacia abajo (se desplaza con el dedo) */
body.vertical .menu { position: relative; } body.vertical .menu::after { content: '▼'; position: absolute; right: 6px; bottom: 4px; width: 14px; height: 12px; line-height: 12px; text-align: center; font-size: 8px; color: var(--marron); background: var(--papel); border: 2px solid var(--marron); pointer-events: none; animation: rebote 1.2s ease-in-out infinite alternate; }
@keyframes rebote { to { transform: translateY(2px); } } @media (prefers-reduced-motion: reduce) { body.vertical .menu::after { animation: none; } }
body.vertical .menu ul { padding-bottom: 8px; }

/* en el móvil pequeño el héroe se encoge para no pisar los marcadores de arriba */
body.vertical .escena .heroe { top: 8%; bottom: 2px; display: flex; align-items: flex-end; justify-content: center; } body.vertical .heroe canvas, body.vertical .heroe img { max-height: 100%; max-width: 100%; width: auto; height: auto; image-rendering: pixelated; }
body.vertical select { font-size: 8px; text-overflow: ellipsis; }

/* botón fijo para salir al menú de personajes (antes solo estaba al final del menú, oculto al desplazar) */
.sup .volver { flex: 0 0 auto; } .sup .volver button { font-size: 8px; color: inherit; white-space: nowrap; }
body.vertical .sup .caja.volver { flex: 0 0 auto; justify-content: center; min-height: 32px; } body.vertical .sup .caja.volver button { font-size: 7px; }
body.vertical .sup .nombre { flex: 1 1 calc(100% - 106px); min-width: 0; }

/* vertical: fondo propio en 9:16 (arte/fondos/<id>-v.webp, elegido con <picture> por la misma proporción que activa body.vertical) */
body.vertical img.fondo-ia { object-position: center bottom; }

/* selector de idioma: cuadradito con la bandera arriba y lista en una ventana */
.btn-cab .bandera { display: block; }
.idiomas-lista { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.idioma-op small.idioma-aviso { opacity: 1; color: var(--oro, #c9a227); }
/* vertical: una sola escala de letra (antes había 5, 6, 6,67, 7, 8, 9, 11 y 12 px mezclados y etiquetas en mayúsculas diminutas):
   etiquetas 7 px en minúscula normal, texto y botones 8 px, nombres 9 px, cifras grandes 12 px */
body.vertical .cifra span, body.vertical .atributo small, body.vertical .reglas h6 { font-size: 7px; text-transform: none; letter-spacing: 0; }
body.vertical .estado, body.vertical .estado small, body.vertical .estado b, body.vertical .estado button { font-size: 8px; }
body.vertical .acciones .grande, body.vertical .acciones .caja > button { font-size: 8px; }
body.vertical .titulo .t-n { font-size: 7px; } body.vertical .btn-cab { font-size: 8px; }
body.vertical .menu li button, body.vertical .sup .caja.volver button { font-size: 8px; }
body.vertical .panel-cab .titulo { font-size: 9px; } body.vertical .titulo .t-s { font-size: 9px; }
body.vertical .contenido, body.vertical .contenido p, body.vertical .contenido li, body.vertical .contenido .btn, body.vertical .contenido button { font-size: 8px; }
body.vertical .contenido h2, body.vertical .contenido h3, body.vertical .contenido h4 { font-size: 9px; }
body.vertical .panel-cab .titulo, body.vertical .panel-cab .titulo .t-s { font-size: 8px; } body.vertical .panel-cab .btn-cab { padding-left: 5px; padding-right: 5px; } body.vertical .panel-cab .titulo { min-width: 0; overflow-wrap: anywhere; overflow: visible; height: auto; padding-top: 2px; padding-bottom: 2px; }
body.vertical .cifra span { overflow-wrap: anywhere; }
body.vertical .panel-cab { height: auto; min-height: 34px; }
body.vertical .panel-cab .titulo { flex-direction: row; flex-wrap: wrap; align-content: center; align-items: baseline; column-gap: 4px; row-gap: 0; line-height: 1.25; }
body.vertical .etq, body.vertical .contenido .etq { font-size: 7px; } body.vertical .pestanas a { font-size: 8px; } body.vertical .pie, body.vertical .pie * { font-size: 7px; }
/* japonés y chino: la fuente de píxeles no tiene esos caracteres; se usa la del sistema, algo mayor y sin separación entre letras */
html:lang(ja) *, html:lang(zh) * { letter-spacing: 0 !important; }
html:lang(ja) #app, html:lang(ja) .modal-fondo, html:lang(ja) .toast, html:lang(ja) body { font-family: 'Noto Sans JP', 'Yu Gothic UI', 'Hiragino Sans', 'Meiryo', sans-serif !important; }
html:lang(zh) #app, html:lang(zh) .modal-fondo, html:lang(zh) .toast, html:lang(zh) body { font-family: 'Noto Sans SC', 'Microsoft YaHei UI', 'PingFang SC', 'Heiti SC', sans-serif !important; }
html:lang(ja) #app button, html:lang(ja) #app input, html:lang(ja) #app select, html:lang(ja) #app textarea,
html:lang(zh) #app button, html:lang(zh) #app input, html:lang(zh) #app select, html:lang(zh) #app textarea { font-family: inherit !important; }
.idioma-op { display: flex; align-items: center; gap: 12px; text-align: left; justify-content: flex-start; }
.idioma-op b { display: block; } .idioma-op small { display: block; font-size: 7px; opacity: .7; margin-top: 2px; }
.idioma-op.activo { outline: 3px solid var(--oro, #c9a227); outline-offset: 1px; }
.idioma-op .bandera { flex: none; }

/* animación ligera del escenario: el personaje respira (anclado a los pies) y motas de luz suben despacio por el ambiente */
.escena .heroe img, .escena .heroe canvas { transform-origin: 50% 100%; animation: respira 3.2s ease-in-out infinite; }
@keyframes respira { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.012, 1.03); } }
.escena.arte::after { content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: .55;
  background-image: radial-gradient(circle, #fff8d6 0 1.5px, transparent 2.5px), radial-gradient(circle, #fff8d6 0 1px, transparent 2px);
  background-size: 120px 150px, 83px 97px; background-position: 0 0, 40px 30px; animation: motas 14s linear infinite; }
@keyframes motas { to { background-position: 14px -150px, 30px -97px; } }
@media (prefers-reduced-motion: reduce) { .escena .heroe img, .escena .heroe canvas, .escena.arte::after { animation: none; } }
.principal > picture { display: contents; }
.principal > picture > source { display: none; }          /* con picture en «contents», el <source> se colocaba como una celda más y descolocaba toda la ficha */
/* reacciones del personaje: sacudida roja al perder PG, brillo verde al curarse; balanceo suave en reposo */
.escena .heroe.golpe { animation: golpe .45s ease-out; } .escena .heroe.golpe img, .escena .heroe.golpe canvas { filter: brightness(1.5) sepia(1) saturate(6) hue-rotate(-35deg); animation: golpe-tinte .45s ease-out forwards; }
@keyframes golpe { 0%, 100% { transform: translateX(0); } 15% { transform: translateX(-7px); } 35% { transform: translateX(6px); } 55% { transform: translateX(-4px); } 75% { transform: translateX(2px); } }
@keyframes golpe-tinte { to { filter: none; } }
.escena .heroe.cura img, .escena .heroe.cura canvas { animation: cura .9s ease-out; }
@keyframes cura { 0% { filter: brightness(1.7) drop-shadow(0 0 10px #6dff8a); } 100% { filter: none; } }
@media (prefers-reduced-motion: reduce) { .escena .heroe.golpe, .escena .heroe.golpe img, .escena .heroe.golpe canvas, .escena .heroe.cura img, .escena .heroe.cura canvas { animation: none; } }
/* ambiente por escenario: capa del tamaño del fondo con partículas que suben, bajan o flotan */
.ambiente { position: absolute; left: 0; top: 0; width: 640px; height: 360px; overflow: hidden; pointer-events: none; z-index: 0; }
body.vertical .ambiente { width: var(--wv, 360px); height: var(--hv, 640px); }
.ambiente i { position: absolute; display: block; border-radius: 50%; opacity: 0; animation: linear infinite; }
.amb-brasas i { bottom: 8%; background: #ffb347; box-shadow: 0 0 6px 1px #ff7a1a; animation-name: sube-brasa; }
@keyframes sube-brasa { 0% { transform: translate(0, 0); opacity: 0; } 15% { opacity: .9; } 100% { transform: translate(14px, -240px); opacity: 0; } }
.amb-nieve i { top: -4%; background: #fff; animation-name: cae-nieve; }
@keyframes cae-nieve { 0% { transform: translate(0, 0); opacity: 0; } 10% { opacity: .9; } 100% { transform: translate(-40px, 420px); opacity: .2; } }
.amb-burbujas i { bottom: -4%; background: transparent; border: 1px solid #bfeaff; animation-name: sube-burbuja; }
@keyframes sube-burbuja { 0% { transform: translate(0, 0); opacity: 0; } 15% { opacity: .8; } 50% { transform: translate(8px, -170px); } 100% { transform: translate(-6px, -340px); opacity: 0; } }
.amb-niebla i { bottom: 12%; background: radial-gradient(closest-side, rgba(220, 235, 240, .35), transparent); border-radius: 50%; animation-name: deriva-niebla; }
@keyframes deriva-niebla { 0% { transform: translateX(-60px); opacity: 0; } 30% { opacity: .8; } 70% { opacity: .8; } 100% { transform: translateX(80px); opacity: 0; } }
.amb-motas i { bottom: 20%; background: #fff8d6; box-shadow: 0 0 4px 1px #fff3b0; animation-name: flota-mota; }
@keyframes flota-mota { 0% { transform: translate(0, 0); opacity: 0; } 25% { opacity: .8; } 50% { transform: translate(10px, -90px); } 100% { transform: translate(-8px, -200px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .ambiente { display: none; } }

/* Panel del DM: el DM y su grupo van en una columna lateral (a la izquierda en horizontal) o en una tira arriba (en vertical); el escenario y el combate, al lado */
.dm-wrap { container-type: inline-size; }
.dm-layout { display: flex; flex-direction: column; gap: 8px; }
.dm-principal { min-width: 0; }
.dm-lateral { display: flex; gap: 8px; align-items: flex-start; overflow-x: auto; padding: 2px; }
.dm-party { display: flex; flex-direction: row; gap: 5px; align-items: stretch; }
.dm-pj-fila { min-width: 150px; }
.dm-lateral .arte-criatura.dm-avatar { float: none; }
@container (min-width: 520px) {
  .dm-layout { flex-direction: row; align-items: flex-start; }
  .dm-lateral { flex-direction: column; width: 184px; flex: none; overflow: visible; }
  .dm-party { flex-direction: column; width: 100%; }
  .dm-pj-fila { min-width: 0; }
  .dm-principal { flex: 1; min-width: 0; }
}

/* Panel del DM: al entrar en modo combate se hace zoom al orden de iniciativa; al salir, se aleja y vuelve la campaña */
@keyframes dm-zoom-in { from { transform: scale(.93); opacity: .25; } to { transform: none; opacity: 1; } }
@keyframes dm-zoom-out { from { transform: scale(1.06); opacity: .25; } to { transform: none; opacity: 1; } }
.dm-zoom-in { animation: dm-zoom-in .28s ease-out; }
.dm-zoom-out { animation: dm-zoom-out .28s ease-out; }
.dm-combate { max-width: 760px; margin: 0 auto; }
/* En horizontal el combate usa todo el ancho: arriba los botones y el campo de batalla (bajo y ancho, para que quepan todos con su nombre), debajo el orden de iniciativa a la izquierda y la ficha del seleccionado a la derecha */
@container (min-width: 520px) {
  .dm-combate { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; max-width: none; align-items: start; }
  .dm-combate > .tarjeta { grid-column: 1 / -1; margin: 0; }
  .dm-col-izq, .dm-col-der { min-width: 0; }
  .dm-combate > .tarjeta:first-child { position: sticky; top: 0; z-index: 6; padding: 4px 8px; }          /* los botones del combate (siguiente turno, automático…) se quedan a la vista al bajar */
  .dm-combate > .tarjeta:first-child p { margin: 1px 0; font-size: 9px !important; line-height: 1.2; }
  .dm-combate > .tarjeta:first-child b { font-size: 11px !important; }
  .dm-combate > .tarjeta:first-child .botones { margin: 2px 0 0; gap: 3px; }
  .dm-combate > .tarjeta:first-child .btn { font-size: 8px; padding: 2px 5px; min-height: 0; border-width: 2px; }
  .dm-combate > .tarjeta:first-child .aviso-caja { padding: 2px 6px; }
}
@media (max-height: 520px) { .dm-combate > .tarjeta:first-child { position: static; } }          /* en un móvil de lado la pantalla es muy baja: la cabecera no se queda fija para no tapar el campo */
@container (min-width: 520px) {
  .dm-combate > .tarjeta:first-child { display: flex; flex-wrap: wrap; align-items: center; column-gap: 8px; }
  .dm-combate > .tarjeta:first-child > div:first-child { flex: none; }
  .dm-combate > .tarjeta:first-child > div:first-child .suave { display: none; }          /* el nombre del escenario y la ronda ya salen en el campo de batalla */
  .dm-combate > .tarjeta:first-child > p { flex: 1; min-width: 0; }
  .dm-combate > .tarjeta:first-child > .botones, .dm-combate > .tarjeta:first-child > .aviso-caja { flex-basis: 100%; }
  .dm-campo { aspect-ratio: auto; height: 180px; max-height: none; min-height: 0; }
  #dm-orden { max-height: 190px; overflow-y: auto; position: relative; }
}
@media (prefers-reduced-motion: reduce) { .dm-zoom-in, .dm-zoom-out { animation: none; } }

/* Campo de batalla del modo combate: jugadores a la izquierda, enemigos a la derecha, sobre el escenario */
.dm-campo { position: relative; width: 100%; aspect-ratio: 16 / 9; min-height: 190px; max-height: 300px; border: 3px solid var(--tinta); border-radius: 4px; overflow: hidden; background: linear-gradient(#2b2540, #14101f); }
.dm-campo-fondo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.dm-campo-etq { position: absolute; left: 8px; top: 8px; right: 8px; background: #000a; color: #fff; padding: 3px 8px; border-radius: 3px; font: 13px system-ui, sans-serif; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-vs { position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%); font-size: 30px; color: #fff; text-shadow: 0 0 6px #000, 0 0 12px #c33; opacity: .85; pointer-events: none; }
.dm-bando { position: absolute; top: 40px; bottom: 6px; display: flex; align-items: flex-end; gap: 6px; width: 46%; }
.dm-bando.jug { left: 8px; justify-content: flex-start; }
.dm-bando.enem { right: 8px; justify-content: flex-end; }
.dm-fig { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; flex: 0 1 auto; min-width: 0; max-height: 100%; padding: 2px; background: none; border: 0; cursor: pointer; color: #fff; font: inherit; }
.dm-fig img, .dm-fig canvas { max-height: calc(100% - 30px); max-width: 100%; width: auto; image-rendering: pixelated; object-fit: contain; }
.dm-fig .arte-criatura { float: none; margin: 0; }
.dm-fig.turno { filter: drop-shadow(0 0 7px #ffd44a) drop-shadow(0 0 2px #ffd44a); z-index: 2; }
.dm-fig.sel { outline: 3px solid #fff; outline-offset: -1px; border-radius: 4px; }
.dm-fig.caido img, .dm-fig.caido canvas, .dm-fig.caido > span:not(.dm-fig-nombre):not(.dm-fig-pg):not(.dm-marca):not(.dm-fig-ini) { opacity: .35; filter: grayscale(1); }
.dm-fig-nombre { margin-top: 2px; max-width: min(96px, 100%); box-sizing: border-box; background: #000b; padding: 1px 5px; border-radius: 3px; font: 9px system-ui, sans-serif; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-fig-pg { display: block; width: 100%; min-width: 38px; height: 5px; margin-top: 2px; background: #555; border: 1px solid #000; }
.dm-fig-pg i { display: block; height: 100%; }
.dm-fig-ini { position: absolute; top: 0; left: 0; z-index: 3; background: #000c; color: #fff; padding: 1px 5px; border-radius: 3px; font: bold 11px system-ui, sans-serif; }
.dm-marca { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); z-index: 3; color: #ffd44a; font-size: 22px; text-shadow: 0 0 4px #000; animation: dm-rebote .7s infinite alternate ease-in-out; }
@keyframes dm-rebote { from { transform: translateX(-50%) translateY(0); } to { transform: translateX(-50%) translateY(7px); } }
@media (prefers-reduced-motion: reduce) { .dm-marca { animation: none; } }
.dm-fig-ini { white-space: nowrap; }
/* Móvil en vertical: el campo es más alto y los bandos van uno encima del otro (jugadores arriba, enemigos abajo) para que quepan todos con un tamaño legible */
@container (max-width: 519px) {
  .dm-campo { aspect-ratio: 4 / 5; max-height: none; min-height: 0; }
  .dm-bando { width: auto; left: 8px; right: 8px; justify-content: center !important; }
  .dm-bando.jug { top: 36px; bottom: 51%; }
  .dm-bando.enem { top: 50%; bottom: 6px; }
}

/* Animaciones del campo de batalla: respiran, el del turno brilla, y al recibir un golpe tiemblan y se ponen rojos, al curarse brillan en verde, al caer se tumban y los que atacan se lanzan hacia el otro bando */
.dm-fig > img, .dm-fig > canvas { transform-origin: 50% 100%; animation: respira 3.2s ease-in-out infinite; }
.dm-fig:nth-child(2n) > img, .dm-fig:nth-child(2n) > canvas { animation-delay: -1.1s; }
.dm-fig:nth-child(3n) > img, .dm-fig:nth-child(3n) > canvas { animation-delay: -2.2s; }
.dm-fig.golpe { animation: golpe .45s ease-out; }
.dm-fig.golpe > img, .dm-fig.golpe > canvas { filter: brightness(1.5) sepia(1) saturate(6) hue-rotate(-35deg); animation: golpe-tinte .6s ease-out forwards; }
.dm-fig.cura > img, .dm-fig.cura > canvas { animation: cura .9s ease-out; }
.dm-fig.cae > img, .dm-fig.cae > canvas { animation: dm-cae .7s ease-in forwards; }
.dm-fig.caido > img, .dm-fig.caido > canvas { animation: none; transform: rotate(-80deg) translateY(8px); }
.dm-bando.enem .dm-fig.ataca > img, .dm-bando.enem .dm-fig.ataca > canvas { animation: dm-ataca-izq .55s ease-out; }
.dm-bando.jug .dm-fig.ataca > img, .dm-bando.jug .dm-fig.ataca > canvas { animation: dm-ataca-der .55s ease-out; }
@keyframes dm-cae { from { transform: none; } to { transform: rotate(-80deg) translateY(8px); } }
@keyframes dm-ataca-izq { 0%, 100% { transform: translateX(0); } 40% { transform: translateX(-46px) scale(1.12); } }
@keyframes dm-ataca-der { 0%, 100% { transform: translateX(0); } 40% { transform: translateX(46px) scale(1.12); } }
@media (prefers-reduced-motion: reduce) { .dm-fig > img, .dm-fig > canvas, .dm-fig.golpe, .dm-fig.golpe > img, .dm-fig.golpe > canvas, .dm-fig.cura > img, .dm-fig.cura > canvas, .dm-fig.cae > img, .dm-fig.cae > canvas, .dm-fig.ataca > img, .dm-fig.ataca > canvas { animation: none; } }

/* Fondo animado de los escenarios (vídeo en bucle): el suelo se funde con la imagen fija */
.fondo-video { position: absolute; pointer-events: none; object-fit: cover; z-index: 0; -webkit-mask-image: linear-gradient(#000 64%, transparent 76%); mask-image: linear-gradient(#000 64%, transparent 76%); }
.fondo-video.principal { left: 0; top: 0; width: 640px; height: 360px; }
body.vertical .fondo-video.principal { width: var(--wv, 360px); height: var(--hv, 640px); }
.fondo-video.dm { inset: 0; width: 100%; height: 100%; }
body.vertical .lista-pj { grid-template-columns: 1fr; }          /* con el botón de borrar, en el móvil en vertical cada personaje ocupa todo el ancho */
.panel-cab.con-logo { height: 46px; }
.panel-cab.con-logo .titulo { padding: 0 8px; }
.panel-cab .titulo picture { display: flex; align-items: center; height: 100%; }          /* en horizontal el logo va en una sola línea larga; en vertical, el de dos líneas */
.panel-cab .logo-cab { height: 30px; width: auto; max-width: 100%; image-rendering: pixelated; display: block; }
body.vertical .panel-cab.con-logo { height: auto; min-height: 46px; }
body.vertical .panel-cab .logo-cab { height: 28px; }          /* en la cabecera el título es el logo (la imagen), en las demás pantallas sigue el texto */
.panel-cab .titulo source { display: none; }
