:root {
  --azul: #3b82f6; --naranja: #f97316; --verde: #22c55e;
  --equipo: #f5c451;
  --fondo: #0b0f17; --panel: #151b27; --panel-2: #1d2433; --borde: #2a3346;
  --texto: #e8ecf3; --tenue: #8b95a8; --oro: #f5c451; --rojo: #ef4444;
  --display: "Space Grotesk", Inter, system-ui, sans-serif;
  --cuerpo: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --arriba: env(safe-area-inset-top, 0px); --abajo: env(safe-area-inset-bottom, 0px);
}
body.azul { --equipo: var(--azul); } body.naranja { --equipo: var(--naranja); } body.verde { --equipo: var(--verde); }
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body { font-family: var(--cuerpo); background: var(--fondo); color: var(--texto); overscroll-behavior: none; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -0.01em; }
h2 { font-size: 22px; } h3 { font-size: 16px; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input { font: inherit; }
svg.i { width: 1em; height: 1em; }
.oculto { display: none !important; }

#app { min-height: 100%; display: flex; flex-direction: column; padding-top: var(--arriba); }
.cab { position: sticky; top: 0; z-index: 3; background: var(--fondo); padding: 14px 18px 12px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--borde); }
.punto { width: 12px; height: 12px; border-radius: 50%; background: var(--equipo); box-shadow: 0 0 12px var(--equipo); flex: none; }
.cab .eq { font: 700 18px var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cab .chip { margin-left: auto; font-size: 12px; color: var(--tenue); background: var(--panel); padding: 5px 10px; border-radius: 99px; white-space: nowrap; }
.cab .volver { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; margin-left: -8px; color: var(--tenue); }
.cab .volver svg { width: 22px; height: 22px; }
.cuerpo { flex: 1; padding: 18px 18px calc(110px + var(--abajo)); display: flex; flex-direction: column; gap: 14px; }

.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--borde); padding: 8px 6px calc(10px + var(--abajo)); background: var(--panel); }
.nav button { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; color: var(--tenue); position: relative; padding: 4px 0; }
.nav svg { width: 23px; height: 23px; }
.nav .on { color: var(--equipo); }
.badge { position: absolute; top: -2px; left: 50%; margin-left: 6px; background: var(--rojo); color: #fff; font: 700 10px var(--cuerpo); border-radius: 99px; padding: 1px 6px; }

.btn { display: flex; align-items: center; justify-content: center; gap: 10px; border-radius: 16px; padding: 15px; font: 700 16px var(--display); background: var(--equipo); color: #0b0f17; width: 100%; }
.btn svg { width: 22px; height: 22px; }
.btn.sec { background: var(--panel-2); color: var(--texto); border: 1px solid var(--borde); }
.btn.grande { padding: 22px; font-size: 19px; }
.btn:disabled { opacity: .45; }
.tarjeta { background: var(--panel); border: 1px solid var(--borde); border-radius: 18px; padding: 16px; }
.tarjeta.fila { display: flex; gap: 14px; align-items: center; }
.tarjeta.fila > svg { width: 28px; height: 28px; color: var(--oro); flex: none; }
.tarjeta.toque { cursor: pointer; }
.tenue { color: var(--tenue); font-size: 13.5px; line-height: 1.45; }
.centro { text-align: center; }
.seccion { font: 700 12px var(--cuerpo); letter-spacing: .1em; text-transform: uppercase; color: var(--tenue); margin-top: 6px; }
.lista { display: flex; flex-direction: column; gap: 10px; }
.estado-c { margin-left: auto; font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 99px; background: var(--panel-2); color: var(--tenue); white-space: nowrap; }
.estado-c.ok { background: color-mix(in srgb, var(--verde) 18%, transparent); color: #86efac; }
.progreso { display: flex; gap: 6px; margin-top: 10px; }
.progreso span { flex: 1; height: 10px; border-radius: 99px; background: var(--panel-2); }
.progreso span.ok { background: var(--equipo); }
.banner { border-radius: 18px; padding: 16px; border: 2px solid var(--oro); background: color-mix(in srgb, var(--oro) 12%, var(--panel)); }
.banner h3 { color: var(--oro); margin-bottom: 4px; }

/* Inventario */
.inv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.item { aspect-ratio: 1; border-radius: 16px; background: var(--panel); border: 1px solid var(--borde); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; font-size: 12px; text-align: center; padding: 6px; position: relative; line-height: 1.2; }
.item svg { width: 34px; height: 34px; color: var(--oro); }
.item.vacio { border-style: dashed; background: transparent; color: #3a4459; }
.item.sel { outline: 3px solid var(--equipo); outline-offset: -3px; }
.item .nuevo { position: absolute; top: 6px; right: 6px; font: 700 9px var(--cuerpo); background: var(--azul); color: #fff; padding: 2px 6px; border-radius: 99px; }
.item .origen { position: absolute; bottom: 6px; width: 8px; height: 8px; border-radius: 50%; }

/* Contenido de objetos y pistas */
.pagina { background: #f3e9d4; color: #3a2f22; border-radius: 14px; padding: 18px; font-family: "DejaVu Serif", Georgia, serif; font-size: 15px; line-height: 1.55; }
.pagina h3 { font-family: inherit; margin-bottom: 8px; }
.pagina p + p { margin-top: 10px; }
.pagina .nota, .nota { font-size: 13px; opacity: .8; font-style: italic; }
.libro { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.libro .pagina { padding: 12px; font-size: 13.5px; }
.libro .pagina p { margin: 0 !important; }
.folio { text-align: center; font-size: 11px; opacity: .6; margin-bottom: 6px; }
.ln { color: #b8a88c; font-size: 11px; margin-right: 4px; }
.glifos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; margin: 10px 0; }
.glifos div { background: rgba(58,47,34,.08); border-radius: 10px; padding: 10px 4px; font: 700 14px var(--display); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.grabado { display: flex; justify-content: center; padding: 14px; margin-top: 10px; background: #f3e9d4; color: #3a2f22; border-radius: 14px; }
.pista-html p + p { margin-top: 8px; }
.pista-html { font-size: 15px; line-height: 1.5; }

/* Candado */
.candado-cab { text-align: center; }
.candado-cab svg { width: 46px; height: 46px; color: var(--equipo); }
.enunciado { font-size: 15.5px; line-height: 1.5; text-align: center; }
.casillas { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.casillas input { width: 52px; height: 68px; border-radius: 14px; background: var(--panel); border: 1px solid var(--borde); color: var(--texto); text-align: center; font: 700 32px var(--display); caret-color: var(--equipo); }
.casillas input:focus { outline: 2px solid var(--equipo); }
.casillas.largo input { width: 42px; height: 58px; font-size: 26px; }
input.palabra { width: 100%; height: 64px; border-radius: 14px; background: var(--panel); border: 1px solid var(--borde); color: var(--texto); text-align: center; font: 700 28px var(--display); letter-spacing: .15em; text-transform: uppercase; }
.mensaje-err { text-align: center; color: #fca5a5; font-size: 14px; min-height: 20px; }
.abierto-ok { text-align: center; color: #86efac; font: 700 18px var(--display); }
.sacude { animation: sacude .35s; }
@keyframes sacude { 25% { transform: translateX(-8px); } 50% { transform: translateX(8px); } 75% { transform: translateX(-4px); } }

/* Hojas y modales */
.velo { position: fixed; inset: 0; z-index: 10; background: rgba(0,0,0,.65); display: flex; align-items: center; justify-content: center; padding: 18px; }
.velo.abajo { align-items: flex-end; padding: 0; }
.modal { width: 100%; max-width: 440px; max-height: 88vh; overflow: auto; background: var(--panel); border-radius: 22px; padding: 22px; border: 2px solid var(--equipo); display: flex; flex-direction: column; gap: 14px; }
.modal .icono-g { width: 64px; height: 64px; border-radius: 50%; margin: 0 auto; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--equipo) 20%, transparent); color: var(--equipo); flex: none; }
.modal .icono-g svg { width: 30px; height: 30px; }
.modal h2 { text-align: center; }
.hoja-inf { width: 100%; background: var(--panel); border-radius: 26px 26px 0 0; padding: 12px 18px calc(22px + var(--abajo)); display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--borde); max-height: 90vh; overflow: auto; }
.asa { width: 44px; height: 5px; border-radius: 99px; background: #3a4459; margin: 0 auto 4px; }
.opcion { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--borde); font-weight: 600; text-align: left; width: 100%; }
.opcion .punto { box-shadow: none; }
.opcion small { margin-left: auto; color: var(--tenue); font-weight: 400; font-size: 12px; display: flex; }
.opcion small svg { width: 18px; height: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-b { padding: 10px 13px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--borde); font-size: 13px; font-weight: 600; }
.chip-b.sel { border-color: var(--equipo); background: color-mix(in srgb, var(--equipo) 16%, var(--panel-2)); }

/* Avisos */
.aviso { display: flex; gap: 12px; padding: 14px; border-radius: 16px; background: var(--panel); border: 1px solid var(--borde); }
.aviso .ic { width: 40px; height: 40px; flex: none; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--c, var(--equipo)) 20%, transparent); color: var(--c, var(--equipo)); }
.aviso .ic svg { width: 20px; height: 20px; }
.aviso b { font-size: 14px; } .aviso p { font-size: 13px; color: var(--tenue); margin-top: 3px; line-height: 1.4; }
.aviso .hora { margin-left: auto; font-size: 11px; color: var(--tenue); white-space: nowrap; }
.aviso.nuevo { border-color: var(--azul); }

/* Escáner */
.escaner { position: fixed; inset: 0; z-index: 20; background: #000; display: flex; flex-direction: column; }
.escaner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.escaner .marco { position: absolute; left: 50%; top: 42%; width: 240px; height: 240px; transform: translate(-50%, -50%); border-radius: 26px; box-shadow: 0 0 0 9999px rgba(0,0,0,.45); }
.escaner .marco::before { content: ""; position: absolute; inset: 0; border: 4px solid var(--equipo); border-radius: 26px;
  -webkit-mask: linear-gradient(#000 0 0) top left / 44px 44px no-repeat, linear-gradient(#000 0 0) top right / 44px 44px no-repeat, linear-gradient(#000 0 0) bottom left / 44px 44px no-repeat, linear-gradient(#000 0 0) bottom right / 44px 44px no-repeat;
          mask: linear-gradient(#000 0 0) top left / 44px 44px no-repeat, linear-gradient(#000 0 0) top right / 44px 44px no-repeat, linear-gradient(#000 0 0) bottom left / 44px 44px no-repeat, linear-gradient(#000 0 0) bottom right / 44px 44px no-repeat; }
.escaner .arriba { position: relative; padding: calc(16px + var(--arriba)) 18px 0; text-align: center; font-size: 14px; }
.escaner .pie { position: absolute; left: 0; right: 0; bottom: calc(26px + var(--abajo)); display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 0 18px; }
.escaner .fila-b { display: flex; gap: 14px; }
.circ { width: 58px; height: 58px; border-radius: 50%; background: rgba(255,255,255,.16); display: flex; align-items: center; justify-content: center; color: #fff; backdrop-filter: blur(6px); }
.circ.on { background: var(--oro); color: #111; }
.circ svg { width: 26px; height: 26px; }
.manual { display: flex; gap: 8px; width: 100%; max-width: 360px; }
.manual input { flex: 1; height: 48px; border-radius: 12px; border: 1px solid rgba(255,255,255,.25); background: rgba(0,0,0,.55); color: #fff; padding: 0 14px; text-transform: uppercase; letter-spacing: .1em; }
.manual button { padding: 0 16px; border-radius: 12px; background: var(--equipo); color: #111; font-weight: 700; }

/* Acertijos */
.parte { font: 700 11px var(--cuerpo); letter-spacing: .08em; text-transform: uppercase; color: var(--equipo); margin-bottom: 8px; }
.fusibles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px; background: #10141d; border-radius: 16px; }
.fusibles div { height: 64px; border-radius: 10px; position: relative; }
.fusibles small { position: absolute; top: 5px; left: 8px; font-size: 11px; color: #0b0f17; opacity: .7; font-weight: 700; }
.tarjeta ul { margin: 8px 0 0 20px; line-height: 1.7; }
.maze { display: grid; gap: 2px; background: #05070b; padding: 6px; border-radius: 14px; touch-action: manipulation; }
.maze div { aspect-ratio: 1; border-radius: 4px; display: flex; align-items: center; justify-content: center; font: 700 15px var(--display); }
.maze .w { background: #4b5873; } .maze .o { background: #0b0f17; } .maze .t { background: color-mix(in srgb, var(--equipo) 45%, #0f141d); }
.maze .yo { background: var(--equipo); color: #0b0f17; }
.simon { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.simon button { aspect-ratio: 1; border-radius: 22px; opacity: .4; transition: opacity .12s, box-shadow .12s; }
.simon button.on { opacity: 1; box-shadow: 0 0 30px currentColor; }
.cel { border-radius: 26px; padding: 26px 16px 22px; background: linear-gradient(170deg, #3b2f58, #0f172a 70%); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.cel .hora { font: 300 64px var(--cuerpo); letter-spacing: -.02em; }
.pin { display: flex; justify-content: center; gap: 14px; margin: 6px 0; }
.pin i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #cbd5e1; }
.pin i.f { background: #cbd5e1; }
.tecl { display: grid; grid-template-columns: repeat(3, 68px); gap: 12px; justify-content: center; }
.tecl button { height: 68px; border-radius: 50%; background: rgba(255,255,255,.1); display: flex; flex-direction: column; align-items: center; justify-content: center; font: 500 26px var(--cuerpo); color: #fff; }
.tecl button small { font-size: 9px; letter-spacing: .12em; color: #cbd5e1; }
.chat { display: flex; flex-direction: column; gap: 10px; }
.burbuja { max-width: 82%; padding: 10px 13px; border-radius: 16px; font-size: 14px; line-height: 1.4; }
.burbuja.el { background: #2a3346; align-self: flex-start; border-bottom-left-radius: 4px; }
.burbuja.yo { background: #22c55e; color: #052e16; align-self: flex-end; border-bottom-right-radius: 4px; }
.dif { position: relative; border-radius: 12px; overflow: hidden; }
.dif .rejilla-t { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); }
.dif .rejilla-t button { border: 1px dashed transparent; }
.dif .rejilla-t button.sel { border: 3px solid var(--oro); box-shadow: inset 0 0 18px rgba(245,196,81,.5); border-radius: 8px; }

.carga { display: flex; align-items: center; justify-content: center; min-height: 60vh; color: var(--tenue); }
.toast { position: fixed; left: 50%; bottom: calc(96px + var(--abajo)); transform: translateX(-50%); z-index: 30; background: var(--panel-2); border: 1px solid var(--borde); padding: 12px 16px; border-radius: 14px; font-size: 14px; max-width: 90vw; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
