:root {
  --bg: #0f1724;
  --ink: #fdf6e3;
  --muted: #9fb3c8;
  --teal: #16a3a0;
  --coral: #ff7a59;
  --sand: #f4d58d;
  --violet: #8b5cf6;
  --panel: #182436;
  --radius: 16px;
  /* sistema visual: espaciado, radios, sombras y capas (usar estos en vez de números sueltos) */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  --r-sm: 10px; --r-md: 16px; --r-lg: 20px; --r-pill: 999px;
  --shadow-1: 0 4px 14px rgba(0,0,0,.35); --shadow-2: 0 10px 30px rgba(0,0,0,.5);
  --tap: 44px;   /* tamaño mínimo tocable */
  --scene-bg: #0f1724;
  /* tipografía (css/fonts.css): Fredoka para títulos y botones, Nunito para texto */
  --font-display: 'Fredoka', 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --fs-xs: 12px; --fs-sm: 14px; --fs-md: 16px; --fs-lg: 19px; --fs-xl: 23px; --fs-2xl: 30px; --fs-3xl: 48px;
  --lh: 1.45;
  font-family: var(--font-body);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
#app { position: relative; height: 100dvh; max-width: 560px; margin: 0 auto; }

.screen { position: absolute; inset: 0; display: none; flex-direction: column; }
.screen.active { display: flex; }

/* ---------- fondo de salto ---------- */
.warp-bg { position: absolute; inset: 0; overflow: hidden;
  background: radial-gradient(circle at 50% 50%, #2a1b5c 0%, #0f1724 60%); }
.warp-bg::before, .warp-bg::after { content: ""; position: absolute; inset: -50%;
  background: repeating-conic-gradient(from 0deg, transparent 0 8deg, rgba(22,163,160,.18) 8deg 9deg, transparent 9deg 20deg);
  animation: spin 40s linear infinite; }
.warp-bg::after { background: repeating-conic-gradient(from 5deg, transparent 0 13deg, rgba(255,122,89,.14) 13deg 14deg, transparent 14deg 27deg);
  animation-duration: 60s; animation-direction: reverse; }
.warp-bg.fast::before { animation-duration: 6s; } .warp-bg.fast::after { animation-duration: 9s; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- título ---------- */
.title-box, .end-box { position: relative; z-index: 1; margin: auto; padding: 24px; text-align: center; width: 100%; }
.logo { font-size: 48px; font-weight: 900; letter-spacing: 4px; color: var(--sand);
  text-shadow: 3px 3px 0 var(--coral), 6px 6px 0 rgba(0,0,0,.4); }
.logo span { color: var(--teal); text-shadow: 3px 3px 0 var(--violet), 6px 6px 0 rgba(0,0,0,.4); }
.tagline { color: var(--muted); margin: 6px 0 28px; }
.episode-card { background: rgba(24,36,54,.85); border: 2px solid var(--teal); border-radius: var(--radius);
  padding: 16px; margin: 0 auto 24px; max-width: 340px; }
.episode-card { position: relative; }
.ep-nav { position: absolute; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--teal); font-size: 22px; padding: 10px; }
.ep-nav[data-d="-1"] { left: 0; } .ep-nav[data-d="1"] { right: 0; }
.ep-nav:disabled { opacity: .15; }
.episode-card .num { color: var(--coral); font-size: 13px; letter-spacing: 2px; text-transform: uppercase; }
.episode-card .t { font-size: 24px; font-weight: 800; margin: 4px 0; }
.episode-card .s { color: var(--muted); font-size: 14px; }
.episode-card .diff { margin-top: 8px; letter-spacing: 2px; }
.title-meta { display: flex; gap: 12px; justify-content: center; align-items: center; margin-top: 20px; }

.btn { border: none; border-radius: 999px; padding: 12px 22px; background: var(--coral); color: #1b1b1b; font-weight: 800;
  box-shadow: 0 4px 0 #b9482d; transition: transform .08s; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #b9482d; }
.btn.big { font-size: 22px; padding: 16px 48px; }
.btn.ghost { background: transparent; color: var(--ink); border: 2px solid var(--muted); box-shadow: none; }
.btn.small { font-size: 14px; padding: 8px 14px; }
.btn.teal { background: var(--teal); box-shadow: 0 4px 0 #0b6b69; }

/* ---------- intro ---------- */
#intro-screen { justify-content: center; align-items: center; }
.intro-text { position: relative; z-index: 1; font-size: 22px; line-height: 1.4; padding: 32px; text-align: center; min-height: 40%;
  display: flex; align-items: center; text-shadow: 0 2px 8px #000; }
.intro-text.fade { animation: introIn .5s ease-out; }
@keyframes introIn { from { opacity: 0; transform: translateY(10px); filter: blur(3px); } }
.tap-hint { position: absolute; bottom: 32px; width: 100%; text-align: center; color: var(--muted); font-size: 13px; animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: .3; } }

/* ---------- HUD ---------- */
.hud { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px calc(6px) ; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--panel); border-bottom: 2px solid #22344d; gap: 8px; }
.hud-scene { font-weight: 800; font-size: 15px; }
.hud-era { color: var(--coral); font-size: 12px; letter-spacing: 1px; }
.hud-progress { display: flex; gap: 6px; }
.hud-progress .dot { width: 14px; height: 14px; border-radius: 50%; background: #2a3b55; border: 2px solid #3c5373; transition: all .3s; }
.hud-progress .dot.on { background: var(--teal); border-color: #7ff3ef; box-shadow: 0 0 10px var(--teal); transform: scale(1.15); }
.hud-timer { font-variant-numeric: tabular-nums; color: var(--sand); font-weight: 700; }

/* ---------- estabilidad ---------- */
.stab { position: relative; display: flex; align-items: center; gap: 8px; padding: 6px 14px; background: var(--panel); }
.stab-track { flex: 1; height: 8px; border-radius: 999px; background: #0f1724; overflow: hidden; }
#stab-bar { height: 100%; width: 100%; border-radius: 999px; transition: width .5s cubic-bezier(.3,1.6,.5,1), background .4s; }
#stab-bar.ok { background: linear-gradient(90deg, #16a3a0, #7ff3ef); }
#stab-bar.mid { background: linear-gradient(90deg, #f4a259, #f4d58d); }
#stab-bar.low { background: linear-gradient(90deg, #e63946, #ff7a59); animation: blink .8s infinite; }
#stab-val { font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; }
.stab-float { position: absolute; right: 70px; top: -2px; font-weight: 900; font-size: 15px; animation: floatUp 1.2s ease-out forwards; pointer-events: none; }
.stab-float.neg { color: #ff5a5f; } .stab-float.pos { color: #7ff3ef; }
@keyframes floatUp { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-22px); } }
#stage.glitch { animation: glitch .35s steps(2) 1, shake .4s; }
#stage.glitch-big { animation: glitch .9s steps(3) 2; }
@keyframes glitch {
  0% { filter: none; clip-path: inset(0); }
  25% { filter: hue-rotate(90deg) saturate(3) contrast(1.4); clip-path: inset(10% 0 30% 0); transform: translateX(-6px); }
  50% { filter: invert(.85) hue-rotate(200deg); clip-path: inset(40% 0 5% 0); transform: translateX(6px); }
  75% { filter: saturate(0) brightness(1.6); clip-path: inset(0 0 60% 0); }
  100% { filter: none; clip-path: inset(0); transform: none; }
}
.end-stars { width: 100%; font-size: 34px; letter-spacing: 4px; margin-bottom: -6px; }
.end-stats { flex-wrap: wrap; }

/* ---------- escena ---------- */
#stage-wrap { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; padding: 8px; }
#stage { position: relative; aspect-ratio: 2 / 3; width: min(100%, calc((100dvh - 180px) * 2 / 3)); height: auto; border-radius: 14px; overflow: hidden;
  box-shadow: 0 8px 30px rgba(0,0,0,.5); background: #000; }
@supports not (aspect-ratio: 2/3) { #stage { width: 100%; } }
#scene-art, #scene-art > * { position: absolute; inset: 0; width: 100%; height: 100%; }
#scene-art img { object-fit: cover; }
#scene-art.fade { animation: sceneIn .45s ease-out; }
@keyframes sceneIn { from { opacity: 0; transform: scale(1.04); filter: blur(4px) hue-rotate(60deg); } }
#hotspots { position: absolute; inset: 0; }
.hotspot { position: absolute; background: transparent; border: none; padding: 0; border-radius: 12px; }
.hotspot.reveal { outline: 3px dashed rgba(244,213,141,.9); background: rgba(244,213,141,.15); animation: pulse 1s infinite; }
.hotspot .lbl { display: none; position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); white-space: nowrap;
  background: rgba(15,23,36,.85); padding: 2px 8px; border-radius: 8px; font-size: 12px; pointer-events: none; }
.hotspot.reveal .lbl { display: block; }
.hotspot.edge-l .lbl { left: 4px; transform: translateY(-50%); }
.hotspot.edge-r .lbl { left: auto; right: 4px; transform: translateY(-50%); }
@keyframes pulse { 50% { background: rgba(244,213,141,.3); } }
#fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#stage.shake { animation: shake .4s; }
@keyframes shake { 20% { transform: translateX(-8px) rotate(-1deg); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px) rotate(1deg); } 80% { transform: translateX(4px); } }

/* ---------- barra inferior ---------- */
.bottom { display: flex; align-items: center; gap: 8px; padding: 8px 10px; padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: var(--panel); border-top: 2px solid #22344d; }
.inventory { flex: 1; display: flex; gap: 8px; overflow-x: auto; min-height: 52px; align-items: center; }
.item { width: 52px; height: 52px; flex: none; border-radius: 12px; background: #22344d; border: 2px solid #3c5373; font-size: 28px;
  display: flex; align-items: center; justify-content: center; }
.item.new { animation: pop .6s; border-color: var(--sand); }
@keyframes pop { 0% { transform: scale(0); } 60% { transform: scale(1.3) rotate(10deg); } 100% { transform: scale(1); } }
.tools { display: flex; gap: 6px; }
.tool { width: 46px; height: 46px; border-radius: 50%; border: 2px solid #3c5373; background: #22344d; font-size: 20px; position: relative; }
.tool:active { transform: scale(.92); }
#hint-count { position: absolute; top: -4px; right: -4px; background: var(--coral); color: #111; font-size: 11px; font-weight: 800;
  border-radius: 999px; padding: 1px 5px; }
#hint-count:empty { display: none; }

/* ---------- diálogo ---------- */
.dialog { position: absolute; left: 10px; right: 10px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 20; background: rgba(253,246,227,.97);
  color: #1d2533; border-radius: var(--radius); padding: 16px 18px 22px; font-size: 17px; line-height: 1.4; border: 3px solid var(--sand);
  box-shadow: 0 10px 30px rgba(0,0,0,.5); animation: dlgIn .2s ease-out; }
.dialog.hidden { display: none; }
@keyframes dlgIn { from { transform: translateY(20px); opacity: 0; } }
.dialog-next { position: absolute; right: 14px; bottom: 6px; color: var(--coral); animation: blink 1s infinite; font-size: 12px; }
.dialog.fail { border-color: var(--coral); background: #ffe9e2; }

/* ---------- modal / puzzles ---------- */
.modal { position: absolute; inset: 0; z-index: 30; background: rgba(5,10,18,.75); display: flex; align-items: center; justify-content: center; padding: 12px; }
.modal.hidden { display: none; }
.modal-card { position: relative; width: 100%; max-height: 100%; overflow-y: auto; background: var(--panel); border: 2px solid var(--teal);
  border-radius: 20px; padding: 22px 18px 18px; animation: dlgIn .25s ease-out; }
.modal-close { position: absolute; top: 8px; right: 10px; background: none; border: none; font-size: 20px; color: var(--muted); }
.modal h2 { margin: 0 0 6px; color: var(--sand); font-size: 22px; }
.modal p { color: var(--muted); margin: 0 0 16px; font-size: 15px; line-height: 1.4; }
.modal.success .modal-card { border-color: var(--sand); box-shadow: 0 0 40px rgba(244,213,141,.4); }

.glyph-sign { font-size: 44px; letter-spacing: 10px; text-align: center; background: #0f1724; border-radius: 12px; padding: 14px; color: #7ff3ef;
  text-shadow: 0 0 12px var(--teal); margin-bottom: 16px; }
.slots { display: flex; justify-content: center; gap: 8px; margin-bottom: 14px; }
.slot { width: 46px; height: 56px; border-radius: 10px; background: #0f1724; border: 2px solid #3c5373; font-size: 28px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; }
.slot.cur { border-color: var(--sand); }
.slot.ok { border-color: var(--teal); background: #0c3b3a; }
.keyboard { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.key { padding: 10px 0; border-radius: 8px; border: none; background: #2a3b55; font-weight: 800; font-size: 16px; }
.key:active { background: var(--teal); }
.key.wide { grid-column: span 2; background: #3c5373; }

.pipes { display: grid; gap: 4px; margin: 0 auto 8px; width: min(100%, 320px); position: relative; }
.pipe { aspect-ratio: 1; background: #0f1724; border-radius: 8px; border: none; padding: 0; transition: transform .15s; }
.pipe svg { width: 100%; height: 100%; display: block; transition: transform .18s ease-out; }
.pipe:active { transform: scale(.94); }
.pipes-wrap { position: relative; padding: 0 22px; }
.pipe-io { position: absolute; font-size: 18px; }

.simon { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: min(100%, 300px); margin: 0 auto; }
.pad { aspect-ratio: 1; border-radius: 24px; border: none; font-size: 40px; opacity: .55; transition: all .12s; }
.pad.lit { opacity: 1; transform: scale(1.06); box-shadow: 0 0 30px currentColor; }
.simon-status { text-align: center; margin: 14px 0 0; font-weight: 700; color: var(--sand); min-height: 24px; }
.stability { height: 10px; background: #0f1724; border-radius: 999px; overflow: hidden; margin-bottom: 14px; }
.stability > div { height: 100%; background: linear-gradient(90deg, var(--coral), var(--sand), var(--teal)); transition: width .5s; }

.rings-wrap { width: min(100%, 290px); margin: 0 auto 10px; }
.rings-svg { width: 100%; display: block; }
.rings-svg .ring { transform-origin: 150px 150px; transition: transform .35s cubic-bezier(.3,1.5,.5,1); }
.rings-svg text { transform-box: fill-box; transform-origin: center; transition: transform .35s cubic-bezier(.3,1.5,.5,1); }
.rings-label { text-align: center; color: var(--muted); font-size: 13px; }
.rings-target { display: flex; justify-content: center; gap: 8px; margin: 6px 0 12px; }
.rings-target .rt { width: 42px; height: 42px; border-radius: 10px; border: 2px solid; display: flex; align-items: center; justify-content: center; font-size: 22px; background: #0f1724; opacity: .6; }
.rings-target .rt.ok { opacity: 1; box-shadow: 0 0 12px currentColor; color: #fdf6e3; }
.rings-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
/* deslizante */
.slide { display: grid; gap: 3px; width: min(100%, 320px); margin: 0 auto; aspect-ratio: 1; background: #0f1724; padding: 3px; border-radius: 10px; }
.slide-tile { border: none; padding: 0; border-radius: 4px; transition: transform .15s; box-shadow: inset 0 0 0 1px rgba(0,0,0,.35); }
.slide-tile:active { filter: brightness(1.2); }
.slide-hole { border-radius: 4px; background: #070b12; }
.slide.solved { gap: 0; transition: gap .4s; }
.slide-tools { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.slide-thumb { width: 56px; height: 56px; border-radius: 8px; border: 2px solid #3c5373; object-fit: cover; }
.slide-count { color: var(--muted); font-size: 13px; }
.btn.on { border-color: var(--sand); color: var(--sand); }
/* espejos */
.mirrors { display: grid; gap: 3px; width: min(100%, 330px); margin: 0 auto; }
.mc { aspect-ratio: 1; border: none; border-radius: 6px; background: #0f1724; font-size: 22px; font-weight: 900; color: #9fb3c8; padding: 0; transition: background .2s; }
.mc.lit { background: #3a3215; box-shadow: inset 0 0 12px var(--beam, rgba(255,214,102,.55)); }
.mc.wall { background: repeating-linear-gradient(45deg, #2a3b55 0 6px, #22344d 6px 12px); }
.mc.src { color: #ffd666; font-size: 24px; }
.mc.tgt { font-size: 22px; filter: grayscale(.8) brightness(.7); }
.mc.tgt.on { filter: none; animation: pop .5s; box-shadow: 0 0 20px #7ff3ef; }
.mc.mir { color: #fdf6e3; background: #22344d; }
.mc.mir.lit { background: #4d4218; color: #ffe9a3; }
.mc.bronze { color: #d9a35b; background: #3b2a16; cursor: default; }
.mc.ghost { color: #b18cff; background: #241a38; cursor: default; animation: pop .4s; }
.mc.slot { color: #4f6683; cursor: default; }
/* diferencias */
.diff-frame { position: relative; width: min(100%, 300px); aspect-ratio: 2 / 3; margin: 0 auto; border-radius: 10px; overflow: hidden; cursor: crosshair; background: #0f1724; }
.diff-frame.before { outline: 3px solid var(--sand); }
.diff-frame.before::after { content: 'ANTES'; position: absolute; top: 8px; left: 8px; background: var(--sand); color: #111; font-weight: 900; font-size: 12px; padding: 2px 8px; border-radius: 6px; }
.diff-img { display: block; width: 100%; height: 100%; object-fit: cover; }
.diff-marks { position: absolute; inset: 0; pointer-events: none; }
.diff-frame.before .diff-marks { display: none; }
.diff-mark { position: absolute; aspect-ratio: 1; translate: -50% -50%; border: 3px solid #7ff3ef; border-radius: 50%; box-shadow: 0 0 12px #7ff3ef; animation: pop .4s; }
.diff-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.diff-status { font-weight: 800; color: var(--sand); }
.notes-list { list-style: none; padding: 0; margin: 0; }
.notes-list li { background: #0f1724; border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; font-size: 15px; }

/* ---------- final ---------- */
.end-title { font-size: 34px; font-weight: 900; color: var(--sand); text-shadow: 3px 3px 0 var(--coral); margin-bottom: 14px; animation: pop .7s; }
.end-stats { display: flex; justify-content: center; gap: 18px; margin-bottom: 18px; font-size: 18px; }
.end-stats b { display: block; font-size: 28px; color: var(--teal); }
.codex-card { background: linear-gradient(135deg, #2a1b5c, #182436); border: 2px solid var(--sand); border-radius: var(--radius); padding: 14px;
  text-align: left; margin: 0 auto 16px; max-width: 360px; animation: pop .8s .3s both; }
.codex-card .k { color: var(--coral); font-size: 12px; letter-spacing: 2px; text-transform: uppercase; }
.codex-card .n { font-size: 20px; font-weight: 800; margin: 2px 0 6px; }
.codex-card .x { font-size: 14px; color: #d5deea; line-height: 1.4; }
.share { background: #0f1724; border-radius: 12px; padding: 12px; font-size: 15px; white-space: pre-wrap; margin: 0 auto 14px; max-width: 360px; text-align: left; }
.end-next { color: var(--muted); margin: 14px 0 10px; font-size: 14px; }

/* ---------- modo Distorsión ---------- */
.dist-btn { margin-top: 14px; background: #2a1b3d; color: #d8c7f0; border: 2px solid #6b3fa0; box-shadow: 0 4px 0 #160d22; }
.dist-btn:disabled { opacity: .55; cursor: default; }
.dist-btn small { opacity: .75; font-weight: 600; }
body.dist { --teal: #7d5bd6; --coral: #c43c5c; --sand: #b9e36a; --panel: #140f1e; --bg: #0a0710; }
body.dist .hud, body.dist .bottom { border-color: #2c1f42; }
body.dist .warp-bg { background: radial-gradient(circle at 50% 50%, #3d0f2a 0%, #0a0710 65%); }
body.dist .dialog { background: rgba(28,20,40,.97); color: #e8def7; border-color: #6b3fa0; }
body.dist .dialog.fail { background: #3a1020; border-color: #c43c5c; }
body.dist .modal-card { border-color: #6b3fa0; }
.dist-overlay { position: absolute; inset: 0; pointer-events: none; display: none; }
body.dist .dist-overlay { display: block;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(10,4,16,.75) 100%),
              repeating-linear-gradient(0deg, rgba(0,0,0,.12) 0 2px, transparent 2px 4px);
  animation: flicker 7s infinite; }
@keyframes flicker { 0%, 91%, 100% { opacity: 1; transform: none; } 92% { opacity: .6; transform: translateX(3px) skewX(2deg); }
  93% { opacity: 1; transform: translateX(-2px); } 96% { opacity: .8; } }
/* si aún no hay imagen -dist, se oscurece la normal por CSS */
#scene-art.fake-dist { filter: saturate(.55) hue-rotate(235deg) brightness(.55) contrast(1.25); }

.toast { position: absolute; left: 50%; top: 70px; transform: translateX(-50%) translateY(-20px); background: var(--sand); color: #1b1b1b;
  padding: 8px 16px; border-radius: 999px; font-weight: 800; opacity: 0; transition: all .3s; z-index: 40; pointer-events: none; white-space: nowrap; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- semana (tira L M X J V S D) ---------- */
.week-strip { max-width: 340px; margin: 0 auto 10px; }
.wk-title { color: var(--muted); font-size: 12px; letter-spacing: 2px; text-transform: uppercase; margin-bottom: 6px; }
.wk-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.wk-day { background: rgba(24,36,54,.85); border: 2px solid #2a3d58; border-radius: 12px; padding: 5px 0 6px; color: var(--ink);
  display: flex; flex-direction: column; align-items: center; gap: 2px; font: inherit; }
.wk-n { font-size: 11px; font-weight: 800; color: var(--muted); }
.wk-i { font-size: 17px; line-height: 1.1; min-height: 19px; }
.wk-day.today { border-color: var(--coral); }
.wk-day.sel { background: #22385a; box-shadow: 0 0 0 2px var(--sand) inset; }
.wk-day.got { border-color: var(--teal); }
.wk-day.missed .wk-i { color: var(--coral); font-weight: 900; }
.wk-day.future, .wk-day.empty { opacity: .4; }
.wk-day.brecha { border-style: dashed; border-color: #8b5cf6; }
.wk-day.brecha.got { border-style: solid; }
.episode-card .late { color: var(--sand); margin-top: 6px; font-size: 13px; }

/* ---------- eco conseguido ---------- */
.echo-card { border-color: var(--sand); }
.echo-ic { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: radial-gradient(circle, var(--c) 0%, transparent 72%); }

/* ---------- puzzle de ordenar (sello) ---------- */
.order-row { display: flex; gap: 8px; justify-content: center; margin: 14px 0 6px; flex-wrap: wrap; }
.order-slot { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 84px; }
.order-num { color: var(--muted); font-size: 12px; font-weight: 800; }
.order-card { width: 84px; min-height: 92px; border-radius: 14px; border: 2px solid #2a3d58; background: #182436; color: var(--ink);
  font: inherit; font-size: 11px; line-height: 1.2; padding: 6px 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.order-card .oi { font-size: 30px; }
.order-card.pick { border-color: var(--sand); transform: translateY(-4px); box-shadow: 0 6px 16px rgba(244,213,141,.25); }
.order-help { text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- interruptores ---------- */
.lights { display: grid; gap: 8px; max-width: 280px; margin: 12px auto; }
.lt { aspect-ratio: 1; border-radius: 14px; border: 2px solid #2a3d58; background: #111b2a; transition: background .15s, box-shadow .15s; }
.lt.on { background: radial-gradient(circle, #fff6c9 0%, var(--sand) 45%, #c99a2e 100%); box-shadow: 0 0 18px rgba(244,213,141,.7); border-color: var(--sand); }

/* ---------- engranajes ---------- */
.gears { display: grid; gap: 4px; max-width: 300px; margin: 12px auto; }
.gc { aspect-ratio: 1; border-radius: 10px; border: 1px solid #2a3d58; background: #142033; position: relative; display: grid; place-items: center; padding: 0; }
.gc.void { background: transparent; border-color: transparent; }
.gc .peg { color: #3c5373; font-size: 18px; }
.gc .gear { font-size: 34px; line-height: 1; color: var(--sand); display: inline-block; }
.gc.motor .gear { color: var(--coral); }
.gc.axle { border-color: var(--teal); }
.gc.axle .gear { color: var(--teal); }
.gc.rust .gear { color: #8a5a3c; }
.gc .want { position: absolute; top: 1px; right: 4px; font-size: 13px; color: var(--teal); font-weight: 900; }
.gear.cw { animation: spin 2s linear infinite; }
.gear.ccw { animation: spin 2s linear infinite reverse; }
@keyframes spin { to { transform: rotate(360deg); } }
.gears.jam { animation: shake .4s; }

/* ---------- balanza ---------- */
.bal-stand { height: 70px; display: flex; justify-content: center; align-items: flex-end; position: relative; margin-top: 10px; }
.bal-stand::after { content: ''; position: absolute; bottom: 0; width: 10px; height: 54px; background: #a3874a; border-radius: 4px; }
.bal-beam { width: 240px; height: 8px; background: var(--sand); border-radius: 4px; margin-bottom: 54px; transition: transform .4s; z-index: 1; }
.bal-pans { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0; }
.bal-pan { min-height: 90px; border: 2px dashed #3c5373; border-radius: 0 0 40px 40px; display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; align-content: flex-start; padding: 6px; }
.bal-tray { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 8px; min-height: 60px; }
.bal-obj { width: 64px; border-radius: 12px; border: 2px solid #2a3d58; background: #182436; color: var(--ink); font: inherit; font-size: 10px; padding: 4px 2px; display: flex; flex-direction: column; align-items: center; }
.bal-obj .oi { font-size: 24px; }

/* ---------- palancas ---------- */
.levers { display: flex; gap: 14px; justify-content: center; margin: 16px 0; }
.lever-col { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.lever-lbl { font-size: 20px; color: var(--sand); }
.lever { width: 40px; height: 96px; border-radius: 20px; background: #111b2a; border: 2px solid #3c5373; position: relative; padding: 0; }
.lever .knob { position: absolute; left: 4px; width: 28px; height: 28px; border-radius: 50%; background: var(--coral); bottom: 6px; transition: bottom .18s; box-shadow: 0 3px 0 rgba(0,0,0,.4); }
.lever.up .knob { bottom: 58px; background: var(--teal); }

/* ---------- reloj ---------- */
.clock { width: 220px; margin: 10px auto; }
.clock svg { width: 100%; display: block; }
.clock-btns { display: flex; gap: 6px; justify-content: center; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: 13px; }

/* ---------- variaciones ---------- */
.lt.ic { font-size: 26px; display: grid; place-items: center; background: #111b2a; box-shadow: none; }
.lt.ic.on { background: #2a2a12; box-shadow: 0 0 14px rgba(244,213,141,.5); }
.lt.goal { outline: 2px dashed var(--teal); outline-offset: -6px; }
.order-slot.out .order-card { opacity: .55; border-style: dashed; }
.lever.small { width: 34px; height: 70px; }
.lever.small .knob { width: 22px; height: 22px; left: 4px; }
.lever.small.up .knob { bottom: 38px; }

/* ---------- cables ---------- */
.connect { display: grid; gap: 3px; max-width: 320px; margin: 12px auto; touch-action: none; user-select: none; }
.cn { aspect-ratio: 1; border-radius: 8px; background: #142033; display: grid; place-items: center; position: relative; }
.cn.wall { background: repeating-linear-gradient(45deg, #3c5373 0 5px, #22344d 5px 10px); }
.cn-dot { width: 64%; height: 64%; border-radius: 50%; display: grid; place-items: center; color: var(--ink); font-weight: 900; box-shadow: 0 0 10px rgba(0,0,0,.4); pointer-events: none; }
.cn-wire { width: 34%; height: 34%; border-radius: 50%; pointer-events: none; }

/* ---------- puertas lógicas ---------- */
.logic { max-width: 320px; margin: 8px auto 0; }
.logic svg { width: 100%; display: block; }
.logic-ins { display: flex; justify-content: space-around; max-width: 320px; margin: 0 auto 8px; }

/* ---------- gravedad ---------- */
.tilt { display: grid; gap: 3px; max-width: 300px; margin: 12px auto; touch-action: none; }
.tc { aspect-ratio: 1; border-radius: 8px; background: #142033; display: grid; place-items: center; position: relative; }
.tc.wall { background: #3c5373; }
.tc .hole { position: absolute; width: 60%; height: 60%; border-radius: 50%; border: 4px solid; background: #050a12; }
.tc .ball { position: relative; width: 70%; height: 70%; border-radius: 50%; display: grid; place-items: center; font-size: 18px; box-shadow: inset -4px -4px 0 rgba(0,0,0,.25); }
.tc .ball.anti { outline: 2px dashed var(--ink); outline-offset: 2px; }
.tilt-arrows { display: grid; grid-template-columns: repeat(4, 52px); gap: 8px; justify-content: center; margin-top: 8px; }

/* ---------- bloques ---------- */
.blocks { position: relative; width: min(300px, 82vw); aspect-ratio: 1; margin: 12px auto; background: #142033; border-radius: 12px; border: 3px solid #3c5373; }
.blk { position: absolute; padding: 0; border: 3px solid #0f1724; border-radius: 10px; background: #5b6f8c; transition: left .15s, top .15s; font-size: 22px; }
.blk.key { background: var(--coral); }
.blk.ghost { background: repeating-linear-gradient(45deg, #8b5cf6 0 6px, #5b3a8c 6px 12px); }
.blk-exit { position: absolute; right: -9px; width: 9px; background: var(--teal); border-radius: 0 4px 4px 0; }
.blocks.solved .blk.key { left: 110% !important; transition: left .5s; }

/* ---------- ecuaciones ---------- */
.eq-list { display: flex; flex-direction: column; gap: 6px; align-items: center; margin: 10px 0; }
.eq { font-size: 22px; letter-spacing: 2px; background: #142033; border-radius: 12px; padding: 6px 14px; }
.eq.q { font-size: 24px; border: 2px solid var(--sand); margin: 0 auto 10px; text-align: center; }
.eq.q.ok { border-color: var(--teal); }
.numpad { grid-template-columns: repeat(3, 1fr) !important; max-width: 240px; margin: 0 auto; }
.key.ok { background: var(--teal); color: #0f1724; }

/* ---------- sudoku de símbolos ---------- */
.latin { display: grid; gap: 2px; max-width: 280px; margin: 12px auto; }
.lc { aspect-ratio: 1; border-radius: 6px; background: #142033; border: 1px solid #2a3d58; color: var(--ink); font-size: 26px; padding: 0; }
.lc.fixed { background: #22344d; }
.lc.bad { background: #5a2430; }
.lc.br { margin-right: 4px; } .lc.bb { margin-bottom: 4px; }
.latin.diag .lc.dg { box-shadow: inset 0 0 0 2px rgba(139,92,246,.6); }

/* ---------- pantalla final: se puede desplazar y siempre hay salida ---------- */
#end-screen { overflow-y: auto; -webkit-overflow-scrolling: touch; }
#end-screen .end-box { margin: 0 auto; padding-top: 48px; padding-bottom: calc(28px + env(safe-area-inset-bottom)); }
#end-screen .warp-bg { position: fixed; }
.end-close { position: fixed; top: calc(10px + env(safe-area-inset-top)); right: max(12px, calc(50% - 268px)); z-index: 5; width: 40px; height: 40px;
  border-radius: 50%; border: 2px solid #3c5373; background: rgba(15,23,36,.85); color: var(--ink); font-size: 18px; }

/* =====================================================================
   Repaso visual (2026-11-25)
   ===================================================================== */
/* pantallas que pueden ser más altas que el móvil: se desplazan */
#title-screen { overflow-y: auto; }
#title-screen .warp-bg { position: fixed; }

/* botones: tamaño tocable, foco visible, desactivados */
.btn { min-height: var(--tap); }
.btn.small { min-height: 36px; }
.btn:disabled { opacity: .45; filter: grayscale(.4); box-shadow: none; }
button:focus-visible, .hotspot:focus-visible { outline: 3px solid var(--sand); outline-offset: 2px; }
.tool, .item { min-width: var(--tap); min-height: var(--tap); }

/* portada: logo y tarjeta del salto con la imagen de su escena */
.logo-img { width: 92px; height: 92px; display: block; margin: 0 auto -6px; filter: drop-shadow(0 6px 14px rgba(0,0,0,.5)); }
.episode-card { overflow: hidden; isolation: isolate; }
.episode-card::before { content: ''; position: absolute; inset: 0; z-index: -1; background-image: linear-gradient(180deg, rgba(15,23,36,.55) 0%, rgba(15,23,36,.92) 70%), var(--ep-img, none);
  background-size: cover; background-position: center 30%; }
.episode-card .t, .episode-card .s { text-shadow: 0 2px 6px rgba(0,0,0,.8); }

/* intro: saltar */
.skip { position: absolute; top: calc(var(--sp-3) + env(safe-area-inset-top)); right: var(--sp-3); z-index: 2; }

/* HUD: menú */
.hud-right { display: flex; align-items: center; gap: var(--sp-2); }
.hud-menu { width: 38px; height: 38px; border-radius: var(--r-sm); border: 2px solid #3c5373; background: #22344d; font-size: 18px; padding: 0; }
.menu-list { display: flex; flex-direction: column; gap: var(--sp-3); align-items: stretch; margin: var(--sp-4) 0 var(--sp-2); }
.menu-note { text-align: center; font-size: 13px !important; }

/* escena: fondo del color de la realidad */
#stage-wrap { background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--scene-bg) 70%, #000 0%) 0%, var(--bg) 75%); }

/* diálogo con retrato */
.dialog.has-face { padding-left: 96px; min-height: 104px; }
.dialog-face { display: none; position: absolute; left: 8px; bottom: 8px; width: 84px; height: 84px; }
.dialog.has-face .dialog-face { display: block; }
.dialog-face img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 3px 4px rgba(0,0,0,.35)); }
.dialog-who { display: none; font-size: 12px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase; color: var(--coral); margin-bottom: 2px; }
.dialog.has-face .dialog-who { display: block; }

/* iconos con imagen */
.art-ic { width: 82%; height: 82%; object-fit: contain; display: block; margin: auto; }
.item .art-ic { width: 40px; height: 40px; }
.wk-i .art-ic { width: 20px; height: 20px; }
.echo-ic .art-ic { width: 30px; height: 30px; }
.inv-empty { color: #4f6683; font-size: 13px; padding-left: var(--sp-1); }

/* Códice con ilustración */
.codex-card { position: relative; }
.codex-art { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--r-sm); margin-bottom: var(--sp-2); display: block; }

/* móviles bajos: la portada cabe sin desplazar */
@media (max-height: 700px) {
  .logo-img { width: 60px; height: 60px; }
  .logo { font-size: 40px; }
  .tagline { margin: 4px 0 14px; }
  .episode-card { padding: 12px; margin-bottom: 14px; }
  .episode-card .t { font-size: 21px; }
  .btn.big { font-size: 20px; padding: 12px 40px; }
  .title-meta { margin-top: 12px; }
  #title-screen .title-box > div:has(#btn-dist) { margin-top: -4px; }
}

/* HUD: el nombre de la escena en una línea */
.hud-left { flex: 1; min-width: 0; }
.hud-scene { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 380px) { .hud-progress { gap: 4px; } .hud-progress .dot { width: 11px; height: 11px; } .hud { padding-left: 10px; padding-right: 10px; } }

/* =====================================================================
   Repaso visual de puzzles (2026-11-25)
   ===================================================================== */
/* --- cifrado: cada glifo sobre su casilla, en una placa --- */
.glyph-plate { background: radial-gradient(circle at 50% 0%, #17324a 0%, #0b1320 80%); border: 2px solid #2a3d58; border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-2); margin-bottom: var(--sp-3); box-shadow: inset 0 0 24px rgba(22,163,160,.15); }
.glyph-plate .slots { margin: 0; gap: 6px; flex-wrap: nowrap; }
.slot-col { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1 1 0; max-width: 46px; min-width: 0; }
.slot-g { font-size: 30px; line-height: 1; color: #7ff3ef; text-shadow: 0 0 12px var(--teal); }
.slot-col .slot { width: 100%; height: 48px; display: grid; place-items: center; font-size: 24px; }
.slot.full { border-color: #5b7aa0; }
.slot.ok { animation: pop .4s; }

/* --- tuberías: piezas con relieve, giro animado, fluido que corre --- */
.pipes-wrap { padding: 0 30px; }
.pipe { background: linear-gradient(160deg, #182436, #0d1522); box-shadow: inset 0 0 0 1px #22344d, inset 0 -3px 0 rgba(0,0,0,.35); }
.pipe.empty { background: #0b121d; box-shadow: none; }
.pipe svg { transition: transform .22s cubic-bezier(.3,1.4,.5,1); }
.pipe line.p { stroke: #5b6f8c; stroke-width: 24; stroke-linecap: round; }
.pipe line.f { stroke: transparent; stroke-width: 8; stroke-linecap: round; stroke-dasharray: 10 14; }
.pipe .hub { fill: #5b6f8c; }
.pipe.wet line.p { stroke: var(--wet); }
.pipe.wet line.f { stroke: var(--glow); animation: flow .6s linear infinite; }
.pipe.wet .hub { fill: var(--glow); }
@keyframes flow { to { stroke-dashoffset: -24; } }
.pipes.solved .pipe.wet { box-shadow: inset 0 0 14px var(--wet); }
.pipe-io { position: absolute; width: 30px; display: grid; place-items: center; }
.pipe-io span { font-size: 24px; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: #0b121d; border: 2px solid #3c5373; }
.pipe-io.left { left: 0; } .pipe-io.right { right: 0; }
.pipe-io.on span { border-color: var(--wet, #38e1dc); box-shadow: 0 0 14px var(--wet, #38e1dc); animation: pop .5s; }

/* --- espejos: el rayo se dibuja --- */
.mirrors { position: relative; }
.mirrors .beam { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; overflow: visible; }
.mirrors .beam polyline { fill: none; stroke: var(--beam, rgba(255,214,102,.75)); stroke-width: 3.2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; filter: drop-shadow(0 0 4px var(--beam, #ffd666)); }
.mirrors .beam polyline { stroke-width: 9px; opacity: .45; }
.mirrors .beam polyline.core { stroke: #fff8d6; stroke-width: 3px; opacity: 1; filter: none; }
.mirrors .beam.hit polyline { animation: beamPulse 1s ease-in-out infinite; }
@keyframes beamPulse { 50% { opacity: .7; } }
.mc.lit { box-shadow: none; background: #1b2232; }

/* --- cables: tramos de cable --- */
.cn-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.cn-svg line { stroke: var(--w); stroke-width: 30; stroke-linecap: round; }
.cn-svg circle { fill: var(--w); }
.cn-dot { position: relative; z-index: 1; border: 3px solid rgba(15,23,36,.6); }
.cn.done .cn-svg { filter: drop-shadow(0 0 5px var(--w)); }

/* --- sudoku: recuadros y casillas fijas --- */
.latin { gap: 0; border: 3px solid #5b7aa0; border-radius: var(--r-sm); overflow: hidden; }
.lc { border-radius: 0; border: 1px solid #2a3d58; }
.lc.br { margin-right: 0; border-right: 3px solid #5b7aa0; }
.lc.bb { margin-bottom: 0; border-bottom: 3px solid #5b7aa0; }
.lc.fixed { background: #2c4366; box-shadow: inset 0 0 0 2px rgba(244,213,141,.25); }
.lc:not(.fixed):active { background: #22344d; }

/* --- gravedad: bolas que ruedan y tablero que se inclina --- */
.tilt { position: relative; perspective: 600px; transition: transform .25s; }
.tilt .ball { position: absolute; border-radius: 50%; display: grid; place-items: center; font-size: 18px; z-index: 2;
  box-shadow: inset -4px -4px 0 rgba(0,0,0,.25), 0 3px 6px rgba(0,0,0,.4); transition: left .32s cubic-bezier(.4,1.5,.6,1), top .32s cubic-bezier(.4,1.5,.6,1), transform .3s, opacity .3s; }
.tilt .ball.anti { outline: 2px dashed var(--ink); outline-offset: 2px; }
.tilt .ball.sunk { transform: scale(0); opacity: 0; }
.tilt.tU { animation: tiltU .3s; } .tilt.tD { animation: tiltD .3s; } .tilt.tL { animation: tiltL .3s; } .tilt.tR { animation: tiltR .3s; }
@keyframes tiltU { 50% { transform: rotateX(8deg); } } @keyframes tiltD { 50% { transform: rotateX(-8deg); } }
@keyframes tiltL { 50% { transform: rotateY(-8deg); } } @keyframes tiltR { 50% { transform: rotateY(8deg); } }
.tc.wall { background: linear-gradient(160deg, #4b6488, #2c3f5c); box-shadow: inset 0 -3px 0 rgba(0,0,0,.35); }

/* --- balanza: platillos colgando de la barra --- */
.bal-stand { height: 190px; align-items: flex-start; margin-top: 6px; }
.bal-stand::after { height: 150px; top: 30px; bottom: auto; }
.bal-beam { position: relative; margin: 30px 0 0; width: 220px; }
.bal-beam::before { content: ''; position: absolute; left: 50%; top: -6px; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%; background: var(--sand); }
.bal-str { position: absolute; top: 4px; width: 2px; height: 34px; background: #a3874a; }
.bal-str.l { left: 10px; } .bal-str.r { right: 10px; }
.bal-pan { position: absolute; top: 36px; width: 120px; min-height: 64px; margin: 0; transform-origin: 50% 0; transition: transform .4s;
  border: 3px solid var(--sand); border-top: none; border-radius: 0 0 60px 60px; background: rgba(244,213,141,.06); padding: 4px; }
.bal-pan.l { left: -49px; } .bal-pan.r { right: -49px; }
.bal-pan .bal-obj { width: 52px; padding: 2px; }
.bal-pan .bal-obj .oi { font-size: 20px; }

/* --- reloj, ordenar y bloques --- */
.clock-btns .btn { min-width: 64px; }
.order-row { flex-wrap: nowrap; gap: 6px; }
.order-slot { width: auto; flex: 1 1 0; min-width: 0; max-width: 84px; }
.order-card { width: 100%; min-height: 86px; }
.blocks { background-image: linear-gradient(rgba(60,83,115,.35) 1px, transparent 1px), linear-gradient(90deg, rgba(60,83,115,.35) 1px, transparent 1px);
  background-size: calc(100% / var(--n, 6)) calc(100% / var(--n, 6)); }
.bal-beam { width: 196px; }
.bal-pan { width: 104px; }
.bal-pan.l { left: -41px; } .bal-pan.r { right: -41px; }
.bal-pan .bal-obj { width: 46px; }
.modal h2 { padding-right: 34px; }

/* =====================================================================
   Tipografía (2026-11-25): Fredoka + Nunito, escala --fs-*
   ===================================================================== */
body { font-size: var(--fs-md); line-height: var(--lh); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
button, input { font-family: inherit; }
/* Fredoka: todo lo que es "voz del juego" (títulos, botones, rótulos, números grandes) */
.logo, .episode-card .t, .episode-card .num, .end-title, .modal h2, .hud-scene, .dialog-who, .wk-n, .wk-title,
.btn, .codex-card .n, .codex-card .k, .end-stats b, .end-stars, .lab h1, .lab h3, .order-num, .slot, .slot-col .slot, .key, .eq,
.simon-status, .rings-target, .lc, .tool, .menu-list .btn, .stab-float { font-family: var(--font-display); }
.logo { font-weight: 700; font-size: var(--fs-3xl); letter-spacing: 3px; }
.episode-card .t { font-size: var(--fs-xl); font-weight: 600; letter-spacing: .2px; }
.episode-card .num, .codex-card .k, .wk-title { font-weight: 600; letter-spacing: 2px; }
.end-title { font-weight: 700; font-size: var(--fs-2xl); }
.modal h2 { font-weight: 600; font-size: var(--fs-xl); letter-spacing: .2px; }
.btn { font-weight: 600; letter-spacing: .3px; }
.btn.big { font-size: var(--fs-xl); }
.btn.small { font-size: var(--fs-sm); }
.hud-scene { font-weight: 600; font-size: var(--fs-md); }
.hud-era { font-size: var(--fs-xs); font-weight: 700; }
.codex-card .n { font-weight: 600; font-size: var(--fs-lg); }
.key { font-weight: 600; font-size: var(--fs-md); }
/* Nunito: lectura */
.tagline { font-size: var(--fs-md); font-weight: 600; }
.intro-text { font-size: var(--fs-xl); font-weight: 600; line-height: 1.4; }
.dialog { font-size: 17px; font-weight: 600; line-height: var(--lh); }
.modal p { font-size: 15px; line-height: var(--lh); }
.codex-card .x, .episode-card .s { line-height: 1.4; }
/* cifras de ancho fijo: contadores, tiempos, resultados */
.hud-timer, #stab-val, .end-stats, .diff-status, .slide-count, .share, .stab-float, .eq { font-variant-numeric: tabular-nums; }
.hud-timer, #stab-val { font-family: var(--font-display); font-weight: 600; }
.share { font-family: var(--font-body); font-weight: 700; white-space: pre-wrap; line-height: 1.5; }
@media (max-height: 700px) { .logo { font-size: 40px; } .episode-card .t { font-size: 21px; } .btn.big { font-size: 20px; } }

/* =====================================================================
   Efectos y animaciones (2026-11-25)
   ===================================================================== */
/* ambiente de la escena (partículas en js/fx.js) y viñeta */
#amb { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
#hotspots { z-index: 2; }
#stage::after { content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 3;
  background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(5,8,14,.45) 100%); }
/* la escena "respira" muy despacio (muy poco, para no mover las zonas clicables) */
#scene-art img { animation: breathe 22s ease-in-out infinite alternate; transform-origin: 50% 40%; }
@keyframes breathe { to { transform: scale(1.018); } }

/* objeto que vuela al inventario */
.fly-item { position: fixed; left: 0; top: 0; width: 44px; height: 44px; z-index: 200; pointer-events: none; display: grid; place-items: center; font-size: 34px;
  filter: drop-shadow(0 0 10px rgba(244,213,141,.8)); }
.fly-item img { width: 100%; height: 100%; object-fit: contain; }

/* cambio de pantalla */
.screen.active { animation: screenIn .35s ease-out; }
@keyframes screenIn { from { opacity: 0; transform: scale(.985); } }

/* portada: el logo flota, el botón principal respira, hoy late en la semana */
.logo-img { animation: bob 4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-3deg); } }
#btn-play { animation: glowPulse 2.6s ease-in-out infinite; }
@keyframes glowPulse { 50% { box-shadow: 0 4px 0 #b9482d, 0 0 26px rgba(255,122,89,.55); } }
.wk-day.today { animation: todayPulse 2s ease-in-out infinite; }
@keyframes todayPulse { 50% { box-shadow: 0 0 0 3px rgba(255,122,89,.35); } }
.title-box .logo { animation: logoIn .8s cubic-bezier(.3,1.5,.5,1); }
@keyframes logoIn { from { opacity: 0; transform: translateY(-14px) scale(.92); } }

/* puzzle resuelto: sello ✓ */
.modal.success .modal-card::after { content: '✓'; position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); font-size: 110px; font-weight: 900;
  color: var(--sand); text-shadow: 0 0 30px rgba(244,213,141,.8); animation: stamp .55s cubic-bezier(.3,1.6,.5,1); pointer-events: none; font-family: var(--font-display); }
@keyframes stamp { from { transform: translate(-50%, -50%) scale(2.6) rotate(-14deg); opacity: 0; } }

/* pantalla final: estrellas una a una, brillo en el eco */
.end-stars { animation: starsIn .9s cubic-bezier(.3,1.6,.5,1) .2s both; }
@keyframes starsIn { from { transform: scale(.3); opacity: 0; letter-spacing: 30px; } }
.echo-card { position: relative; overflow: hidden; }
.echo-card::after { content: ''; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 35%, rgba(255,255,255,.22) 50%, transparent 65%);
  transform: translateX(-100%); animation: sheen 2.8s ease-in-out 1s infinite; pointer-events: none; }
@keyframes sheen { 60%, 100% { transform: translateX(100%); } }

/* diálogo: aparece con un pequeño rebote; el retrato entra desde abajo */
.dialog:not(.hidden) .dialog-face img { animation: faceIn .35s cubic-bezier(.3,1.6,.5,1); }
@keyframes faceIn { from { transform: translateY(16px) scale(.8); opacity: 0; } }

/* Distorsión: aberración cromática y sacudidas */
body.dist .hud-scene, body.dist .end-title, body.dist .modal h2 { text-shadow: 1.5px 0 rgba(255,0,90,.55), -1.5px 0 rgba(0,220,255,.45); }
body.dist #stage { animation: distJolt 11s steps(1) infinite; }
@keyframes distJolt { 0%, 96%, 100% { transform: none; filter: none; } 97% { transform: translateX(-3px) skewX(-1deg); filter: hue-rotate(40deg); } 98% { transform: translateX(4px); } }
body.dist #stage::after { background: radial-gradient(ellipse at 50% 45%, transparent 40%, rgba(20,2,14,.7) 100%); }

/* accesibilidad: si el sistema pide menos movimiento, sin animaciones decorativas */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
#fx { z-index: 4; }
.dist-overlay { z-index: 3; }

/* ---------- ecos oscuros y formas de MoMo ---------- */
.wk-day.dark { box-shadow: inset 0 -4px 0 #8b5cf6; }
.wk-day.dark .wk-n::after { content: ' ◆'; color: #b18cff; font-size: 9px; }
.echo-card.dark { border-color: #8b5cf6; background: linear-gradient(160deg, #1d1230, #0f0a18); }
.form-card { border-color: #b18cff; text-align: center; }
.form-art { width: 140px; height: 140px; object-fit: contain; display: block; margin: 0 auto var(--sp-2); filter: drop-shadow(0 0 16px rgba(177,140,255,.6)); animation: bob 3.5s ease-in-out infinite; }

/* ---------- privacidad y consentimiento ---------- */
.title-privacy { display: inline-block; margin-top: 14px; font-size: 12px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; opacity: .8; }
#modal-body a, .menu-note a { color: var(--sand); text-underline-offset: 3px; }
.menu-list.consent { flex-direction: row; }
.menu-list.consent .btn { flex: 1; }   /* "sí" y "no" con el mismo peso */
.momo-ask { display: flex; gap: var(--sp-3); align-items: flex-start; }
.momo-ask > div:last-child { flex: 1; min-width: 0; }
.momo-face { flex: 0 0 72px; height: 72px; font-size: 48px; text-align: center; animation: momo-bob 2.4s ease-in-out infinite; }
.momo-face img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 3px 6px rgba(139,92,246,.5)); }
.momo-ask h2 { margin-top: 0; }
.consent-small { font-size: 13px !important; color: var(--muted) !important; }
@keyframes momo-bob { 50% { transform: translateY(-5px); } }
@media (prefers-reduced-motion: reduce) { .momo-face { animation: none; } }
