:root {
  --bg-0: #0a0713;
  --bg-1: #150d24;
  --bg-2: #1e1233;
  --ink: #f7f3ff;
  --ink-dim: #b7abd0;
  --ink-faint: #7d719a;
  --line: rgba(255, 255, 255, .10);
  --line-strong: rgba(255, 255, 255, .20);
  --glass: rgba(255, 255, 255, .055);
  --glass-2: rgba(255, 255, 255, .10);
  --pink: #ff5c9a;
  --pink-soft: #ff8fc0;
  --gold: #ffc94d;
  --lime: #7ef0a8;
  --violet: #9b7bff;
  --red: #ff4d5e;
  --shadow: 0 24px 60px rgba(0, 0, 0, .55);
  --radius: 22px;
  --radius-sm: 14px;
  --ease: cubic-bezier(.2, .8, .25, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg-0);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, .display {
  font-family: 'Baloo 2', 'Trebuchet MS', system-ui, sans-serif;
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -.02em;
  margin: 0;
}

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input { font: inherit; }
img { max-width: 100%; display: block; }

.is-hidden { display: none !important; }

#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 900;
}

/* ============ SCREENS ============ */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  opacity: 0;
  z-index: 1;
}

.screen.is-active {
  display: flex;
  opacity: 1;
  z-index: 5;
}

.screen.is-fading {
  animation: screenIn .55s var(--ease) both;
}

@keyframes screenIn {
  from { opacity: 0; transform: scale(.985); }
  to   { opacity: 1; transform: scale(1); }
}

.eyebrow {
  margin: 0;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--pink-soft);
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .85rem 1.5rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: .95rem;
  background: var(--glass);
  border: 1px solid var(--line-strong);
  transition: transform .18s var(--ease), background .18s var(--ease), box-shadow .18s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.btn:hover { background: var(--glass-2); transform: translateY(-2px); }
.btn:active { transform: translateY(0) scale(.98); }

.btn-primary {
  background: linear-gradient(135deg, var(--pink) 0%, #b64dff 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 12px 30px rgba(255, 92, 154, .32);
}

.btn-primary:hover {
  box-shadow: 0 16px 38px rgba(255, 92, 154, .45);
  background: linear-gradient(135deg, #ff74ab 0%, #c364ff 100%);
}

.btn-big { padding: 1.05rem 2.4rem; font-size: 1.02rem; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; }

.btn.is-busy { opacity: .6; pointer-events: none; }

/* ============ 1. LOCK SCREEN (sencillo) ============ */
#screen-lock {
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  background: #000;
}

.lock-box {
  position: relative;
  width: min(420px, 100%);
  text-align: center;
}

.lock-title {
  font-size: clamp(1.6rem, 6vw, 2.1rem);
  margin: .3rem 0 .2rem;
}

.lock-title span {
  color: var(--gold);
}

.lock-sub {
  margin: 0 0 1.6rem;
  color: var(--ink-faint);
  font-size: .82rem;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.countdown {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: .3rem;
  margin-bottom: 1.5rem;
}

.countdown > i {
  font-style: normal;
  font-size: 1.7rem;
  color: var(--ink-faint);
  line-height: 1.1;
}

.cd-cell {
  display: grid;
  justify-items: center;
  gap: .1rem;
  min-width: 58px;
}

.cd-cell:first-child { min-width: 40px; }

.cd-cell b {
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.cd-cell span {
  font-size: .6rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.countdown.is-done .cd-cell b { color: var(--lime); }

.lock-waiting {
  margin: 0;
  color: var(--ink-dim);
  font-size: .88rem;
}

.lock-label {
  display: block;
  margin: 0 0 .5rem;
  font-size: .68rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  text-align: left;
}

.lock-form { display: grid; gap: .7rem; }

.lock-input-wrap {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .2rem .5rem .2rem .9rem;
  background: #000;
  border: 2px solid #fff;
  border-radius: 6px;
}

.lock-input-wrap:focus-within { border-color: var(--gold); }

#lock-input,
#safe-input {
  flex: 1;
  min-width: 0;
  padding: .7rem 0;
  background: none;
  border: 0;
  outline: none;
  color: #fff;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 1rem;
  letter-spacing: .04em;
}

#lock-input::placeholder,
#safe-input::placeholder { color: #6a6a6a; letter-spacing: normal; }

#lock-input:disabled,
#safe-input:disabled {
  color: #555;
  -webkit-text-fill-color: #555;
  cursor: not-allowed;
}

.lock-input-wrap:has(#lock-input:disabled) { opacity: .5; }

#lock-submit:disabled {
  opacity: .4;
  pointer-events: none;
}

.lock-eye {
  padding: .45rem .5rem;
  border-radius: 6px;
  opacity: .5;
  font-size: 1rem;
  transition: opacity .2s, background .2s;
}

.lock-eye:hover { opacity: 1; background: #1a1a1a; }

.lock-go {
  display: grid;
  gap: 1rem;
}

.lock-go-text {
  margin: 0;
  font-size: .92rem;
  line-height: 1.6;
  color: var(--ink-dim);
}

.lock-go-text strong { color: var(--gold); }

/* ---- aviso de parte conseguida ---- */
.part-toast {
  align-self: center;
  display: grid;
  justify-items: center;
  gap: .1rem;
  margin-top: .6rem;
  padding: .7rem 1.8rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, rgba(255, 201, 77, .18), rgba(255, 201, 77, .05));
  border: 1px solid rgba(255, 201, 77, .5);
  text-align: center;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: boxIn .4s var(--ease) both;
}

.part-toast-label {
  font-size: .64rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--gold);
}

.part-toast-name {
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.1;
}

/* ---- la caja fuerte ---- */
#screen-safe {
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  overflow-y: auto;
  background: radial-gradient(900px 600px at 50% -10%, #3a1b5e 0%, transparent 60%), var(--bg-0);
}

.safe-wrap { width: min(520px, 100%); margin: auto; }

.safe-box {
  padding: 2.4rem 2rem 2rem;
  border-radius: var(--radius);
  text-align: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, .03));
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  animation: boxIn .6s var(--ease) both;
}

@keyframes entraPista {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: none; }
}

.safe-hint.is-shown { display: block; }

.safe-title {
  font-size: clamp(1.7rem, 7vw, 2.3rem);
  margin: .3rem 0 .5rem;
}

.safe-hint {
  margin: 0 0 1.5rem;
  font-size: .9rem;
  line-height: 1.6;
  color: var(--ink-dim);
  /* sale al fallar: si no, es un parrafo gris mas */
  display: none;
  border-left: 3px solid var(--gold);
  padding: .6rem .9rem;
  background: rgba(255, 210, 74, .07);
  border-radius: 0 6px 6px 0;
  animation: entraPista .35s ease-out;
}

.parts {
  display: grid;
  gap: .55rem;
  margin-bottom: 1.6rem;
}

.part {
  display: grid;
  grid-template-columns: 26px 1fr;
  grid-template-rows: auto auto;
  column-gap: .6rem;
  align-items: center;
  padding: .7rem .9rem;
  border-radius: var(--radius-sm);
  text-align: left;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--line);
}

.part.is-got {
  background: rgba(255, 201, 77, .1);
  border-color: rgba(255, 201, 77, .42);
}

.part-num {
  grid-row: 1 / 3;
  font-size: .8rem;
  color: var(--ink-faint);
}

.part-val {
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--ink-faint);
  letter-spacing: .04em;
}

.part.is-got .part-val { color: var(--gold); }

.part-title {
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.lock-error {
  min-height: 1.2rem;
  margin: .8rem 0 0;
  font-size: .8rem;
  color: #ff6b78;
}

.sound-toggle {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  z-index: 20;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-size: 1.1rem;
  color: var(--ink-dim);
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--line);
  transition: color .2s, background .2s;
}

.sound-toggle:hover { color: #fff; background: rgba(255, 255, 255, .14); }
.sound-toggle.is-off { opacity: .4; }

/* ---------- caja de dialogo estilo Undertale ---------- */
#undertale-box { z-index: 950; }

.ut-box {
  position: relative;
  width: min(560px, 100%);
  padding: 26px 30px 30px;
  background: #000;
  border: 5px solid #fff;
  border-radius: 3px;
  color: #fff;
  font-family: 'Pixelify Sans', 'Courier New', monospace;
  font-size: 1.35rem;
  line-height: 1.65;
  letter-spacing: .01em;
  text-align: left;
  animation: utIn .18s steps(4) both;
}

@keyframes utIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.ut-text { margin: 0; }

.ut-next {
  position: absolute;
  right: 18px;
  bottom: 12px;
  width: 0;
  height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-top: 12px solid #fff;
  animation: utBlink .7s steps(1) infinite;
}

@keyframes utBlink {
  0%, 49%   { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* ============ 2. WISH SCREEN ============ */
#screen-wish {
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.25rem;
  overflow-y: auto;
  background:
    radial-gradient(900px 640px at 12% -8%, #4b1f6b 0%, transparent 60%),
    radial-gradient(820px 580px at 92% 12%, #5c1440 0%, transparent 58%),
    radial-gradient(900px 700px at 50% 118%, #25124a 0%, transparent 62%),
    var(--bg-0);
}

.balloons {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.balloon {
  position: absolute;
  bottom: -22vh;
  width: 54px;
  height: 68px;
  border-radius: 50% 50% 48% 48%;
  opacity: .5;
  filter: blur(.4px);
  animation: floatUp linear infinite;
}

.balloon::after {
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: inherit;
}

@keyframes floatUp {
  0%   { transform: translateY(0) translateX(0) rotate(0deg); opacity: 0; }
  12%  { opacity: .55; }
  85%  { opacity: .4; }
  100% { transform: translateY(-125vh) translateX(38px) rotate(24deg); opacity: 0; }
}

.wish-wrap {
  position: relative;
  z-index: 2;
  width: min(680px, 100%);
  margin: auto;
}

.wish-card {
  position: relative;
  padding: 3rem 2.4rem 2.4rem;
  border-radius: 30px;
  text-align: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, .085), rgba(255, 255, 255, .028));
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .16);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  animation: boxIn .75s var(--ease) both .1s;
}

.card-tape {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  width: 116px;
  height: 30px;
  background: linear-gradient(180deg, rgba(255, 201, 77, .85), rgba(255, 201, 77, .55));
  border-radius: 3px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .3);
}

/* cake */
.cake {
  position: relative;
  width: 122px;
  height: 118px;
  margin: .2rem auto 1rem;
  transform: scale(.92);
}

.candle { position: absolute; top: 0; left: 50%; transform: translateX(-50%); }

.candle i {
  display: block;
  width: 11px;
  height: 34px;
  border-radius: 4px;
  background: repeating-linear-gradient(180deg, #fff 0 6px, var(--pink) 6px 12px);
}

.candle::after {
  content: "";
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  width: 15px;
  height: 20px;
  border-radius: 50% 50% 45% 45%;
  background: radial-gradient(circle at 50% 68%, #fff 0%, var(--gold) 42%, #ff7a18 78%, rgba(255, 90, 0, 0) 100%);
  animation: flame 1.1s ease-in-out infinite alternate;
  transform-origin: 50% 100%;
}

@keyframes flame {
  from { transform: translateX(-50%) scaleY(1) scaleX(1); opacity: .95; }
  to   { transform: translateX(-50%) scaleY(1.18) scaleX(.9); opacity: 1; }
}

.cake-body {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: 132px;
  height: 66px;
  border-radius: 10px 10px 16px 16px;
  background: linear-gradient(180deg, #ffd3e4 0%, #f7a8c6 50%, #e57ba4 100%);
  box-shadow: inset 0 -8px 18px rgba(0, 0, 0, .16);
  display: flex;
  justify-content: space-evenly;
  align-items: flex-end;
  padding-bottom: 8px;
}

.cake-body::before {
  content: "";
  position: absolute;
  top: -13px;
  left: -3px;
  right: -3px;
  height: 20px;
  border-radius: 14px;
  background: #fff6fa;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .12);
}

.cake-body span {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .2);
}

.cake-body span:nth-child(1) { background: var(--red); }
.cake-body span:nth-child(2) { background: var(--gold); }
.cake-body span:nth-child(3) { background: var(--violet); }

.cake-plate {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 158px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(180deg, #dfe4ee, #a8b0c2);
  box-shadow: 0 8px 20px rgba(0, 0, 0, .4);
}

.wish-title {
  font-size: clamp(2.2rem, 9vw, 3.5rem);
  margin: .35rem 0 .2rem;
  background: linear-gradient(120deg, #fff 0%, var(--gold) 45%, var(--pink) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.wish-name {
  margin: 0 0 1.4rem;
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--pink-soft);
}

.age-badge {
  display: inline-flex;
  align-items: baseline;
  gap: .5rem;
  margin: -.6rem 0 1.3rem;
  padding: .5rem 1.3rem;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255, 201, 77, .2), rgba(255, 92, 154, .2));
  border: 1px solid rgba(255, 201, 77, .4);
}

.age-num {
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--gold);
  line-height: 1;
}

.age-label {
  font-size: .75rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.wish-text {
  margin: 0 0 1.1rem;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.7;
  white-space: pre-line;
}

.wish-closing {
  margin: 0 0 1.5rem;
  color: var(--ink-dim);
  font-style: italic;
  font-size: .95rem;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .7rem;
  margin-bottom: 1.5rem;
}

.gallery.is-hidden { display: none; }

.shot {
  position: relative;
  margin: 0;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: linear-gradient(140deg, #3a2158, #1c1233);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  transition: transform .25s var(--ease), border-color .25s var(--ease);
}

.shot:hover { transform: translateY(-4px) rotate(-1.5deg); border-color: var(--pink); }

.shot img { width: 100%; height: 100%; object-fit: cover; }

.shot figcaption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 1.1rem .5rem .45rem;
  font-size: .68rem;
  text-align: center;
  color: var(--ink-dim);
  background: linear-gradient(transparent, rgba(0, 0, 0, .78));
}

.shot.is-empty figcaption { color: var(--ink-faint); }

.wish-foot {
  margin: 1rem 0 0;
  font-size: .75rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* ============ 3. GAME ============ */
.screen-game { background: #05060c; }

#canvas-wrap { position: absolute; inset: 0; }
#canvas-wrap canvas { display: block; width: 100%; height: 100%; }

.hud {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 1.1rem;
  pointer-events: none;
  z-index: 10;
}

.hud > * { pointer-events: none; }

/* ------------------------------------------------------------------
 * EL ANCHO DE LA HUD
 * ------------------------------------------------------------------
 *
 * En un monitor grande, el hud-top es un flex con space-between y sus hijos
 * se separan hasta los bordes: el nombre del nivel a la izquierda y el
 * contador de huevos a 2500 px. El ojo tiene que dar medio metro de viaje
 * para pasar de uno a otro, y eso ya no es un HUD: es un mapa.
 *
 * Aqui se les pone un tope de ancho y se centran. Por debajo de 1100 px no
 * cambia nada, que es donde esta casi todo el mundo; por encima, el
 * contenido se queda en una columna comoda.
 *
 * Y nada de vw: anadir tamaños en vw es justo lo que hace que un HUD cambie de
 * tamano con el monitor. Un tope en px es lo que hace que NO cambie.
 */
/* OJO: esto es SOLO para la barra de arriba y la historia.
 *
 * Antes era ".hud > *", y eso metia a todo lo que cuelga del hud. Entre lo
 * que se cuelga hay cosas colocadas con left:50% y translate(-50%), como
 * .boss-win y .chase-box: a esas les ponia width:100% y se estiraban de lado
 * a lado. En un PC el tope de 1100 px las tapaba; en un movil no hay tope y se
 * quedaba a pantalla completa. */
.hud-top,
.hud-story {
  max-width: 1100px;
  margin-inline: auto;
  width: 100%;
}

.hud-top {
  align-items: flex-start;
}

.hud-level,
.hud-eggs,
.hud-hint {
  max-width: 26rem;
}

/* el objetivo de la izquierda y el boton de la derecha, sin separarse mas
   de lo comodo aunque el monitor sea enorme */
.hud-top > :first-child { margin-right: auto; }
.hud-top > :last-child { margin-left: auto; }
.hud button, .hud .lock-panel { pointer-events: auto; }

.hud-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.hud-level {
  padding: .6rem 1rem;
  border-radius: var(--radius-sm);
  background: rgba(10, 8, 20, .62);
  border: 1px solid var(--line);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.hud-tag {
  display: block;
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--gold);
}

.hud-name {
  display: block;
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
}

.hud-tools { display: flex; gap: .45rem; flex-wrap: wrap; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem .85rem;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--ink-dim);
  background: rgba(10, 8, 20, .62);
  border: 1px solid var(--line);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: color .2s, background .2s, transform .2s var(--ease);
}

.chip:hover { color: var(--ink); background: rgba(30, 20, 55, .8); transform: translateY(-2px); }
.chip b { color: var(--gold); font-weight: 700; }
.chip-quit { font-size: 1.05rem; line-height: 1; padding: .5rem .7rem; }

.hud-story {
  align-self: center;
  max-width: 520px;
  margin: .6rem auto 0;
  padding: .55rem 1.1rem;
  text-align: center;
  font-size: .84rem;
  color: var(--ink-dim);
  background: rgba(10, 8, 20, .58);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: opacity .7s var(--ease), transform .7s var(--ease);
  animation: boxIn .5s var(--ease) both .2s;
}

.hud-story.is-gone {
  opacity: 0;
  transform: translateY(-8px);
}

.buddy-status {
  align-self: center;
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-top: .5rem;
  padding: .45rem 1rem;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--gold);
  background: rgba(10, 8, 20, .78);
  border: 1px solid rgba(255, 201, 77, .35);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: boxIn .3s var(--ease) both;
}

.buddy-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 0 rgba(255, 201, 77, .6);
  animation: buddyPing 1.1s ease-out infinite;
}

@keyframes buddyPing {
  0%   { box-shadow: 0 0 0 0 rgba(255, 201, 77, .55); }
  70%  { box-shadow: 0 0 0 9px rgba(255, 201, 77, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 201, 77, 0); }
}

.hud-bottom {
  display: grid;
  justify-items: center;
  gap: .6rem;
  margin-top: auto;
}

.tooltip {
  position: absolute;
  left: 50%;
  bottom: 20rem;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .1rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius-sm);
  background: rgba(10, 8, 20, .84);
  border: 1px solid rgba(255, 201, 77, .4);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  white-space: nowrap;
  animation: tipIn .2s var(--ease) both;
}

@keyframes tipIn {
  from { opacity: 0; transform: translateX(-50%) translateY(6px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.tooltip strong { font-size: .92rem; color: var(--gold); }
.tooltip span { font-size: .72rem; color: var(--ink-faint); }

.hud-bottom { display: grid; justify-items: center; gap: .6rem; }

.lock-panel {
  width: min(460px, 100%);
  padding: 1rem 1.2rem 1.1rem;
  border-radius: var(--radius);
  background: rgba(10, 8, 20, .68);
  border: 1px solid var(--line-strong);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .5);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  text-align: center;
}

.lock-panel-title {
  margin: 0 0 .7rem;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.locks { display: flex; flex-direction: column; gap: .9rem; margin-bottom: .9rem; }

.lock-row { display: grid; gap: .4rem; justify-items: center; padding-bottom: 14px; }

.lock-row-label {
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.dials { display: flex; gap: .4rem; }

.dial-wrap { position: relative; display: grid; place-items: center; }

.dial {
  width: 46px;
  height: 58px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--ink);
  background: linear-gradient(180deg, rgba(255, 255, 255, .1), rgba(0, 0, 0, .3));
  border: 1.5px solid var(--line-strong);
  transition: transform .14s var(--ease), border-color .2s, background .2s, color .2s;
}

.dial:hover { transform: translateY(-2px); border-color: var(--gold); }
.dial.is-active { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255, 201, 77, .18); }

.dial.is-solved {
  color: #0d2b18;
  background: linear-gradient(180deg, #9df3bd, var(--lime));
  border-color: var(--lime);
}

.dial.is-solved::after {
  content: "\2713";
  position: absolute;
  top: 3px;
  right: 5px;
  font-size: .72rem;
  font-weight: 800;
  color: #0d2b18;
  line-height: 1;
}

.dial-mark {
  position: absolute;
  bottom: -14px;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: .6rem;
  font-weight: 700;
  color: var(--ink-faint);
  background: rgba(255, 255, 255, .07);
  border: 1px solid var(--line);
}

.lock-panel.is-shaking { animation: shake .5s var(--ease); }

.lock-msg {
  min-height: 1.15rem;
  margin: .7rem 0 0;
  font-size: .82rem;
  font-weight: 500;
  color: var(--ink-dim);
  opacity: 0;
  transition: opacity .25s var(--ease);
}

.lock-msg.is-shown { opacity: 1; }
.lock-msg.is-bad { color: #ff8a95; }
.lock-msg.is-good { color: var(--lime); }

.controls-hint {
  margin: 0;
  padding: .35rem .9rem;
  border-radius: 999px;
  font-size: .7rem;
  color: var(--ink-faint);
  background: rgba(10, 8, 20, .5);
  border: 1px solid var(--line);
}

.hud-bottom .lock-panel { margin-bottom: .2rem; }

/* sheets / modals */
.sheet {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: rgba(4, 3, 10, .74);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: fadeIn .25s var(--ease) both;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.sheet-inner {
  position: relative;
  width: min(520px, 100%);
  max-height: 84vh;
  overflow-y: auto;
  padding: 2rem 1.8rem 1.8rem;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #221538, #170e29);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  animation: boxIn .4s var(--ease) both;
}

.sheet-inner h2 { font-size: 1.5rem; margin: .3rem 0 1rem; }

.sheet-close {
  position: absolute;
  top: .7rem;
  right: .9rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--ink-dim);
  background: var(--glass);
}

.sheet-close:hover { color: var(--ink); background: var(--glass-2); }

.notebook-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .7rem; }

.notebook-list li {
  padding: .8rem 1rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 201, 77, .07);
  border-left: 3px solid var(--gold);
  font-size: .9rem;
}

.notebook-list li.is-bonus {
  background: rgba(155, 123, 255, .1);
  border-left-color: var(--violet);
}

.notebook-list li b {
  display: block;
  margin-bottom: .2rem;
  color: var(--gold);
  font-size: .82rem;
}

.notebook-list li.is-bonus b { color: var(--violet); }

.notebook-list li span { color: var(--ink-dim); white-space: pre-line; }

.notebook-empty { color: var(--ink-faint); font-size: .9rem; text-align: center; margin: 0; }

.help-list { margin: 0 0 1.4rem; padding-left: 1.1rem; display: grid; gap: .55rem; }
.help-list li { font-size: .9rem; color: var(--ink-dim); }
.help-list b { color: var(--ink); }

.clue-body {
  margin: 0 0 1.2rem;
  font-size: .96rem;
  line-height: 1.7;
  color: var(--ink);
  white-space: pre-line;
}

.clue-reward {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
  padding: .7rem 1rem;
  border-radius: var(--radius-sm);
  background: rgba(126, 240, 168, .1);
  border: 1px solid rgba(126, 240, 168, .3);
}

.clue-reward-label {
  font-size: .68rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.clue-reward-value {
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--lime);
  letter-spacing: .1em;
}

.sheet-clue { border-color: rgba(255, 201, 77, .34); }

.loader {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1rem;
  background: #05060c;
  z-index: 25;
  color: var(--ink-dim);
  font-size: .85rem;
  transition: opacity .4s var(--ease);
}

.loader.is-done { opacity: 0; pointer-events: none; }

.spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .12);
  border-top-color: var(--gold);
  animation: spin .9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============ 4. FINAL ============ */
#screen-final {
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.25rem;
  overflow-y: auto;
  text-align: center;
  background:
    radial-gradient(900px 640px at 50% 0%, #4b1f6b 0%, transparent 60%),
    radial-gradient(800px 560px at 15% 100%, #5c1440 0%, transparent 58%),
    var(--bg-0);
}

.final-wrap { width: min(640px, 100%); margin: auto; animation: boxIn .8s var(--ease) both; }

.final-title {
  font-size: clamp(2.4rem, 10vw, 4rem);
  margin: .4rem 0 1.4rem;
  background: linear-gradient(120deg, #fff, var(--gold) 50%, var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.egg-row {
  display: flex;
  justify-content: center;
  gap: .45rem;
  margin: 0 0 1.4rem;
  font-size: 1.7rem;
  flex-wrap: wrap;
}

.wish-card .egg-row { margin-bottom: 1.1rem; }

.egg-row span {
  animation: eggPop .55s var(--ease) both;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, .4));
}

@keyframes eggPop {
  from { opacity: 0; transform: scale(.2) rotate(-40deg); }
  to   { opacity: 1; transform: none; }
}

.final-letter {
  padding: 2rem 1.8rem;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, .075), rgba(255, 255, 255, .025));
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  margin-bottom: 1.6rem;
}

.final-message {
  margin: 0 0 1.2rem;
  font-size: 1rem;
  line-height: 1.8;
  white-space: pre-line;
  color: var(--ink);
}

.final-closing {
  margin: 0;
  font-style: italic;
  color: var(--pink-soft);
  font-size: .95rem;
}

.final-actions { display: flex; gap: .7rem; justify-content: center; flex-wrap: wrap; }

.wish-card.is-final { padding: 2rem 2rem 1.8rem; }

.wish-card.is-final .cake { transform: scale(.58); margin: -0.4rem auto 0.2rem; }
.wish-card.is-final .wish-title { font-size: clamp(1.9rem, 7vw, 2.7rem); margin-bottom: .1rem; }
.wish-card.is-final .wish-name { margin-bottom: .9rem; }
.wish-card.is-final .wish-text { font-size: .93rem; line-height: 1.6; margin-bottom: .8rem; }
.wish-card.is-final .wish-closing { margin-bottom: 1rem; }
.wish-card.is-final .gallery { gap: .5rem; margin-bottom: 1.1rem; }
.wish-card.is-final .shot { aspect-ratio: 4 / 3; }
.wish-card.is-final .egg-row { font-size: 1.4rem; margin-bottom: .8rem; }
.wish-card.is-final .wish-foot { margin-top: .7rem; }

/* ============ RESPONSIVE ============ */
/* =============================================================================
   EL HUD EN EL MOVIL
   ============================================================================
   Con 720 px habia UNA regla que tocaba cuatro cosas. En un movil el HUD se
   iba de casa: la barra de arriba peleando con los botones, la del jefe mas
   ancha que la pantalla, y el aviso del perseguidor montado encima del
   joystick.

   Aqui no se adivinan anchos de pantalla: se apila en columna, con
   porcentajes y con env(safe-area-inset-*). Asi funciona en un movil de 320
   como en una tablet.
*/
@media (max-width: 720px) {
  /* La barra se parte en dos lineas: el nivel arriba, los botones abajo.
     Antes los dos compiten por el mismo ancho y se pisan. */
  .hud-top {
    flex-direction: column;
    align-items: stretch;
    gap: .5rem;
  }
  .hud-level { max-width: none; }
  .hud-tools { justify-content: center; gap: .4rem; }
  .hud-tools .chip { padding: .45rem .6rem; font-size: .72rem; }

  .hud-tag { font-size: .58rem; }
  .hud-name { font-size: .95rem; }

  .hud-story {
    max-width: 100%;
    font-size: .8rem;
    padding: .5rem .65rem;
  }

  /* La barra del jefe: que sea ANCHO DE PANTALLA menos el margen, y no los
     420 px fijos que se salian en un movil de 390. */
  .boss-hud {
    width: calc(100% - 1.4rem);
    max-width: 420px;
  }
  .boss-hud-name { font-size: .9rem; }

  /* El aviso del perseguidor, por encima del joystick y no debajo. */
  .chase-box {
    bottom: calc(max(1.1rem, env(safe-area-inset-bottom)) + 168px);
    width: min(300px, calc(100% - 2.2rem));
  }
  .chase-warn { font-size: 1.1rem; }

  /* La victoria del jefe, mas arriba para que no caiga en el joystick. */
  .boss-win {
    top: 42%;
    width: calc(100% - 1.8rem);
    max-width: 26rem;
  }
  .boss-win-text { font-size: .9rem; }

  .buddy-status { font-size: .78rem; }

  /* Los controles tactiles un poco mas grandes: son el pulgar, y 132 px se
     quedan cortos en una pantalla pequena. */
  body.es-movil .joystick { width: 118px; height: 118px; }
  body.es-movil .btn-accion { width: 70px; height: 70px; }

  /* El boton de accion se separa del joystick, que si no se pisan. */
  .tooltip { bottom: 19rem; }
}

/* Pantallas anchas pero bajitas: un movil en horizontal. Ahi el alto es lo
   que falta, no el ancho, y el joystick se come media pantalla. */
@media (max-width: 900px) and (max-height: 480px) {
  .hud { padding: .5rem; }
  body.es-movil .joystick { width: 96px; height: 96px; }
  body.es-movil .joy-muneca { width: 44px; height: 44px; }
  body.es-movil .btn-accion { width: 58px; height: 58px; }
  .chase-box { bottom: calc(max(.5rem, env(safe-area-inset-bottom)) + 118px); }
  .hud-story { font-size: .72rem; }
  .hud-name { font-size: .85rem; }
}

/* --- lo de antes de 720 px, que se queda --- */
@media (max-width: 720px) {
  .wish-card { padding: 2.4rem 1.3rem 1.8rem; }
  .lock-box { padding: 2.1rem 1.3rem 1.7rem; }

  .gallery { grid-template-columns: repeat(2, 1fr); }

  .hud { padding: .7rem; }
  .hud-story { font-size: .8rem; max-width: 92%; }

  .dial { width: 40px; height: 52px; font-size: 1.45rem; }

  .lock-panel { padding: .8rem .8rem 1rem; }

  .controls-hint { font-size: .62rem; }

  .tooltip { bottom: 18.5rem; }
}

@media (max-height: 620px) {
  .cake { transform: scale(.78); margin-bottom: .8rem; }
  }

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

/* ---------------- BOSS 2011-X ---------------- */

.boss-hud {
  align-self: center;
  display: grid;
  gap: .35rem;
  width: min(420px, 88%);
  margin-top: .5rem;
  padding: .6rem 1rem .7rem;
  border-radius: var(--radius);
  background: rgba(20, 4, 4, .72);
  border: 1px solid rgba(255, 85, 60, .4);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .55);
  backdrop-filter: blur(6px);
}

.boss-hud-name {
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: #ff8a6a;
  text-align: center;
}

.boss-hp {
  height: 12px;
  border-radius: 99px;
  background: rgba(0, 0, 0, .5);
  border: 1px solid rgba(255, 120, 80, .3);
  overflow: hidden;
}

.boss-hp-fill {
  height: 100%;
  width: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #ff3b20, #ffa53b);
  transition: width .32s var(--ease);
}

.boss-hud-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
}

.boss-levers {
  display: flex;
  gap: .34rem;
}

.boss-lever {
  width: 26px;
  height: 8px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .18);
  transition: background .25s var(--ease), box-shadow .25s var(--ease);
}

.boss-lever.is-on {
  background: #7ef0a8;
  border-color: #bfffd8;
  box-shadow: 0 0 10px rgba(126, 240, 168, .7);
}

.boss-hearts {
  font-size: 1rem;
  letter-spacing: .12em;
  color: #ff5a5a;
}

.boss-hearts .is-lost { opacity: .22; }

.boss-hud.is-hurt { animation: shake .4s var(--ease); }

/* panel inferior durante la pelea */
.boss-panel {
  width: min(460px, 100%);
  padding: 1rem 1.2rem;
  border-radius: var(--radius);
  background: rgba(20, 4, 4, .68);
  border: 1px solid rgba(255, 85, 60, .35);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .5);
  text-align: center;
}

.boss-panel-title {
  margin: 0 0 .5rem;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #ff8a6a;
}

.boss-panel-text {
  margin: 0;
  font-size: .84rem;
  color: var(--ink-dim);
  line-height: 1.5;
}

/* mensaje de victoria */
.boss-win {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 26;
  display: grid;
  justify-items: center;
  gap: .9rem;
  width: min(480px, 88%);
  padding: 1.8rem 1.6rem 1.6rem;
  text-align: center;
  border-radius: var(--radius);
  background: rgba(14, 5, 5, .93);
  border: 1px solid rgba(255, 140, 90, .45);
  box-shadow: 0 26px 70px rgba(0, 0, 0, .7);
}

.boss-win-text {
  margin: 0;
  font-size: .9rem;
  line-height: 1.65;
  color: var(--ink-dim);
  white-space: pre-line;
}

.boss-win-code {
  margin: 0;
  padding: .7rem 1rem;
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: .1em;
  color: var(--gold);
  background: rgba(255, 210, 74, .08);
  border: 1px dashed rgba(255, 210, 74, .45);
  border-radius: 10px;
}

.boss-win-hint {
  margin: 0;
  font-size: .74rem;
  color: var(--ink-faint);
  line-height: 1.5;
}

/* ---------------- INTRO: EL GATO ---------------- */

.intro {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  background: #07060c;
  overflow: hidden;
}

.intro.is-done { display: none; }

.intro.is-playing { cursor: default; }

.intro-stage {
  position: relative;
  width: min(74vh, 74vw);
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
}

.intro-cat {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 0 40px rgba(120, 180, 255, .35));
  animation: introFloat 3.4s ease-in-out infinite;
}

.intro.is-blowing .intro-cat { animation: none; }

/* la imagen crece un poco antes de reventar */
.intro.is-blowup .intro-cat {
  animation: introBlow .5s ease-in forwards;
}

.intro-box {
  position: absolute;
  left: 50%;
  bottom: 8vh;
  transform: translateX(-50%);
  width: min(440px, 86vw);
  padding: .8rem 1.1rem;
  text-align: center;
  border-radius: 12px;
  background: rgba(10, 8, 20, .8);
  border: 1px solid rgba(140, 180, 255, .25);
}

.intro-text {
  margin: 0;
  font-size: .9rem;
  color: var(--ink-dim);
}

.intro-skip {
  position: absolute;
  top: 14px;
  right: 14px;
  padding: .35rem .7rem;
  font-size: .68rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 99px;
  cursor: pointer;
}

.intro-skip:hover { color: var(--ink); border-color: rgba(255, 255, 255, .3); }

/* trozos al reventar */
.intro-shards { position: absolute; inset: 0; }

.intro-shard {
  position: absolute;
  width: var(--w);
  height: var(--h);
  left: var(--x);
  top: var(--y);
  background: var(--c);
  opacity: 0;
  border-radius: 3px;
  animation: introFly var(--d) cubic-bezier(.2, .6, .4, 1) forwards;
}

@keyframes introFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-10px) scale(1.012); }
}

@keyframes introBlow {
  0%   { transform: scale(1); filter: brightness(1); }
  55%  { transform: scale(1.14); filter: brightness(2.4); }
  100% { transform: scale(1.5); opacity: 0; filter: brightness(4); }
}

@keyframes introFly {
  0%   { opacity: 1; transform: translate(0, 0) rotate(0deg) scale(1); }
  70%  { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--tx), var(--ty)) rotate(var(--r)) scale(.3); }
}

/* ---------------- CAJA DE CODIGO ANTICIPADA ---------------- */

.early-code {
  margin-top: 1.1rem;
  border-top: 1px solid var(--line);
  padding-top: .9rem;
}

.early-code-summary {
  font-size: .7rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  cursor: pointer;
  list-style: none;
  text-align: center;
}

.early-code-summary::-webkit-details-marker { display: none; }

.early-code-summary:hover { color: var(--ink-dim); }

.early-code .lock-form { margin-top: .8rem; }

/* ---------------- FINAL: solo cajas de Undertale ---------------- */

.screen-final {
  background: #000;
  z-index: 40;
}

.screen-final .final-spacer {
  min-height: 46vh;
  margin: 0;
}

/* ---------------- EXTRAS: codigos secretos ---------------- */

.extra-capa {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
  --sacudida: 0px;
}

.extra-capa.is-hidden { display: none; }

.extra-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform-origin: center;
  will-change: transform, filter;
}

.extra-canvas.is-hidden { display: none; }

.extra-box {
  position: relative;
  z-index: 2;
  max-width: min(560px, 88vw);
  text-align: center;
  transform: translate(var(--sacudida), 0);
}

.extra-texto {
  margin: 0;
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-size: 1rem;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, .8);
}

.extra-cerrar {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 3;
  width: 38px;
  height: 38px;
  font-size: 1.3rem;
  line-height: 1;
  color: #fff;
  background: rgba(0, 0, 0, .45);
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 50%;
  cursor: pointer;
}

.extra-cerrar:hover { background: rgba(0, 0, 0, .7); }

/* --- el susto --- */
.es-salto {
  background: #000;
  animation: extraFlash .12s steps(2) 3;
}

.es-salto .extra-capa { cursor: none; }
.es-bosque .extra-capa,
.es-flip .extra-capa,
.es-cruce .extra-capa { cursor: none; }
.es-baille .extra-capa { cursor: none; }

@keyframes extraFlash {
  0%   { background: #fff; }
  100% { background: #000; }
}

/* --- la foto --- */
.es-foto {
  background: rgba(4, 4, 8, .94);
  cursor: zoom-out;
}

.es-foto .extra-foto-img {
  width: min(78vmin, 88vw);
  height: min(78vmin, 88vw);
  object-fit: cover;
  border-radius: 50%;
  box-shadow: 0 0 90px rgba(120, 180, 255, .3);
  animation: extraPop .45s cubic-bezier(.2, 1.4, .4, 1);
}

.es-foto .extra-texto {
  margin-top: 1rem;
  font-size: 1.4rem;
  letter-spacing: .1em;
  text-transform: uppercase;
}

@keyframes extraPop {
  0%   { transform: scale(.3) rotate(-12deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* --- el vuelo --- */
.es-vuelo {
  background: radial-gradient(circle at 50% 40%, #1b1030, #05030c 70%);
}

.es-vuelo .extra-texto {
  position: absolute;
  bottom: 12vh;
  font-size: 1.3rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #9fd8ff;
}

/* --- la nota --- */
.es-lore {
  background: #000;
  padding: 1.5rem;
}

.es-lore .extra-box {
  width: min(620px, 92vw);
  padding: 1.6rem 1.8rem;
  text-align: left;
  background: #000;
  border: 4px solid #fff;
  box-shadow: 0 0 0 3px #000, 0 0 40px rgba(255, 255, 255, .18);
}

.es-lore .extra-texto {
  font-family: 'Courier New', monospace;
  font-size: 1.02rem;
  line-height: 1.7;
  color: #fff;
  text-shadow: none;
  white-space: pre-line;
}

/* --- el teleport --- */
.es-teleporte {
  background: #04030a;
  cursor: pointer;
}

.es-teleporte .extra-texto {
  font-size: 1.1rem;
  letter-spacing: .08em;
  color: #8affd6;
}

.extra-anillo {
  width: 180px;
  height: 180px;
  margin: 0 auto 1.4rem;
  border: 3px solid #6cffc4;
  border-radius: 50%;
  animation: extraSpin 1.1s linear infinite;
  box-shadow: 0 0 40px rgba(108, 255, 196, .45), inset 0 0 30px rgba(108, 255, 196, .25);
}

@keyframes extraSpin {
  0%   { transform: scale(.5) rotate(0deg); opacity: .3; }
  50%  { transform: scale(1) rotate(180deg); opacity: 1; }
  100% { transform: scale(.5) rotate(360deg); opacity: .3; }
}

/* La nota final de la ayuda, y el hueco de la lista de mando. */
.help-nota {
  margin: .9rem 0 0;
  color: rgba(255, 255, 255, .55);
  font-size: .88rem;
  line-height: 1.5;
}

.help-list[hidden] { display: none; }

/* ============ EL CANAL: avisos que llegan del servidor ============ */

/* Los avisos van pegados al borde de arriba, por encima de todo.
 * z-index: 62 esta por encima del HUD (15) pero por debajo del velo de la
 * cinematica (90): durante la pelicula se ven sobre la imagen, no sobre el
 * negro. */
.avisos {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  padding: 1rem .75rem 0;
  pointer-events: none;   /* no roban clics al juego */
  z-index: 62;
}

.aviso-flotante {
  max-width: min(560px, 88vw);
  padding: .7rem 1.15rem;
  text-align: center;
  background: rgba(10, 10, 18, .95);
  border: 1px solid rgba(255, 201, 77, .55);
  border-top: 2px solid var(--gold);
  border-radius: 5px;
  color: #fff6e2;
  font-size: clamp(.95rem, 2.6vw, 1.12rem);
  line-height: 1.45;
  letter-spacing: .01em;
  box-shadow: 0 10px 34px rgba(0, 0, 0, .72);
  animation: avisoEntra .34s var(--ease);
}

.aviso-flotante.se-va {
  animation: avisoSale .4s var(--ease) forwards;
}

@keyframes avisoEntra {
  from { opacity: 0; transform: translateY(-14px); }
}

@keyframes avisoSale {
  to { opacity: 0; transform: translateY(-10px); }
}

/* En movil, un poco mas abajo para no chocar con el reloj de la pagina ni
   con el notch. */
@media (max-width: 640px) {
  .avisos { padding-top: max(.75rem, env(safe-area-inset-top)); }
  .aviso-flotante { font-size: 1rem; padding: .65rem .9rem; }
}

/* Con reduced-motion no hay entradas ni salidas, solo aparece y desaparece */
@media (prefers-reduced-motion: reduce) {
  .aviso-flotante,
  .aviso-flotante.se-va { animation: none; }
}

/* ============ EL COMBATE POR FASES ============ */

/* El cartel de fase. Va centrado y grande, por encima del HUD: es la unica
   forma de que el jugador sepa que las reglas han cambiado. Si sale pequeno, en
   medio de la accion, no se lee y no sirve de nada. */
.boss-fase {
  position: absolute;
  left: 50%;
  top: 22%;
  transform: translateX(-50%);
  width: min(560px, 84vw);
  padding: 1.2rem 1.6rem 1.35rem;
  text-align: center;
  background: rgba(8, 8, 14, .93);
  border: 1px solid rgba(255, 90, 69, .5);
  border-left: 3px solid #ff3b28;
  border-radius: 4px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .8);
  pointer-events: none;
  z-index: 26;
}

.boss-fase-num {
  display: block;
  color: rgba(255, 120, 90, .8);
  font-size: .74rem;
  letter-spacing: .34em;
  margin-bottom: .3rem;
}

.boss-fase-nombre {
  display: block;
  color: #ff6a4d;
  font-size: clamp(1.7rem, 6vw, 2.9rem);
  font-weight: 800;
  letter-spacing: .12em;
  line-height: 1.05;
  text-shadow: 0 0 26px rgba(255, 50, 30, .45);
}

.boss-fase-regla {
  margin: .55rem 0 0;
  color: rgba(255, 236, 228, .9);
  font-size: clamp(.92rem, 2.4vw, 1.06rem);
  line-height: 1.5;
}

.boss-fase-cont {
  display: block;
  margin-top: .55rem;
  color: var(--gold);
  font-size: .92rem;
  letter-spacing: .18em;
}

/* la entrada: golpe seco, sin rebote */
.boss-fase.is-in { animation: faseEntra .34s var(--ease); }

@keyframes faseEntra {
  from { opacity: 0; transform: translateX(-50%) translateY(-14px) scale(.97); }
}

/* En movil se pega arriba, que en el centro se come la escena. */
@media (max-width: 640px) {
  .boss-fase { top: 5.5rem; width: 90vw; padding: 1rem 1.1rem 1.1rem; }
}

/* ============ LA PERSECUCION ============ */

/* El aviso de abajo: solo aparece cuando el perseguidor esta cerca, para no
   tapar la pantalla todo el tiempo. */
.chase-box {
  position: absolute;
  left: 50%;
  bottom: 2.4rem;
  transform: translateX(-50%);
  width: min(300px, 62vw);
  text-align: center;
  pointer-events: none;
  z-index: 16;
  animation: chaseEntra .22s ease;
}

.chase-warn {
  margin: 0 0 .45rem;
  color: #ff5a45;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: .32em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, .85);
  animation: chaseLate .5s ease-in-out infinite alternate;
}

.chase-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .6);
  border: 1px solid rgba(255, 90, 69, .3);
  overflow: hidden;
}

.chase-meter {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff8a3d, #ff2a1e);
  box-shadow: 0 0 10px rgba(255, 60, 40, .8);
  transition: width .16s linear;
}

@keyframes chaseLate { from { opacity: .55; } to { opacity: 1; } }
@keyframes chaseEntra { from { opacity: 0; transform: translate(-50%, 8px); } }

/* La pantalla de captura. Sale un instante y main.js quita el nivel. */
.chase-catch {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  background: rgba(20, 0, 0, .82);
  color: #ffd7d0;
  z-index: 30;
  animation: chaseEntra .18s ease;
}

.chase-catch svg.lucide { width: 62px; height: 62px; color: #ff3b28; }
.chase-catch p { margin: .3rem 0 0; font-size: 1.5rem; font-weight: 700; letter-spacing: .05em; }
.chase-catch small { color: rgba(255, 215, 208, .62); letter-spacing: .12em; }

/* ============ MOVIL ============ */

/* El lienzo se queda con el dedo. Sin esto el navegador hace scroll con el
   arrastre y la camara no gira nunca: es el motivo numero uno de que "no
   funciona en el movil". */
canvas {
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

/* Los controles tactiles vienen escondidos. game.js pone es-movil en el body
   cuando detecta pantalla tactil. Sin esa clase no ocupan sitio ni se ven,
   aunque esten en el HTML. */
.joystick,
.btn-accion { display: none; }

body.es-movil .joystick {
  display: block;
  position: absolute;
  left: max(1.1rem, env(safe-area-inset-left));
  bottom: max(1.1rem, env(safe-area-inset-bottom));
  width: 132px;
  height: 132px;
  z-index: 15;
  touch-action: none;
}

.joy-base {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 201, 77, .3);
  background: radial-gradient(circle at 50% 50%,
    rgba(255, 201, 77, .1) 0%,
    rgba(10, 10, 18, .5) 70%);
  backdrop-filter: blur(3px);
  transition: border-color .18s ease, background .18s ease;
}

.joystick.is-pulsado .joy-base {
  border-color: rgba(255, 201, 77, .62);
  background: radial-gradient(circle at 50% 50%,
    rgba(255, 201, 77, .2) 0%,
    rgba(10, 10, 18, .45) 70%);
}

.joy-muneca {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 54px;
  height: 54px;
  margin: 0;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 201, 77, .82);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .5);
  transition: transform .05s linear;
}

.joystick.is-pulsado .joy-muneca { transition: none; }

/* El boton de accion. En movil no hay raton: sin este boton no se puede leer
   nada, porque leer exige hacer clic justo encima. */
body.es-movil .btn-accion {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  right: max(1.1rem, env(safe-area-inset-right));
  bottom: calc(max(1.1rem, env(safe-area-inset-bottom)) + 26px);
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 2px solid rgba(255, 201, 77, .38);
  background: rgba(12, 12, 20, .72);
  color: var(--gold);
  touch-action: manipulation;
  transition: transform .09s ease, background .09s ease;
}

body.es-movil .btn-accion:active {
  transform: scale(.9);
  background: rgba(255, 201, 77, .26);
}

body.es-movil .btn-accion svg.lucide { width: 30px; height: 30px; }

/* En movil los botones de la interfaz tienen que ser mas grandes que en PC:
   con el dedo gordo, 40 px de alto no se pulsan. */
body.es-movil .hud-btn,
body.es-movil .icon-btn { min-height: 46px; min-width: 46px; }

body.es-movil .dialog-btn { min-height: 52px; font-size: 1.02rem; }

/* ============ MANDO ============ */

/* El aviso de "mando conectado". Vive en el HUD y se va solo a los 3.6 s.
   Se pone con is-off en el HTML para que no aparezca ni un frame al
   arrancar. */
.pad-aviso {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(.94);
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .8rem 1.3rem;
  background: rgba(8, 8, 14, .9);
  border: 1px solid rgba(255, 201, 77, .34);
  border-radius: 999px;
  color: var(--gold);
  font-size: .9rem;
  letter-spacing: .06em;
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s ease, transform .3s var(--ease);
  z-index: 20;
}

.pad-aviso.is-off { opacity: 0; transform: translate(-50%, -50%) scale(.94); }

.pad-aviso svg.lucide { width: 1.25em; height: 1.25em; }

/* ============ ICONOS (lucide) ============ */

/* lucide mete un <svg class="lucide"> donde estaba el <i data-lucide>.
   Se le da un tamano por defecto y se centra con la linea de texto, para
   que no se vea descuadrado dentro de los botones redonditos del HUD. */
svg.lucide {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: -0.125em;
  stroke-width: 2;
  pointer-events: none;
}

/* El <i> que hace de contenedor: mismo tamano, para que el texto que lo
   rodea no cambie de tamano cuando lucide lo sustituya. Sin esto, los
   botones dan un salto al cargar el script. */
i[data-lucide] {
  font-style: normal;
  line-height: 1;
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  text-align: center;
}

/* los chips del HUD */
.chip svg.lucide { font-size: 1.05em; }
.chip-quit svg.lucide { font-size: 1.15em; }

/* la cruz de las hojas y la del extra */
.sheet-close svg.lucide,
.extra-cerrar svg.lucide { font-size: 1.2em; }

/* el boton de sonido */
.sound-toggle svg.lucide { font-size: 1.25em; }

/* el ojo de las claves */
.lock-eye svg.lucide { font-size: 1.1em; }

/* el boton de pistas: el icono va antes de la palabra */
#btn-notebook svg.lucide { margin-right: .25em; }

/* el huevo de los recuerdos, dentro de la fila */
.egg-row svg.lucide { width: 1.15em; height: 1.15em; }
/* ============ CINEMATICA DE ENTRADA ============ */

.cine {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  cursor: pointer;
}

.cine.is-on { display: block; }

/* Al terminar hay que apagar la seccion entera. Si se deja 'is-on' puesto el
   velo sigue encima del juego, en negro, y se come los clics. */
.cine.is-done { display: none; }

/* La transicion del velo solo se enciende con esta clase. Durante la
   cinematica el velo se mueve a cada frame, y con transition se quedaria
   siempre detras del valor real, que es peor que no tenerlo. */
.cine-velo.is-fundido { transition: opacity .85s ease; }

/* La pantalla de carga del relevo. z-index 5 la deja por encima del velo (que
   no tiene z-index) y por encima del boton de saltar (3), de modo que
   mientras carga no se puede pulsar nada. */
.cine-carga {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1rem;
  background: #05060c;
  color: var(--ink-dim);
  font-size: .85rem;
  letter-spacing: .04em;
  opacity: 0;
  pointer-events: none;
  transition: opacity .4s var(--ease);
}

.cine-carga.is-on { opacity: 1; pointer-events: auto; }

/* Mientras dura, el HUD se aparta: los dials y el cartel del nivel en
   pantalla rompen la ilusion por completo. */
body.cine-on .hud,
body.cine-on .loader { opacity: 0; pointer-events: none; }

body.cine-on .hud,
body.cine-on .loader { transition: opacity 0.45s ease; }

/* el negro del fundido, y las dos barras de cine */
.cine-velo {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 1;
  pointer-events: none;
}

/* la viñeta: se ve el centro de la imagen y se van las esquinas. Es lo que
   mas "video" hace el conjunto, y a diferencia de las barras no tapa nada */
.cine-velo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 46%, rgba(0, 0, 0, 0) 34%, rgba(0, 0, 0, 0.62) 100%);
  opacity: 0.9;
}

.cine-barra {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 5.2vh;
  background: #000;
  pointer-events: none;
  transform: scaleY(0);
  transform-origin: top;
  transition: transform 0.9s cubic-bezier(0.4, 0, 0.2, 1);
}

.cine-barra-abajo {
  top: auto;
  bottom: 0;
  transform-origin: bottom;
}

.cine.is-on .cine-barra { transform: scaleY(1); }

/* el dialogo, abajo. El fondo es un degradado que se disuelve: un recuadro
   negro sólido se vería como un cartel, no como un subtitulo */
.cine-caja {
  position: absolute;
  left: 50%;
  bottom: 11vh;
  transform: translateX(-50%);
  width: min(760px, 88vw);
  text-align: center;
  padding: 1.1em 1.6em 1em;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.5) 42%, rgba(0, 0, 0, 0.62) 100%);
  border-radius: 14px;
}

.cine-nombre {
  display: inline-block;
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-size: 15px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #ffd97a;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
}

.cine-nombre.is-on { opacity: 1; transform: translateY(0); }

.cine-texto {
  margin: 10px 0 0;
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-size: clamp(17px, 2.5vw, 26px);
  line-height: 1.5;
  color: #fff;
  min-height: 1.5em;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.95), 0 0 3px rgba(0, 0, 0, 0.9);
}

/* Las lineas que rompen la cuarta pared. Sin cambiar el texto: el nombre se
   pone de otro color y la caja se inclina un pelo, como un guiño */
.cine-texto.es-meta {
  color: #cfe9ff;
  font-style: italic;
  animation: cine-meta 0.5s ease-out both;
}

.cine-nombre.es-meta { color: #7fd4ff; }

@keyframes cine-meta {
  from { transform: translateX(-4px) skewX(-1.2deg); opacity: 0.4; }
  to { transform: none; opacity: 1; }
}

/* el cursor del raton al terminar de escribir */
.cine-texto::after {
  content: "";
  display: inline-block;
  width: 0.5em;
  height: 1.05em;
  margin-left: 3px;
  vertical-align: -0.16em;
  background: #ffd97a;
  opacity: 0.85;
  animation: cine-cursor 0.9s steps(2, start) infinite;
}

@keyframes cine-cursor {
  0%, 50% { opacity: 0.85; }
  51%, 100% { opacity: 0; }
}

.cine-saltar {
  position: absolute;
  right: 18px;
  bottom: 3.2vh;
  z-index: 3;
  padding: 7px 14px;
  font: inherit;
  font-size: 13px;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.cine-saltar:hover { background: rgba(255, 255, 255, 0.18); color: #fff; }

/* en movil la caja sube un poco, que si no choca con la barra */
@media (max-height: 520px) {
  .cine-caja { bottom: 11vh; }
}


/* =============================================================================
   LA PANTALLA DE CARGA
   =============================================================================
   Va antes de la cinematica. El fondo es el mismo verde del bosque para que
   el corte a la escena 3D no se note: si esto fuera negro, al pasar al bosque
   de golpe el ojo ve un fogonazo y se pierde la impresion de entrar.
*/
.cargador {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(120% 90% at 50% 8%, #2f4a24 0%, #1c2c17 55%, #101a0d 100%);
  color: var(--ink);
  transition: opacity .45s ease, visibility .45s;
}
.cargador.is-out { opacity: 0; visibility: hidden; }
.cargador.is-done { display: none; }

.cargador-caja {
  width: min(30rem, 100%);
  text-align: center;
}

.cargador-kicker {
  margin: 0 0 .4rem;
  font-size: .72rem;
  letter-spacing: .34em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: .85;
}

.cargador-titulo {
  margin: 0 0 1.6rem;
  font-size: clamp(1.4rem, 5.5vw, 2rem);
  font-weight: 600;
  letter-spacing: .01em;
}

/* la pista es la pista: una guia vacia, no una barra con adornos */
.cargador-pista {
  height: 3px;
  width: 100%;
  border-radius: 3px;
  background: rgba(255, 255, 255, .12);
  overflow: hidden;
}
.cargador-pista > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, #7fbf5a, var(--gold));
  transition: width .28s cubic-bezier(.22, .8, .3, 1);
}

/* lo que se esta haciendo de verdad, no un "cargando" */
.cargador-nombre {
  margin: 1rem 0 .2rem;
  font-size: .92rem;
  color: var(--ink);
}
.cargador-detalle {
  margin: 0;
  font-size: .8rem;
  color: var(--ink-dim);
  min-height: 1.2em;
  font-variant-numeric: tabular-nums;
}
.cargador-pie {
  margin: 1.6rem 0 0;
  font-size: .72rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: .7;
  min-height: 1.2em;
}


/* =============================================================================
   EL CLARO: el HUD
   =============================================================================
   Es un sitio abierto, no un pasillo, asi que el HUD va arriba y en plan
  央 centro: abajo molesta mas cuando estas mirando al suelo corriendo.
*/
.claro-hud {
  position: fixed;
  top: max(1rem, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  width: min(34rem, calc(100% - 2rem));
  /* el mismo tope que el resto de la hud: en un monitor grande, un bloque
     centrado de 34rem ya esta, y sin esto se nota el vacio a los lados */
  text-align: center;
  pointer-events: none;
}

.aviso-nivel {
  margin: 0 0 .7rem;
  font-size: clamp(.92rem, 2.6vw, 1.1rem);
  line-height: 1.5;
  color: var(--ink);
  text-shadow: 0 2px 10px rgba(0, 0, 0, .85);
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .4s ease, transform .4s ease;
}
.aviso-nivel.is-shown { opacity: 1; transform: none; }

.claro-progreso {
  display: flex;
  gap: .5rem;
  justify-content: center;
}
.claro-progreso > i {
  width: .6rem;
  height: .6rem;
  border-radius: 50%;
  border: 1.5px solid var(--gold);
  background: transparent;
  transition: background .3s ease, transform .3s ease, box-shadow .3s ease;
}
.claro-progreso > i.hecho {
  background: var(--gold);
  transform: scale(1.15);
  box-shadow: 0 0 12px rgba(255, 210, 74, .7);
}
.claro-progreso.completo > i.hecho {
  background: #7fbf5a;
  border-color: #7fbf5a;
}
