:root {
  color-scheme: dark;
  font: 500 16px/1.45 system-ui, sans-serif;
  color: #f1f8ff;
  background: #06111f;
  --cian: #83edff;
  --tenue: #aabdd0;
  --borde: #4d7992;
  --fondo: #081727;
  --tacto: 44px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100dvh;
}
button, input { font: inherit; }
button {
  min-height: var(--tacto);
  border: 1px solid var(--borde);
  border-radius: 8px;
  padding: .45rem .8rem;
  color: inherit;
  cursor: pointer;
  font-weight: 700;
}
button:disabled { cursor: default; }
.principal:disabled { opacity: .55; }
:focus-visible { outline: 2px solid #ffdd9c; outline-offset: 3px; }
button:not(:disabled):hover { border-color: var(--cian); }
.suave { background: #0a1b2a; }
.principal { background: #9af1ff; color: #062334; border-color: #9af1ff; }
.metal { background: linear-gradient(#903a3e, #58151d); border-color: #c66c70; color: #fff4f3; }
.barra {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .65rem;
  padding: .65rem clamp(.7rem, 3vw, 3rem);
  background: #06111fee;
  border-bottom: 1px solid #354a5e;
}
.marca { display: inline-flex; align-items: center; min-height: 38px; }
.marca img { width: clamp(106px, 13vw, 170px); height: auto; }
.herramientas { display: flex; gap: .4rem; }
.herramientas button { font-size: .82rem; }
.entrada {
  display: grid;
  align-items: end;
  min-height: calc(100dvh - 67px);
  padding: clamp(1rem, 5vw, 6rem);
  background: linear-gradient(180deg, #0514220d 35%, #04111d 100%), url('/portalx/escenas/recorrido.webp') 33% center / cover no-repeat;
}
.portada { width: min(36rem, 100%); text-shadow: 0 2px 12px #030f1b; }
.portada button { text-shadow: none; }
h1, h2, p { margin: 0; }
h1 {
  font-weight: 900;
  letter-spacing: -.05em;
  line-height: .9;
  font-style: italic;
}
h1 em { color: var(--cian); text-shadow: 0 0 22px #31ddff62; }
.portada h1 { font-size: clamp(3.2rem, 8vw, 7rem); }
.portada p { margin-top: 1.2rem; font-size: clamp(1rem, 2vw, 1.3rem); max-width: 32ch; }
.datos-entrada, .acciones-entrada { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1.25rem; }
.datos-entrada span { color: var(--tenue); background: #071725dc; border: 1px solid #426478; border-radius: 8px; padding: .32rem .66rem; }
.datos-entrada strong { color: var(--cian); }
.juego {
  width: min(1920px, 100%);
  margin: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(224px, 21vw, 304px);
  gap: clamp(.65rem, 1.5vw, 1.5rem);
  padding: clamp(.65rem, 1.5vw, 1.5rem);
}
.escena { min-width: 0; }
.encabezado {
  display: flex;
  align-items: center;
  gap: .65rem 1rem;
  min-height: 44px;
  margin-bottom: .55rem;
}
.encabezado h1 { font-size: clamp(1.85rem, 4vw, 3.6rem); }
#progreso { color: var(--cian); font-size: .88rem; font-variant-numeric: tabular-nums; }
#recorrido { margin-left: auto; font-size: .8rem; }
.tablero {
  position: relative;
  isolation: isolate;
  height: clamp(330px, calc(100dvh - 240px), 820px);
  overflow: hidden;
  border: 1px solid #365465;
  border-radius: 12px;
  background: radial-gradient(ellipse at center, #173f52, #06111f 76%);
}
.tablero > section { position: absolute; inset: 0; overflow: hidden; }
.tablero > .visible { z-index: 1; }
.marco { position: absolute; transform-origin: top left; }
.marco img { display: block; width: 100%; height: 100%; }
.nivel h2 {
  position: absolute;
  z-index: 1;
  inset: auto 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  padding: .6rem .85rem;
  background: linear-gradient(transparent, #03101be8);
  text-shadow: 0 1px 3px #010608;
  font-size: .93rem;
  pointer-events: none;
}
.nivel h2 strong { color: var(--cian); font-variant-numeric: tabular-nums; }
.opciones { position: absolute; inset: 0; pointer-events: none; }
.portal {
  display: grid;
  place-items: end center;
  position: absolute;
  translate: -50% -50%;
  min-width: var(--tacto);
  min-height: var(--tacto);
  padding: 0 0 clamp(3px, 10%, 7px);
  border: 2px solid transparent;
  border-radius: 50%;
  background: transparent;
  pointer-events: auto;
}
.portal span {
  display: grid;
  place-items: center;
  min-width: 1.65rem;
  min-height: 1.65rem;
  padding: 0 .2rem;
  border: 1px solid #abf6ffbb;
  border-radius: 100vw;
  color: #fff;
  background: #071c29e8;
  font-size: .83rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.marco[data-sin-imagen] .portal {
  border-color: #75dfff;
  background: radial-gradient(ellipse, #123549 30%, #0e5c7788);
}
.portal:disabled { pointer-events: none; }
.portal:not(:disabled):hover, .portal:focus-visible, .portal[data-resultado="espera"] {
  border-color: #ccfbff;
  background: radial-gradient(ellipse, #0ea9d02c, #8beaff64);
  box-shadow: inset 0 0 18px #81e9ffbc, 0 0 20px #36e1ff9c;
}
.portal[data-resultado="acierto"] { border-color: #a8ffd8; background: #06987560; box-shadow: 0 0 20px #3effa8; }
.portal[data-resultado="fallo"] { border-color: #ffaba3; background: #a91426a5; box-shadow: 0 0 20px #ed5148; }
.portal[data-revelando] { animation: abrir-portal .38s ease-out; }
@keyframes abrir-portal { 50% { transform: scale(.91); } }
.ruta {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: start;
  padding: 0;
  margin: .7rem 0 0;
  font-size: .78rem;
  font-variant-numeric: tabular-nums;
}
.ruta li { display: grid; place-items: center; position: relative; gap: .25rem; color: var(--tenue); }
.ruta li:not(:last-child)::after {
  content: '';
  position: absolute;
  height: 1px;
  top: .82rem;
  left: calc(50% + .88rem);
  right: calc(-50% + .88rem);
  background: #48677b;
}
.ruta li[aria-current] { color: #fff; font-weight: 800; }
.ruta b {
  display: grid;
  place-items: center;
  width: 1.65rem;
  height: 1.65rem;
  border: 1px solid #6e899b;
  border-radius: 50%;
}
.ruta li[data-superado] b { background: #183d4d; border-color: #66d4e8; color: var(--cian); }
.ruta li[aria-current] b { background: #a0f2ff; border-color: #a0f2ff; color: #062334; }
.panel {
  min-width: 0;
  align-self: stretch;
  align-content: center;
  display: grid;
  gap: .8rem;
  padding: clamp(.75rem, 1.7vw, 1.6rem);
  background: linear-gradient(155deg, #112735, #061422 70%);
  border: 1px solid #3b596a;
  border-top: 2px solid #c26960;
  border-radius: 14px;
}
.balance { display: grid; color: var(--tenue); }
.balance strong { color: var(--cian); font-size: clamp(1.55rem, 3vw, 2.4rem); line-height: 1.15; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.estado { border-top: 1px solid #3b5263; padding-top: .7rem; }
.estado h2 { font-size: clamp(.95rem, 1.55vw, 1.32rem); line-height: 1.2; }
.estado p { color: #ccdae7; font-size: .86rem; margin-top: .28rem; }
.acciones, .decision, .opciones-clave { display: grid; gap: .4rem; }
.decision { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.decision button { padding-inline: .3rem; font-size: .85rem; }
.volver { color: #bfdae8; font-size: .85rem; justify-self: start; }
dialog {
  position: fixed;
  max-height: min(90dvh, 600px);
  width: min(92vw, 480px);
  overflow: auto;
  border: 1px solid #64889a;
  border-radius: 13px;
  background: #0b1928;
  color: inherit;
  padding: 1rem;
}
dialog::backdrop { background: #020915cb; }
dialog h2 { margin-bottom: .55rem; }
dialog label { display: block; margin-bottom: .3rem; }
dialog input { width: 100%; min-height: 44px; color: inherit; background: #06111f; border: 1px solid #7694a5; border-radius: 7px; padding: .45rem .6rem; }
#billetera {
  top: calc(var(--px-viewport-top, 0px) + var(--px-viewport-height, 100dvh) / 2);
  bottom: auto;
  transform: translateY(-50%);
  max-height: calc(var(--px-viewport-height, 100dvh) - 14px);
  margin-block: 0;
}
#error-clave:not(:empty) { margin-top: .35rem; color: #ffd1cf; }
.botones-dialogo { display: flex; gap: .55rem; margin-top: .65rem; }
table { width: 100%; border-collapse: collapse; margin: .75rem 0; font-size: .86rem; font-variant-numeric: tabular-nums; }
th, td { border-bottom: 1px solid #3e566b; padding: .36rem .25rem; text-align: center; }
@media (max-width: 760px) and (orientation: portrait) {
  .entrada { background-position: 29% center; padding-bottom: max(2rem, env(safe-area-inset-bottom)); }
  .juego { grid-template-columns: minmax(0, 1fr); }
  .tablero { height: clamp(260px, 49dvh, 440px); }
  .tablero:has(.panorama.visible) { height: clamp(166px, 49vw, 355px); }
  .ruta span { white-space: nowrap; font-size: .66rem; }
  .panel { gap: .5rem; padding: .75rem; }
  .opciones-clave { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  #sonido span:last-child, #pantalla span:last-child { display: none; }
  .herramientas button { min-width: 44px; }
}
@media (max-width: 380px) {
  .encabezado { flex-wrap: wrap; }
  #progreso { flex: 1; }
  #recorrido { margin-left: 0; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .barra { padding: .2rem .6rem; }
  .herramientas button { min-height: 40px; }
  .entrada { min-height: calc(100dvh - 47px); }
  .juego { grid-template-columns: minmax(0, 1fr) minmax(164px, 27vw); padding: .42rem .55rem; gap: .46rem; }
  .encabezado { margin-bottom: .3rem; min-height: 38px; }
  .encabezado button { min-height: 38px; }
  .encabezado h1 { font-size: clamp(1.65rem, 6vh, 3.1rem); }
  .tablero { height: max(164px, calc(100dvh - 159px)); }
  .ruta { margin-top: .35rem; font-size: .73rem; }
  .panel { padding: .45rem; gap: .35rem; }
  .estado { padding-top: .32rem; }
  .estado p { font-size: .75rem; }
  .balance strong { font-size: 1.45rem; }
  .panel button { min-height: 38px; font-size: .76rem; padding: .24rem; }
  .opciones-clave { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
