/* Marca Sostec, en la línea visual de Primer Turno y Escudo Preventivo */
:root {
  --navy: #0E2347; --navy2: #17325F; --card: rgba(19, 43, 82, .94);
  --gold: #E2A821; --gold2: #F2C14E;
  --ink: #F3F5FA; --muted: #A9B8D1; --line: rgba(255, 255, 255, .14);
  --ok: #2FBF71; --bad: #E5484D;
  --display: "Plus Jakarta Sans", system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  --body: Manrope, system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  --seg-arriba: env(safe-area-inset-top, 0px);
  --seg-abajo: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--navy); color: var(--ink); font-family: var(--body); -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { font-family: var(--display); margin: 0; }

#lienzo { position: fixed; inset: 0; }
#lienzo canvas { display: block; width: 100%; height: 100%; touch-action: none; }
#hud, #acciones, #guia, #relator, #toast { user-select: none; -webkit-user-select: none; }

/* ---------- HUD ---------- */
#hud { position: fixed; top: calc(10px + var(--seg-arriba)); left: 10px; right: 10px; display: flex; gap: 8px; align-items: stretch; z-index: 10; pointer-events: none; }
.hud-dato { background: rgba(10, 26, 54, .82); border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 74px; }
.hud-etq { font: 700 10px var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.hud-dato > span:last-child { font: 800 20px var(--display); font-variant-numeric: tabular-nums; }
.vidas { color: #ff6b6f; letter-spacing: .08em; }
.hud-escudo { min-width: 150px; }
.barra-escudo { width: 130px; height: 12px; margin-top: 6px; border-radius: 999px; background: rgba(255, 255, 255, .12); overflow: hidden; }
#hud-escudo { height: 100%; width: 50%; border-radius: inherit; background: linear-gradient(90deg, var(--gold), var(--gold2)); transition: width .35s; }
.hud-botones { margin-left: auto; pointer-events: auto; }
.hud-btn { min-width: 46px; min-height: 46px; border-radius: 12px; border: 1px solid var(--line); background: rgba(10, 26, 54, .82); font-weight: 800; }
.hud-btn:hover { border-color: var(--gold); }

/* ---------- Acciones ---------- */
#acciones { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(14px + var(--seg-abajo)); display: flex; gap: 8px; z-index: 10; }
#acciones button { display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(10, 26, 54, .85); font-weight: 700; }
#acciones button:hover, #acciones button.activa { border-color: var(--gold); background: rgba(226, 168, 33, .22); }
#acciones button.informar { border-color: rgba(229, 72, 77, .6); }
#acciones kbd { font: 800 12px var(--display); background: var(--gold); color: var(--navy); border-radius: 6px; padding: 2px 7px; }

#guia { position: fixed; left: 14px; bottom: calc(16px + var(--seg-abajo)); display: grid; gap: 6px; font-size: 13px; color: rgba(255, 255, 255, .78); text-shadow: 0 1px 3px rgba(0, 0, 0, .6); z-index: 9; pointer-events: none; }
.tecla { display: inline-block; min-width: 24px; text-align: center; padding: 1px 6px; margin-right: 3px; border-radius: 6px; border: 1px solid rgba(255, 255, 255, .45); background: rgba(10, 26, 54, .45); font-weight: 700; }

/* ---------- Relator y avisos ---------- */
.relator { position: fixed; left: 50%; bottom: calc(84px + var(--seg-abajo)); transform: translateX(-50%); width: min(760px, calc(100% - 32px)); background: rgba(10, 26, 54, .9); border-left: 4px solid var(--gold); border-radius: 10px; padding: 12px 16px 12px 46px; font-size: 18px; line-height: 1.4; z-index: 12; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); }
.relator::before { content: "🎙"; position: absolute; left: 14px; top: 11px; font-size: 18px; }
.relator.entra { animation: entra .25s ease-out; }
@keyframes entra { from { opacity: 0; transform: translate(-50%, 8px); } }
#toast { position: fixed; top: calc(80px + var(--seg-arriba)); left: 50%; transform: translateX(-50%); background: rgba(10, 26, 54, .92); border: 1px solid var(--gold); padding: 9px 16px; border-radius: 999px; font-weight: 700; font-size: 14px; z-index: 12; max-width: calc(100% - 32px); }

/* ---------- Pantallas ---------- */
.pantalla { position: fixed; inset: 0; display: flex; align-items: center; padding: 24px; z-index: 20; overflow-y: auto; }
.pantalla.centro { justify-content: center; background: rgba(8, 20, 45, .55); }
.pantalla.inicio { background: linear-gradient(90deg, rgba(10, 26, 54, .92) 0%, rgba(10, 26, 54, .7) 45%, rgba(10, 26, 54, 0) 70%); }
.tarjeta { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 24px; width: min(480px, 100%); box-shadow: 0 18px 40px rgba(0, 0, 0, .35); }
.pantalla.inicio .tarjeta { background: none; border: 0; box-shadow: none; padding: 0; width: min(500px, 100%); }
.cargando { margin: 0; color: var(--muted); }
.brand { font: 700 12px/1 var(--display); letter-spacing: .16em; text-transform: uppercase; color: var(--gold2); margin: 0 0 10px; }
.titulo { font-size: clamp(34px, 6vw, 54px); line-height: 1; letter-spacing: -.02em; }
.titulo em { font-style: normal; color: var(--gold); }
.cinta { height: 10px; border-radius: 3px; background: repeating-linear-gradient(-45deg, var(--gold) 0 12px, #0A1A36 12px 24px); max-width: 240px; margin: 14px 0 16px; }
.lead { color: var(--muted); font-size: 16px; line-height: 1.5; margin: 0 0 16px; }
.aviso { border: 1px solid rgba(229, 72, 77, .55); background: rgba(229, 72, 77, .12); border-radius: 12px; padding: 10px 14px; font-size: 14px; line-height: 1.45; margin: 0 0 18px; }
.aviso b { color: #ff9a9d; }
.arena-resultado { border: 1px solid rgba(226, 168, 33, .6); background: rgba(226, 168, 33, .12); border-radius: 12px; padding: 10px 14px; font-size: 15px; margin: 0 0 18px; }
.arena-resultado b { color: #f2b632; letter-spacing: .1em; }
.etq-grupo { font: 700 12px var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.personajes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 18px; }
.personajes button { border: 1px solid var(--line); background: rgba(255, 255, 255, .06); border-radius: 12px; padding: 12px 6px; font-weight: 700; }
.personajes button.on { border-color: var(--gold); background: rgba(226, 168, 33, .18); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 22px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, .08); font: 800 16px var(--display); }
.btn.primario { background: var(--gold); color: var(--navy); border-color: var(--gold); }
.btn.primario:hover { background: var(--gold2); }
.fila-btn { display: flex; gap: 10px; flex-wrap: wrap; }
.pie { font-size: 12px; color: var(--muted); margin-top: 16px; }
.datos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 16px 0; }
.datos div { background: rgba(255, 255, 255, .06); border-radius: 12px; padding: 10px 12px; }
.datos b { display: block; font: 800 22px var(--display); }
.datos span { font-size: 13px; color: var(--muted); }

/* ---------- Inventario, avisos y golpe ---------- */
#hud-inv { position: fixed; top: calc(76px + var(--seg-arriba)); left: 10px; display: flex; flex-wrap: wrap; gap: 6px; max-width: 46%; z-index: 10; pointer-events: none; }
.chip-inv { background: rgba(10, 26, 54, .82); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 700; }
.chip-inv.ing { border-color: var(--ok); color: #9be6bd; }
.chip-inv.malo { border-color: var(--bad); color: #ff9a9d; text-decoration: line-through; }
.vidas.sin { color: var(--muted); }
#recon { position: fixed; top: calc(122px + var(--seg-arriba)); left: 50%; transform: translateX(-50%); background: linear-gradient(90deg, var(--gold), var(--gold2)); color: var(--navy); padding: 9px 18px; border-radius: 999px; font-weight: 800; font-size: 14px; z-index: 12; box-shadow: 0 8px 24px rgba(0, 0, 0, .3); animation: entra .3s ease-out; max-width: calc(100% - 32px); }
#flash { position: fixed; inset: 0; pointer-events: none; z-index: 15; background: radial-gradient(circle, rgba(229, 72, 77, 0) 40%, rgba(229, 72, 77, .55) 100%); opacity: 0; }
#flash.on { animation: flash .6s ease-out; }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }
.relator.supervisor { border-left-color: var(--bad); }
.relator.supervisor::before { content: "📣"; }

/* ---------- Panel modal ---------- */
.modal { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(8, 20, 45, .5); }
.modal-tarjeta { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 22px; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: 0 18px 40px rgba(0, 0, 0, .4); position: relative; }
.modal.tono-peligro .modal-tarjeta { border-color: rgba(229, 72, 77, .7); padding-top: 0; }
.modal.tono-ok .modal-tarjeta { border-color: var(--ok); }
.franja-peligro { height: 12px; margin: 0 -22px 16px; border-radius: 18px 18px 0 0; background: repeating-linear-gradient(-45deg, var(--bad) 0 12px, #3A0F14 12px 24px); }
.modal.tono-peligro .brand { color: #ff9a9d; }
.modal h2 { font-size: 22px; line-height: 1.25; margin-bottom: 8px; }
.modal-texto { color: var(--muted); font-size: 15px; line-height: 1.5; }
.modal-texto p { margin: 0 0 8px; }
.modal-texto b { color: var(--ink); }
.modal-texto .correcto { color: #9be6bd; font-weight: 700; }
.modal-reloj { height: 8px; border-radius: 999px; background: rgba(255, 255, 255, .12); overflow: hidden; margin: 10px 0 4px; }
.modal-reloj div { height: 100%; width: 100%; background: linear-gradient(90deg, var(--bad), var(--gold)); }
.opciones { display: grid; gap: 8px; margin-top: 14px; }
.opcion { display: flex; align-items: center; gap: 12px; text-align: left; min-height: 50px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, .06); }
.opcion:hover, .opcion:focus-visible { border-color: var(--gold); background: rgba(226, 168, 33, .14); outline: none; }
.opcion kbd { font: 800 12px var(--display); background: rgba(255, 255, 255, .14); border-radius: 6px; padding: 3px 8px; }
.opcion small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; margin-top: 2px; }
.opcion.primaria { border-color: var(--gold); background: rgba(226, 168, 33, .2); }
.opcion.primaria kbd { background: var(--gold); color: var(--navy); }
.opcion.secundaria { opacity: .8; }
.modal.ancho .modal-tarjeta { width: min(860px, 100%); }
.opciones.grilla { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.opcion.con-imagen { flex-direction: column; align-items: stretch; text-align: center; gap: 6px; padding: 8px; position: relative; }
.opcion.con-imagen img { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 10px; background: radial-gradient(circle at 50% 40%, #e9eef5, #9aa6b8); }
.opcion.con-imagen kbd { position: absolute; top: 12px; left: 12px; }
.opciones.grilla .opcion:not(.con-imagen) { justify-content: center; }
.modal-imagen { display: block; width: min(240px, 60%); aspect-ratio: 1; object-fit: contain; margin: 4px auto 10px; border-radius: 14px; background: radial-gradient(circle at 50% 40%, #e9eef5, #9aa6b8); }
/* Escena horizontal (decisiones y consecuencias): ocupa el ancho de la tarjeta */
.modal-imagen.ancha { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: #0A1A36; margin: 2px 0 12px; }
.modal.con-imagen-ancha .modal-tarjeta { width: min(640px, 100%); }
/* Fondo tenue (preguntas para recuperar vidas) */
.modal.con-fondo .modal-tarjeta { background: linear-gradient(rgba(19, 43, 82, .9), rgba(19, 43, 82, .94)), var(--fondo) center / cover; }

/* Foto breve que no detiene el juego (cuasi accidente) */
#foto-breve { position: fixed; top: calc(122px + var(--seg-arriba)); right: 14px; width: min(280px, 42vw); background: rgba(10, 26, 54, .92); border: 1px solid var(--gold); border-radius: 12px; overflow: hidden; z-index: 12; pointer-events: none; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); }
#foto-breve img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
#foto-breve span { display: block; padding: 7px 10px; font-weight: 700; font-size: 13px; }
#foto-breve.entra { animation: entra-der .3s ease-out; }
@keyframes entra-der { from { opacity: 0; transform: translateX(16px); } }

/* Iconos del inventario */
.chip-inv img { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; vertical-align: middle; margin: -3px 6px -3px -6px; background: #dfe3e8; }
.chip-inv.malo img { opacity: .6; }

/* Retrato del relator */
.relator.con-retrato { padding-left: 74px; min-height: 64px; }
.relator.con-retrato::before { content: ""; left: 10px; top: 50%; width: 52px; height: 52px; margin-top: -26px; border-radius: 50%; border: 2px solid var(--gold); background: var(--retrato) center / cover; }
.relator.con-retrato.supervisor::before { content: ""; border-color: var(--bad); }

/* Portada: foto de fondo detrás del degradado */
.pantalla.inicio.con-portada { background: linear-gradient(90deg, rgba(10, 26, 54, .94) 0%, rgba(10, 26, 54, .72) 45%, rgba(10, 26, 54, .1) 75%), var(--portada) center / cover; }

/* Encabezado del informe */
.inf-foto { width: 100%; aspect-ratio: 21 / 6; object-fit: cover; border-radius: 16px; margin: 0 0 18px; display: block; }

/* ---------- Informe ---------- */
.pantalla.informe-pantalla { align-items: flex-start; background: var(--navy); }
.informe { width: min(1000px, 100%); margin: 0 auto; padding-bottom: 40px; }
.inf-cab { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.inf-cab h2 { font-size: clamp(24px, 4vw, 34px); }
.inf-meta { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.indice { display: flex; gap: 18px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 18px; margin-bottom: 14px; }
.indice h3 { font-size: 20px; }
.indice-num { flex: none; width: 108px; height: 108px; border-radius: 50%; display: grid; place-content: center; text-align: center; background: conic-gradient(var(--gold) calc(var(--v) * 1%), rgba(255, 255, 255, .1) 0); position: relative; }
.indice-num::before { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: var(--card); }
.indice-num b, .indice-num span { position: relative; }
.indice-num b { font: 800 34px var(--display); }
.indice-num span { font-size: 12px; color: var(--muted); }
.datos-4 { grid-template-columns: repeat(4, 1fr); }
.inf-sub { margin: 26px 0 10px; font-size: 18px; }
.arbol { background: var(--card); border: 1px solid rgba(229, 72, 77, .5); border-radius: 16px; padding: 16px; margin-bottom: 12px; }
.arbol h3 { font-size: 17px; margin-bottom: 10px; }
.gema { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.gema > div { background: rgba(255, 255, 255, .05); border-radius: 12px; padding: 10px 12px; border-top: 3px solid var(--gold); }
.gema ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.medida { margin: 12px 0 0; color: #9be6bd; }
.reflex { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.recon { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 6px; }
.recon li { background: rgba(255, 255, 255, .05); border-radius: 10px; padding: 8px 12px; font-size: 14px; }
.tabla-scroll { overflow-x: auto; border-radius: 14px; border: 1px solid var(--line); }
.tabla { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabla th, .tabla td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.tabla th { font: 700 11px var(--display); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); background: rgba(255, 255, 255, .04); }
.tabla small { display: block; color: var(--muted); }
.chip { display: inline-block; padding: 3px 9px; border-radius: 999px; font-weight: 700; font-size: 12px; background: rgba(255, 255, 255, .1); white-space: nowrap; }
.chip.resuelto, .chip.reconocimiento { background: rgba(47, 191, 113, .2); color: #9be6bd; }
.chip.parcial { background: rgba(226, 168, 33, .2); color: var(--gold2); }
.chip.accidente { background: rgba(229, 72, 77, .25); color: #ff9a9d; }
.chip.omitido, .chip.cuasi, .chip.falla { background: rgba(255, 138, 31, .2); color: #ffc18a; }

@media (max-width: 720px) {
  .datos-4 { grid-template-columns: repeat(2, 1fr); }
  .gema { grid-template-columns: 1fr 1fr; }
  .indice { flex-direction: column; text-align: center; }
  #hud-inv { max-width: calc(100% - 20px); top: calc(70px + var(--seg-arriba)); }
  .pantalla.inicio { background: rgba(10, 26, 54, .86); }
  #guia { display: none; }
  #acciones { width: calc(100% - 20px); }
  #acciones button { flex: 1; justify-content: center; padding: 0 6px; font-size: 13px; }
  #acciones kbd { display: none; }
  .hud-escudo { min-width: 0; }
  .barra-escudo { width: 70px; }
  .hud-dato { min-width: 0; padding: 6px 8px; }
  .relator { font-size: 15px; bottom: calc(76px + var(--seg-abajo)); }
}
