:root {
  color-scheme: light;
  --ink: #2b2140;
  --night: #1d1630;
  --pink: #ff4f6d;
  --yellow: #ffd23f;
  --teal: #2ec4b6;
  --ok: #22b357;
  --bad: #e23b3b;
  --card: #fff;
  --font: "Baloo 2", ui-rounded, "Trebuchet MS", system-ui, sans-serif;
  --title: "Lilita One", "Baloo 2", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--night);
  color: var(--ink);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
button { font-family: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
img { -webkit-user-drag: none; }

/* ------------------------------------------------------------ Juego */
#app {
  position: relative; height: 100%; height: 100dvh; display: flex; flex-direction: column;
  max-width: 1280px; margin: 0 auto; background: var(--night); overflow: hidden;
}
.hud {
  flex: 0 0 auto; display: flex; align-items: center; gap: 6px;
  padding: calc(6px + env(safe-area-inset-top, 0px)) 8px 6px;
  background: linear-gradient(180deg, #3a2d57, #2b2140); color: #fff; z-index: 3;
}
.hud-btn {
  flex: 0 0 auto; width: 38px; height: 38px; border: 0; border-radius: 12px;
  background: rgba(255,255,255,.14); color: #fff; display: grid; place-items: center;
}
.hud-btn svg { width: 20px; height: 20px; }
.hud-vidas { display: flex; gap: 1px; }
.hud-vidas img { width: 24px; height: 24px; }
.hud-vidas img.escudo { filter: drop-shadow(0 0 3px #7fd3ff); }
.hud-kit, .hud-der { display: flex; align-items: center; gap: 4px; }
.hud-der { margin-left: auto; }
.chip {
  display: inline-flex; align-items: center; gap: 2px; padding: 2px 8px 2px 4px; border-radius: 99px;
  background: rgba(255,255,255,.12); font-weight: 800; font-size: 15px; line-height: 1; white-space: nowrap;
}
.chip img { width: 22px; height: 22px; }
.chip.gemas { background: rgba(46,196,182,.25); }
.racha { gap: 3px; padding: 6px 8px; }
.racha i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.25); }
.racha i.on { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }
.racha.mega { background: linear-gradient(90deg, #ff4f6d, #ffd23f, #2ec4b6, #a57be0); }
@media (max-width: 400px) {
  .chip { font-size: 13px; padding: 2px 6px 2px 3px; }
  .chip img { width: 18px; height: 18px; }
  .hud-vidas img { width: 20px; height: 20px; }
  .racha { display: none; }
}

.stage { position: relative; flex: 1 1 auto; min-height: 200px; overflow: hidden; touch-action: none; }
#cv { display: block; position: absolute; inset: 0; width: 100%; height: 100%; }
.toast {
  position: absolute; left: 50%; top: 10px; transform: translate(-50%, -12px); opacity: 0;
  max-width: calc(100% - 24px); padding: 8px 16px; border-radius: 16px; background: rgba(29,22,48,.88); color: #fff;
  font-weight: 700; font-size: 16px; text-align: center; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 2;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.jefe-barra {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); width: min(80%, 360px);
  color: #fff; font-family: var(--title); font-size: 15px; text-align: center; text-shadow: 0 2px 0 rgba(0,0,0,.4); pointer-events: none;
}
.jefe-barra i { display: block; height: 12px; margin-top: 2px; border-radius: 99px; background: rgba(0,0,0,.45); border: 2px solid #fff; overflow: hidden; }
.jefe-barra b { display: block; height: 100%; background: linear-gradient(90deg, #ff4f6d, #ffd23f); transition: width .3s; }

/* Controles táctiles */
.ctrl {
  flex: 0 0 auto; position: relative; display: flex; align-items: center; justify-content: space-between;
  height: 172px; padding: 8px 18px calc(10px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, #2b2140, #1d1630); touch-action: none;
}
.pad { position: relative; width: 150px; height: 150px; touch-action: none; }
.pad img { width: 100%; height: 100%; pointer-events: none; }
.pad-dot { position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px; border-radius: 50%; background: rgba(255,210,63,.85); opacity: 0; pointer-events: none; transition: opacity .1s; }
.pad.on .pad-dot { opacity: 1; }
.bomb-btn { width: 118px; height: 118px; border: 0; padding: 0; background: none; touch-action: none; }
.bomb-btn img { width: 100%; height: 100%; pointer-events: none; transition: transform .08s; }
.bomb-btn.on img { transform: scale(.92); }
.bomb-btn.lleno img { filter: grayscale(.7) brightness(.8); }
.teclas { display: none; margin: 0; color: #cfc6ea; font-size: 15px; text-align: center; flex: 1; }
body.pc .pad, body.pc .bomb-btn { display: none; }
body.pc .teclas { display: block; }
body.pc .ctrl { height: auto; padding: 8px 12px; justify-content: center; }

@media (orientation: landscape) and (max-height: 560px) {
  body:not(.pc) .ctrl { position: absolute; inset: auto 0 0 0; height: auto; background: none; padding: 0 12px calc(8px + env(safe-area-inset-bottom, 0px)); pointer-events: none; z-index: 2; }
  body:not(.pc) .pad, body:not(.pc) .bomb-btn { pointer-events: auto; opacity: .85; }
  body:not(.pc) .pad { width: 132px; height: 132px; }
  body:not(.pc) .bomb-btn { width: 100px; height: 100px; }
}

/* Pregunta */
.ask {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; padding: 0 8px calc(8px + env(safe-area-inset-bottom, 0px));
  animation: subir .22s ease-out;
}
@keyframes subir { from { transform: translateY(40px); opacity: 0; } }
.ask-card {
  max-width: 560px; margin: 0 auto; padding: 10px 12px 12px; border-radius: 22px; background: var(--card);
  box-shadow: 0 -4px 0 #ffd23f, 0 10px 30px rgba(0,0,0,.45);
}
.ask-top { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; color: #5a4f75; }
.ask-top img { width: 30px; height: 30px; }
.ask-top span { flex: 1; }
.ask-voz { border: 0; background: #f0ebfa; border-radius: 10px; width: 34px; height: 30px; font-size: 16px; }
.ask-op { font-family: var(--title); font-size: clamp(40px, 11vw, 60px); line-height: 1.1; text-align: center; color: var(--ink); padding: 4px 0 6px; letter-spacing: .5px; }
.ask-op.ok { color: var(--ok); }
.ask-op.mal { color: var(--bad); font-size: clamp(30px, 8vw, 46px); }
.ask-op small { display: block; font-family: var(--font); font-size: 17px; font-weight: 700; color: #5a4f75; letter-spacing: 0; }
.ask-time { height: 10px; border-radius: 99px; background: #eee8f7; overflow: hidden; margin-bottom: 10px; }
.ask-time i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ff4f6d, #ffd23f 40%, #2ec4b6); transform-origin: left; }
.ask-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ask-opts button {
  position: relative; min-height: 62px; border: 0; border-radius: 16px; font-family: var(--title); font-size: 30px;
  background: linear-gradient(180deg, #6f5bd6, #5442b8); color: #fff; box-shadow: 0 5px 0 #3a2d8a; transition: transform .06s;
}
.ask-opts button:nth-child(2) { background: linear-gradient(180deg, #ff6f8a, #e8435f); box-shadow: 0 5px 0 #a82a42; }
.ask-opts button:nth-child(3) { background: linear-gradient(180deg, #34c9b9, #1fa596); box-shadow: 0 5px 0 #13786d; }
.ask-opts button:nth-child(4) { background: linear-gradient(180deg, #ffa940, #f08a1c); box-shadow: 0 5px 0 #a85a0a; }
.ask-opts button:active { transform: translateY(3px); box-shadow: none; }
.ask-opts button kbd { position: absolute; left: 8px; top: 4px; font: 700 12px var(--font); opacity: .6; }
.ask-opts button.ok { background: var(--ok); box-shadow: 0 5px 0 #157a3a; }
.ask-opts button.mal { background: #9c97ab; box-shadow: 0 5px 0 #6b667a; }
body:not(.pc) .ask-opts button kbd { display: none; }
@media (min-width: 700px) { .ask-opts { grid-template-columns: repeat(4, 1fr); } }

/* Capas (pausa, inicio de nivel, fin) */
.over {
  position: absolute; inset: 0; z-index: 8; display: grid; place-items: center; padding: 16px;
  background: rgba(20,14,36,.72); backdrop-filter: blur(2px); animation: fade .2s;
}
@keyframes fade { from { opacity: 0; } }
.card {
  width: min(100%, 440px); max-height: 100%; overflow-y: auto; padding: 18px 18px 16px; border-radius: 26px; background: var(--card);
  text-align: center; box-shadow: 0 8px 0 rgba(0,0,0,.25); animation: pop .3s cubic-bezier(.2,1.5,.5,1);
}
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.card h2 { margin: 0 0 4px; font-family: var(--title); font-weight: 400; font-size: 30px; line-height: 1.1; color: var(--ink); }
.card .sub { margin: 0 0 10px; color: #5a4f75; font-weight: 600; }
.card .mundo-tag { display: inline-block; margin-bottom: 6px; padding: 2px 12px; border-radius: 99px; color: #fff; font-weight: 800; font-size: 14px; }
.card .estrellas { font-size: 40px; letter-spacing: 4px; margin: 4px 0; }
.card .estrellas span { display: inline-block; animation: pop .4s backwards; }
.card .estrellas .off { filter: grayscale(1) opacity(.3); }
.card .datos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 10px 0; }
.card .datos div { background: #f4f0fb; border-radius: 14px; padding: 6px 4px; font-size: 13px; color: #5a4f75; font-weight: 700; }
.card .datos b { display: block; font-size: 20px; color: var(--ink); font-family: var(--title); font-weight: 400; }
.card .enemigos { display: flex; justify-content: center; gap: 4px; flex-wrap: wrap; margin: 8px 0; }
.card .enemigos img { width: 40px; height: 45px; }
.card .jefe-img { width: 150px; height: 168px; margin: -6px auto 0; display: block; }
.card .consejo { background: #fff6d6; border-radius: 14px; padding: 8px 10px; font-size: 15px; font-weight: 600; color: #6b5310; margin: 8px 0; }
.btns { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.btn {
  border: 0; border-radius: 16px; padding: 12px 16px; font-family: var(--title); font-size: 21px; color: #fff;
  background: linear-gradient(180deg, #ff6f8a, #e8435f); box-shadow: 0 5px 0 #a82a42;
}
.btn:active { transform: translateY(3px); box-shadow: none; }
.btn.alt { background: #efeaf8; color: var(--ink); box-shadow: 0 5px 0 #cfc6e3; }
.btn.oro { background: linear-gradient(180deg, #ffe066, #ffc21f); color: #5a3b00; box-shadow: 0 5px 0 #c08a00; }
.btn.teal { background: linear-gradient(180deg, #34c9b9, #1fa596); box-shadow: 0 5px 0 #13786d; }
.btn.lila { background: linear-gradient(180deg, #e1d2ff, #bfa6f5); color: #2b1f55; box-shadow: 0 5px 0 #8a6fd0; }
.fila { display: flex; gap: 8px; }
.fila .btn { flex: 1; }

/* ------------------------------------------------------------ Menús */
.menu {
  position: fixed; inset: 0; overflow-y: auto; color: #fff; z-index: 10;
  background: radial-gradient(circle at 50% 0%, #4b3a78, #2b2140 55%, #1d1630);
}
.menu-in { max-width: 860px; margin: 0 auto; padding: calc(10px + env(safe-area-inset-top, 0px)) 14px calc(24px + env(safe-area-inset-bottom, 0px)); }
.portada { display: flex; flex-direction: column; align-items: center; text-align: center; min-height: 100%; }
.portada .logo { width: min(92%, 520px); margin-top: 6px; filter: drop-shadow(0 6px 0 rgba(0,0,0,.25)); }
.portada .lema { margin: -4px 0 6px; font-weight: 700; color: #e3dbff; font-size: 17px; }
.escena { position: relative; width: min(100%, 520px); margin: 0 auto 10px; }
.escena canvas { display: block; width: 100%; height: auto; border-radius: 22px; box-shadow: 0 6px 0 rgba(0,0,0,.25); }
.portada .btns { width: min(100%, 380px); }
.portada .btn { font-size: 24px; }
.portada .mini { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 99px; padding: 8px 14px;
  background: rgba(255,255,255,.12); color: #fff; font-weight: 800; font-size: 15px;
}
.pill img { width: 22px; height: 22px; }
.top {
  display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 2;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 0 8px; background: linear-gradient(180deg, #2f2449 75%, rgba(47,36,73,0));
}
.top h1 { margin: 0; font-family: var(--title); font-weight: 400; font-size: 26px; flex: 1; }
.volver { width: 42px; height: 42px; border: 0; border-radius: 14px; background: rgba(255,255,255,.14); color: #fff; font-size: 22px; }
.mundos { display: grid; gap: 14px; }
@media (min-width: 720px) { .mundos { grid-template-columns: 1fr 1fr; } }
.mundo {
  position: relative; border-radius: 22px; overflow: hidden; padding: 12px 12px 14px; min-height: 170px;
  background-size: cover; background-position: center 70%; box-shadow: 0 6px 0 rgba(0,0,0,.3);
}
.mundo::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(20,14,36,.05), rgba(20,14,36,.55)); }
.mundo > * { position: relative; }
.mundo h2 { margin: 0; font-family: var(--title); font-weight: 400; font-size: 24px; text-shadow: 0 2px 0 rgba(0,0,0,.45); }
.mundo p { margin: 0 0 8px; font-weight: 700; font-size: 14px; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.mundo .est { position: absolute; right: 12px; top: 12px; background: rgba(0,0,0,.4); border-radius: 99px; padding: 2px 10px; font-weight: 800; }
.mundo.cerrado { filter: grayscale(.85) brightness(.75); }
.niveles { display: flex; gap: 8px; justify-content: space-between; }
.nv {
  position: relative; flex: 1; aspect-ratio: 1; max-width: 70px; border: 0; border-radius: 18px; padding: 0;
  background: #fff; color: var(--ink); font-family: var(--title); font-size: 24px; box-shadow: 0 4px 0 rgba(0,0,0,.35);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1;
}
.nv small { font-family: var(--font); font-size: 11px; font-weight: 800; letter-spacing: -1px; margin-top: 2px; }
.nv.jefe { background: linear-gradient(180deg, #ffe066, #ffb21f); }
.nv.jefe img { width: 38px; height: 43px; margin-top: -4px; }
.nv.hecho { box-shadow: 0 4px 0 #1fa596; }
.nv:disabled { background: rgba(255,255,255,.45); color: rgba(43,33,64,.5); cursor: default; }
.nv:disabled img { filter: grayscale(1) opacity(.4); }
.seccion-t { font-family: var(--title); font-weight: 400; font-size: 20px; margin: 14px 0 8px; }
.tienda { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.item {
  border: 0; border-radius: 20px; padding: 10px 8px; background: rgba(255,255,255,.1); color: #fff; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 800;
}
.item img { width: 76px; height: 95px; }
.item.bomba img { width: 72px; height: 72px; }
.item .precio { display: inline-flex; align-items: center; gap: 2px; background: rgba(0,0,0,.3); border-radius: 99px; padding: 1px 10px; }
.item .precio img { width: 20px; height: 20px; }
.item.puesto { background: rgba(46,196,182,.35); outline: 3px solid var(--teal); }
.item.caro { opacity: .55; }
.opciones { display: flex; flex-wrap: wrap; gap: 8px; }
.op {
  border: 0; border-radius: 16px; padding: 10px 14px; background: rgba(255,255,255,.12); color: #fff; font-weight: 800; font-size: 16px;
  display: flex; flex-direction: column; align-items: center; min-width: 76px;
}
.op small { font-weight: 600; opacity: .8; font-size: 12px; }
.op.on { background: var(--yellow); color: #3b2a00; box-shadow: 0 4px 0 #c08a00; }
.nota { color: #cfc6ea; font-size: 15px; font-weight: 600; margin: 6px 0; }
.interruptor { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-radius: 16px; background: rgba(255,255,255,.08); margin-bottom: 8px; font-weight: 700; }
.interruptor button { border: 0; border-radius: 99px; padding: 6px 14px; font-weight: 800; background: rgba(255,255,255,.2); color: #fff; min-width: 64px; }
.interruptor button.on { background: var(--teal); }
.reto-info { background: rgba(255,255,255,.08); border-radius: 20px; padding: 12px 14px; font-weight: 600; color: #e3dbff; }
.reto-info ol { margin: 6px 0; padding-left: 22px; }
.reto-info li { margin: 2px 0; }
