/* ==========================================================================
   DETECTIVE ORTOGRÁFICO · PlayLab Games · styles.css
   Idea visual: una comisaría de dibujos animados. La pieza protagonista es la
   PIZARRA DE CORCHO con las carpetas de casos unidas por el hilo rojo; el resto
   (fichas, sellos, cartas) usa papel y tinta de máquina de escribir.
   1. Tokens   2. Base y botones   3. Comisaría   4. Partida   5. Modos
   6. Hoja y fin   7. Libreta, archivos, medallas, ranking   8. Efectos   9. Responsive
   ========================================================================== */

/* ---------- 1. TOKENS ---------- */
:root {
  --azul: #1E4FB8;          /* uniforme de policía */
  --azul-osc: #132A6B;
  --tinta: #1A2350;         /* texto */
  --oro: #FFC83D;           /* placa */
  --oro-osc: #C8961A;
  --manila: #F2C96B;        /* carpetas */
  --papel: #FFFDF5;
  --corcho: #C98B4E;
  --rojo: #E63946;          /* sello de error / hilo */
  --verde: #1F9D5C;         /* sello correcto */
  --pared: #D9E8FF;
  --sombra: 0 4px 0 rgba(19, 42, 107, .25);
  --r: 18px;
  --f: "Fredoka", "Baloo 2", "Nunito", "Trebuchet MS", system-ui, sans-serif;
  --maquina: "Special Elite", "Courier New", Courier, monospace;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
*, *::before, *::after { box-sizing: inherit; }
html { height: 100%; scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  margin: 0; min-height: 100%;
  font-family: var(--f); color: var(--tinta); font-size: 17px; line-height: 1.4;
  background-color: var(--pared);
  background-image:
    linear-gradient(90deg, rgba(30, 79, 184, .06) 1px, transparent 1px),
    linear-gradient(rgba(30, 79, 184, .06) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-tap-highlight-color: transparent;
}
html, body { overflow-x: hidden; }
#app { max-width: 1040px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; position: relative; overflow-x: clip; }
.comisaria > *, .placa-datos, .niveles-botones > * { min-width: 0; }
[hidden] { display: none !important; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 4px solid var(--oro); outline-offset: 3px; border-radius: 12px; }
h1, h2, h3 { margin: 0; line-height: 1.15; }

/* ---------- 2. BOTONES ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  min-height: 52px; padding: .55em 1.25em; border: 3px solid var(--tinta); border-radius: 16px;
  font-weight: 600; font-size: 1.05rem; background: #fff; box-shadow: 0 5px 0 var(--tinta);
  transition: transform .08s, box-shadow .08s;
}
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--tinta); }
.btn:disabled { opacity: .45; }
.btn-verde { background: var(--verde); color: #fff; }
.btn-azul { background: var(--azul); color: #fff; }
.btn-rojo { background: var(--rojo); color: #fff; }
.btn-blanco { background: #fff; }
.btn-grande { min-height: 62px; font-size: 1.25rem; }
.btn-ancho { width: 100%; }
.btn-cuadrado { width: 52px; padding: 0; font-size: 1.3rem; }
.enlace { background: none; border: 0; padding: .2em .3em; color: var(--azul); text-decoration: underline; font-weight: 600; }
.chip { border: 2px solid var(--tinta); background: #fff; border-radius: 999px; padding: .35em .8em; font-weight: 600; font-size: .9rem; }

/* ---------- 3. COMISARÍA ---------- */
.pantalla { padding: 14px 14px 28px; }
.sirena { display: flex; justify-content: center; gap: 4px; margin: 0 auto 4px; width: 92px; height: 18px;
  background: var(--tinta); border-radius: 10px 10px 4px 4px; padding: 3px; }
.luz { flex: 1; border-radius: 7px 7px 2px 2px; }
.luz.roja { background: #ff6b6b; animation: destello 1.2s infinite; }
.luz.azul { background: #5aa2ff; animation: destello 1.2s .6s infinite; }
@keyframes destello { 0%, 45% { opacity: 1; box-shadow: 0 0 14px currentColor; } 50%, 100% { opacity: .35; box-shadow: none; } }

.cabecera { text-align: center; }
.logo-playlab { width: min(210px, 52vw); height: auto; display: block; margin: 2px auto 0; filter: drop-shadow(0 6px 10px rgba(19, 42, 107, .25)); }
.titulo { font-weight: 700; font-size: clamp(2.1rem, 8.4vw, 3.6rem); letter-spacing: -.01em; margin-top: 4px;
  color: var(--azul-osc); text-shadow: 0 4px 0 var(--oro); }
.titulo-a, .titulo-b { display: inline-block; }
.titulo-b { position: relative; }
.titulo-b::after { /* la lupa que investiga la palabra */
  content: ""; position: absolute; right: -.42em; top: -.18em; width: .62em; height: .62em; border-radius: 50%;
  border: .09em solid var(--rojo); background: rgba(170, 225, 255, .45);
  box-shadow: .22em .22em 0 -.18em var(--tinta); transform: rotate(-10deg);
  animation: lupaBusca 5s ease-in-out infinite;
}
@keyframes lupaBusca { 0%, 100% { transform: translate(0, 0) rotate(-10deg); } 50% { transform: translate(-2.6em, .1em) rotate(-10deg); } }
.lema { margin: 8px auto 0; font-weight: 600; font-size: 1.08rem; max-width: 34ch; }
.sublema { margin: 4px 0 0; color: var(--azul); font-weight: 500; }

.comisaria { display: grid; gap: 14px; margin-top: 14px; }

.placa { --rango: var(--verde); display: flex; gap: 12px; align-items: center; background: #fff; border: 3px solid var(--tinta);
  border-radius: var(--r); padding: 10px 14px; box-shadow: var(--sombra); position: relative; }
.placa::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 8px; border-radius: 14px 14px 0 0; background: var(--rango); }
.placa-avatar { width: 92px; flex: none; }
.placa-avatar .det, .panel-avatar .det, .fin-avatar .det { width: 100%; height: auto; display: block; }
.placa-datos { flex: 1; min-width: 0; }
.placa-datos p { margin: 0; }
.placa-nick { font-weight: 700; font-size: 1.15rem; word-break: break-all; }
.placa-rango { color: var(--rango); font-size: 1.02rem; margin-top: 2px !important; }
.progreso { height: 14px; border-radius: 99px; background: #E6ECF8; border: 2px solid var(--tinta); overflow: hidden; margin-top: 6px; }
.progreso-relleno { display: block; height: 100%; width: 0; background: repeating-linear-gradient(45deg, var(--oro), var(--oro) 8px, #ffd970 8px, #ffd970 16px); transition: width .6s; }
.progreso-txt { font-size: .85rem; margin-top: 3px !important; }
.placa-extra { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.chip-dato { background: #F1F5FF; border: 2px solid #C9D6F2; border-radius: 99px; padding: 1px 10px; font-size: .95rem; }

.niveles { background: var(--azul-osc); color: #fff; border-radius: var(--r); padding: 10px 12px 12px; }
.niveles-titulo { margin: 0 0 8px; font-size: .95rem; }
.niveles-titulo b { color: var(--oro); font-weight: 600; }
.niveles-botones { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.nivel-btn { --c: var(--verde); border: 2px solid rgba(255, 255, 255, .35); border-radius: 12px; background: rgba(255, 255, 255, .08);
  color: #fff; padding: 6px 2px; display: grid; justify-items: center; line-height: 1.1; min-height: 56px; }
.nivel-btn b { font-size: 1.3rem; }
.nivel-btn span { font-size: .72rem; }
.nivel-btn.activo { background: var(--c); border-color: #fff; box-shadow: 0 0 0 3px var(--oro); }
.nivel-btn:disabled { opacity: .5; }

/* Pizarra de corcho */
.pizarra { position: relative; display: grid; gap: 14px; padding: 22px 16px 18px; border-radius: 22px;
  background-color: var(--corcho);
  background-image: radial-gradient(rgba(90, 50, 20, .35) 1.2px, transparent 1.6px), radial-gradient(rgba(255, 230, 190, .35) 1px, transparent 1.4px);
  background-size: 14px 14px, 19px 19px; background-position: 0 0, 7px 9px;
  border: 10px solid #8A5A2E; box-shadow: inset 0 0 0 3px rgba(0, 0, 0, .15), 0 6px 0 rgba(19, 42, 107, .25); }
.hilo { display: none; }
.pizarra::after { /* hilo rojo que une las chinchetas */ content: ""; position: absolute; left: calc(50% + 9px); top: 30px; bottom: 52px; width: 3px; z-index: 0;
  background: repeating-linear-gradient(var(--rojo) 0 7px, #b52431 7px 9px); border-radius: 2px; pointer-events: none; transform: rotate(1deg); }
.carpeta { z-index: 1; }
.carpeta { position: relative; text-align: left; border: 3px solid var(--tinta); border-radius: 6px 14px 14px 14px;
  background: var(--manila); padding: 18px 16px 14px 76px; min-height: 96px; box-shadow: 0 6px 0 rgba(0, 0, 0, .25);
  transition: transform .15s; display: grid; align-content: center; }
.carpeta::before { /* pestaña */ content: ""; position: absolute; left: -3px; top: -16px; width: 42%; height: 18px;
  background: var(--manila); border: 3px solid var(--tinta); border-bottom: 0; border-radius: 10px 10px 0 0; }
.carpeta::after { /* etiqueta de color del modo */ content: ""; position: absolute; right: 12px; top: 10px; width: 40px; height: 10px; border-radius: 4px; background: var(--c); }
.c-patrulla { --c: var(--rojo); transform: rotate(-1.2deg); }
.c-interrogatorio { --c: var(--azul); transform: rotate(.9deg); }
.c-escena { --c: var(--verde); transform: rotate(-.6deg); }
.carpeta:hover { transform: rotate(0) translateY(-3px); }
.carpeta:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.chincheta { position: absolute; top: -8px; left: 50%; width: 20px; height: 20px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ff9a9a, var(--rojo) 60%); border: 2px solid #7a1a20; z-index: 2; }
.carpeta-icono { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 50px; height: 50px; border-radius: 50%;
  background: #fff; border: 3px solid var(--c); display: grid; place-items: center; font-size: 1.6rem; }
.carpeta-nombre { font-weight: 700; font-size: 1.35rem; }
.carpeta-lema { font-family: var(--maquina); font-size: .95rem; color: #5a4520; }

.accesos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.acceso { position: relative; display: flex; align-items: center; gap: 10px; text-align: left; min-height: 60px;
  background: #fff; border: 3px solid var(--tinta); border-radius: 14px; padding: 8px 12px; font-weight: 600; box-shadow: var(--sombra); }
.acceso:active { transform: translateY(3px); box-shadow: none; }
.acceso-icono { font-size: 1.6rem; }
.acceso-sub { margin-left: auto; font-size: .8rem; color: #5a6690; font-weight: 500; }
.burbuja { position: absolute; top: -9px; right: -7px; background: var(--rojo); color: #fff; border: 2px solid #fff; min-width: 28px; height: 28px;
  border-radius: 99px; display: grid; place-items: center; font-size: .85rem; padding: 0 6px; }
.acceso:last-child { grid-column: 1 / -1; justify-content: center; }
.pie { text-align: center; font-size: .82rem; color: #4a5680; margin: 18px 0 0; }

/* ---------- APODO ---------- */
.pantalla-centro { display: grid; place-items: center; min-height: 100vh; }
.panel { width: min(460px, 100%); background: #fff; border: 3px solid var(--tinta); border-radius: 22px; padding: 18px 20px 20px; text-align: center; box-shadow: var(--sombra); }
.panel-avatar { width: 110px; margin: 0 auto; }
.panel-nota { margin: 6px 0 12px; }
.nick-fila { display: flex; gap: 8px; }
#nick { flex: 1; min-width: 0; font: inherit; font-weight: 700; font-size: 1.35rem; text-align: center; letter-spacing: .04em;
  border: 3px solid var(--tinta); border-radius: 14px; padding: 8px 10px; text-transform: uppercase; }
.nick-error { color: var(--rojo); min-height: 1.4em; margin: 6px 0; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.panel-botones { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }

/* ---------- 4. PARTIDA ---------- */
#pantalla-juego { padding: 0 0 20px; min-height: 100vh; display: flex; flex-direction: column; }
.hud { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  background: var(--azul-osc); color: #fff; }
.btn-hud { background: rgba(255, 255, 255, .12); color: #fff; border-color: rgba(255, 255, 255, .4); box-shadow: none; min-height: 44px; width: 44px; }
.hud-modo { display: flex; align-items: center; gap: 6px; min-width: 0; }
#hud-icono { font-size: 1.5rem; }
.hud-modo-txt { display: grid; line-height: 1.1; min-width: 0; }
.hud-modo-txt b { font-size: .98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-modo-txt small { font-size: .78rem; opacity: .85; white-space: nowrap; }
.hud-datos { display: flex; gap: 6px; margin-left: auto; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.hud-dato { background: rgba(255, 255, 255, .12); border-radius: 99px; padding: 2px 9px; font-size: .95rem; white-space: nowrap; }
.hud-racha.encendida { background: #ff7b22; animation: latido .8s infinite; }
.hud-vidas { letter-spacing: -2px; }
.vida.perdida { filter: grayscale(1); opacity: .35; }
.btn-lupa { border: 2px solid var(--oro); background: var(--oro); color: var(--tinta); border-radius: 99px; min-height: 44px; padding: 0 12px; font-weight: 700; }
.btn-lupa:disabled { opacity: .45; }
.barra-tiempo { height: 8px; background: rgba(19, 42, 107, .15); }
.barra-tiempo span { display: block; height: 100%; width: 100%; background: var(--verde); transition: width .2s linear; }
body.alarma .barra-tiempo span { background: var(--rojo); }
body.alarma .hud-tiempo { background: var(--rojo); animation: latido .5s infinite; }
body.alarma .hud { animation: sirenaHud 1s infinite; }
@keyframes sirenaHud { 0%, 49% { box-shadow: inset 0 -5px 0 #ff6b6b; } 50%, 100% { box-shadow: inset 0 -5px 0 #5aa2ff; } }

.zona-juego { position: relative; flex: 1; padding: 12px 14px 0; overflow-x: clip; }
.detective-hud { position: absolute; right: 8px; top: 6px; width: 66px; z-index: 3; pointer-events: none; }
.detective-hud .det { width: 100%; height: auto; }
.zona { max-width: 680px; margin: 0 auto; }
.instruccion { text-align: center; font-weight: 600; font-size: 1.15rem; margin: 6px 70px 10px; min-height: 1.4em; }
.aviso-racha, .aviso-refuerzo { position: absolute; left: 50%; transform: translateX(-50%); margin: 0; pointer-events: none; z-index: 5;
  font-weight: 700; white-space: nowrap; opacity: 0; max-width: calc(100% - 16px); overflow: hidden; text-overflow: ellipsis; }
.aviso-racha { top: 40px; color: #fff; background: #ff7b22; border: 3px solid var(--tinta); padding: 4px 14px; border-radius: 99px; }
.aviso-refuerzo { top: auto; bottom: 6px; background: #fff; border: 2px dashed var(--azul); color: var(--azul); padding: 3px 12px; border-radius: 99px; font-size: .9rem; }
.aviso-racha.ver { animation: avisoPop 1.8s ease-out; }
.aviso-refuerzo.ver { animation: avisoPop 3s ease-out; }
@keyframes avisoPop { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.7); } 12% { opacity: 1; transform: translate(-50%, 0) scale(1.08); } 20%, 80% { opacity: 1; transform: translate(-50%, 0) scale(1); } 100% { opacity: 0; transform: translate(-50%, -12px); } }

/* ---------- 5a. PATRULLA ---------- */
.mazo { position: relative; height: 260px; max-width: 420px; margin: 0 auto; touch-action: pan-y; }
.ficha { position: absolute; inset: 0; background: var(--papel); border: 3px solid var(--tinta); border-radius: 18px;
  display: grid; place-items: center; padding: 34px 18px 20px; box-shadow: 0 8px 0 rgba(19, 42, 107, .25);
  background-image: linear-gradient(transparent 36px, #ffb3b8 36px, #ffb3b8 38px, transparent 38px),
                    repeating-linear-gradient(transparent 0 37px, rgba(30, 79, 184, .12) 37px 38px);
  touch-action: none; user-select: none; cursor: grab; --ok: 0; --mal: 0; }
.ficha-fondo { transform: rotate(4deg) translateY(6px); background: var(--manila); background-image: none; cursor: default; }
.ficha.arrastrando { cursor: grabbing; transition: none; }
.ficha.entra { animation: fichaEntra .28s ease-out; }
@keyframes fichaEntra { from { transform: translateY(-24px) scale(.94) rotate(-3deg); opacity: 0; } }
.ficha.sale-der { transition: transform .3s ease-in, opacity .3s; transform: translateX(130%) rotate(18deg) !important; opacity: 0; }
.ficha.sale-izq { transition: transform .3s ease-in, opacity .3s; transform: translateX(-130%) rotate(-18deg) !important; opacity: 0; }
.ficha-num { position: absolute; top: 8px; left: 16px; font-family: var(--maquina); font-size: .9rem; color: #5a6690; }
.ficha-texto { font-weight: 700; font-size: clamp(2.2rem, 11vw, 3.4rem); text-align: center; line-height: 1.1; word-break: break-word; }
.ficha-texto.larga { font-size: clamp(1.5rem, 6.4vw, 2.2rem); }
.ficha-texto.muy-larga { font-size: clamp(1.2rem, 5vw, 1.6rem); font-weight: 600; }
.ficha-huella { position: absolute; right: 14px; bottom: 12px; width: 44px; height: 54px; border-radius: 50% 50% 46% 46%; opacity: .16;
  background: repeating-radial-gradient(ellipse at 50% 60%, var(--tinta) 0 2px, transparent 2px 5px); }
.sello { position: absolute; top: 44%; font-family: var(--maquina); font-size: 1.6rem; padding: 2px 12px; border: 4px solid; border-radius: 8px;
  pointer-events: none; opacity: 0; }
.sello-ok { left: 14px; color: var(--verde); transform: rotate(-14deg); opacity: var(--ok); }
.sello-mal { right: 14px; color: var(--rojo); transform: rotate(12deg); opacity: var(--mal); }
.ficha.marca-ok .sello-ok, .ficha.marca-mal .sello-mal { opacity: 1; animation: sellar .25s ease-out; }
@keyframes sellar { from { transform: scale(2) rotate(-14deg); opacity: 0; } }
.pista-carta { max-width: 420px; margin: 14px auto 0; background: #FFF4C9; border: 2px dashed var(--oro-osc); border-radius: 12px; padding: 8px 12px; text-align: center; }
.deslizar { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 480px; margin: 22px auto 0; }
.btn-decision { min-height: 70px; border-radius: 18px; border: 3px solid var(--tinta); font-weight: 700; font-size: 1.15rem; color: #fff; box-shadow: 0 6px 0 var(--tinta); }
.btn-decision:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--tinta); }
.btn-decision.mal { background: var(--rojo); }
.btn-decision.bien { background: var(--verde); }
.ayuda-teclas { text-align: center; font-size: .85rem; color: #5a6690; margin: 10px 0 0; }

/* ---------- 5b. INTERROGATORIO ---------- */
.declaracion { position: relative; margin-top: 18px; background: var(--papel); border: 3px solid var(--tinta); border-radius: 16px; padding: 30px 18px 22px;
  box-shadow: 0 6px 0 rgba(19, 42, 107, .2); text-align: center; }
.declaracion.entra { animation: fichaEntra .3s ease-out; }
.declaracion-cinta { position: absolute; top: -14px; left: 50%; transform: translateX(-50%) rotate(-1.5deg); white-space: nowrap;
  background: var(--oro); border: 2px solid var(--tinta); padding: 2px 14px; font-family: var(--maquina); font-size: .9rem; }
.declaracion.duelo .declaracion-cinta { background: #ffd1f0; }
.declaracion-texto { margin: 0; font-size: clamp(1.35rem, 5.4vw, 1.9rem); font-weight: 600; line-height: 1.35; }
.hueco { display: inline-block; min-width: 3.2em; border-bottom: 4px dashed var(--azul); color: var(--azul); padding: 0 .2em; }
.hueco.bien { color: var(--verde); border-color: var(--verde); border-bottom-style: solid; }
.hueco.mal { color: var(--rojo); border-color: var(--rojo); border-bottom-style: solid; text-decoration: line-through; }
.interrogante { color: #5a6690; font-family: var(--maquina); font-weight: 400; font-size: 1.15rem; }
.opciones { display: grid; gap: 10px; margin-top: 18px; }
.opciones.dos { grid-template-columns: 1fr 1fr; align-items: stretch; }
.opciones.dos:has(.vs) { grid-template-columns: 1fr auto 1fr; }
.opciones.dos.largas { grid-template-columns: 1fr; }
.opciones.dos.largas .vs { display: none; }
.vs { align-self: center; font-weight: 700; color: var(--rojo); font-size: 1.3rem; }
.opcion { display: flex; align-items: center; gap: 10px; min-height: 64px; text-align: left; background: #fff; border: 3px solid var(--tinta);
  border-radius: 16px; padding: 8px 14px; font-size: 1.3rem; font-weight: 600; box-shadow: 0 5px 0 var(--tinta); }
.opciones.dos:not(.largas) .opcion { justify-content: center; text-align: center; font-size: 1.45rem; }
.opcion:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--tinta); }
.opcion-letra { flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--azul); color: #fff; display: grid; place-items: center; font-size: 1rem; }
.opciones.dos:not(.largas) .opcion-letra { display: none; }
.opcion.correcta, .opcion.era-correcta { background: #D9F7E6; border-color: var(--verde); box-shadow: 0 5px 0 var(--verde); }
.opcion.incorrecta { background: #FFE1E3; border-color: var(--rojo); box-shadow: 0 5px 0 var(--rojo); animation: sacude .35s; }
.opcion.descartada { opacity: .3; text-decoration: line-through; }
.opcion:disabled:not(.correcta):not(.incorrecta):not(.era-correcta) { opacity: .55; }
#pista-int { max-width: none; }

/* ---------- 5c. ESCENA DEL CRIMEN ---------- */
.documento { position: relative; margin: 0 auto; padding: 18px 16px; border: 3px solid var(--tinta); box-shadow: 0 6px 0 rgba(19, 42, 107, .2); }
.documento.entra { animation: fichaEntra .35s ease-out; }
.doc-linea { margin: 0 0 8px; line-height: 2.1; }
.palabra { border: 0; background: none; padding: 2px 3px; border-radius: 8px; font-size: 1.22rem; font-weight: 500; position: relative;
  line-height: 1.3; min-height: 36px; }
.palabra:hover { background: rgba(255, 200, 61, .35); }
.palabra.atrapada { background: #D9F7E6; outline: 3px solid var(--verde); border-radius: 50%; padding: 4px 10px; animation: atrapar .45s ease-out; }
.palabra.escapada { background: #FFE1E3; outline: 3px dashed var(--rojo); border-radius: 10px; }
.palabra s { color: var(--rojo); opacity: .8; }
.corregida { color: var(--verde); font-weight: 700; }
.palabra.inocente { animation: sacude .4s; background: #eee; }
.palabra.sospechosa { background: #FFF1B8; box-shadow: 0 0 0 3px var(--oro); animation: latido .7s infinite; }
.atrapado-sello { position: absolute; left: 50%; top: -1.3em; transform: translateX(-50%) rotate(-6deg); font-family: var(--maquina); font-size: .72rem;
  color: #fff; background: var(--rojo); padding: 0 6px; border-radius: 4px; white-space: nowrap; animation: sellar .3s ease-out; }
@keyframes atrapar { 0% { transform: scale(1.4); } 60% { transform: scale(.95); } }
.doc-carta { background: var(--papel); border-radius: 4px; transform: rotate(-.5deg);
  background-image: repeating-linear-gradient(transparent 0 41px, rgba(30, 79, 184, .12) 41px 42px); padding-top: 12px; }
.doc-remite { font-family: var(--maquina); color: #5a6690; margin: 0 0 6px; }
.doc-cartel { background: #FFF6D6; border-radius: 22px; border-width: 5px; text-align: center; outline: 4px dashed var(--rojo); outline-offset: -14px; padding: 26px 18px; }
.doc-cartel .doc-linea:first-child .palabra { font-weight: 700; font-size: 1.5rem; color: var(--azul-osc); }
.doc-lista { background: #fff; border-radius: 6px; max-width: 420px; background-image: linear-gradient(90deg, transparent 38px, #ffb3b8 38px, #ffb3b8 40px, transparent 40px); padding-left: 52px; }
.doc-lista .doc-linea { margin: 0; border-bottom: 1px solid #DCE4F5; line-height: 1.8; }
.doc-lista .doc-linea::before { content: "☐ "; color: #9aa6c8; }
.doc-titulo { font-weight: 700; margin: 0 0 6px; }

/* ---------- 6. HOJA DE EXPLICACIÓN ---------- */
.hoja { position: fixed; top: 0; left: 0; width: 100%; height: 100vh; height: 100dvh; z-index: 50; display: flex; flex-direction: column;
  justify-content: flex-end; align-items: center; background: rgba(19, 42, 107, .45); overscroll-behavior: contain; }
.hoja-caja { width: 100%; max-width: 560px; max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); display: flex; flex-direction: column;
  background: #fff; border: 3px solid var(--tinta); border-bottom: 0; border-radius: 24px 24px 0 0; text-align: center; animation: subir .25s ease-out; overflow: hidden; }
.hoja-cuerpo { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 14px 18px 4px; }
.hoja-cuerpo > * { overflow-wrap: anywhere; }
@keyframes subir { from { transform: translateY(100%); } }
.hoja-sello { font-size: 2.4rem; margin: 0; line-height: 1; }
.hoja h2 { font-size: 1.55rem; margin-top: 4px; }
.hoja.bien h2 { color: var(--verde); }
.hoja.mal h2 { color: var(--rojo); }
.hoja-correcta { font-size: 1.2rem; margin: 10px 0 4px; }
.hoja-correcta b { font-size: 1.3rem; background: #D9F7E6; padding: 0 6px; border-radius: 6px; }
.hoja-explicacion { margin: 6px 0; }
.hoja-truco { background: #FFF4C9; border: 2px dashed var(--oro-osc); border-radius: 14px; padding: 8px 12px; margin: 10px 0 0; text-align: left; }
.hoja-truco b { display: block; font-size: .85rem; color: #8a6200; }
.hoja-lista ul { list-style: none; padding: 0; margin: 10px 0 0; text-align: left; display: grid; gap: 6px; }
.hoja-lista li { background: #F4F7FF; border-radius: 12px; padding: 6px 10px; }
.hoja-lista li.no { background: #FFF0F1; }
.hoja-lista s { color: var(--rojo); }
.hoja-lista small { display: block; color: #4a5680; }
.hoja-botones { flex: none; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; padding: 10px 18px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 2px solid #E6ECF8; background: #fff; }
.hoja-botones .btn { flex: 1 1 160px; min-height: 50px; }

.cuenta { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(19, 42, 107, .55); }
#cuenta-txt { font-size: clamp(3rem, 16vw, 6rem); font-weight: 700; color: #fff; text-shadow: 0 6px 0 var(--rojo); text-align: center; }
#cuenta-txt.pop { animation: pop .4s ease-out; }
@keyframes pop { from { transform: scale(2.2); opacity: 0; } }

/* ---------- FIN ---------- */
.pantalla-lista { max-width: 720px; margin: 0 auto; }
#pantalla-fin { text-align: center; }
.fin-cartel { display: inline-block; background: var(--rojo); color: #fff; border: 4px solid var(--tinta); border-radius: 18px; padding: 8px 22px 10px;
  transform: rotate(-2deg); box-shadow: var(--sombra); margin-top: 8px; }
.fin-sirena { margin: 0; font-size: 2rem; line-height: 1; }
.fin-cartel h2 { font-size: clamp(1.7rem, 7vw, 2.4rem); }
.fin-subtitulo { margin: 4px 0 0; font-weight: 500; }
.fin-avatar { width: 110px; margin: 10px auto 0; }
.fin-estrellas { font-size: 2.8rem; letter-spacing: 6px; color: #C9D2EA; }
.fin-estrellas span.on { color: var(--oro); text-shadow: 0 3px 0 var(--oro-osc); display: inline-block; animation: estrellaGira .6s backwards; }
@keyframes estrellaGira { from { transform: scale(0) rotate(-180deg); } }
.fin-datos { list-style: none; padding: 0; margin: 10px auto; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; max-width: 480px; }
.fin-datos li { background: #fff; border: 2px solid var(--tinta); border-radius: 14px; padding: 8px; }
.fin-datos .fin-puntos { grid-column: 1 / -1; font-size: 1.5rem; background: var(--oro); }
.fin-mult { font-size: .95rem; color: #4a5680; margin: 4px 0; }
.fin-guardado { font-weight: 600; margin: 6px 0; min-height: 1.4em; }
.fin-guardado.ok { color: var(--verde); }
.fin-guardado.local { color: #8a6200; }
.fin-casos h3 { font-family: var(--maquina); font-weight: 400; margin: 14px 0 6px; }
.fin-casos ul { list-style: none; padding: 0; margin: 0 auto; max-width: 480px; display: grid; gap: 6px; }
.fin-casos li { display: flex; justify-content: space-between; gap: 10px; background: var(--manila); border: 2px solid var(--tinta); border-radius: 10px; padding: 6px 12px; text-align: left; flex-wrap: wrap; }
.c-mal { color: #a4161f; text-decoration: line-through; }
.c-ok { font-weight: 700; color: #0d5f36; }
.fin-botones { display: grid; gap: 10px; max-width: 420px; margin: 18px auto 0; }

/* ---------- 7. LISTAS ---------- */
.barra { display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 10px; margin-bottom: 12px; }
.barra h2 { font-size: 1.45rem; text-align: center; }
.barra-dato { font-weight: 700; background: #fff; border: 2px solid var(--tinta); border-radius: 99px; padding: 2px 10px; }
.nota-seccion { text-align: center; color: #4a5680; font-size: .92rem; }
.segmentos { display: flex; background: #fff; border: 3px solid var(--tinta); border-radius: 14px; padding: 3px; gap: 3px; margin-bottom: 12px; }
.seg { flex: 1; border: 0; background: none; border-radius: 10px; min-height: 44px; font-weight: 600; }
.seg[aria-pressed="true"], .seg[aria-selected="true"] { background: var(--azul); color: #fff; }
.seg b { background: rgba(0, 0, 0, .12); border-radius: 99px; padding: 0 8px; margin-left: 4px; }
.vacio { text-align: center; font-size: 1.1rem; padding: 20px; }

.lista-casos { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 14px; }
.caso { background: var(--papel); border: 3px solid var(--tinta); border-radius: 6px 16px 16px 16px; padding: 12px 14px; box-shadow: var(--sombra); position: relative; }
.caso p { margin: 2px 0; }
.caso-num { font-family: var(--maquina); color: #5a6690; }
.caso-mal span { color: #a4161f; text-decoration: line-through; font-weight: 600; }
.caso-ok span { color: #0d5f36; font-weight: 700; font-size: 1.1rem; }
.caso-estado { font-weight: 600; }
.caso .btn { margin-top: 8px; width: 100%; }
.caso.resuelto::after { content: "RESUELTO"; position: absolute; right: 12px; top: 14px; font-family: var(--maquina); color: var(--verde);
  border: 3px solid var(--verde); padding: 0 8px; transform: rotate(10deg); border-radius: 6px; }

.lista-archivos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.archivos-nivel { grid-column: 1 / -1; margin-top: 10px; font-size: 1.1rem; color: var(--azul-osc); }
.archivo { text-align: left; background: #CFD6E6; border: 3px solid var(--tinta); border-radius: 4px 12px 12px 12px; padding: 10px; min-height: 110px;
  display: grid; align-content: space-between; gap: 4px; filter: saturate(.3); }
.archivo.abierto { background: var(--manila); filter: none; box-shadow: var(--sombra); }
.archivo-num { font-family: var(--maquina); font-size: .78rem; }
.archivo-titulo { font-weight: 700; line-height: 1.15; }
.archivo-estado { font-size: .85rem; }
.archivo-abierto h2 { margin: 6px 0; }
.archivo-ejemplos { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.archivo-ejemplos span { background: #E8F0FF; border-radius: 99px; padding: 2px 10px; font-weight: 600; }

.lista-medallas { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.medalla-item { display: flex; align-items: center; gap: 12px; background: #fff; border: 3px solid var(--tinta); border-radius: 16px; padding: 10px 14px; opacity: .6; }
.medalla-item.conseguida { opacity: 1; background: #FFF4C9; box-shadow: var(--sombra); }
.medalla-item span:nth-child(2) { flex: 1; display: grid; }
.medalla-item small { color: #4a5680; }
.medalla-icono { font-size: 2rem; width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: #E6ECF8; border: 3px solid var(--tinta); filter: grayscale(1); }
.conseguida .medalla-icono { background: var(--oro); filter: none; }

.rk-filtros { display: grid; gap: 8px; }
.rk-selects { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rk-selects select { width: 100%; font: inherit; font-weight: 600; min-height: 46px; border: 3px solid var(--tinta); border-radius: 12px; padding: 0 8px; background: #fff; color: var(--tinta); }
.rk-tabla { background: #fff; border: 3px solid var(--tinta); border-radius: 16px; overflow: hidden; margin-top: 12px; }
.rk-cabecera, .rk-lista li { display: grid; grid-template-columns: 70px 1fr 90px 90px; align-items: center; gap: 6px; padding: 8px 12px; }
.rk-cabecera { background: var(--azul-osc); color: #fff; font-size: .82rem; font-weight: 600; }
.rk-lista { list-style: none; margin: 0; padding: 0; }
.rk-lista li:nth-child(odd) { background: #F4F7FF; }
.rk-lista li.yo { background: #FFF4C9; font-weight: 700; }
.rk-pos { font-size: 1.3rem; text-align: center; }
.rk-nick { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.rk-caso { font-size: .88rem; }
.rk-pts { text-align: right; font-weight: 700; }
.rk-estado { text-align: center; padding: 12px; margin: 0; }
.rk-estado:empty { display: none; }

.opciones-lista { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.opciones-lista li { display: flex; align-items: center; gap: 12px; justify-content: space-between; background: #fff; border: 3px solid var(--tinta); border-radius: 16px; padding: 10px 14px; }
.opciones-lista li span { display: grid; }
.opciones-lista small { color: #4a5680; }
.interruptor { flex: none; width: 64px; height: 36px; border-radius: 99px; border: 3px solid var(--tinta); background: #C9D2EA; position: relative; }
.interruptor::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 2px solid var(--tinta); transition: left .2s; }
.interruptor[aria-checked="true"] { background: var(--verde); }
.interruptor[aria-checked="true"]::after { left: 29px; }

/* ---------- CAPAS ---------- */
.capa { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: rgba(19, 42, 107, .6); padding: 16px; }
.modal-caja { width: min(480px, 100%); max-height: 88vh; overflow: auto; background: #fff; border: 3px solid var(--tinta); border-radius: 22px; padding: 18px 20px; text-align: center; animation: pop .25s ease-out; }
.ascenso { --rango: var(--oro); position: relative; overflow: hidden; width: min(440px, 100%); background: #fff; border: 4px solid var(--tinta); border-radius: 26px; padding: 22px 20px; text-align: center; animation: pop .4s ease-out; }
.asc-rayos { position: absolute; inset: -50%; background: repeating-conic-gradient(from 0deg, rgba(255, 200, 61, .25) 0 10deg, transparent 10deg 20deg); animation: gira 12s linear infinite; }
.ascenso > *:not(.asc-rayos) { position: relative; }
.asc-insignia { font-size: 4.5rem; margin: 0; line-height: 1; animation: insignia 1s ease-out; }
@keyframes insignia { from { transform: rotateY(720deg) scale(.2); } }
.asc-rango { font-size: 1.5rem; font-weight: 700; color: var(--rango); margin: 6px 0; }
.asc-premio { font-weight: 600; }
@keyframes gira { to { transform: rotate(360deg); } }

/* ---------- 8. EFECTOS ---------- */
.flotante { position: absolute; z-index: 30; transform: translate(-50%, 0); font-weight: 700; font-size: 1.3rem; pointer-events: none;
  animation: flota 1.1s ease-out forwards; text-shadow: 0 2px 0 #fff; white-space: nowrap; }
.flotante.ok { color: var(--verde); }
.flotante.mal { color: var(--rojo); }
@keyframes flota { to { transform: translate(-50%, -60px); opacity: 0; } }
@keyframes latido { 50% { transform: scale(1.08); } }
@keyframes sacude { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 140%); z-index: 90;
  background: var(--tinta); color: #fff; padding: 10px 18px; border-radius: 16px; font-weight: 600; width: max-content; max-width: calc(100vw - 24px); text-align: center;
  transition: transform .25s, opacity .25s; pointer-events: none; opacity: 0; visibility: hidden; }
.toast.visible { transform: translate(-50%, 0); opacity: 1; visibility: visible; }
.toast.archivo, .toast.medalla { background: var(--manila); color: var(--tinta); border: 3px solid var(--tinta); }
.toast.caso { background: var(--verde); }
.medalla-gira { display: inline-block; animation: insignia 1s ease-out; font-size: 1.4rem; }
.confeti { position: fixed; inset: 0; pointer-events: none; z-index: 95; overflow: hidden; }
.confeti span { position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 2px; animation: caer 2s ease-in forwards; }
.confeti span.estrella { clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); width: 16px; height: 16px; }
@keyframes caer { to { transform: translate(var(--x), 105vh) rotate(var(--giro)); } }

/* Caras del detective */
.det .boca, .det .gota { display: none; }
.det[data-cara="normal"] .b-normal, .det[data-cara="feliz"] .b-feliz, .det[data-cara="sorpresa"] .b-sorpresa,
.det[data-cara="nervioso"] .b-nervioso, .det[data-cara="nervioso"] .gota { display: block; }
.det[data-cara="feliz"] { animation: salto .5s; }
.det[data-cara="sorpresa"] .cejas { transform: translateY(-4px); }
.det[data-cara="nervioso"] { animation: tiembla .25s infinite; }
.det .lupa-det { transform-origin: 100px 100px; animation: lupaMueve 3s ease-in-out infinite; }
@keyframes salto { 40% { transform: translateY(-10px); } }
@keyframes tiembla { 50% { transform: translateX(2px) rotate(1deg); } }
@keyframes lupaMueve { 50% { transform: rotate(-12deg); } }

/* Menos animaciones */
body.calma *, body.calma *::before, body.calma *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- 9. RESPONSIVE ---------- */
@media (min-width: 700px) {
  .pantalla { padding: 18px 24px 36px; }
  .comisaria { grid-template-columns: 1.1fr 1fr; align-items: start; }
  .placa, .niveles { grid-column: 1; }
  .pizarra { grid-column: 2; grid-row: 1 / span 3; }
  .accesos { grid-column: 1; }
  .placa-avatar { width: 110px; }
  .mazo { height: 300px; }
  .zona-juego { padding-top: 18px; }
  .detective-hud { width: 90px; right: 20px; }
  .hoja { justify-content: center; padding: 16px; }
  .hoja-caja { border-radius: 24px; border-bottom: 3px solid var(--tinta); }
  .fin-datos { grid-template-columns: repeat(4, 1fr); }
  .fin-datos .fin-puntos { grid-column: 1 / -1; }
}
@media (min-width: 980px) {
  .comisaria { grid-template-columns: 1fr 1.1fr 1fr; }
  .placa { grid-column: 1; grid-row: 1; }
  .niveles { grid-column: 1; grid-row: 2; }
  .accesos { grid-column: 3; grid-row: 1 / span 2; grid-template-columns: 1fr; }
  .acceso:last-child { justify-content: flex-start; }
  .pizarra { grid-column: 2; grid-row: 1 / span 2; }
}
@media (max-width: 420px) {
  body { font-size: 16px; }
  .hud { gap: 5px; padding: 6px; }
  .hud-modo-txt small { display: none; }
  .hud-dato { padding: 2px 6px; font-size: .88rem; }
  .instruccion { margin-right: 58px; margin-left: 0; text-align: left; font-size: 1.02rem; }
  .detective-hud { width: 54px; }
  .carpeta { padding-left: 70px; }
  .rk-cabecera, .rk-lista li { grid-template-columns: 44px 1fr 70px 70px; padding: 8px; }
  .opciones.dos:not(.largas) .opcion { font-size: 1.2rem; }
  .palabra { font-size: 1.1rem; }
}
.hoja-correcta s { color: var(--rojo); }
/* Placa-estrella del rango */
.estrella-placa { --c: var(--verde); display: inline-grid; place-items: center; width: 1.5em; height: 1.5em; vertical-align: -.35em;
  background: var(--oro); clip-path: polygon(50% 0, 61% 32%, 96% 32%, 68% 53%, 79% 88%, 50% 67%, 21% 88%, 32% 53%, 4% 32%, 39% 32%); }
.estrella-placa b { display: grid; place-items: center; width: 52%; height: 52%; border-radius: 50%; background: var(--c); color: #fff; font-size: .55em; margin-top: 8%; }
.asc-insignia .estrella-placa { width: 1.3em; height: 1.3em; filter: drop-shadow(0 4px 0 var(--oro-osc)); }
/* Modo oscuro del sistema: el juego mantiene su identidad clara, solo se atenúa la pared */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --pared: #B9CCF0; } }
:root[data-theme="dark"] { --pared: #B9CCF0; }

/* Pantallas bajitas (móvil en horizontal o con barras grandes): hoja más compacta */
@media (max-height: 640px) {
  .hoja-sello { font-size: 1.7rem; }
  .hoja h2 { font-size: 1.25rem; }
  .hoja-correcta { font-size: 1.05rem; margin-top: 4px; }
  .hoja-correcta b { font-size: 1.1rem; }
  .hoja-truco, .hoja-explicacion { font-size: .95rem; }
  .hoja-botones { padding-top: 8px; }
  .hoja-botones .btn { min-height: 46px; }
}
/* Móviles muy estrechos (320 px) */
@media (max-width: 360px) {
  .pantalla { padding-left: 10px; padding-right: 10px; }
  .placa { gap: 8px; padding: 10px; }
  .placa-avatar { width: 70px; }
  .niveles-botones { gap: 4px; }
  .nivel-btn span { font-size: .62rem; }
  .accesos { grid-template-columns: 1fr; }
  .hud-datos { gap: 4px; }
  .btn-lupa { padding: 0 8px; }
  .hoja-botones .btn { flex-basis: 100%; }
}
body.con-hoja { overflow: hidden; }
