:root {
  color-scheme: light;
  --ink: #24104f;
  --muted: #6b5a96;
  --pink: #ff3d8b;
  --gold: #ffd23f;
  --gold2: #ffb21a;
  --violet: #7b2ff7;
  --line: #e2d9fb;
  --font: "Baloo 2", ui-rounded, "Trebuchet MS", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: #1a0b3d; color: var(--ink); font-family: var(--font);
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
}
button { font-family: inherit; color: inherit; }
button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ------------------------------ Juego ------------------------------ */
#app {
  position: fixed; inset: 0; overflow: hidden; display: grid;
  grid-template-rows: auto 1fr auto; grid-template-columns: 100%;
  grid-template-areas: "hud" "stage" "tools";
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; z-index: 0; }
.hud, .tools, .toolhint { position: relative; z-index: 2; }
.stage { grid-area: stage; min-height: 0; pointer-events: none; }
.hud { grid-area: hud; display: flex; flex-direction: column; gap: 6px; padding: 8px 10px 4px; max-width: 640px; width: 100%; margin: 0 auto; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-top { display: flex; align-items: center; gap: 8px; }
.hbtn {
  flex: 0 0 auto; width: 42px; height: 42px; border: 0; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  background: rgba(255, 255, 255, .95); color: var(--ink); box-shadow: 0 3px 0 rgba(0, 0, 0, .25);
}
.hbtn svg { width: 22px; height: 22px; }
.hbtn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, .25); }
.lvl { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.02; color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .35); }
.lvl b { font-size: 19px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lvl span { font-size: 13px; font-weight: 700; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-mid { display: flex; gap: 8px; align-items: stretch; }
.moves {
  flex: 0 0 auto; min-width: 74px; border-radius: 18px; padding: 4px 8px 3px; text-align: center; color: #fff;
  background: linear-gradient(180deg, #ff5fa2, #e2207a); box-shadow: 0 4px 0 #a3105a, inset 0 2px 0 rgba(255, 255, 255, .35);
  display: flex; flex-direction: column; justify-content: center; line-height: 1;
}
.moves b { font-size: 32px; font-weight: 800; text-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.moves span { font-size: 11px; font-weight: 800; letter-spacing: .02em; opacity: .95; }
.moves.low { animation: lowmv .7s ease-in-out infinite; background: linear-gradient(180deg, #ff7a3d, #e23b2b); box-shadow: 0 4px 0 #9c1d12; }
@keyframes lowmv { 50% { transform: scale(1.07); } }
.moves.bump b { animation: bump .25s ease-out; }
.goals {
  flex: 1 1 auto; min-width: 0; display: flex; gap: 6px; align-items: stretch; justify-content: center;
  background: rgba(255, 255, 255, .94); border-radius: 18px; padding: 5px 6px; box-shadow: 0 4px 0 rgba(0, 0, 0, .25);
}
.goal {
  flex: 1 1 0; min-width: 0; max-width: 92px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  border-radius: 12px; padding: 2px 2px 1px; background: #f4efff; position: relative;
}
.goal img { width: 30px; height: 30px; display: block; }
.goal .gi { width: 30px; height: 30px; display: grid; place-items: center; font-size: 22px; line-height: 1; }
.goal b { font-size: 17px; font-weight: 800; line-height: 1; white-space: nowrap; }
.goal.done { background: #dcfbe6; }
.goal.done b { color: #14903f; }
.goal.bump { animation: bump .3s ease-out; }
@keyframes bump { 40% { transform: scale(1.18); } }
.scorebar { display: flex; align-items: center; gap: 8px; }
.sb-track { position: relative; flex: 1 1 auto; height: 14px; border-radius: 99px; background: rgba(0, 0, 0, .35); box-shadow: inset 0 2px 3px rgba(0, 0, 0, .35); }
.sb-track i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: inherit; background: linear-gradient(90deg, #ffe35c, #ffb21a); box-shadow: 0 0 8px rgba(255, 210, 63, .7); transition: width .25s; }
.sb-mark { position: absolute; top: -3px; width: 4px; height: 20px; margin-left: -2px; border-radius: 3px; background: rgba(255, 255, 255, .8); }
.sb-stars { display: flex; gap: 2px; }
.sb-stars i, .stars i, .nstars i, .wstar {
  display: inline-block; background: rgba(255, 255, 255, .3);
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
.sb-stars i { width: 20px; height: 20px; }
.sb-stars i.on { background: var(--gold); animation: starIn .45s cubic-bezier(.3, 1.8, .5, 1) both; }
.sb-pts { min-width: 58px; text-align: right; color: #fff; font-size: 18px; font-weight: 800; text-shadow: 0 2px 0 rgba(0, 0, 0, .35); }

.tools { grid-area: tools; display: flex; justify-content: center; gap: 10px; padding: 4px 10px 10px; }
.tool {
  border: 0; border-radius: 18px; padding: 5px 12px 5px 8px; min-height: 48px; display: flex; align-items: center; gap: 6px; cursor: pointer;
  background: rgba(255, 255, 255, .95); color: var(--ink); box-shadow: 0 4px 0 rgba(0, 0, 0, .25); font-weight: 800; font-size: 15px;
}
.tool .ti { font-size: 22px; }
.tool b { min-width: 24px; height: 24px; border-radius: 99px; display: grid; place-items: center; background: var(--violet); color: #fff; font-size: 14px; }
.tool:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.tool:disabled { opacity: .45; cursor: default; }
.tool.on { background: var(--gold); box-shadow: 0 0 0 3px #fff, 0 4px 0 rgba(0, 0, 0, .25); }
.tools.reto .tool { display: none; }
.toolhint {
  position: absolute; left: 50%; bottom: calc(70px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 3;
  background: var(--ink); color: #fff; border-radius: 99px; padding: 6px 16px; font-weight: 800; font-size: 15px; white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .35); pointer-events: none;
}
@media (orientation: landscape) and (max-height: 560px) {
  #app { grid-template-columns: minmax(220px, 34%) 1fr; grid-template-rows: auto 1fr; grid-template-areas: "hud stage" "tools stage"; }
  .hud { padding-top: 8px; }
  .tools { align-items: flex-start; align-content: flex-start; flex-wrap: wrap; }
  .toolhint { left: 66%; bottom: 14px; }
}

/* ------------------------------ Capas (intro, fin) ------------------------------ */
.ov { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(20, 6, 48, .62); backdrop-filter: blur(3px); overflow-y: auto; }
.card {
  width: min(100%, 420px); background: #fff; border-radius: 28px; padding: 18px 18px 16px; text-align: center; position: relative;
  box-shadow: 0 8px 0 rgba(0, 0, 0, .25), 0 20px 50px rgba(0, 0, 0, .45); animation: cardIn .35s cubic-bezier(.3, 1.5, .5, 1) both;
  display: flex; flex-direction: column; gap: 12px;
}
@keyframes cardIn { from { transform: scale(.8) translateY(20px); opacity: 0; } }
.card .ribbon {
  margin: -40px auto 0; padding: 8px 26px 6px; border-radius: 16px; color: #fff; font-size: 24px; font-weight: 800; line-height: 1.05;
  background: linear-gradient(180deg, #ff5fa2, #e2207a); box-shadow: 0 5px 0 #a3105a; text-shadow: 0 2px 0 rgba(0, 0, 0, .25); max-width: 92%;
}
.card .ribbon small { display: block; font-size: 14px; opacity: .92; }
.card .ribbon.win { background: linear-gradient(180deg, #47d97a, #18a64a); box-shadow: 0 5px 0 #0f7a33; }
.card .ribbon.lose { background: linear-gradient(180deg, #8f80c9, #5b4b9c); box-shadow: 0 5px 0 #3d2f73; }
.card h2 { margin: 0; font-size: 26px; line-height: 1.05; }
.card p { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.3; color: var(--muted); }
.glist { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.gl { display: flex; align-items: center; gap: 10px; background: #f4efff; border-radius: 14px; padding: 6px 10px; font-weight: 800; font-size: 16px; line-height: 1.15; }
.gl img, .gl .gi { width: 36px; height: 36px; flex: 0 0 auto; display: grid; place-items: center; font-size: 26px; }
.gl.ok { background: #dcfbe6; }
.gl.no { background: #ffe8ec; }
.gl em { margin-left: auto; font-style: normal; font-size: 14px; color: var(--muted); white-space: nowrap; }
.tip { display: flex; gap: 10px; align-items: center; text-align: left; background: #fff6d6; border-radius: 16px; padding: 8px 12px; font-weight: 700; font-size: 15px; line-height: 1.3; color: #6b4b00; }
.tip span { font-size: 26px; }
.tip.new { box-shadow: 0 0 0 3px var(--gold); }
.mv { font-size: 18px; font-weight: 800; color: var(--ink); }
.stars { display: flex; justify-content: center; gap: 8px; margin: 4px 0 0; }
.stars i { width: 58px; height: 58px; background: #e2dcf5; }
.stars i:nth-child(2) { transform: translateY(-12px); width: 70px; height: 70px; }
.stars i.on { background: var(--gold); animation: starIn .5s cubic-bezier(.3, 1.8, .5, 1) both; }
.stars i.on:nth-child(2) { animation-delay: .35s; } .stars i.on:nth-child(3) { animation-delay: .7s; }
@keyframes starIn { from { transform: scale(0) rotate(-50deg); } }
.big-pts { font-size: 34px; font-weight: 800; line-height: 1; color: var(--ink); }
.big-pts small { display: block; font-size: 14px; color: var(--muted); }
.prize { background: #f3ecff; border-radius: 14px; padding: 6px 10px; font-weight: 800; color: var(--violet); }
.btns { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  flex: 1 1 130px; border: 0; border-radius: 18px; min-height: 56px; padding: 10px 16px; cursor: pointer; touch-action: manipulation;
  font: 800 20px var(--font); color: #fff; background: linear-gradient(180deg, #9a5bff, #7b2ff7); box-shadow: 0 5px 0 #4f1aa8;
}
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #4f1aa8; }
.btn.gold { color: var(--ink); background: linear-gradient(180deg, #ffe45c, #ffc21a); box-shadow: 0 5px 0 #d79a00; }
.btn.gold:active { box-shadow: 0 2px 0 #d79a00; }
.btn.alt { color: var(--ink); background: #fff; box-shadow: 0 5px 0 var(--line), inset 0 0 0 3px var(--line); }
.btn.alt:active { box-shadow: 0 2px 0 var(--line), inset 0 0 0 3px var(--line); }
.btn.wide { flex-basis: 100%; }

/* ------------------------------ Menú ------------------------------ */
.menu {
  position: fixed; inset: 0; overflow-y: auto; z-index: 5; color: #fff;
  background:
    radial-gradient(240px 200px at 10% 0, rgba(255, 120, 220, .35), transparent 70%),
    radial-gradient(240px 200px at 90% 6%, rgba(120, 200, 255, .3), transparent 70%),
    linear-gradient(180deg, #24104f 0, #4a1a9a 520px, #2a0f63 100%);
}
.menu::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .55;
  background-image:
    radial-gradient(2px 2px at 12% 18%, #fff, transparent), radial-gradient(2px 2px at 82% 12%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 30% 40%, #fff, transparent), radial-gradient(2px 2px at 70% 34%, #ffe9a8, transparent),
    radial-gradient(1.5px 1.5px at 50% 8%, #fff, transparent), radial-gradient(2px 2px at 92% 52%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 6% 62%, #ffe9a8, transparent), radial-gradient(1.5px 1.5px at 40% 76%, #fff, transparent);
  animation: twinkle 3s ease-in-out infinite alternate;
}
@keyframes twinkle { to { opacity: .2; } }
.menu-in { position: relative; max-width: 640px; margin: 0 auto; padding: calc(10px + env(safe-area-inset-top, 0px)) 16px calc(26px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 14px; }
.m-top { display: flex; justify-content: space-between; gap: 8px; }
.chip {
  border: 0; border-radius: 999px; padding: 4px 14px; min-height: 40px; background: rgba(255, 255, 255, .95); color: var(--ink);
  font: 800 15px var(--font); box-shadow: 0 3px 0 rgba(0, 0, 0, .25); cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.chip svg { width: 20px; height: 20px; }
.chip .wstar { width: 18px; height: 18px; background: var(--gold2); }
.logo { display: block; width: min(56vw, 230px); height: auto; margin: -2px auto -12px; filter: drop-shadow(0 10px 16px rgba(0, 0, 0, .4)); }
.logo .bob { animation: bob 2.6s ease-in-out infinite; transform-origin: 130px 100px; }
.logo .tw { animation: tw 1.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.logo .tw:nth-of-type(2) { animation-delay: .5s; } .logo .tw:nth-of-type(3) { animation-delay: 1s; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-2deg); } }
@keyframes tw { 50% { transform: scale(.4); opacity: .4; } }
.menu h1 {
  margin: 0; text-align: center; font-size: clamp(46px, 14vw, 70px); line-height: .9; font-weight: 800; color: #fff;
  -webkit-text-stroke: 9px #1a0b3d; paint-order: stroke fill; text-shadow: 0 6px 0 #1a0b3d;
}
.menu h1 span { color: var(--pink); }
.m-lede { margin: 0; text-align: center; font-size: 17px; line-height: 1.3; font-weight: 700; color: #ece4ff; }
.m-row { display: flex; gap: 10px; }
.m-row .btn { flex: 1 1 0; }
.m-play { font-size: 22px; min-height: 62px; }
.reto-how { margin: -4px 0 0; font-size: 14px; color: #ddd2ff; font-weight: 700; text-align: center; line-height: 1.35; }
.helps { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; font-weight: 800; font-size: 15px; color: #ece4ff; }
.helps span { background: rgba(0, 0, 0, .25); border-radius: 99px; padding: 3px 12px; }

.world {
  border-radius: 24px; padding: 12px 12px 14px; background: var(--wbg); position: relative; overflow: hidden;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .2), 0 6px 0 rgba(0, 0, 0, .25);
}
.world::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: var(--wdeco, none); opacity: .35; }
.world.locked { filter: saturate(.3) brightness(.75); }
.w-h { position: relative; z-index: 1; display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; line-height: 1.05; text-shadow: 0 2px 0 rgba(0, 0, 0, .3); }
.w-h .ic { font-size: 28px; }
.w-h small { display: block; font-size: 13px; opacity: .9; }
.w-h .wcount { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; font-size: 15px; background: rgba(0, 0, 0, .3); border-radius: 99px; padding: 3px 10px; white-space: nowrap; }
.w-h .wcount .wstar { width: 16px; height: 16px; background: var(--gold); }
.path { position: relative; z-index: 1; margin-top: 10px; display: grid; grid-template-columns: repeat(5, 1fr); row-gap: 12px; }
.path svg.trail { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.node {
  justify-self: center; position: relative; width: 56px; height: 56px; border: 0; border-radius: 50%; cursor: pointer; padding: 0;
  background: radial-gradient(circle at 35% 30%, #fff, #e7defe 70%); color: var(--ink); font: 800 22px var(--font);
  box-shadow: 0 4px 0 rgba(0, 0, 0, .3), inset 0 -3px 0 rgba(0, 0, 0, .08); display: grid; place-items: center;
}
.node:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, .3); }
.node .nstars { position: absolute; bottom: -9px; left: 50%; transform: translateX(-50%); display: flex; gap: 0; }
.nstars i { width: 15px; height: 15px; background: rgba(0, 0, 0, .25); }
.nstars i.on { background: var(--gold); filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .4)); }
.node.done { background: radial-gradient(circle at 35% 30%, #fff7c2, #ffd23f 70%); }
.node.boss { width: 62px; height: 62px; }
.node.boss::before { content: "👑"; position: absolute; top: -10px; left: -10px; font-size: 18px; transform: rotate(-24deg); }
.node.next { box-shadow: 0 0 0 4px #fff, 0 4px 0 rgba(0, 0, 0, .3); animation: nglow 1.3s ease-in-out infinite; }
@keyframes nglow { 50% { box-shadow: 0 0 0 4px #fff, 0 0 22px 6px rgba(255, 255, 255, .8); transform: scale(1.06); } }
.node:disabled { cursor: default; background: rgba(255, 255, 255, .25); color: rgba(255, 255, 255, .8); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .35); font-size: 18px; }
.w-lock { position: relative; z-index: 1; margin: 8px 0 0; font-size: 14px; font-weight: 700; opacity: .95; }
.m-foot { text-align: center; font-size: 14px; font-weight: 700; color: #cbbcf5; margin: 0; }

@media (prefers-reduced-motion: reduce) {
  .card, .stars i.on, .sb-stars i.on, .node.next, .logo .bob, .logo .tw, .menu::before, .moves.low, .goal.bump { animation: none; }
}

/* Rediseño nov. 2026: gema y cristales de plastilina en lugar del logo dibujado. */
.logo.arte { width: min(90vw, 380px); margin: 0 auto -4px; filter: none; }
@media (orientation: landscape) and (max-height: 500px) { .logo.arte { width: auto; height: 22vh; } }
