/* BACKROOMS no-clip — estética terminal sucio / Darkwood */
@font-face { font-family: 'Press Start 2P'; src: url('../assets/fonts/PressStart2P-Regular.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'VT323'; src: url('../assets/fonts/VT323-Regular.ttf') format('truetype'); font-display: swap; }
* { box-sizing: border-box; margin: 0; padding: 0; }
#virtual-cursor { position: fixed; width: 14px; height: 14px; background: rgba(217,198,110,0.8); border: 2px solid #fff; border-radius: 50%; pointer-events: none; z-index: 999999; display: none; transform: translate(-50%, -50%); box-shadow: 0 0 8px #000; transition: transform 0.05s linear; }
#virtual-cursor.vc-active { transform: translate(-50%, -50%) scale(0.8); background: #fff; border-color: var(--amarillo); }
:root {
  --amarillo: #d9c66e;
  --amarillo-osc: #8a7a3d;
  --hueso: #efe8d0;
  --gris: #9a9482;
  --rojo: #c94a3a;
  --verde: #6aa86a;
  --panel: #14120d;
  --borde: #3a352a;
  --font-title: 'Press Start 2P', 'Courier New', monospace;
  --font-body: 'VT323', 'Courier New', monospace;
  /* --marco (border-image 9-slice) lo inyecta js/ui/icons.js al cargar */
}
html, body { height: 100%; background: #060504; color: var(--hueso);
  font-family: var(--font-body); overflow: hidden; }
#app { height: 100vh; display: flex; align-items: center; justify-content: center; }

/* iconos pixel-art (js/ui/icons.js) */
.icono { image-rendering: pixelated; vertical-align: -3px; }

/* capa de fundido entre pantallas (cosmética; el cambio real es síncrono) */
#fade { position: fixed; inset: 0; background: #000; opacity: 0;
  pointer-events: none; transition: opacity .28s ease-out; z-index: 60; }

/* marco pixel-art 9-slice para paneles importantes */
.marco { border: 8px solid transparent;
  border-image: var(--marco) 8 fill stretch; background: none; }

.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: flex-start; background: radial-gradient(ellipse at center, #0c0a06 0%, #050403 80%); z-index: 20;
  overflow-y: auto; padding: 24px 12px; -webkit-overflow-scrolling: touch; }

/* ---------- título ---------- */
.title-box { text-align: center; max-width: 640px; padding: 26px 32px; margin: auto; }
.title-box h1 { font-family: var(--font-title); font-size: 38px; letter-spacing: 8px;
  color: var(--amarillo); line-height: 1.3;
  text-shadow: 0 0 24px rgba(217,198,110,.35), 4px 4px 0 #000; margin-bottom: 10px; }
.glitch { animation: flicker 4s infinite; }
@keyframes flicker {
  0%,93%,100% { opacity: 1; } 94% { opacity: .6; } 95% { opacity: 1; }
  96% { opacity: .3; } 97% { opacity: 1; }
}
.subtitle { color: var(--gris); letter-spacing: 3px; margin-bottom: 28px; font-size: 17px; }
.intro-text { color: var(--hueso); line-height: 1.6; margin-bottom: 5px; font-size: 19px; }
.backrooms-census { display: inline-flex; align-items: center; gap: 9px; min-height: 21px;
  margin: 0 auto 11px; padding: 1px 9px; border: 1px solid rgba(217,198,110,.22);
  border-radius: 2px; background: rgba(9,8,5,.58); color: #948c70; font-size: 14px;
  letter-spacing: .6px; white-space: nowrap; box-shadow: inset 0 0 14px rgba(0,0,0,.45); }
.census-signal { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%;
  background: #8f844e; box-shadow: 0 0 7px rgba(217,198,110,.65);
  animation: census-pulse 2.8s ease-in-out infinite; }
.backrooms-census.census-offline { color: #716c5c; border-color: rgba(130,125,105,.15); }
.backrooms-census.census-offline .census-signal { background: #514f46; box-shadow: none; animation: none; }
@keyframes census-pulse {
  0%, 100% { opacity: .45; }
  50% { opacity: 1; box-shadow: 0 0 11px rgba(217,198,110,.9); }
}
.seed-row { margin-bottom: 18px; color: var(--gris); font-size: 16px; }
.seed-row input { background: #0a0906; border: 1px solid var(--borde); color: var(--amarillo);
  font-family: inherit; font-size: 16px; padding: 6px 10px; width: 180px; }
.room-row { margin: -4px 0 18px; color: var(--gris); font-size: 15px; }
.room-row input { background: #0a0906; border: 1px solid var(--borde); color: var(--amarillo);
  font-family: inherit; font-size: 15px; padding: 6px 10px; width: 180px; }
.hint { margin-top: 26px; color: #6a6455; font-size: 15px; line-height: 1.7; }

.btn-big { display: inline-block; background: var(--amarillo-osc); color: #0a0906;
  border: 2px solid var(--amarillo); font-family: var(--font-title);
  font-size: 13px; letter-spacing: 2px; padding: 15px 30px; cursor: pointer;
  box-shadow: 0 0 18px rgba(217,198,110,.15); transition: all .15s; }
.btn-big:hover { background: var(--amarillo); box-shadow: 0 0 28px rgba(217,198,110,.4); }
.btn-big:active { transform: translateY(2px); box-shadow: 0 0 10px rgba(217,198,110,.2); }
.btn-small { display: inline-block; background: transparent; color: var(--gris);
  border: 1px solid var(--borde); font-family: inherit; font-size: 16px;
  padding: 7px 16px; cursor: pointer; margin-top: 12px; transition: all .12s; }
.btn-small:hover { color: var(--hueso); border-color: var(--gris); }
.btn-small:active { transform: translateY(1px); }
/* botón discreto de partida en solitario, bajo el DESPERTAR grande */
.btn-offline { display: block; margin: 7px auto 0; padding: 3px 10px;
  background: transparent; color: var(--gris); border: 1px solid var(--borde);
  font-family: inherit; font-size: 13px; letter-spacing: 1px; cursor: pointer;
  opacity: .8; transition: all .12s; }
.btn-offline:hover { color: var(--hueso); border-color: var(--gris); opacity: 1; }
.btn-offline:active { transform: translateY(1px); }
/* aviso sutil de "hay novedades" (changelog no visto): desaparece al abrirlo */
.btn-small.novedad { border-color: var(--amarillo); color: var(--amarillo);
  animation: glow-novedad 2.2s ease-in-out infinite; }
@keyframes glow-novedad {
  0%, 100% { box-shadow: 0 0 4px rgba(217,198,110,.25); }
  50% { box-shadow: 0 0 13px rgba(217,198,110,.75); }
}
@media (prefers-reduced-motion: reduce) {
  .btn-small.novedad { animation: none; box-shadow: 0 0 10px rgba(217,198,110,.5); }
  .census-signal { animation: none; }
}

/* ---------- tarjeta de nivel ---------- */
.level-card { max-width: 680px; width: 92%; padding: 34px 38px; position: relative;
  border: 8px solid transparent; border-image: var(--marco) 8 fill stretch;
  box-shadow: 0 0 60px rgba(0,0,0,.9); margin: auto; }
.level-card.card-in { animation: card-in .35s ease-out; }
@keyframes card-in { from { opacity: 0; transform: translateY(16px); } }
.card-danger { position: absolute; top: -4px; left: -4px; right: -4px; height: 5px; }
.level-card h2 { font-family: var(--font-title); color: var(--amarillo);
  font-size: 17px; line-height: 1.5; margin-bottom: 8px; }
.card-class { color: var(--gris); font-size: 16px; letter-spacing: 1px; margin-bottom: 18px; }
.card-desc { line-height: 1.55; font-size: 19px; margin-bottom: 16px; }
.card-quote { border-left: 3px solid var(--amarillo-osc); padding-left: 14px;
  color: #b8ad8a; font-style: italic; font-size: 17px; margin-bottom: 18px; }
.card-rules { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.card-rules span { background: #201c12; border: 1px solid var(--borde);
  padding: 4px 10px; font-size: 15px; color: #cfc49a; display: inline-flex;
  align-items: center; gap: 5px; }
.card-foot { display: flex; align-items: center; justify-content: space-between; }
.card-foot a { color: #7a90a8; font-size: 15px; }

/* ---------- juego ---------- */
#screen-game { position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; background: #030302; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
#game-wrap { position: relative; width: var(--game-w, 960px); height: var(--game-h, 600px);
  max-width: 100vw; max-height: calc(var(--vh, 1vh) * 100); touch-action: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#game-canvas { display: block; width: 100%; height: 100%; background: #000; border: 1px solid #22201a;
  box-shadow: 0 0 80px rgba(0,0,0,1); image-rendering: pixelated; touch-action: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#gl-canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 1px solid #22201a; touch-action: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#smiler-threat {
  position: fixed; left: 50%; top: 50%; width: 48px; height: 48px;
  z-index: 35; pointer-events: none; opacity: 0;
  image-rendering: pixelated; image-rendering: crisp-edges;
  transform: translate(-50%, -50%) scale(.5);
  filter: drop-shadow(0 0 12px rgba(255,255,255,.95)) drop-shadow(0 0 38px rgba(255,45,20,.8));
  transition: opacity .12s linear, transform .12s linear;
}
body.smiler-death #smiler-threat { opacity: 0 !important; }
body.smiler-death .end-box::before {
  content: ''; position: absolute; inset: -120px; pointer-events: none; z-index: -1;
  background: url('../assets/sprites/smiler.png') center 34% / min(74vw, 680px) auto no-repeat;
  image-rendering: pixelated; opacity: .26;
  filter: drop-shadow(0 0 42px rgba(255,60,30,.8));
}
body.smiler-death .end-box { position: relative; z-index: 1; overflow: visible; }
#game-wrap.modo3d #game-canvas { position: relative; background: transparent; box-shadow: none; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 90px; height: 4px;
  background: #3a352a; outline: none; cursor: pointer; vertical-align: middle; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 12px; height: 12px;
  background: var(--amarillo); border: 1px solid #0a0906; cursor: pointer; }
input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px; border: 1px solid #0a0906; background: var(--amarillo); cursor: pointer; border-radius: 0; }
/* v16: botón-pergamino del registro completo + moodles de estado (arriba) */
#btn-log { position: absolute; top: 10px; left: 10px; width: 28px; height: 28px;
  background: rgba(10,9,6,.72); border: 1px solid var(--borde); cursor: pointer;
  display: flex; align-items: center; justify-content: center; z-index: 12; }
#btn-log:hover { border-color: var(--amarillo-osc); box-shadow: 0 0 8px rgba(217,198,110,.25); }
/* botón táctil de Ajustes (equivale a ESC, que no existe en móvil); oculto
   en escritorio (la tecla ESC ya hace lo mismo), a la izquierda de btn-log */
#btn-esc { display: none; position: absolute; top: 10px; left: 10px; width: 28px; height: 28px;
  background: rgba(10,9,6,.72); border: 1px solid var(--borde); cursor: pointer;
  align-items: center; justify-content: center; z-index: 12; }
#btn-esc:hover { border-color: var(--amarillo-osc); box-shadow: 0 0 8px rgba(217,198,110,.25); }
#log-panel { position: absolute; top: 44px; left: 10px; width: 360px; max-height: 68%;
  overflow: auto; background: rgba(12,11,7,.95); border: 1px solid var(--borde);
  padding: 12px 16px; z-index: 13; }
#log-panel h3 { color: var(--amarillo); font-size: 16px; margin-bottom: 8px; }
#log-full p { font-size: 14px; line-height: 1.45; color: #cfc8b0; margin-bottom: 1px; }
#log-full p.danger { color: #e88a7a; } #log-full p.good { color: #a8d8a0; }
#log-full p.event { color: #d8c88a; font-style: italic; }
#moodles { position: absolute; top: 10px; right: 10px; display: flex;
  flex-direction: column; gap: 6px; align-items: flex-end; pointer-events: auto; }
.moodle { width: 34px; height: 34px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; background: rgba(10,9,6,.75);
  border: 2px solid; box-shadow: 0 0 6px rgba(0,0,0,.6); }
.moodle-1 { border-color: #d9a531; }
.moodle-2 { border-color: #e0742c; }
.moodle-3 { border-color: #d94a35; animation: moodle-pulse 1.1s infinite; }
@keyframes moodle-pulse { 50% { transform: scale(1.14); box-shadow: 0 0 12px rgba(217,74,53,.55); } }

/* v15: HUD limpio — solo manos + mochila (todo lo demás es contextual) */
#hud-manos { position: absolute; right: 14px; bottom: 14px; display: flex;
  gap: 8px; align-items: center; }
.icono-ctrl { image-rendering: pixelated; vertical-align: middle; }
#hud-equipo { position: absolute; left: 14px; bottom: 14px; display: flex;
  flex-direction: column; gap: 8px; align-items: center; }
.mano-slot { width: 48px; height: 48px; background: rgba(10,9,6,.72);
  border: 1px solid var(--borde); border-bottom-width: 3px; position: relative;
  cursor: pointer; color: #55503f; font-size: 18px; overflow: hidden; }
.mano-slot:hover { border-color: var(--amarillo-osc); }
.mano-slot.activa { border-color: var(--amarillo); box-shadow: 0 0 10px rgba(217,198,110,.35); }
.eq-hud-slot { width: 48px; height: 48px; background: rgba(10,9,6,.72);
  border: 1px solid var(--borde); border-bottom-width: 3px; position: relative;
  display: flex; align-items: center; justify-content: center; color: #55503f;
  font-size: 18px; overflow: hidden; }
.eq-hud-slot:hover { border-color: var(--amarillo-osc); }
.eq-hud-slot.puesto { border-color: var(--amarillo); box-shadow: 0 0 10px rgba(217,198,110,.35); }
.eq-hud-slot .eq-ph { font-size: 10px; letter-spacing: .4px; }
/* v16: mano pixel-art de fondo (espejada según el lado) + objeto encima */
.mano-img { position: absolute; bottom: 1px; left: 50%; margin-left: -15px; opacity: .95; }
.mano-slot.vacia .mano-img { opacity: .3; }
.mano-item { position: absolute; top: 3px; left: 50%; margin-left: -11px;
  filter: drop-shadow(1px 1px 0 rgba(0,0,0,.8)); }
/* v19: atajo de teclado en pequeñito en la esquina de cada mano */
.k-mano { position: absolute; top: 1px; right: 3px; font-size: 11px;
  color: #6a6455; z-index: 1; text-shadow: 1px 1px 0 #000; }
/* feedback de pulsación al usar la mano (clic o tecla) */
.mano-slot.pulsada { animation: manoPulso .18s ease; }
@keyframes manoPulso {
  0%   { transform: translateY(0); border-bottom-width: 3px; }
  45%  { transform: translateY(2px); border-bottom-width: 1px;
         background: rgba(217,198,110,.22); box-shadow: 0 0 14px rgba(217,198,110,.6); }
  100% { transform: translateY(0); border-bottom-width: 3px; }
}
@media (prefers-reduced-motion: reduce) {
  .mano-slot.pulsada { animation: none; background: rgba(217,198,110,.22); }
}
#btn-mochila { width: 52px; height: 52px; background: rgba(16,14,9,.8);
  border: 1px solid var(--amarillo-osc); cursor: pointer; display: flex;
  align-items: center; justify-content: center; margin-left: 6px; }
#btn-mochila:hover { box-shadow: 0 0 12px rgba(217,198,110,.3); }
#backpack-panel { position: absolute; inset: 0; background: rgba(0,0,0,.6);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  z-index: 15; overflow-y: auto; padding: 24px 12px; -webkit-overflow-scrolling: touch; }
/* v17: mochila inmersiva — bolsillos de tela cosida y manos a los lados */
#backpack-box { max-width: 560px; }
#backpack-box h3 { display: flex; align-items: center; gap: 8px; }
#backpack-layout { display: flex; align-items: center; justify-content: center;
  gap: 18px; margin: 16px 0 10px;
  background: radial-gradient(ellipse at 50% 30%, #241c12, #14100a 75%);
  border: 2px solid #3d2f1c; border-radius: 6px; padding: 16px 14px;
  outline: 1px dashed #5a4a2e; outline-offset: -7px; }
.bp-mano-col { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.bp-label { font-size: 12px; color: #8a8470; text-align: center; line-height: 1.25; }
.bp-mano { width: 62px; height: 62px; }
#backpack-slots { display: grid; grid-template-columns: repeat(3, 62px); gap: 10px; }
.inv-slot { width: 62px; height: 62px;
  background: radial-gradient(circle at 50% 35%, #221a10, #120e08 80%);
  border: 2px solid #3d2f1c; border-radius: 4px;
  box-shadow: inset 0 3px 8px rgba(0,0,0,.75); display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-size: 10px; cursor: pointer;
  color: var(--hueso); position: relative; }
.inv-slot:hover { border-color: var(--amarillo-osc); }
.inv-slot .k { position: absolute; top: 1px; left: 4px; color: #6a6455; font-size: 12px; }
.inv-slot .nombre { font-size: 10.5px; color: #b8ad8a; max-width: 58px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
#bp-hint { font-size: 13.5px; line-height: 1.45; }
/* v20: equipamiento vestible + efectos activos */
#bp-equipo { display: flex; align-items: center; gap: 8px; margin: 4px 0 8px;
  padding: 8px 10px; background: #0d0b07; border: 1px solid var(--borde); flex-wrap: wrap; }
.bp-eq-label { color: var(--gris); font-size: 13px; letter-spacing: 1px; }
.eq-slot { width: 44px; height: 44px; background: radial-gradient(circle at 50% 40%, #1d1710, #100c07 85%);
  border: 2px solid #3d2f1c; border-radius: 4px; display: flex; align-items: center;
  justify-content: center; cursor: pointer; position: relative;
  box-shadow: inset 0 2px 6px rgba(0,0,0,.7); }
.eq-slot:hover { border-color: var(--amarillo-osc); }
.eq-slot.puesto { border-color: var(--amarillo-osc); }
.eq-ph { color: #55503f; font-size: 11px; }
#bp-efectos { display: flex; flex-wrap: wrap; gap: 5px; margin-left: auto; max-width: 55%;
  justify-content: flex-end; }
.fx { display: inline-flex; align-items: center; gap: 4px; background: #14200f;
  border: 1px solid #3a5a2e; color: #a8d8a0; font-size: 12px; padding: 2px 8px;
  border-radius: 9px; cursor: default; }
.fx.fx-mal { background: #200f0f; border-color: #5a2e2e; color: #e8a09a; }

/* v20: tooltips instantáneos (moodles a la izquierda, chips hacia arriba) */
.tip-left, .tip-up { position: relative; }
.tip-left:hover::after, .tip-up:hover::after {
  content: attr(data-tip); position: absolute; z-index: 45; pointer-events: none;
  background: #14120d; border: 1px solid var(--amarillo-osc); color: var(--hueso);
  padding: 7px 10px; font-size: 13px; line-height: 1.4; width: max-content;
  max-width: 250px; box-shadow: 0 0 14px rgba(0,0,0,.85); white-space: normal; }
.tip-left:hover::after { right: calc(100% + 10px); top: 50%; transform: translateY(-50%); }
.tip-up:hover::after { bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); }
#ctrl-list { margin-top: 14px; color: var(--gris); font-size: 15px; line-height: 1.7;
  border-top: 1px solid var(--borde); padding-top: 10px; }
#ctrl-list b { color: var(--hueso); letter-spacing: 1px; }
#item-modal { position: absolute; inset: 0; background: rgba(0,0,0,.6);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  z-index: 17; overflow-y: auto; padding: 24px 12px; -webkit-overflow-scrolling: touch; }
#item-icon { font-size: 22px; }
.item-effect { color: var(--amarillo); font-size: 13px; }
#sound-menu, #music-menu { position: absolute; inset: 0; background: rgba(0,0,0,.6);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  z-index: 25; overflow-y: auto; padding: 24px 12px; -webkit-overflow-scrolling: touch; }
.sound-row { display: flex; align-items: center; gap: 12px; margin: 12px 0; font-size: 13px; }
.sound-row label { width: 130px; color: var(--hueso); }
.sound-row input[type=range] { flex: 1; -webkit-appearance: none; appearance: none; height: 4px;
  background: #3a352a; outline: none; cursor: pointer; }
.sound-row input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none;
  width: 13px; height: 13px; background: var(--amarillo); border: 1px solid #0a0906; cursor: pointer; }
/* v20: el checkbox del dado se veía como un slider vacío — ahora es un checkbox */
.chk-row input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--amarillo);
  cursor: pointer; vertical-align: middle; margin-right: 6px; }
/* v20.2: fila de debug (teleport a niveles) */
#debug-nivel, #debug-objeto, #opt-camara-modo, #opt-resolucion, #opt-fps { flex: 1; background: #0a0906; border: 1px solid var(--borde);
  color: var(--amarillo); font-family: inherit; font-size: 16px; padding: 7px 10px;
  cursor: pointer; min-width: 0; box-sizing: border-box; }
/* el desplegable de cámara va en blanco hueso, como el resto del menú */
#opt-camara-modo, #opt-camara-modo option, #opt-resolucion, #opt-resolucion option, #opt-fps, #opt-fps option { color: var(--hueso); background: #0a0906; }
#debug-container { border-top: 1px dashed var(--borde); padding-top: 10px; margin-top: 10px; }
/* v23: contraseña de guardián + versión del juego en Ajustes */
#admin-row { border-top: 1px dashed var(--borde); padding-top: 10px; }
#admin-clave { flex: 1; background: #0a0906; border: 1px solid var(--borde);
  color: var(--amarillo); font-family: inherit; font-size: 14px; padding: 5px 8px;
  min-width: 0; outline: none; }
#admin-clave:focus { border-color: var(--amarillo-osc); }
#admin-msg { margin: 2px 0 0 142px; color: #e88a7a; font-size: 12px; min-height: 14px; }
/* v25: cámara libre con el ratón (mantener y arrastrar) */
#game-wrap.orbitando { cursor: grabbing; }
#game-wrap canvas { cursor: grab; }
/* v25: pantalla completa real — el lienzo llena el monitor, sin bordes */
body.fs #game-canvas, body.fs #gl-canvas { border: none; box-shadow: none; }
#ajustes-version { margin-top: 10px; text-align: right; color: var(--gris);
  font-size: 12px; opacity: .8; }
/* v23.3: motivo visible cuando el título no puede conectar */
#title-net { margin: 8px auto 0; max-width: 440px; color: #e88a7a;
  font-size: 14px; line-height: 1.4; }
/* v23: barras de guardián (salud/comida/bebida/cordura) — abajo-izquierda */
#debug-stats { position: absolute; left: 14px; bottom: 182px; display: flex;
  flex-direction: column; gap: 4px; background: rgba(10,9,6,.72);
  border: 1px solid var(--borde); padding: 8px 10px; pointer-events: none; }
.dbg-fila { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.dbg-lab { width: 56px; color: var(--hueso); }
.dbg-track { width: 130px; height: 8px; background: #201c12;
  border: 1px solid #3a352a; }
.dbg-fill { height: 100%; width: 0; transition: width .25s ease-out; }
.dbg-v { width: 26px; text-align: right; color: var(--gris); }
.sound-row span { width: 36px; text-align: right; color: var(--gris); font-size: 12px; }
.chk-row { flex: 1; color: var(--gris); font-size: 13px; cursor: pointer; }
.chk-row input { accent-color: var(--amarillo); cursor: pointer; vertical-align: middle; }

#minimap { position: absolute; top: 40px; right: 12px; background: rgba(6,5,3,.82);
  border: 1px solid var(--borde); cursor: pointer; image-rendering: pixelated; }
#minimap:hover { border-color: var(--amarillo-osc); }
#minimap-big { position: absolute; inset: 0; background: rgba(0,0,0,.75);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 16; cursor: pointer; }
#minimap-big canvas { background: rgba(6,5,3,.95); border: 1px solid var(--amarillo-osc);
  image-rendering: pixelated; max-width: 84vmin; max-height: 84vmin; }
#minimap-big p { color: var(--gris); font-size: 12px; margin-top: 10px; }

/* v16: registro contextual arriba a la izquierda — pequeño y efímero */
#game-log { position: absolute; left: 44px; top: 10px; width: 340px; max-height: 84px;
  overflow: hidden; font-size: 13px; line-height: 1.35; color: #cfc8b0;
  text-shadow: 1px 1px 2px #000; pointer-events: none; display: flex;
  flex-direction: column; align-items: flex-start; }
#game-log p { background: rgba(8,7,4,.5); padding: 1px 8px; margin-bottom: 2px;
  transition: opacity 1s ease-out; }
#game-log p.log-out { opacity: 0; }
#game-log p.danger { color: #e88a7a; } #game-log p.good { color: #a8d8a0; }
#game-log p.event { color: #d8c88a; font-style: italic; }

#touch-controls { display: none; position: fixed; inset: auto 0 16px 0; z-index: 45;
  pointer-events: none; justify-content: space-between; align-items: flex-end;
  padding: 0 max(18px, env(safe-area-inset-right)) 0 max(18px, env(safe-area-inset-left));
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#touch-controls button { pointer-events: auto; min-width: 52px; min-height: 48px;
  background: rgba(10,9,6,.74); border: 1px solid var(--borde); color: var(--hueso);
  font: 13px var(--font-title); box-shadow: 0 0 12px rgba(0,0,0,.45);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  -webkit-user-drag: none; -webkit-tap-highlight-color: transparent; }
#touch-controls *, #game-wrap canvas { -webkit-user-drag: none; }
#touch-controls button:active { border-color: var(--amarillo); color: var(--amarillo);
  transform: translateY(1px); }
/* joystick (online: movimiento libre) y D-pad (offline por turnos: un paso
   por toque, sin él la espera del auto-repeat lo hacía sentir poco fluido al
   girar) — #touch-controls.modo-dpad decide cuál de los dos se ve, fijado
   una vez al cargar según se use ?online= o ?autostart= */
.touch-joystick { width: 128px; height: 128px; pointer-events: auto; touch-action: none; }
#touch-controls.modo-dpad .touch-joystick { display: none; }
.joy-base { position: relative; width: 100%; height: 100%; border-radius: 50%;
  background: rgba(10,9,6,.6); border: 1px solid var(--borde);
  box-shadow: inset 0 0 16px rgba(0,0,0,.55), 0 0 12px rgba(0,0,0,.45);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.joy-stick { position: absolute; left: 50%; top: 50%; width: 46%; height: 46%;
  border-radius: 50%; background: rgba(217,198,110,.16); border: 1px solid var(--amarillo);
  transform: translate(-50%, -50%); pointer-events: none; }
.joy-base.activo .joy-stick { background: rgba(217,198,110,.3); }
.touch-dpad { display: none; grid-template-columns: repeat(3, 54px); grid-template-rows: repeat(3, 50px); gap: 4px; }
#touch-controls.modo-dpad .touch-dpad { display: grid; }
.touch-dpad [data-dir="up"] { grid-column: 2; grid-row: 1; }
.touch-dpad [data-dir="left"] { grid-column: 1; grid-row: 2; }
.touch-dpad [data-dir="down"] { grid-column: 2; grid-row: 3; }
.touch-dpad [data-dir="right"] { grid-column: 3; grid-row: 2; }
.touch-actions { display: grid; grid-template-columns: repeat(2, 58px); gap: 7px; }
.touch-actions [data-touch="map"] { grid-column: 1 / span 2; }

@media (pointer: coarse) {
  body.game-active #touch-controls { display: flex; }
  #hud-manos, #hud-equipo { display: none; }
  #screen-game { align-items: center; justify-content: center; overflow: hidden; }
  #game-wrap { max-width: 100vw; max-height: calc(var(--vh, 1vh) * 100); overflow: hidden; }
  #btn-esc { display: flex; top: max(8px, env(safe-area-inset-top)); left: max(8px, env(safe-area-inset-left)); }
  #btn-log { top: max(8px, env(safe-area-inset-top)); left: calc(max(8px, env(safe-area-inset-left)) + 36px); }
  #btn-game-menu { top: max(8px, env(safe-area-inset-top)); left: calc(max(8px, env(safe-area-inset-left)) + 72px); }
  #game-log { left: calc(max(8px, env(safe-area-inset-left)) + 110px); top: max(8px, env(safe-area-inset-top)); width: min(42vw, 300px); }
  #moodles { top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); transform: scale(.9); transform-origin: top right; }
  .title-box { max-width: 96vw; max-height: calc(var(--vh, 1vh) * 96); padding: 12px 18px; overflow: auto; }
  .title-box h1 { font-size: clamp(22px, 7vw, 34px); letter-spacing: clamp(3px, 1.2vw, 8px); }
  .intro-text { font-size: 18px; }
  .room-row input { width: min(180px, 46vw); }
  .hint { display: none; }
  .modal-box { max-width: 94vw; max-height: calc(var(--vh, 1vh) * 92); overflow: auto; }
  #backpack-box { max-width: 94vw; max-height: calc(var(--vh, 1vh) * 92); overflow: auto; }
  #backpack-layout { gap: 10px; padding: 12px 10px; }
  #backpack-slots { grid-template-columns: repeat(3, 56px); gap: 8px; }
  .inv-slot { width: 56px; height: 56px; }
  .bp-mano { width: 56px; height: 56px; }
  #bp-efectos { max-width: 100%; justify-content: flex-start; }
}
@media (pointer: coarse) and (orientation: portrait) {
  body.game-active #rotate-overlay,
  body.card-active #rotate-overlay { display: flex; }
}
@media (pointer: coarse) and (orientation: landscape) {
  #touch-controls { inset: auto env(safe-area-inset-right) max(8px, env(safe-area-inset-bottom)) env(safe-area-inset-left);
    padding: 0 12px; }
  #touch-controls button { min-width: 58px; min-height: 52px; }
}
@media (pointer: coarse) and (orientation: landscape) and (max-height: 430px) {
  #touch-controls { padding: 0 8px; }
  #touch-controls button { min-width: 46px; min-height: 42px; font-size: 11px; }
  .touch-joystick { width: 104px; height: 104px; }
  .touch-dpad { grid-template-columns: repeat(3, 48px); grid-template-rows: repeat(3, 42px); gap: 3px; }
  .touch-actions { grid-template-columns: repeat(2, 50px); gap: 5px; }
  #moodles { transform: scale(.78); }
  #game-log { display: none; }
}

/* ---------- dado ---------- */
#dice-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; z-index: 15; }
#dice-box { text-align: center; }
#dice-face { width: 96px; height: 96px; margin: 0 auto 14px;
  border: 8px solid transparent; border-image: var(--marco) 8 fill stretch;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-title); font-size: 30px; color: var(--amarillo);
  box-shadow: 0 0 40px rgba(217,198,110,.3); }
#dice-face.rolling { animation: shake .1s infinite; }
@keyframes shake { 0%{transform:rotate(-4deg)} 50%{transform:rotate(4deg)} 100%{transform:rotate(-2deg)} }
#dice-text { color: var(--hueso); font-size: 17px; text-shadow: 1px 1px 2px #000; }

/* ---------- modal salida ---------- */
#exit-modal, #choice-modal { position: absolute; inset: 0; background: rgba(0,0,0,.6);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  z-index: 14; overflow-y: auto; padding: 24px 12px; -webkit-overflow-scrolling: touch; }
.modal-box { border: 8px solid transparent; border-image: var(--marco) 8 fill stretch;
  max-width: 480px; width: 90%; padding: 24px 28px; margin: auto; }
.modal-box h3 { color: var(--amarillo); font-size: 20px; margin-bottom: 12px; }
.modal-box p { font-size: 17px; line-height: 1.5; margin-bottom: 10px; }
.modal-box .warn { color: #e8a05a; font-size: 15px; }
.modal-btns { display: flex; gap: 10px; row-gap: 8px; align-items: center; margin-top: 14px;
  flex-wrap: wrap; } /* v20: USAR/EMPUÑAR/Arrojar/Tirar/Cerrar caben en dos filas */
#item-modal .btn-big { font-size: 11px !important; padding: 9px 16px !important; }
#item-modal .btn-small { margin-top: 0; padding: 7px 12px; font-size: 15px; }

/* ---------- diario ---------- */
#journal-panel { position: absolute; top: 40px; right: 12px; width: 250px; max-height: 70%;
  overflow: auto; background: rgba(12,11,7,.94); border: 1px solid var(--borde);
  padding: 16px; z-index: 13; }
#journal-panel h3 { color: var(--amarillo); font-size: 17px; margin-bottom: 10px; }
#journal-panel ol { padding-left: 20px; font-size: 15px; line-height: 1.6; color: #cfc8b0; }

/* ---------- perfiles ---------- */
#profile-box { background: rgba(20,18,13,.65); border: 1px solid var(--borde);
  padding: 14px 18px; margin-bottom: 20px; }
.profile-title { color: var(--gris); font-size: 13px; letter-spacing: 3px; margin-bottom: 10px; }
.profile-row { display: flex; gap: 8px; justify-content: center; align-items: center;
  flex-wrap: wrap; margin-bottom: 8px; }
.profile-row .btn-small { margin-top: 0; }
#profile-select, #profile-name { background: #0a0906; border: 1px solid var(--borde);
  color: var(--amarillo); font-family: inherit; padding: 6px 10px; font-size: 16px; }
#profile-select { min-width: 140px; }
#profile-name { width: 140px; }
#profile-records { color: #8a8470; font-size: 15px; margin: 4px 0 8px; }
/* flecha propia en TODOS los desplegables, separada del borde derecho
   (con la flecha nativa el navegador la pega al borde y padding-right no la mueve) */
#opt-camara-modo, #debug-nivel, #profile-select, #opt-resolucion, #opt-fps {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='7' viewBox='0 0 11 7'%3E%3Cpath d='M1 1l4.5 4.5L10 1' fill='none' stroke='%23d9c66e' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ---------- códice ---------- */
#codex-panel, #changelog-panel { position: fixed; inset: 0; background: rgba(3,3,2,.88);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  z-index: 30; overflow-y: auto; padding: 24px 12px; -webkit-overflow-scrolling: touch; }
.codex-box-wrapper { position: relative; max-height: 88vh; margin: auto; }
.codex-box { width: min(720px, 94vw); max-height: 88vh; overflow: auto;
  border: 8px solid transparent; border-image: var(--marco) 8 fill stretch;
  padding: 24px 30px; }
.btn-close-box {
  position: absolute;
  top: 20px;
  right: 34px;
  background: transparent;
  border: 1px solid var(--borde);
  color: var(--gris);
  font-family: inherit;
  font-size: 20px;
  line-height: 1;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .12s;
  z-index: 10;
}
.btn-close-box:hover {
  color: var(--hueso);
  border-color: var(--gris);
}
.btn-close-box:active {
  transform: translateY(1px);
}
.codex-box h2 { color: var(--amarillo); font-size: 22px; margin-bottom: 6px; }
.codex-records { color: var(--gris); font-size: 16px; margin-bottom: 18px; }
.codex-box h3 { color: var(--gris); font-size: 16px; letter-spacing: 1px; margin: 18px 0 8px; }
#codex-history { padding-left: 34px; font-size: 14px; line-height: 1.65; color: #cfc8b0; }

/* v19: códice compacto — secciones y niveles como DESPLEGABLES */
details.cdx { border: 1px solid var(--borde); background: #0d0c08; margin-bottom: 8px; }
details.cdx > summary { cursor: pointer; padding: 9px 14px; color: var(--amarillo);
  font-size: 16px; letter-spacing: 1px; list-style: none;
  display: flex; align-items: center; gap: 8px; user-select: none; }
details.cdx > summary::-webkit-details-marker { display: none; }
details.cdx > summary::before { content: '▸'; color: var(--amarillo-osc);
  transition: transform .15s; font-size: 14px; }
details.cdx[open] > summary::before { transform: rotate(90deg); }
details.cdx > summary:hover { background: #14120c; }
.cdx-n { margin-left: auto; color: var(--gris); font-size: 14px; letter-spacing: 0; }
details.cdx > div, details.cdx > ol { padding: 6px 14px 12px; }
.changelog-ul { padding: 6px 14px 12px 30px; margin: 0; }
.changelog-ul li { color: #cfc8b0; font-size: 14.5px; line-height: 1.55; margin-bottom: 4px; }
.changelog-ul li::marker { color: var(--amarillo-osc); }
.cdx-nivel { border: 1px solid var(--borde); border-left: 4px solid #888;
  margin-bottom: 4px; background: #0f0e0a; }
.cdx-nivel > summary { list-style: none; cursor: pointer; padding: 6px 10px;
  font-size: 15px; color: var(--hueso); display: flex; gap: 7px; align-items: center;
  user-select: none; }
.cdx-nivel > summary::-webkit-details-marker { display: none; }
.cdx-nivel > summary:hover { background: #16130d; }
.cdx-nivel .meta-min { margin-left: auto; color: #8a8470; font-size: 13px; white-space: nowrap; }
.cdx-nivel .cuerpo { padding: 4px 12px 10px; }
.cdx-nivel .meta { color: #8a8470; font-size: 13.5px; margin-bottom: 6px; }
.cdx-nivel .desc { color: #cfc8b0; font-size: 14.5px; line-height: 1.45; }
.cdx-nivel .stats { color: var(--amarillo); font-size: 14px; margin-top: 6px; }
.cdx-nivel a { color: #7a90a8; font-size: 13.5px; }
.cdx-nivel ul { padding-left: 18px; color: #cfc8b0; font-size: 14px; line-height: 1.5; }

/* colección de coleccionables (v15) */
.col-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.col-cuenta { width: 100%; color: var(--amarillo); font-size: 14px; margin-bottom: 2px; }
.col-card { width: 78px; padding: 6px 3px 5px; background: #0f0e0a; text-align: center;
  border: 1px solid var(--borde); font-size: 11.5px; line-height: 1.2; color: #cfc8b0;
  position: relative; }
.col-wiki { position: absolute; top: 1px; right: 2px; opacity: .55; line-height: 0; }
.col-wiki:hover { opacity: 1; }
.col-card img { image-rendering: pixelated; display: block; margin: 0 auto 4px; }
.col-card.col-locked { color: #5a5546; }
.col-nivel { border: 1px solid var(--borde); background: #0f0e0a; padding: 10px 14px;
  margin-bottom: 8px; font-size: 15px; }
.col-nivel ul { padding-left: 20px; color: #cfc8b0; line-height: 1.55; }
.col-nivel .col-locked, li.col-locked { color: #5a5546; font-style: italic; }

/* ---------- fin ---------- */
.end-box { max-width: 620px; width: 92%;
  border: 8px solid transparent; border-image: var(--marco) 8 fill stretch;
  padding: 34px 38px; max-height: 90vh; overflow: auto; margin: auto; }
.end-box h1 { font-family: var(--font-title); font-size: 22px; line-height: 1.5; margin-bottom: 12px; }
.end-box h1.muerte { color: var(--rojo); text-shadow: 0 0 24px rgba(201,74,58,.4); }
.end-box h1.victoria { color: var(--verde); text-shadow: 0 0 24px rgba(106,168,106,.4); }
#end-cause { color: var(--hueso); font-size: 18px; line-height: 1.5; margin-bottom: 18px; }
#end-stats { display: flex; gap: 22px; margin-bottom: 22px; color: var(--gris); font-size: 15px; }
#end-stats b { color: var(--amarillo); display: block; font-family: var(--font-title); font-size: 14px; padding-bottom: 4px; }
.end-box h3 { color: var(--gris); font-size: 16px; margin-bottom: 8px; letter-spacing: 1px; }
#end-journal { padding-left: 22px; font-size: 16px; line-height: 1.7; color: #cfc8b0; margin-bottom: 26px; }

/* ---------- scrollbars retro ---------- */
::-webkit-scrollbar { width: 10px; background: #0a0906; border-left: 1px solid var(--borde); }
::-webkit-scrollbar-thumb { background: var(--amarillo-osc); border: 1px solid #0a0906; }
::-webkit-scrollbar-thumb:hover { background: var(--amarillo); }
* { scrollbar-width: thin; scrollbar-color: var(--amarillo-osc) #0a0906; }

/* v26.8: resalte de arrastre para ranuras válidas */
.slot-highlight-valid {
  border-color: var(--amarillo) !important;
  box-shadow: 0 0 10px rgba(217, 198, 110, 0.45) !important;
  background: rgba(217, 198, 110, 0.12) !important;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

#gamepad-menu {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.8);
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-y: auto;
  padding: 24px 12px;
  -webkit-overflow-scrolling: touch;
}

/* ---------- Ajustes de Responsividad para Alturas Cortas (max-height) ---------- */
@media (max-height: 800px) {
  .title-box { padding: 13px 20px; }
  .title-box h1 { font-size: 30px; letter-spacing: 5px; margin-bottom: 6px; }
  .subtitle { margin-bottom: 16px; font-size: 15px; }
  .intro-text { margin-bottom: 1px; font-size: 16px; line-height: 1.45; }
  .backrooms-census { min-height: 16px; margin: 0 auto 5px; padding: 0 7px;
    font-size: 13px; line-height: 14px; }
  #profile-box { padding: 10px 14px; margin-bottom: 12px; }
  .profile-title { margin-bottom: 6px; }
  .seed-row { margin-bottom: 10px; }
  .room-row { margin-bottom: 10px; }
  .btn-big { padding: 12px 24px; }
  .hint { margin-top: 14px; font-size: 13px; line-height: 1.5; }
  
  .level-card { padding: 20px 24px; }
  .level-card h2 { font-size: 15px; margin-bottom: 4px; }
  .card-class { margin-bottom: 10px; font-size: 14px; }
  .card-desc { font-size: 16px; margin-bottom: 10px; }
  .card-quote { font-size: 15px; margin-bottom: 10px; padding-left: 10px; }
  .card-rules { margin-bottom: 12px; }
  
  .modal-box { padding: 16px 20px; }
  .modal-box h3 { font-size: 17px; margin-bottom: 8px; }
  .modal-box p { font-size: 15px; }
  
  .codex-box { padding: 16px 20px; }
  .codex-box h2 { font-size: 18px; }
  
  .end-box { padding: 20px 24px; }
  .end-box h1 { font-size: 18px; }
}

@media (max-height: 680px) {
  .title-box { padding: 8px 12px; }
  .title-box h1 { font-size: 24px; letter-spacing: 3px; margin-bottom: 4px; }
  .subtitle { margin-bottom: 8px; font-size: 14px; }
  .intro-text { margin-bottom: 8px; font-size: 14px; line-height: 1.35; }
  .backrooms-census { display: none; }
  #profile-box { padding: 8px 10px; margin-bottom: 8px; }
  .seed-row { margin-bottom: 6px; }
  .room-row { margin-bottom: 6px; }
  .btn-big { padding: 10px 20px; font-size: 11px; }
  .hint { margin-top: 8px; font-size: 12px; }
  
  .level-card { padding: 12px 18px; }
  .level-card h2 { font-size: 14px; }
  .card-desc { font-size: 14px; line-height: 1.4; }
  .card-quote { font-size: 13.5px; }
  .card-rules span { padding: 2px 6px; font-size: 13.5px; }
  
  .modal-box { padding: 12px 16px; }
}

@media (max-height: 580px) {
  .intro-text { display: none; }
  .hint { display: none; }
  .card-quote { display: none; }
}

/* --- Estilos para la selección de música de menú (v26) --- */
.btn-music-float {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #0a0906;
  border: 1px solid var(--borde);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  transition: transform 0.15s, background-color 0.15s, border-color 0.15s;
}
.btn-music-float:hover {
  background: #1a1811;
  border-color: var(--amarillo);
  transform: scale(1.08);
}
.btn-music-float:active {
  transform: scale(0.95);
}

.music-list-container {
  width: 100%;
  margin-top: 15px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.music-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: #0a0906;
  border: 1px solid var(--borde);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.music-item:hover {
  background: #15130d;
  border-color: var(--amarillo);
}
.music-item.active {
  border-color: var(--amarillo);
  background: #1a1811;
}
.music-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
}
.music-title {
  font-size: 14px;
  color: var(--hueso);
  font-weight: bold;
}
.music-author {
  font-size: 12px;
  color: #8a8470;
}
.music-status {
  font-size: 12px;
  color: var(--amarillo);
  font-weight: bold;
}
.btn-music-float * {
  pointer-events: none;
}


/* ---------- modo espectador (v30, solo guardián) ---------- */
#espectador-bar {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  background: rgba(14, 12, 9, .88); border: 1px solid #7ab8e8; border-radius: 6px;
  padding: 5px 14px; color: #cfe2f0;
  font: 19px var(--font-body); letter-spacing: 1px; z-index: 40;
}
#espectador-bar .esp-ojo { font-size: 16px; }
#espectador-bar b { color: #ffe9a0; }
#espectador-bar button {
  background: #0a0906; color: #cfe2f0; border: 1px solid #2a4a62; border-radius: 4px;
  font: 16px var(--font-body); padding: 1px 10px; cursor: pointer;
}
#espectador-bar button:hover { border-color: #7ab8e8; }
/* espectando, el HUD del cuerpo desaparece: solo queda el nivel y su gente */
body.espectando #hud-manos, body.espectando #hud-equipo,
body.espectando #moodles, body.espectando #debug-stats,
body.espectando #touch-controls { display: none !important; }
