:root {
  --ink: #120c16;
  --panel: #2b1f33;
  --panel-2: #3a2b45;
  --panel-hi: #4d3a5c;
  --cream: #fff4e0;
  --muted: #cdb8d8;
  --pink: #ff7eb6;
  --pink-d: #c9578a;
  --pink-l: #ffc2dd;
  --gold: #ffd34d;
  --gold-d: #c8871a;
  --green: #5be36b;
  --red: #ff4d6d;
  --sky: #7cc2f1;
  --font: 'Silkscreen', 'Pixelify Sans', 'Courier New', monospace; /* Silkscreen solo trae los números */
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  background: #0b0810; overflow: hidden;
  font-family: var(--font); color: var(--cream);
  font-variant-ligatures: none;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
#app { position: fixed; inset: 0; overflow: hidden; }
#game {
  position: absolute; left: 0; top: 0;
  image-rendering: pixelated; image-rendering: crisp-edges;
  touch-action: none;
}
.hidden { display: none !important; }
/* botones ocultos a propósito (por ahora no se usan; sacar la clase "off" para volver a mostrarlos) */
.off { display: none !important; }
img.ico, .ico { image-rendering: pixelated; }
button { font-family: var(--font); cursor: pointer; }

/* ---------- Botones pixel ---------- */
.btn {
  font-size: 18px; font-weight: 700; letter-spacing: 0.5px;
  color: #3a0f25; background: var(--pink);
  border: 3px solid var(--ink);
  box-shadow: inset -3px -4px 0 var(--pink-d), inset 3px 3px 0 var(--pink-l), 0 4px 0 var(--ink);
  padding: 10px 18px; border-radius: 0;
  transition: transform 0.05s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(3px); box-shadow: inset 3px 3px 0 var(--pink-d), 0 1px 0 var(--ink); }
.btn.alt { background: #8fd3ff; color: #0e2a40; box-shadow: inset -3px -4px 0 #4f9fd0, inset 3px 3px 0 #d4efff, 0 4px 0 var(--ink); }
.btn.danger { background: #ff8a7a; color: #3a0f0f; box-shadow: inset -3px -4px 0 #d0503f, inset 3px 3px 0 #ffd0c8, 0 4px 0 var(--ink); }
.btn.big { font-size: 22px; padding: 12px 26px; min-width: 240px; }
.btn.small { font-size: 15px; padding: 8px 12px; }
.btn:disabled { background: #6b5a75; color: #2b1f33; box-shadow: inset -3px -4px 0 #4d3f57, inset 3px 3px 0 #8c7a97, 0 4px 0 var(--ink); cursor: not-allowed; filter: none; }

.panel {
  position: relative;
  background: var(--panel);
  border: 3px solid var(--ink);
  box-shadow: inset 0 0 0 3px var(--panel-hi), inset 0 0 0 6px var(--panel), 0 6px 0 var(--ink), 0 0 40px rgba(0,0,0,0.5);
  padding: 18px;
}
.panel h2 { margin: 0 0 8px; font-size: 26px; color: var(--gold); text-shadow: 0 3px 0 var(--ink); }
.panel h3 { margin: 6px 0; font-size: 18px; color: var(--pink); }
.panel p { margin: 6px 0; line-height: 1.35; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }

/* ---------- Pantallas ---------- */
.screen { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 20; }
.screen.modal { background: rgba(10, 6, 16, 0.55); padding: 12px; }

#screen-title { animation: title-in 0.9s ease-out; }
@keyframes title-in { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }
.title-wrap { text-align: center; padding: 16px; max-width: 680px; }
.logo { margin: 0; line-height: 0.95; font-family: 'Pixelify Sans', monospace; font-weight: 700; }
.logo .l1 {
  display: block; font-size: clamp(38px, min(8vw, 11vh), 84px); color: var(--pink); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill;
  text-shadow: 0 6px 0 var(--ink), 0 0 34px rgba(255,126,182,0.45);
  animation: logo-bob 3.2s ease-in-out infinite;
}
.logo .l2 { position: relative; display: inline-flex; align-items: center; margin-top: 12px; font-size: clamp(20px, min(3.8vw, 5vh), 34px); }
@keyframes logo-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.menu .row { margin-top: 0; }
#settings-ok, #controls-ok { margin-top: 14px; }
.link-btn { background: none; border: 0; color: #fff4e0; font-size: 14px; text-decoration: underline; text-shadow: 0 2px 0 var(--ink); padding: 2px 6px; opacity: 0.85; }
.link-btn:hover { opacity: 1; }

/* ---------- Arranque ---------- */
.splash-btn {
  font-family: 'Pixelify Sans', monospace; font-size: clamp(22px, 4vw, 34px); font-weight: 700; color: #fff4e0;
  background: rgba(43,31,51,0.85); border: 3px solid var(--ink); box-shadow: 0 5px 0 var(--ink); padding: 14px 26px;
  text-shadow: 0 3px 0 var(--ink); animation: soft-pulse 2.2s ease-in-out infinite;
}
@keyframes soft-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.025); } }
#screen-splash.leaving { pointer-events: none; }
#screen-splash.leaving .splash-btn { animation: splash-out 0.9s ease-in forwards; }
@keyframes splash-out {
  0% { opacity: 1; transform: scale(1); }
  30% { opacity: 1; transform: scale(1.08); }
  100% { opacity: 0; transform: scale(0.9) translateY(10px); filter: blur(2px); }
}

/* ---------- Intro ---------- */
#intro { position: absolute; inset: 0; z-index: 16; cursor: pointer; user-select: none; -webkit-user-select: none; }
#intro .bars div { position: absolute; left: 0; right: 0; height: 0; background: #0b0810; transition: height 0.7s ease; }
#intro .bar-top { top: 0; } #intro .bar-bot { bottom: 0; }
#intro.on .bars div { height: 7vh; }
.intro-caption {
  position: absolute; top: calc(7vh + 14px); left: 50%; transform: translateX(-50%); margin: 0; white-space: nowrap;
  font-size: clamp(15px, 2.4vw, 20px); color: #fff4e0; background: rgba(11,8,16,0.7); border: 2px solid var(--ink); padding: 4px 14px;
  text-shadow: 0 2px 0 var(--ink); animation: caption-in 0.6s ease-out;
}
/* entra bajando un poquito, pero siempre centrada (el translateX tiene que estar en la animación) */
@keyframes caption-in { from { opacity: 0; transform: translate(-50%, -14px); } to { opacity: 1; transform: translateX(-50%); } }
.intro-skip {
  position: absolute; top: calc(7vh + 12px); right: 14px; font-family: inherit; font-size: 14px; color: var(--muted);
  background: rgba(11,8,16,0.6); border: 2px solid var(--ink); padding: 4px 10px; z-index: 2;
}
.intro-skip:hover { color: #fff4e0; }
.intro-box {
  position: absolute; left: 50%; bottom: calc(7vh + 12px); transform: translateX(-50%); width: min(640px, 94vw);
  display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start;
  background: var(--panel); border: 3px solid var(--ink); box-shadow: inset 0 0 0 3px var(--panel-hi), 0 5px 0 var(--ink); padding: 12px 16px 14px 12px;
}
.intro-box img { width: 54px; height: 72px; image-rendering: pixelated; background: var(--panel-2); border: 3px solid var(--ink); }
.intro-box b { display: block; color: var(--gold); font-size: 17px; text-shadow: 0 2px 0 var(--ink); }
.intro-box p { margin: 4px 0 0; font-size: clamp(16px, 2.4vw, 20px); line-height: 1.3; min-height: 2.6em; }
.intro-next { position: absolute; right: 10px; bottom: 6px; color: var(--pink); font-size: 12px; animation: soft-pulse 0.8s ease-in-out infinite; }
.intro-note { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(10,6,16,0.5); padding: 12px; }
.intro-note .paper {
  width: min(420px, 92vw); max-height: 86vh; overflow-y: auto; background: #fff8e8; color: #3a2a3a; padding: 18px 22px 16px;
  border: 3px solid var(--ink); box-shadow: 6px 8px 0 rgba(0,0,0,0.35); transform: rotate(-2deg); text-align: center;
  background-image: repeating-linear-gradient(to bottom, transparent 0 27px, #e7d9c4 27px 28px);
  animation: note-in 0.5s ease-out;
}
.intro-note p { white-space: pre-line; text-align: left; font-family: 'Caveat', cursive; font-size: 23px; line-height: 1.2; margin: 0 0 12px; }
.kit-panel { width: min(1080px, 94vw); max-height: 92vh; overflow-y: auto; background: var(--panel); color: var(--cream); border: 4px solid var(--ink);
  box-shadow: 0 8px 0 rgba(0,0,0,0.35); padding: clamp(14px, 2.6vh, 28px) clamp(14px, 2.4vw, 30px); text-align: center; animation: kit-in 0.45s ease-out; }
.kit-panel h3 { margin: 0 0 clamp(10px, 2vh, 20px); color: var(--gold); text-shadow: 0 3px 0 var(--ink); font-size: clamp(22px, 3.2vw, 42px); }
.kit-items { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(8px, 1.6vw, 18px); margin-bottom: clamp(12px, 2.2vh, 22px); }
.kit-item { display: flex; flex-direction: column; align-items: center; gap: 8px; background: var(--panel-2); border: 3px solid var(--ink); padding: clamp(10px, 2vh, 18px) clamp(8px, 1.2vw, 14px); }
.kit-item img { width: clamp(52px, 7vw, 104px); height: clamp(52px, 7vw, 104px); object-fit: contain; image-rendering: pixelated; animation: kit-pop 0.5s ease-out both; }
.kit-item:nth-child(2) img { animation-delay: 0.15s; } .kit-item:nth-child(3) img { animation-delay: 0.3s; }
.kit-item b { color: var(--gold); font-size: clamp(18px, 2.2vw, 30px); text-shadow: 0 2px 0 var(--ink); }
.kit-panel p { font-family: inherit; white-space: normal; }
.kit-item p { margin: 0; font-size: clamp(16px, 1.75vw, 25px); line-height: 1.4; text-align: center; }
#intro-kit-ok { font-size: clamp(18px, 2.2vw, 30px); padding: 0.5em 1.4em; }
.kit-panel .kit-hint { text-align: center; margin: 10px 0 0; font-size: clamp(14px, 1.5vw, 21px); color: var(--muted); }
@media (max-width: 620px) { .kit-items { grid-template-columns: 1fr; } .kit-item { flex-direction: row; text-align: left; } }
@keyframes kit-in { from { opacity: 0; transform: translateY(20px) scale(0.92); } to { opacity: 1; transform: none; } }
@keyframes kit-pop { 0% { transform: scale(0); } 70% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes note-in { from { opacity: 0; transform: rotate(-12deg) translateY(30px) scale(0.85); } to { opacity: 1; transform: rotate(-2deg); } }
.tagline { font-size: clamp(14px, 2.4vw, 19px); margin: 10px 0 4px; text-shadow: 0 2px 0 var(--ink); }
.pick { margin: 14px 0 6px; font-weight: 700; color: var(--gold); text-shadow: 0 2px 0 var(--ink); }
.chars { display: flex; gap: 14px; justify-content: center; margin-bottom: 14px; }
.char {
  background: var(--panel); border: 3px solid var(--ink);
  box-shadow: inset 0 0 0 3px var(--panel-hi), 0 4px 0 var(--ink);
  padding: 8px 12px 6px; color: var(--cream); font-size: 17px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 104px;
}
.char img { width: 60px; height: 80px; image-rendering: pixelated; }
.char.sel { background: #5a2a4a; box-shadow: inset 0 0 0 3px var(--pink), 0 4px 0 var(--ink); }
.char.sel span::before { content: '♥ '; color: var(--pink); }
.menu { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.hint { font-size: 14px; color: var(--muted); text-shadow: 0 2px 0 var(--ink); margin-top: 12px; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
#stats {
  position: absolute; left: calc(10px + env(safe-area-inset-left)); top: calc(10px + env(safe-area-inset-top));
  display: flex; flex-direction: column; gap: 6px;
}
.bar { display: flex; align-items: center; gap: 6px; }
.bar .ico { width: 27px; height: 27px; }
.bar .track {
  width: clamp(110px, 20vw, 190px); height: 16px; background: #1d1424;
  border: 3px solid var(--ink); box-shadow: 0 3px 0 rgba(0,0,0,0.4); position: relative; overflow: hidden;
}
.bar .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; transition: width 0.15s; }
.bar .fill::after { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: rgba(255,255,255,0.35); }
#bar-hp .fill { background: #ff4d6d; }
#bar-en .fill { background: #ffd23f; }
#bar-en.low .fill { background: #ff8a3d; animation: blink 0.5s steps(2) infinite; }
#bar-hp.low .fill { animation: blink 0.5s steps(2) infinite; }
.bar .num { font-size: 15px; font-weight: 700; text-shadow: 0 2px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 -2px 0 var(--ink); min-width: 70px; }
@keyframes blink { 50% { opacity: 0.45; } }

#money-box {
  position: absolute; left: calc(10px + env(safe-area-inset-left)); top: calc(70px + env(safe-area-inset-top));
  display: flex; align-items: center; gap: 6px; font-size: 22px; font-weight: 700; color: var(--gold);
  text-shadow: 0 3px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 -2px 0 var(--ink);
}
#money-box .ico { width: 27px; height: 27px; }
#money-box.bump { animation: bump 0.25s; }
@keyframes bump { 40% { transform: scale(1.18); } }

#inv-box {
  position: absolute; left: calc(12px + env(safe-area-inset-left)); top: calc(102px + env(safe-area-inset-top));
  display: flex; gap: 12px;
}
.inv { display: flex; align-items: center; gap: 4px; font-size: 18px; font-weight: 700; text-shadow: 0 2px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 -2px 0 var(--ink); }
.inv .ico { width: 15px; height: 24px; object-fit: contain; }
.inv kbd { font-family: var(--font); font-size: 11px; background: var(--panel); border: 2px solid var(--ink); padding: 0 4px; color: var(--muted); text-shadow: none; }
body.touch .inv kbd { display: none; }
/* con joystick, en vez de la tecla T se ve el botón Y (redondo y amarillo, como en el control) */
.inv kbd.key-pad { display: none; }
body.pad .inv kbd.key-keys { display: none; }
body.pad .inv kbd.key-pad {
  display: inline-grid; place-items: center; width: 18px; height: 18px; padding: 0; border-radius: 50%;
  background: #f2c14e; color: #2b1d2b; border: 2px solid var(--ink); font-size: 11px; line-height: 1;
}
.tbtn.mini { width: 52px; height: 52px; background: var(--panel-2); box-shadow: inset -3px -3px 0 var(--panel), 0 3px 0 var(--ink); color: var(--cream); font-size: 13px; gap: 1px; }
.tbtn.mini .ico { width: 14px; height: 22px; object-fit: contain; }
.tbtn.tool span { font-size: 8px; }
.tbtn.torch { right: calc(210px + env(safe-area-inset-right)); bottom: calc(40px + env(safe-area-inset-bottom)); }
.tbtn.tool { right: calc(210px + env(safe-area-inset-right)); bottom: calc(100px + env(safe-area-inset-bottom)); }
#depth-box {
  position: absolute; right: calc(10px + env(safe-area-inset-right)); top: calc(54px + env(safe-area-inset-top));
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
#depth-num { font-size: 20px; font-weight: 700; text-shadow: 0 3px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 -2px 0 var(--ink); }
#depth-layer { font-size: 13px; color: var(--muted); text-shadow: 0 2px 0 var(--ink); }
#gauge {
  position: relative; width: 16px; height: clamp(120px, 34vh, 260px);
  background: linear-gradient(#77492a 0%, #964a30 12%, #5f5f72 25%, #6e5563 40%, #272a38 60%, #26193a 85%);
  border: 3px solid var(--ink); box-shadow: 0 3px 0 rgba(0,0,0,0.4);
}
#gauge-fill { position: absolute; left: 0; right: 0; top: 0; height: 0; background: rgba(255,255,255,0.18); }
#gauge-you { position: absolute; left: -8px; width: 26px; height: 4px; background: var(--pink); border: 1px solid var(--ink); transform: translateY(-2px); }
#gauge-best { position: absolute; left: -2px; right: -2px; height: 2px; background: rgba(255,255,255,0.6); }
.gauge-gift { position: absolute; right: 18px; transform: translateY(-50%); display: flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 700; text-shadow: 0 2px 0 var(--ink); white-space: nowrap; }
.gauge-gift img { width: 20px; height: 22px; image-rendering: pixelated; }
.gauge-gift.done img { filter: grayscale(1) brightness(0.8); }
.gauge-gift.done span { text-decoration: line-through; opacity: 0.7; }

.icon-btn {
  pointer-events: auto; position: absolute; right: calc(10px + env(safe-area-inset-right)); top: calc(10px + env(safe-area-inset-top));
  width: 38px; height: 38px; background: var(--panel); border: 3px solid var(--ink);
  box-shadow: inset 0 0 0 2px var(--panel-hi), 0 3px 0 var(--ink); display: flex; gap: 5px; align-items: center; justify-content: center;
}
.icon-btn span { width: 5px; height: 15px; background: var(--cream); }

#quick-btns {
  position: absolute; right: calc(56px + env(safe-area-inset-right)); top: calc(10px + env(safe-area-inset-top));
  display: flex; gap: 6px; pointer-events: auto;
}
.q-btn {
  position: relative; height: 38px; min-width: 38px; padding: 0 6px; background: var(--panel); border: 3px solid var(--ink);
  box-shadow: inset 0 0 0 2px var(--panel-hi), 0 3px 0 var(--ink); display: flex; gap: 4px; align-items: center; justify-content: center; color: var(--muted);
}
.q-btn .ico { width: 20px; height: 20px; object-fit: contain; }
.q-btn small { font-size: 11px; font-weight: 700; }
.q-btn.off .ico { opacity: 0.45; }
.q-btn.off::after { content: ''; position: absolute; left: 5px; right: 5px; top: 50%; height: 3px; background: var(--red); transform: rotate(-35deg); box-shadow: 0 0 0 1px var(--ink); }
.q-btn.auto.on { background: #5a2a4a; color: var(--cream); box-shadow: inset 0 0 0 2px var(--pink), 0 3px 0 var(--ink); }
.q-btn.auto.on.active small { color: var(--gold); }
.q-btn:active { transform: translateY(2px); }
.tbtn.dig.latched { outline: 4px solid var(--pink); outline-offset: 2px; }
#toasts { position: absolute; left: 50%; top: calc(12px + env(safe-area-inset-top)); pointer-events: none; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; width: min(90vw, 460px); }
.toast {
  background: rgba(43,31,51,0.92); border: 3px solid var(--ink); padding: 6px 12px; font-size: 16px; text-align: center;
  box-shadow: 0 3px 0 var(--ink); animation: toastIn 0.2s ease-out;
}
.toast.good { color: var(--gold); }
.toast.warn { color: #ffb36b; }
@keyframes toastIn { from { transform: translateY(-8px); opacity: 0; } }
#prompt {
  /* centrado sin transform: si el centrado dependiera de la animación, el primer instante aparecía corrido a la derecha */
  position: absolute; left: 0; right: 0; margin: 0 auto; width: max-content; max-width: 94vw; bottom: calc(22% + env(safe-area-inset-bottom));
  background: rgba(43,31,51,0.92); border: 3px solid var(--ink); padding: 8px 14px; font-size: 17px; box-shadow: 0 3px 0 var(--ink);
  white-space: nowrap; animation: pulse 1.2s infinite;
}
@keyframes pulse { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }

/* ---------- Táctil ---------- */
#touch { position: absolute; inset: 0; pointer-events: none; z-index: 11; }
#stick {
  pointer-events: auto; position: absolute;
  left: calc(22px + env(safe-area-inset-left)); bottom: calc(22px + env(safe-area-inset-bottom));
  width: 128px; height: 128px; border-radius: 50%;
  background: rgba(20,12,26,0.35); border: 3px solid rgba(255,244,224,0.35);
  touch-action: none;
}
#stick-knob {
  position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%;
  background: rgba(255,244,224,0.55); border: 3px solid rgba(18,12,22,0.6);
}
.tbtn {
  pointer-events: auto; position: absolute; border-radius: 50%;
  width: 84px; height: 84px; border: 3px solid var(--ink); font-size: 15px; font-weight: 700;
  color: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1;
  touch-action: none; opacity: 0.88;
}
.tbtn small { font-size: 8px; font-weight: 400; margin-top: 3px; max-width: 64px; }
.tbtn.down { transform: scale(0.94); opacity: 1; }
.tbtn.dig { right: calc(118px + env(safe-area-inset-right)); bottom: calc(26px + env(safe-area-inset-bottom)); background: #ffd34d; box-shadow: inset -4px -4px 0 #c8871a, 0 4px 0 var(--ink); }
.tbtn.jump { right: calc(20px + env(safe-area-inset-right)); bottom: calc(76px + env(safe-area-inset-bottom)); background: #8fd3ff; box-shadow: inset -4px -4px 0 #4f9fd0, 0 4px 0 var(--ink); }
.tbtn.act { right: calc(40px + env(safe-area-inset-right)); bottom: calc(184px + env(safe-area-inset-bottom)); width: 104px; height: 46px; border-radius: 0; background: var(--pink); box-shadow: inset -3px -3px 0 var(--pink-d), 0 4px 0 var(--ink); opacity: 1; }

/* ---------- Taller ---------- */
.panel.shop { width: min(720px, 96vw); max-height: 92vh; display: flex; flex-direction: column; padding: 14px; }
.shop header { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.shop-cat { width: 39px; height: 52px; image-rendering: pixelated; }
.shop-title { flex: 1; }
.shop-title h2 { margin: 0; }
.shop-title p { margin: 0; font-size: 14px; color: var(--muted); }
.shop-money { display: flex; align-items: center; gap: 6px; font-size: 22px; font-weight: 700; color: var(--gold); text-shadow: 0 2px 0 var(--ink); }
.shop-money .ico { width: 27px; height: 27px; }
.close { width: 40px; height: 40px; background: var(--panel-2); border: 3px solid var(--ink); color: var(--cream); font-size: 20px; box-shadow: 0 3px 0 var(--ink); }
#shop-list { overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; padding: 2px 4px 6px 2px; touch-action: pan-y; }
.up {
  background: var(--panel-2); border: 3px solid var(--ink); box-shadow: inset 0 0 0 2px var(--panel-hi);
  padding: 10px; display: grid; grid-template-columns: 44px 1fr; gap: 4px 10px; align-items: start;
}
.up .up-ico { width: 44px; height: 44px; background: #1d1424; border: 3px solid var(--ink); display: flex; align-items: center; justify-content: center; grid-row: span 2; }
.up .up-ico img { width: 30px; height: 30px; object-fit: contain; image-rendering: pixelated; }
.up h4 { margin: 0; font-size: 17px; color: var(--cream); }
.up .desc { font-size: 13px; color: var(--muted); margin: 0; line-height: 1.25; }
.up .pips { display: flex; gap: 3px; margin: 4px 0 2px; grid-column: 2; }
.up .pip { width: 14px; height: 8px; background: #1d1424; border: 2px solid var(--ink); }
.up .pip.on { background: var(--green); }
.up .vals { grid-column: 1 / -1; font-size: 14px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.up .vals .now { color: var(--muted); }
.up .vals .next { color: var(--green); }
.up .buy { grid-column: 1 / -1; width: 100%; font-size: 16px; padding: 7px; }
.up.max .buy { background: #6b5a75; }
.up.supply { grid-column: 1 / -1; }
.shop-section { grid-column: 1 / -1; margin: 6px 0 -2px; font-size: 15px; color: var(--gold); text-shadow: 0 2px 0 var(--ink); }
.up .tier { font-size: 13px; color: var(--pink); margin: 0; }
.up .buy-row { grid-column: 1 / -1; display: flex; gap: 8px; }
.up .buy-row .btn { flex: 1; font-size: 15px; padding: 7px 4px; }
.up.locked { opacity: 0.7; }
.up.locked h4 { color: var(--muted); letter-spacing: 2px; }
.up .lock { display: grid; place-items: center; width: 100%; height: 100%; font-size: 22px; color: var(--muted); }
.up .have { font-size: 14px; color: var(--muted); grid-column: 2; }

/* ---------- Regalo ---------- */
.panel.gift { width: min(460px, 94vw); text-align: center; overflow: hidden; padding: 22px 20px 20px; }
.gift .rays {
  position: absolute; left: 50%; top: 70px; width: 600px; height: 600px; margin: -300px 0 0 -300px;
  background: repeating-conic-gradient(rgba(255,211,77,0.13) 0 10deg, transparent 10deg 20deg);
  animation: spin 14s linear infinite; pointer-events: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.gift-img { position: relative; width: 117px; height: 126px; image-rendering: pixelated; animation: floaty 1.6s ease-in-out infinite; }
@keyframes floaty { 50% { transform: translateY(-8px); } }
.gift-kicker { position: relative; color: var(--pink); font-weight: 700; margin: 8px 0 0 !important; }
.gift h2 { position: relative; font-size: 30px; }
#gift-text { position: relative; white-space: pre-line; font-size: 18px; margin-bottom: 16px !important; }
/* titular grande: "¡¡El primer regalo!!" con las letras que caen rebotando y después ondean */
.gift-headline {
  position: relative; z-index: 1; margin: 0 0 6px !important; font-size: clamp(26px, 5.4vw, 40px); font-weight: 700; line-height: 1.1;
  color: var(--gold); text-transform: uppercase; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 0 4px 0 var(--ink);
}
.gift-headline span { display: inline-block; opacity: 0; }
.gift-headline span.w { opacity: 1; white-space: nowrap; animation: none !important; }
.gift-headline.long { font-size: clamp(22px, 4.6vw, 34px); }
.gift-headline.go span:not(.w) { animation: hl-in 0.5s cubic-bezier(.4,0,.6,1.6) both, hl-wave 1.8s ease-in-out 0.9s infinite; }
.gift-headline span.w span:nth-child(3n+1) { color: var(--pink); }
@keyframes hl-in { from { opacity: 0; transform: translateY(-26px) scale(0.4) rotate(-20deg); } to { opacity: 1; transform: none; } }
@keyframes hl-wave { 0%, 100% { opacity: 1; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-4px); } }
/* el dibujo de la caja de bombones: a 3x (2x en pantallas chicas) */
.gift-img.art { width: calc(var(--w, 48) * 3px); height: calc(var(--h, 50) * 3px); }
.gift-img.pop { animation: gift-in 0.7s cubic-bezier(.4,0,.6,1.5) 0.2s both, floaty 1.6s ease-in-out 0.9s infinite; }
@keyframes gift-in { from { opacity: 0; transform: scale(0.2) rotate(-25deg); } to { opacity: 1; transform: none; } }
.panel.gift > *:not(.rays):not(.confetti) { position: relative; z-index: 1; }
/* papel picado */
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.confetti i { position: absolute; top: -14px; width: 6px; height: 10px; opacity: 0.9; animation: confetti-fall linear infinite both; }
.confetti i:nth-child(2n) { width: 8px; height: 6px; }
@keyframes confetti-fall { to { transform: translate(var(--dx), 640px) rotate(var(--r)); } }
@media (prefers-reduced-motion: reduce) { .confetti { display: none; } .gift-headline.go span:not(.w) { animation: none; opacity: 1; } }

/* ---------- Pausa / mensajes ---------- */
.panel.pause, .panel.msg { width: min(520px, 94vw); text-align: center; max-height: 92vh; overflow-y: auto; }
.pause .vols, .panel .vols { display: grid; gap: 6px; margin-top: 12px; background: var(--panel-2); border: 3px solid var(--ink); padding: 8px 12px; }
.pause .vols label { display: grid; grid-template-columns: 80px 1fr 44px; align-items: center; gap: 10px; font-size: 14px; text-align: left; }
.pause .vols output { color: var(--gold); text-align: right; }
.pause .vols input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 10px; background: var(--ink); border: 2px solid var(--panel-hi); cursor: pointer; }
.pause .vols input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 18px; background: var(--pink); border: 2px solid var(--ink); box-shadow: inset -2px -2px 0 var(--pink-d); }
.pause .vols input[type=range]::-moz-range-thumb { width: 12px; height: 16px; background: var(--pink); border: 2px solid var(--ink); border-radius: 0; box-shadow: inset -2px -2px 0 var(--pink-d); }
.panel .controls { background: var(--panel-2); border: 3px solid var(--ink); padding: 8px 12px; margin-top: 12px; text-align: left; font-size: 14px; }
.pause .controls p { margin: 4px 0; }
.pause .controls b { color: var(--gold); }
.pause .tips { color: var(--muted); }
.ctl-touch { display: none; }
body.touch .ctl-touch { display: block; }
body.touch .ctl-desk { display: none; }
.ctl-pad { display: none; }
body.pad .ctl-pad { display: block; }
body.pad .ctl-desk, body.pad .ctl-touch { display: none; }
#msg-text { white-space: pre-line; font-size: 17px; }

#fade { position: absolute; inset: 0; background: #0b0810; opacity: 0; pointer-events: none; z-index: 15; transition: opacity 0.6s; }
#fade.on { opacity: 1; }
#fade.white { background: #fff8e8; }
/* ---------- Barra de vida de Aguilus ---------- */
#boss-bar {
  position: absolute; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(320px, 46vw);
  display: grid; gap: 3px; text-align: center; pointer-events: none;
}
#boss-bar span { font-weight: 700; color: #c98cff; font-size: 16px; text-shadow: 0 2px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink); }
#boss-bar .track { height: 14px; background: var(--ink); border: 3px solid var(--ink); box-shadow: 0 3px 0 rgba(0,0,0,0.4); }
#boss-bar .fill { height: 100%; width: 100%; background: linear-gradient(#d9a6ff, #8a4fd0); transition: width 0.3s; }
#rotate-hint { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); font-size: 13px; color: var(--muted); z-index: 25; text-shadow: 0 2px 0 var(--ink); pointer-events: none; white-space: nowrap; }

@media (max-height: 460px) {
  .logo .l1 { font-size: 40px; } .logo .l2 { font-size: 22px; } .logo .two { width: 46px; height: 46px; font-size: 28px; }
  .tagline { margin: 4px 0; font-size: 14px; }
  .pick { margin: 6px 0 4px; }
  .char img { width: 54px; height: 66px; }
  .btn.big { font-size: 18px; padding: 8px 20px; min-width: 200px; }
  .menu { gap: 8px; }
  #gauge { height: 110px; }
  #inv-box {
  position: absolute; left: calc(12px + env(safe-area-inset-left)); top: calc(102px + env(safe-area-inset-top));
  display: flex; gap: 12px;
}
.inv { display: flex; align-items: center; gap: 4px; font-size: 18px; font-weight: 700; text-shadow: 0 2px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 -2px 0 var(--ink); }
.inv .ico { width: 15px; height: 24px; object-fit: contain; }
.inv kbd { font-family: var(--font); font-size: 11px; background: var(--panel); border: 2px solid var(--ink); padding: 0 4px; color: var(--muted); text-shadow: none; }
body.touch .inv kbd { display: none; }
.tbtn.mini { width: 52px; height: 52px; background: var(--panel-2); box-shadow: inset -3px -3px 0 var(--panel), 0 3px 0 var(--ink); color: var(--cream); font-size: 13px; gap: 1px; }
.tbtn.mini .ico { width: 14px; height: 22px; object-fit: contain; }
.tbtn.torch { right: calc(210px + env(safe-area-inset-right)); bottom: calc(40px + env(safe-area-inset-bottom)); }
.tbtn.tool { right: calc(210px + env(safe-area-inset-right)); bottom: calc(100px + env(safe-area-inset-bottom)); }
#depth-box { top: 52px; }
  .panel h2 { font-size: 22px; }
  .gift-img { width: 78px; height: 84px; }
  .gift-img.art { width: calc(var(--w, 48) * 2px); height: calc(var(--h, 50) * 2px); }
  .tbtn { width: 74px; height: 74px; }
  .tbtn.dig { right: calc(104px + env(safe-area-inset-right)); }
  .tbtn.jump { bottom: calc(66px + env(safe-area-inset-bottom)); }
  .tbtn.act { bottom: calc(160px + env(safe-area-inset-bottom)); }
  #stick { width: 112px; height: 112px; }
  .tbtn.mini { width: 46px; height: 46px; }
  .tbtn.torch { right: calc(186px + env(safe-area-inset-right)); bottom: calc(34px + env(safe-area-inset-bottom)); }
  .tbtn.tool { right: calc(186px + env(safe-area-inset-right)); bottom: calc(94px + env(safe-area-inset-bottom)); }
  #inv-box { top: calc(96px + env(safe-area-inset-top)); }
  .inv { font-size: 15px; }
  #quick-btns {
  position: absolute; right: calc(56px + env(safe-area-inset-right)); top: calc(10px + env(safe-area-inset-top));
  display: flex; gap: 6px; pointer-events: auto;
}
.q-btn {
  position: relative; height: 38px; min-width: 38px; padding: 0 6px; background: var(--panel); border: 3px solid var(--ink);
  box-shadow: inset 0 0 0 2px var(--panel-hi), 0 3px 0 var(--ink); display: flex; gap: 4px; align-items: center; justify-content: center; color: var(--muted);
}
.q-btn .ico { width: 20px; height: 20px; object-fit: contain; }
.q-btn small { font-size: 11px; font-weight: 700; }
.q-btn.off .ico { opacity: 0.45; }
.q-btn.off::after { content: ''; position: absolute; left: 5px; right: 5px; top: 50%; height: 3px; background: var(--red); transform: rotate(-35deg); box-shadow: 0 0 0 1px var(--ink); }
.q-btn.auto.on { background: #5a2a4a; color: var(--cream); box-shadow: inset 0 0 0 2px var(--pink), 0 3px 0 var(--ink); }
.q-btn.auto.on.active small { color: var(--gold); }
.q-btn:active { transform: translateY(2px); }
.tbtn.dig.latched { outline: 4px solid var(--pink); outline-offset: 2px; }
#toasts { top: auto; bottom: calc(10px + env(safe-area-inset-bottom)); width: 42vw; flex-direction: column-reverse; }
  .toast { font-size: 13px; padding: 4px 8px; }
  #prompt { font-size: 14px; }
}
@media (max-width: 520px) {
  .bar .track { width: 96px; }
  .bar .num { font-size: 13px; min-width: 56px; }
  #money-box { font-size: 18px; }
  .gauge-gift span { display: none; }
  #shop-list { grid-template-columns: 1fr; }
  #quick-btns {
  position: absolute; right: calc(56px + env(safe-area-inset-right)); top: calc(10px + env(safe-area-inset-top));
  display: flex; gap: 6px; pointer-events: auto;
}
.q-btn {
  position: relative; height: 38px; min-width: 38px; padding: 0 6px; background: var(--panel); border: 3px solid var(--ink);
  box-shadow: inset 0 0 0 2px var(--panel-hi), 0 3px 0 var(--ink); display: flex; gap: 4px; align-items: center; justify-content: center; color: var(--muted);
}
.q-btn .ico { width: 20px; height: 20px; object-fit: contain; }
.q-btn small { font-size: 11px; font-weight: 700; }
.q-btn.off .ico { opacity: 0.45; }
.q-btn.off::after { content: ''; position: absolute; left: 5px; right: 5px; top: 50%; height: 3px; background: var(--red); transform: rotate(-35deg); box-shadow: 0 0 0 1px var(--ink); }
.q-btn.auto.on { background: #5a2a4a; color: var(--cream); box-shadow: inset 0 0 0 2px var(--pink), 0 3px 0 var(--ink); }
.q-btn.auto.on.active small { color: var(--gold); }
.q-btn:active { transform: translateY(2px); }
.tbtn.dig.latched { outline: 4px solid var(--pink); outline-offset: 2px; }
#toasts { top: calc(118px + env(safe-area-inset-top)); width: 92vw; }
  .toast { font-size: 13px; }
}

/* menú de prueba de canciones */
.songs { display: grid; gap: 4px; margin: 10px 0; text-align: left; }
.songs h3 { margin: 8px 0 2px; font-size: 14px; color: var(--gold); text-shadow: 0 2px 0 var(--ink); }
.songs .song-row { display: flex; flex-wrap: wrap; gap: 6px; }
.songs .song { flex: 1 1 140px; font-size: 13px; }
.songs .song.sel { background: var(--pink); color: var(--ink); }
.songs .song-src { margin: 2px 0 0; font-size: 11px; color: var(--muted); }
.songs .song.gen { border-color: #4f9fd0; }

/* joystick flotante: zona de la mitad izquierda donde aparece al apoyar el pulgar */
#stick-zone { pointer-events: auto; position: absolute; left: 0; bottom: 0; width: 40%; height: 72%; touch-action: none; }
#stick.active { border-color: rgba(255,244,224,0.6); background: rgba(20,12,26,0.45); }
html, body, button { -webkit-tap-highlight-color: transparent; }
/* iPad y pantallas grandes: botones más grandes */
@media (pointer: coarse) and (min-width: 900px) and (min-height: 600px) {
  .tbtn { width: 100px; height: 100px; font-size: 17px; }
  .tbtn.dig { right: calc(140px + env(safe-area-inset-right)); bottom: calc(34px + env(safe-area-inset-bottom)); }
  .tbtn.jump { right: calc(28px + env(safe-area-inset-right)); bottom: calc(96px + env(safe-area-inset-bottom)); }
  .tbtn.torch { right: calc(256px + env(safe-area-inset-right)); bottom: calc(48px + env(safe-area-inset-bottom)); }
  .tbtn.tool { right: calc(256px + env(safe-area-inset-right)); bottom: calc(108px + env(safe-area-inset-bottom)); }
  .tbtn.act { bottom: calc(220px + env(safe-area-inset-bottom)); width: 120px; height: 54px; }
  #stick { width: 150px; height: 150px; }
  #stick-knob { width: 64px; height: 64px; margin: -32px 0 0 -32px; }
}

/* jugar online */
.join-row { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
.join-row input {
  width: 140px; font-family: var(--font); font-size: 22px; text-align: center; letter-spacing: 6px; text-transform: uppercase;
  background: var(--ink); color: var(--cream); border: 3px solid var(--panel-hi); padding: 6px 8px; user-select: text; -webkit-user-select: text;
}
.on-status { margin: 12px 0 4px; font-size: 15px; color: var(--cream); }
.on-status.error { color: #ff8c8c; }
.on-status.ok { color: #9cf08a; }
.on-room { font-size: 44px; letter-spacing: 10px; color: var(--gold); text-shadow: 0 3px 0 var(--ink); margin: 4px 0 10px; }
#net-badge {
  position: absolute; left: 50%; top: calc(8px + env(safe-area-inset-top)); transform: translateX(-50%);
  background: rgba(43,31,51,0.85); border: 2px solid var(--ink); padding: 3px 10px; font-size: 13px; color: #9cf08a; white-space: nowrap; pointer-events: none;
}
/* ya conectados: el cartelito se desvanece para no tapar el HUD */
#net-badge.gone { opacity: 0; transform: translate(-50%, -6px); transition: opacity 0.9s ease, transform 0.9s ease; }

/* ---------- Título animado ---------- */
.logo-box { position: relative; display: inline-block; padding: 6px 8px; }
/* cada letra de "Cumple Panchita" cae, después ondea; al pasar el mouse salta */
.logo .l1 .ch { display: inline-block; animation: ch-drop 0.55s cubic-bezier(.3,1.6,.5,1) both, ch-wave 2.6s ease-in-out infinite; animation-delay: calc(var(--i) * 45ms), calc(0.9s + var(--i) * 90ms); }
.logo .l1 .ch.sp { width: 0.32em; }
.logo .hv { display: inline-block; }
.logo .l1 .ch:hover .hv { color: var(--gold); }
.logo .l1 .hv.pop { animation: ch-pop 0.5s ease-out; color: var(--gold); }
@keyframes ch-drop { from { opacity: 0; transform: translateY(-80px) rotate(-20deg); } to { opacity: 1; transform: none; } }
@keyframes ch-wave { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes ch-pop { 0% { transform: none; } 35% { transform: translateY(-14px) scale(1.25) rotate(-8deg); } 70% { transform: translateY(2px) scale(0.95); } 100% { transform: none; } }
.logo .l1 { animation: none; }
/* "Salven los regalos": cartel de neón derecho: solo el tubo rectangular con bordes redondeados (sin caja atrás);
   al aparecer titila como un tubo que arranca y termina quedando prendido */
.logo .stamp {
  --neon: #ff6fd0;
  display: inline-block; font-size: 1.45em; line-height: 1; padding: 0.22em 0.55em 0.28em;
  color: #fff3c4; background: transparent;
  border: 3px solid #ffb3e6; border-radius: 0.5em;
  text-shadow: 0 2px 0 rgba(29,20,32,0.55), 0 0 3px #ffd34d, 0 0 9px #ffb02e, 0 0 18px rgba(255,150,40,0.85);
  box-shadow: 0 0 8px 2px var(--neon), 0 0 22px 4px rgba(255,111,208,0.55), inset 0 0 10px rgba(255,111,208,0.55);
  animation: neon-on 1.5s steps(1, end) 0.95s both, neon-hum 7s steps(1, end) 3s infinite;
}
@keyframes neon-on {
  0%, 9%, 14%, 27%, 31%, 52% { color: #b9a48a; border-color: #b98aa8; text-shadow: 0 2px 0 rgba(29,20,32,0.55); box-shadow: none; }
  8%, 13%, 24%, 30%, 46% { color: #fff3c4; border-color: #ffb3e6;
    text-shadow: 0 2px 0 rgba(29,20,32,0.55), 0 0 3px #ffd34d, 0 0 9px #ffb02e, 0 0 18px rgba(255,150,40,0.85);
    box-shadow: 0 0 8px 2px var(--neon), 0 0 22px 4px rgba(255,111,208,0.55), inset 0 0 10px rgba(255,111,208,0.55); }
  56%, 100% { color: #fff3c4; border-color: #ffb3e6;
    text-shadow: 0 2px 0 rgba(29,20,32,0.55), 0 0 3px #ffd34d, 0 0 9px #ffb02e, 0 0 18px rgba(255,150,40,0.85);
    box-shadow: 0 0 8px 2px var(--neon), 0 0 22px 4px rgba(255,111,208,0.55), inset 0 0 10px rgba(255,111,208,0.55); }
}
/* de vez en cuando el tubo hace un parpadeo cortito, como los neones de verdad */
@keyframes neon-hum { 0%, 96%, 98%, 100% { opacity: 1; } 97% { opacity: 0.55; } }
.logo .stamp .hv.pop { animation: neon-flick 0.45s steps(1); }
@keyframes neon-flick { 0%, 40%, 100% { opacity: 1; } 20%, 60% { opacity: 0.3; } }
/* el sello del 2 sacude un poquito todo el título */
.logo-box { animation: title-thump 0.35s ease-out 2.82s, title-thump 0.4s ease-out 7.33s; }
@keyframes title-thump { 20% { transform: translate(-3px, 3px); } 45% { transform: translate(3px, -2px); } 70% { transform: translate(-2px, 1px); } }
/* el 2: un número bien legible en una medalla */
.logo .two {
  font-style: normal; font-family: 'Silkscreen', 'Pixelify Sans', monospace; font-weight: 700;
  display: inline-grid; place-items: center; width: 1.9em; height: 1.9em; font-size: 1.15em; line-height: 1;
  color: #fff4e0; background: var(--pink); border: 3px solid var(--ink); border-radius: 50%;
  box-shadow: inset -4px -4px 0 var(--pink-d), 0 4px 0 var(--ink); text-shadow: 0 3px 0 var(--ink);
  /* cae como sello, queda 3 segundos y después se despega y se cae */
  animation: two-in 0.4s cubic-bezier(.5,0,.6,1.4) 2.5s both, two-pulse 1.55s ease-in-out 2.9s 2, two-peel 1.1s cubic-bezier(.5,0,.9,.6) 6s forwards;
}
/* lugar de los sellos: afuera del flujo (así el cartel queda centrado), montado sobre la punta derecha del cartel */
.logo .badge { position: absolute; z-index: 1; display: grid; place-items: center; left: calc(100% - 0.25em); top: -0.6em; }
@keyframes two-peel {
  0% { transform: rotate(10deg); }
  18% { transform: translate(3px, -5px) rotate(-12deg) scale(1.06); }
  30% { transform: translate(5px, -2px) rotate(-4deg) scale(1.04); opacity: 1; }
  100% { transform: translate(40px, 70vh) rotate(260deg) scale(0.9); opacity: 0; visibility: hidden; }
}
/* sello grande: torta de cumple con ¡25! */
.logo .cake {
  /* centrada justo donde estaba el 2, sin cambiar el lugar que ocupa */
  position: absolute; left: 50%; top: 50%; width: 4.3em; height: 4.16em; margin: -2.3em 0 0 -1.15em; cursor: pointer;
  animation: cake-in 0.45s cubic-bezier(.5,0,.6,1.4) 7s both, cake-pulse 2s ease-in-out 7.6s infinite;
}
.logo .cake .hv {
  display: block; position: relative; width: 100%; height: 100%;
  /* borde de sticker crema y sombrita */
  filter: drop-shadow(2px 0 0 #fff4e0) drop-shadow(-2px 0 0 #fff4e0) drop-shadow(0 2px 0 #fff4e0) drop-shadow(0 -2px 0 #fff4e0) drop-shadow(0 4px 0 var(--ink));
}
.logo .cake svg { display: block; width: 100%; height: 100%; shape-rendering: crispEdges; }
.logo .cake svg.num { position: absolute; left: 22%; width: 56%; top: 59%; height: auto; overflow: visible; }
.logo .cake svg.num .fg { fill: #fff4e0; }
.logo .cake svg.num .sh { fill: var(--ink); }
.logo .cake .fl { animation: flame 0.5s steps(2) infinite; }
@keyframes flame { 50% { opacity: 0.55; } }
@keyframes cake-in {
  0% { opacity: 0; transform: scale(3) rotate(-28deg); filter: blur(2px); }
  70% { opacity: 1; transform: scale(0.88) rotate(-4deg); filter: none; }
  100% { opacity: 1; transform: rotate(-8deg); }
}
@keyframes cake-pulse { 0%, 100% { transform: rotate(-8deg) scale(1); } 50% { transform: rotate(-4deg) scale(1.06); } }
.logo .cake .hv.pop { animation: cake-wiggle 0.5s ease-in-out; }
@keyframes cake-wiggle { 0%, 100% { transform: none; } 25% { transform: rotate(-10deg) scale(1.1); } 75% { transform: rotate(8deg) scale(1.1); } }
.logo .two .hv { display: grid; place-items: center; width: 100%; height: 100%; }
.logo .two .hv.pop { animation: two-spin 0.6s ease-in-out; }
/* el 2 cae como un sello: grande y borroso desde arriba, golpea y queda torcidito */
@keyframes two-in {
  0% { opacity: 0; transform: scale(3.4) rotate(-30deg); filter: blur(2px); }
  70% { opacity: 1; transform: scale(0.88) rotate(14deg); filter: none; }
  100% { opacity: 1; transform: rotate(10deg); }
}
@keyframes two-pulse { 0%, 100% { transform: rotate(10deg) scale(1); } 50% { transform: rotate(4deg) scale(1.1); } }
@keyframes two-spin { 0% { transform: none; } 70% { transform: rotate(330deg) scale(1.2); } 100% { transform: rotate(360deg); } }
/* regalitos flotando alrededor del título */
.title-gift {
  position: absolute; width: 34px; height: 34px; image-rendering: pixelated; cursor: pointer;
  filter: drop-shadow(0 3px 0 rgba(29,20,32,0.7)); animation: gift-float 3s ease-in-out infinite;
}
.title-gift.g1 { left: -30px; top: 8%; animation-duration: 3.2s; }
.title-gift.g2 { left: -46px; top: 52%; width: 42px; height: 42px; animation-duration: 2.7s; animation-delay: -1s; }
.title-gift.g3 { right: 16%; top: -22px; width: 26px; height: 26px; animation-duration: 3.6s; animation-delay: -2s; }
@keyframes gift-float { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-10px) rotate(6deg); } }
.title-gift.pop { animation: gift-pop 0.55s ease-out; }
@keyframes gift-pop { 0% { transform: scale(1); } 30% { transform: scale(1.35) rotate(-14deg); } 60% { transform: scale(0.9) rotate(10deg); } 100% { transform: scale(1); } }
.title-fx { position: absolute; pointer-events: none; font-size: 16px; color: var(--pink); text-shadow: 0 2px 0 var(--ink); animation: fx-fly 0.9s ease-out forwards; }
@keyframes fx-fly { from { opacity: 1; transform: translate(0, 0) scale(0.6); } to { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1.2); } }
/* brillitos que titilan */
.logo-box .spark { position: absolute; color: var(--gold); font-size: 14px; text-shadow: 0 0 8px rgba(255,211,77,0.9); pointer-events: none; animation: twinkle 1.8s ease-in-out infinite; }
.spark.s1 { left: 12%; top: -4px; } .spark.s2 { right: 6%; top: 10%; animation-delay: -0.6s; font-size: 10px; }
.spark.s3 { left: 4%; bottom: 18%; animation-delay: -1.1s; } .spark.s4 { right: 24%; bottom: -6px; animation-delay: -0.3s; font-size: 11px; }
.spark.s5 { left: 46%; top: -12px; animation-delay: -1.4s; font-size: 9px; }
@keyframes twinkle { 0%, 100% { opacity: 0.15; transform: scale(0.6) rotate(0deg); } 50% { opacity: 1; transform: scale(1.2) rotate(45deg); } }
@media (prefers-reduced-motion: reduce) {
  .logo .l1 .ch, .logo .hv, .logo .stamp, .logo .two, .logo .cake, .title-gift, .logo-box, .logo-box .spark { animation: none !important; }
  .logo .two { display: none; }
}

.logo .l1 .w { display: inline-block; white-space: nowrap; }
.logo .two svg { width: 58%; height: 58%; shape-rendering: crispEdges; overflow: visible; }
.logo .two svg .fg { fill: #fff4e0; }
.logo .two svg .sh { fill: var(--ink); }

/* iPhone acostado (pantallas bajitas): el título arriba y abajo dos columnas, personajes a la izquierda y menú a la derecha */
@media (max-height: 500px) and (orientation: landscape) {
  #screen-title { overflow-y: auto; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
  #screen-title .title-wrap {
    margin: auto; max-width: none; padding: 10px 16px 8px;
    display: grid; grid-template-columns: auto auto; column-gap: 34px; justify-content: center; align-items: center;
  }
  #screen-title .logo-box { grid-column: 1 / -1; justify-self: center; padding: 2px 8px; margin-bottom: 14px; }
  #screen-title .logo .l1 { font-size: 34px; }
  #screen-title .logo .l2 { font-size: 18px; margin-top: 8px; }
  #screen-title .pick { grid-column: 1; grid-row: 2; margin: 0 0 4px; align-self: end; }
  #screen-title .chars { grid-column: 1; grid-row: 3; margin: 0; gap: 10px; }
  #screen-title .char { min-width: 92px; padding: 6px 10px 4px; font-size: 15px; }
  #screen-title .char img { width: 48px; height: 64px; }
  #screen-title .hint { grid-column: 1; grid-row: 4; margin: 6px 0 0; font-size: 12px; max-width: 230px; justify-self: center; align-self: start; }
  #screen-title #ios-hint { grid-column: 1 / -1; grid-row: 5; max-width: none; }
  #screen-title .menu { grid-column: 2; grid-row: 2 / 5; gap: 7px; }
  #screen-title .btn.big { font-size: 17px; padding: 7px 16px; min-width: 210px; }
  #screen-title .menu > .btn:not(.big) { font-size: 15px; padding: 6px 12px; }
  #screen-title .btn.small { font-size: 13px; padding: 5px 9px; }
  #screen-title .link-btn { font-size: 13px; }
}

/* ---------- Pelea final ---------- */
/* recuerdo: la imagen en sepia y con los bordes como de sueño */
body.flashback #game { filter: sepia(0.85) saturate(0.85) brightness(1.06) contrast(0.95); }
#flashback { position: absolute; inset: 0; pointer-events: none; z-index: 14;
  background: radial-gradient(ellipse at center, rgba(255,240,210,0) 55%, rgba(255,236,200,0.55) 80%, rgba(255,246,228,0.95) 100%);
  animation: fb-breathe 3s ease-in-out infinite; }
@keyframes fb-breathe { 50% { opacity: 0.85; } }

/* segundo joystick (derecha): aparece en la pelea, donde apoyás el pulgar */
#aim-zone, #aim-stick { display: none; }
#touch.fight #aim-zone { display: block; pointer-events: auto; position: absolute; right: 0; bottom: 0; width: 46%; height: 72%; touch-action: none; }
#touch.fight #aim-stick {
  display: block; pointer-events: none; position: absolute;
  right: calc(120px + env(safe-area-inset-right)); bottom: calc(24px + env(safe-area-inset-bottom));
  width: 112px; height: 112px; border-radius: 50%;
  background: rgba(20,40,60,0.35); border: 3px solid rgba(143,211,255,0.45);
}
#touch.fight #aim-stick.active { border-color: rgba(143,211,255,0.85); background: rgba(20,40,70,0.5); }
#aim-knob { position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; margin: -25px 0 0 -25px; border-radius: 50%; background: rgba(143,211,255,0.7); border: 3px solid rgba(18,12,22,0.6); }
#aim-stick small { position: absolute; left: 0; right: 0; bottom: -16px; text-align: center; font-size: 10px; color: rgba(255,244,224,0.7); }
#touch.fight #t-dig, #touch.fight #t-torch { display: none; }
#touch.fight .tbtn.jump { z-index: 2; }
#touch.fight .tbtn.act { z-index: 2; }
#touch.fight .tbtn.tool { z-index: 2; }
@media (min-width: 900px) and (min-height: 600px) {
  #touch.fight #aim-stick { width: 150px; height: 150px; right: calc(150px + env(safe-area-inset-right)); }
}

/* joystick: el botón elegido con la cruz */
/* foco del joystick: el botón se ilumina con un brillo suave que late y un destello que lo cruza */
.pad-focus { outline: none !important; animation: pad-glow 1.6s ease-in-out infinite; }
button.pad-focus { position: relative; overflow: hidden; transform: translateY(-2px) scale(1.04); transition: transform 0.12s ease-out; z-index: 1; }
button.pad-focus::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: -60%; width: 45%; pointer-events: none;
  background: linear-gradient(105deg, transparent 0%, rgba(255,255,255,0.55) 50%, transparent 100%);
  animation: pad-shine 1.6s ease-in-out infinite;
}
@keyframes pad-glow {
  0%, 100% { filter: brightness(1.08) drop-shadow(0 0 3px rgba(255,232,150,0.8)) drop-shadow(0 0 9px rgba(255,140,200,0.35)); }
  50% { filter: brightness(1.2) drop-shadow(0 0 6px rgba(255,240,180,0.95)) drop-shadow(0 0 18px rgba(255,150,210,0.6)); }
}
@keyframes pad-shine { 0% { left: -60%; } 55%, 100% { left: 130%; } }
@media (prefers-reduced-motion: reduce) { .pad-focus, button.pad-focus::after { animation: none; } }

/* menú de efectos de sonido: botones numerados en dos columnas */
.sfx-list { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; align-items: start; }
.sfx-list .sfx { text-align: left; font-size: 13px; padding: 6px 8px; }
.sfx-list .sfx b { color: #0e2a40; margin-right: 2px; }

/* apertura del cofre (antes del cartel del regalo) */
#chest-open { position: absolute; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: rgba(8, 4, 14, 0.82); transition: background 0.25s; }
#chest-open canvas { width: min(94vw, 640px, calc(92vh * 84 / 64)); image-rendering: pixelated; transition: opacity 0.2s; }
#chest-open.out { background: transparent; pointer-events: none; }
#chest-open.out canvas { opacity: 0; }
#chest-open .co-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }

/* primeros planos de historieta en las escenas (src/cutin.js) */
#cutin { position: absolute; left: 0; right: 0; top: 7vh; bottom: 7vh; display: flex; align-items: center; justify-content: center; background: #0b0810; pointer-events: none; }
#cutin canvas { height: 100%; max-width: 100%; aspect-ratio: 16 / 9; object-fit: cover; image-rendering: pixelated; }
#cutin.go { animation: cutin-in 0.35s cubic-bezier(.3,1.6,.5,1) both; }
#cutin.go::after { content: ''; position: absolute; inset: 0; background: #fff; animation: cutin-flash 0.25s ease-out both; }
@keyframes cutin-in { from { transform: scale(1.08); } to { transform: none; } }
@keyframes cutin-flash { from { opacity: 0.9; } to { opacity: 0; } }
/* atardecer de la escena final */
#sunset { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(to bottom, rgba(255,110,60,0.42), rgba(255,160,90,0.2) 50%, rgba(90,30,70,0.3)); }

/* Configuración → Escenas */
.scenes-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; margin: 10px 0 12px; text-align: left; }
.scenes-list .btn { text-align: left; font-size: 13px; padding: 7px 9px; }
.scenes-list .btn b { color: var(--ink); margin-right: 3px; }
.scenes-list h3 { grid-column: 1 / -1; margin: 6px 0 0; font-size: 14px; color: var(--gold); text-shadow: 0 2px 0 var(--ink); }
#demo-bar { position: absolute; left: 50%; top: calc(7vh + 8px); transform: translateX(-50%); z-index: 18; box-shadow: 0 0 0 3px var(--ink), 0 4px 0 rgba(0,0,0,0.4); }
/* Configuración → Escenas → Final del juego: se ve el título, pero no se toca (solo "Volver a mi partida") */
#screen-title[inert] { pointer-events: none; }
#screen-title[inert] ~ #demo-bar { z-index: 21; top: auto; bottom: calc(7vh + 8px); }
