:root {
  --ink: #2B2150;
  --ink-soft: #6B6290;
  --card: #FFFFFF;
  --line: #EDE7FF;
  --pink: #FF5D8F;
  --pink-d: #E0346C;
  --yellow: #FFC93C;
  --yellow-d: #E9A400;
  --green: #2EC27E;
  --green-d: #1E9A60;
  --red: #FF6B6B;
  --purple: #8B5CF6;
  --purple-d: #6A3FD6;
  --blue: #3B9EFF;
  --c: var(--purple);
  --cd: var(--purple-d);
  --cs: #E9E0FF;
  --radius: 28px;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(160deg, #DFF1FF 0%, #F3E8FF 45%, #FFE9F3 100%);
  background-attachment: fixed;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  overflow-x: hidden;
  font-size: 20px;
}
button { font-family: inherit; color: inherit; cursor: pointer; border: 0; background: none; touch-action: manipulation; }
input, select { font-family: inherit; }
h1, h2, h3 { margin: 0; font-weight: 800; letter-spacing: -0.01em; }
p { margin: 0.4em 0; line-height: 1.4; }
.small { font-size: 16px; color: var(--ink-soft); }
.grow { flex: 1; }
.row { display: flex; gap: 16px; justify-content: center; align-items: center; margin-top: 18px; }
.row.wrap { flex-wrap: wrap; justify-content: flex-start; }
.col { display: flex; flex-direction: column; gap: 14px; align-items: center; margin-top: 16px; }
.center { text-align: center; }

/* ---------- cielo de fondo ---------- */
.sky { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.cloud { position: absolute; background: #fff; border-radius: 100px; opacity: 0.75; filter: blur(1px); }
.cloud::before, .cloud::after { content: ""; position: absolute; background: #fff; border-radius: 50%; }
.cl1 { width: 220px; height: 60px; top: 9%; left: -240px; animation: drift 70s linear infinite; }
.cl2 { width: 160px; height: 46px; top: 38%; left: -200px; animation: drift 95s linear infinite 20s; }
.cl3 { width: 260px; height: 70px; top: 72%; left: -280px; animation: drift 120s linear infinite 45s; }
.cloud::before { width: 90px; height: 90px; top: -45px; left: 30px; }
.cloud::after { width: 70px; height: 70px; top: -30px; left: 100px; }
@keyframes drift { to { transform: translateX(calc(100vw + 600px)); } }
.float { position: absolute; font-weight: 900; font-size: 64px; color: rgba(139, 92, 246, 0.10); animation: floaty 9s ease-in-out infinite; }
.f1 { top: 14%; left: 6%; } .f2 { top: 22%; right: 8%; animation-delay: -2s; color: rgba(255, 93, 143, .12); }
.f3 { top: 62%; left: 4%; animation-delay: -4s; color: rgba(59, 158, 255, .12); } .f4 { bottom: 8%; right: 12%; animation-delay: -1s; }
.f5 { top: 46%; right: 3%; color: rgba(255, 201, 60, .25); animation-delay: -6s; } .f6 { bottom: 18%; left: 42%; animation-delay: -3s; color: rgba(46, 194, 126, .12); }
.f7 { top: 6%; left: 48%; animation-delay: -5s; color: rgba(255, 138, 61, .14); }
@keyframes floaty { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-26px) rotate(8deg); } }

#app { position: relative; z-index: 1; min-height: 100vh; }
.screen { min-height: 100vh; padding: calc(env(safe-area-inset-top) + 20px) 32px calc(env(safe-area-inset-bottom) + 28px); max-width: 1320px; margin: 0 auto; animation: screenIn 0.35s ease-out; }
@keyframes screenIn { from { transform: translateY(14px); } }

/* ---------- botones ---------- */
.btn {
  --b: var(--purple); --bd: var(--purple-d);
  background: var(--b); color: #fff; font-weight: 800; font-size: 24px;
  padding: 16px 30px; border-radius: 22px; box-shadow: 0 7px 0 var(--bd), 0 12px 24px rgba(43, 33, 80, 0.15);
  transition: transform 0.08s, box-shadow 0.08s; position: relative;
}
.btn:active, .btn.down { transform: translateY(5px); box-shadow: 0 2px 0 var(--bd), 0 4px 10px rgba(43, 33, 80, 0.15); }
.btn:disabled { filter: grayscale(0.8); opacity: 0.6; }
.btn-big { font-size: 30px; padding: 20px 44px; border-radius: 26px; }
.btn-go { --b: var(--green); --bd: var(--green-d); }
.btn-soft { --b: #fff; --bd: #D9D0F5; color: var(--ink); }
.btn-danger { --b: var(--red); --bd: #D94848; }
.btn-jump { --b: var(--yellow); --bd: var(--yellow-d); color: var(--ink); }
.btn-table { --b: var(--purple); --bd: var(--purple-d); font-size: 20px; padding: 12px 16px; }
.btn-round {
  width: 60px; height: 60px; border-radius: 50%; background: #fff; font-size: 26px; font-weight: 900;
  box-shadow: 0 5px 0 #D9D0F5, 0 8px 18px rgba(43, 33, 80, 0.12); flex: none; display: grid; place-items: center;
}
.btn-round:active { transform: translateY(4px); box-shadow: 0 1px 0 #D9D0F5; }
.btn-round.holding { animation: hold 1.2s linear; }
@keyframes hold { to { box-shadow: 0 0 0 10px rgba(139, 92, 246, 0.35); transform: scale(1.1); } }

/* ---------- barra superior ---------- */
.topbar { display: flex; align-items: center; gap: 18px; margin-bottom: 18px; }
.me { display: flex; align-items: center; gap: 14px; background: #fff; padding: 8px 20px 8px 8px; border-radius: 40px; box-shadow: 0 6px 18px rgba(43, 33, 80, 0.1); }
.avatar { width: 62px; height: 62px; border-radius: 50%; background: linear-gradient(135deg, #FFE1EC, #E9E0FF); display: grid; place-items: center; font-size: 38px; }
.me-info b { font-size: 24px; }
.lvl { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--ink-soft); font-weight: 700; }
.lvl-bar { width: 120px; height: 12px; border-radius: 8px; background: var(--line); overflow: hidden; }
.lvl-bar div { height: 100%; background: linear-gradient(90deg, var(--yellow), var(--pink)); border-radius: 8px; transition: width 0.6s; }
.top-title { flex: 1; font-size: 34px; text-align: center; }
.top-pills { display: flex; align-items: center; gap: 12px; }
.pill { display: flex; align-items: center; gap: 8px; background: #fff; border-radius: 30px; padding: 8px 18px; font-size: 24px; font-weight: 800; box-shadow: 0 6px 18px rgba(43, 33, 80, 0.1); min-height: 56px; }
.pill-goal { padding: 6px 16px 6px 8px; font-size: 18px; }
.pill-stars b { color: #D98E00; }
.pill-streak b { color: var(--pink-d); }
.ring { position: relative; display: grid; place-items: center; }
.ring svg { position: absolute; inset: 0; }
.ring circle { transition: stroke-dashoffset 0.8s; }
.ring-inner { font-size: 18px; }

/* ---------- burbujas, mascota, toasts ---------- */
.bubble {
  background: #fff; border-radius: 26px; padding: 18px 24px; font-size: 24px; font-weight: 700; line-height: 1.3;
  box-shadow: 0 8px 22px rgba(43, 33, 80, 0.12); position: relative;
}
.bubble.big { font-size: 30px; }
.bubble-left::before { content: ""; position: absolute; left: -16px; top: 32px; border: 12px solid transparent; border-right: 18px solid #fff; border-left: 0; }
.bubble.pop { animation: pop 0.35s; }
@keyframes pop { 0% { transform: scale(0.85); } 60% { transform: scale(1.06); } 100% { transform: scale(1); } }
.mascot { display: block; overflow: visible; }
.mascot .m-line { stroke: #2B2150; stroke-width: 5; stroke-linecap: round; fill: none; }
.mascot .m-ant { stroke: #7C4DFF; stroke-width: 6; stroke-linecap: round; }
.mascot .m-arm { fill: #8F63FF; }
.mascot .m-eyes { animation: blink 4.5s infinite; transform-origin: 100px 100px; }
.mascot .m-star { animation: twinkle 2s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(0.1); } }
@keyframes twinkle { 50% { transform: scale(1.25) rotate(15deg); } }
.mascot.bob .m-body, .mascot-party .m-body { animation: bob 2.4s ease-in-out infinite; }
.mascot-party .m-body { animation: jump 0.6s ease-in-out 2; }
@keyframes bob { 50% { transform: translateY(-8px); } }
@keyframes jump { 40% { transform: translateY(-22px) scale(1.04, 0.97); } 70% { transform: translateY(0) scale(1.05, 0.94); } }
.pop-in { animation: pop 0.35s; }

.toast {
  position: fixed; top: calc(env(safe-area-inset-top) + 18px); left: 50%; transform: translate(-50%, -160%);
  background: #fff; border-radius: 26px; padding: 18px 30px; font-size: 24px; font-weight: 700; z-index: 60;
  box-shadow: 0 14px 40px rgba(43, 33, 80, 0.25); transition: transform 0.4s cubic-bezier(.3, 1.6, .5, 1); max-width: 90vw; text-align: center;
  border: 4px solid var(--purple);
}
.toast.show { transform: translate(-50%, 0); }
.toast-unlock { border-color: var(--green); }
.toast-crown, .toast-goal { border-color: var(--yellow); }
.toast-badge { border-color: var(--pink); }

.fx-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 80; }
.fly-star { position: fixed; z-index: 90; font-size: 40px; pointer-events: none; transform: translate(-50%, -50%); }

/* ---------- modal ---------- */
.modal-wrap { position: fixed; inset: 0; background: rgba(43, 33, 80, 0.45); display: grid; place-items: center; z-index: 50; opacity: 0; transition: opacity 0.25s; padding: 24px; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal-wrap.show { opacity: 1; }
.modal { background: #fff; border-radius: 36px; padding: 36px 40px; max-width: 760px; width: 100%; max-height: 92vh; overflow: auto; position: relative; transform: scale(0.9); transition: transform 0.3s cubic-bezier(.3, 1.5, .5, 1); box-shadow: 0 30px 80px rgba(43, 33, 80, 0.35); }
.modal-wrap.show .modal { transform: scale(1); }
.modal h2 { font-size: 34px; margin: 6px 0 8px; }
.modal-x { position: absolute; top: 16px; right: 16px; width: 48px; height: 48px; border-radius: 50%; background: var(--line); font-size: 22px; font-weight: 900; }
.modal .center .mascot { margin: 0 auto; }

/* ---------- onboarding ---------- */
.onboarding { display: grid; place-items: center; }
.onb-card { background: rgba(255, 255, 255, 0.75); border-radius: 44px; padding: 44px 56px; max-width: 860px; width: 100%; text-align: center; box-shadow: 0 20px 60px rgba(43, 33, 80, 0.15); }
.onb-mascot { display: flex; align-items: center; gap: 24px; justify-content: center; text-align: left; }
.onb-mascot .mascot .m-body { animation: bob 2.4s ease-in-out infinite; }
.name-input { margin: 28px auto 8px; display: block; font-size: 44px; font-weight: 800; text-align: center; border: 4px solid var(--line); border-radius: 24px; padding: 14px 20px; width: min(520px, 100%); color: var(--ink); outline: none; -webkit-user-select: text; user-select: text; }
.name-input:focus { border-color: var(--purple); }
.onb-sub { font-size: 22px; color: var(--ink-soft); margin: 16px 0 10px; }
.avatars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin: 10px auto 28px; max-width: 620px; }
.avatar-pick { font-size: 52px; background: #fff; border-radius: 24px; aspect-ratio: 1; box-shadow: 0 5px 0 #E6DEFF; transition: transform 0.15s; }
.avatar-pick.on { background: #FFF4CC; box-shadow: 0 0 0 5px var(--yellow), 0 5px 0 var(--yellow-d); transform: scale(1.08); }

/* ---------- inicio ---------- */
.hero { display: flex; align-items: center; gap: 28px; margin: 10px 0 26px; }
.hero-mascot { flex: none; }
.hero-right { flex: 1; display: flex; flex-direction: column; gap: 22px; align-items: flex-start; }
.btn-magic {
  --b: linear-gradient(135deg, #FF5D8F, #8B5CF6); background: linear-gradient(135deg, #FF6FA0 0%, #A66BFF 55%, #6E8BFF 100%);
  box-shadow: 0 9px 0 #5A35C2, 0 18px 34px rgba(110, 70, 220, 0.35); color: #fff; font-size: 40px; font-weight: 900; padding: 22px 44px 18px; border-radius: 34px;
  display: flex; flex-direction: column; align-items: flex-start; position: relative; overflow: hidden; transition: transform 0.08s;
}
.btn-magic small { font-size: 20px; font-weight: 700; opacity: 0.9; margin-top: 2px; }
.btn-magic:active { transform: translateY(6px); box-shadow: 0 3px 0 #5A35C2; }
.btn-magic::after { content: ""; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.45) 50%, transparent 70%); transform: translateX(-100%); animation: shine 3.5s ease-in-out infinite; }
@keyframes shine { 60%, 100% { transform: translateX(100%); } }
.sparkle { display: inline-block; animation: twinkle 1.6s infinite; }

.worlds { display: grid; grid-template-columns: repeat(4, 1fr); gap: 22px; }
.world-card {
  background: linear-gradient(180deg, var(--c) 0%, var(--cd) 100%); color: #fff; border-radius: 34px; padding: 22px 18px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; min-height: 260px; justify-content: center;
  box-shadow: 0 9px 0 rgba(0, 0, 0, 0.18), 0 16px 30px rgba(43, 33, 80, 0.16); transition: transform 0.1s;
}
.world-card:active { transform: translateY(6px) scale(0.98); }
.world-emoji { font-size: 92px; line-height: 1; filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.2)); animation: floaty 6s ease-in-out infinite; }
.world-card:nth-child(2) .world-emoji { animation-delay: -1.5s; } .world-card:nth-child(3) .world-emoji { animation-delay: -3s; } .world-card:nth-child(4) .world-emoji { animation-delay: -4.5s; }
.world-name { font-size: 30px; font-weight: 900; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.15); margin-top: 8px; }
.world-meta { font-size: 18px; font-weight: 700; opacity: 0.95; }
.world-bar { width: 80%; height: 14px; background: rgba(255, 255, 255, 0.3); border-radius: 10px; overflow: hidden; margin-top: 6px; }
.world-bar i { display: block; height: 100%; background: #fff; border-radius: 10px; }
.world-done { position: absolute; top: 12px; right: 14px; font-size: 36px; }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 22px; margin-top: 26px; }
.tile {
  background: #fff; border-radius: 30px; padding: 20px 10px; font-size: 26px; font-weight: 800; display: flex; flex-direction: column; align-items: center; gap: 6px;
  box-shadow: 0 7px 0 #E3DAFB, 0 12px 26px rgba(43, 33, 80, 0.1); transition: transform 0.1s;
}
.tile span { font-size: 56px; }
.tile:active { transform: translateY(5px); box-shadow: 0 2px 0 #E3DAFB; }

/* ---------- mapa del mundo ---------- */
.world .top-title { color: var(--cd); }
.map { position: relative; margin: 0 auto; max-width: 900px; }
.map-path { position: absolute; inset: 0; width: 100%; height: 100%; }
.map-path polyline { fill: none; stroke: var(--c); stroke-width: 14; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 2 26; opacity: 0.45; }
.node-wrap { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; width: 220px; }
.node {
  width: 108px; height: 108px; border-radius: 50%; background: linear-gradient(180deg, var(--c), var(--cd)); color: #fff;
  font-size: 44px; font-weight: 900; box-shadow: 0 9px 0 rgba(0, 0, 0, 0.22), 0 0 0 8px #fff, 0 16px 30px rgba(43, 33, 80, 0.22); position: relative; transition: transform 0.1s;
}
.node:active { transform: translateY(6px); }
.node.locked { background: #E4E0EE; color: #9A93B5; font-size: 36px; box-shadow: 0 9px 0 #CFC8E0, 0 0 0 8px #fff; }
.node.front { animation: pulse 1.6s ease-in-out infinite; }
.node.flash { animation: flash 0.6s 3; }
@keyframes pulse { 50% { box-shadow: 0 9px 0 rgba(0, 0, 0, 0.22), 0 0 0 8px #fff, 0 0 0 22px color-mix(in srgb, var(--c) 30%, transparent); } }
@keyframes flash { 50% { transform: scale(1.18); } }
.node-crown { position: absolute; top: -34px; left: 50%; transform: translateX(-50%) rotate(-8deg); font-size: 44px; }
.node-stars { margin-top: 12px; font-size: 28px; height: 32px; }
.node-label { background: #fff; padding: 4px 14px; border-radius: 14px; font-size: 18px; font-weight: 800; box-shadow: 0 4px 10px rgba(43, 33, 80, 0.1); text-align: center; }
.node-mascot { position: absolute; left: calc(50% + 70px); top: -20px; }
.st { color: #DDD6EE; }
.st.on { color: var(--yellow); text-shadow: 0 2px 0 var(--yellow-d); }
.placed { color: var(--green); font-weight: 900; font-size: 26px; }

.level-card { text-align: center; }
.lc-head { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.lc-head span { font-size: 70px; }
.lc-head h2 { color: var(--cd); }
.lc-stars { font-size: 56px; margin: 6px 0 10px; }
.lc-stats { display: flex; justify-content: center; gap: 20px; margin: 8px 0 14px; }
.lc-stats div { background: var(--cs); border-radius: 20px; padding: 12px 22px; display: flex; flex-direction: column; min-width: 130px; }
.lc-stats b { font-size: 30px; }
.lc-stats span { font-size: 16px; color: var(--ink-soft); font-weight: 700; }
.level-card .btn { margin-top: 14px; }

/* ---------- juego ---------- */
.play { display: flex; flex-direction: column; height: 100vh; height: 100dvh; padding-bottom: calc(env(safe-area-inset-bottom) + 20px); }
.play-top { display: flex; align-items: center; gap: 18px; }
.play-progress { flex: 1; }
.segments { display: flex; gap: 8px; }
.seg { flex: 1; height: 22px; border-radius: 12px; background: rgba(255, 255, 255, 0.85); box-shadow: inset 0 2px 4px rgba(43, 33, 80, 0.08); transition: background 0.3s; }
.seg.now { background: var(--cs); box-shadow: 0 0 0 3px var(--c); }
.seg.ok { background: var(--green); }
.seg.bad { background: #FFB3B3; }
.seg.retry { flex: 0.6; }
.bar, .timer { height: 26px; border-radius: 14px; background: rgba(255, 255, 255, 0.85); overflow: hidden; position: relative; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--pink), var(--purple)); border-radius: 14px; transition: width 0.4s; }
.timer-fill { height: 100%; background: linear-gradient(90deg, var(--red), var(--yellow), var(--green)); border-radius: 14px; transition: width 0.25s linear; }
.timer span { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 900; font-size: 18px; }
.combo { min-width: 90px; display: flex; justify-content: center; }
.combo-badge { background: #FFF1D6; color: #D9631A; border-radius: 30px; padding: 8px 16px; font-weight: 900; font-size: 26px; animation: pop 0.3s; }
.combo-badge.hot { background: linear-gradient(135deg, #FFB703, #FF5D8F); color: #fff; animation: pop 0.3s, wiggle 0.6s ease-in-out infinite 0.3s; }
@keyframes wiggle { 50% { transform: rotate(-6deg) scale(1.05); } }

.play-main { flex: 1; display: grid; grid-template-columns: 1.15fr 1fr; gap: 34px; align-items: center; min-height: 0; margin-top: 18px; }
.play-left { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.play-mascot { display: flex; align-items: center; gap: 12px; }
.play-mascot .bubble { flex: 1; font-size: 26px; }
.play-mascot .bubble::before { content: ""; position: absolute; left: -16px; top: 50%; margin-top: -12px; border: 12px solid transparent; border-right: 18px solid #fff; border-left: 0; }
.play-label { text-align: center; font-weight: 800; color: var(--ink-soft); font-size: 20px; }
.problem-card {
  background: #fff; border-radius: 40px; padding: 40px 30px 22px; text-align: center; position: relative;
  box-shadow: 0 12px 0 var(--cs), 0 20px 50px rgba(43, 33, 80, 0.14); border: 5px solid transparent; transition: border-color 0.2s, background 0.2s;
  min-height: 330px; display: flex; flex-direction: column; justify-content: center;
}
.problem-card.enter { animation: cardIn 0.4s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes cardIn { from { transform: scale(0.85) translateY(20px); } }
.problem-card.good { border-color: var(--green); background: #F0FFF7; animation: good 0.5s; }
@keyframes good { 40% { transform: scale(1.04); } }
.problem-card.bad { border-color: var(--red); background: #FFF4F4; }
.problem-card.shake { animation: shake 0.5s; }
@keyframes shake { 20%, 60% { transform: translateX(-14px); } 40%, 80% { transform: translateX(14px); } }
.problem { font-weight: 900; color: var(--ink); }
.horizontal { display: flex; align-items: center; justify-content: center; gap: 0.25em; font-size: 120px; line-height: 1; flex-wrap: nowrap; }
.horizontal.md { font-size: 100px; }
.horizontal.sm { font-size: 78px; }
.horizontal i, .vertical i { font-style: normal; color: var(--c); }
.vertical { display: inline-flex; flex-direction: column; align-items: flex-end; font-size: 96px; line-height: 1.05; margin: 0 auto; font-variant-numeric: tabular-nums; }
.vertical span i { margin-right: 0.35em; }
.vertical hr { width: 100%; border: 0; border-top: 8px solid var(--ink); border-radius: 4px; margin: 10px 0 14px; }
.answer-box {
  min-width: 1.4em; padding: 0 0.15em; border-radius: 0.2em; background: var(--cs); color: var(--cd); display: inline-block; text-align: center;
  border-bottom: 0.07em solid var(--c); font-variant-numeric: tabular-nums;
}
.answer-box.filled { background: #FFF7D6; color: var(--ink); border-color: var(--yellow); }
.answer-box.q { color: var(--c); }
.problem-card.good .answer-box { background: #C9F5DD; color: var(--green-d); border-color: var(--green); }
.problem-card.bad .answer-box s { color: var(--red); text-decoration-thickness: 0.08em; }
.countdown { font-size: 200px; font-weight: 900; color: var(--c); animation: pop 0.4s; }
.play-tools { display: flex; justify-content: center; gap: 14px; margin-top: 22px; }
.tool { background: var(--cs); color: var(--cd); border-radius: 20px; padding: 10px 22px; font-size: 22px; font-weight: 800; }
.tool:active { transform: scale(0.95); }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; max-width: 470px; margin: 0 auto; width: 100%; }
.key {
  aspect-ratio: 1.15; border-radius: 30px; background: #fff; font-size: 56px; font-weight: 900; color: var(--ink);
  box-shadow: 0 8px 0 #E0D7F7, 0 12px 22px rgba(43, 33, 80, 0.1); transition: transform 0.06s, box-shadow 0.06s;
}
.key.down, .key:active { transform: translateY(6px); box-shadow: 0 2px 0 #E0D7F7; background: #FAF7FF; }
.key-del { background: #FFE9EF; color: var(--pink-d); box-shadow: 0 8px 0 #FFC7D6; font-size: 44px; }
.key-ok { background: var(--green); color: #fff; box-shadow: 0 8px 0 var(--green-d); font-size: 52px; }
.key-ok.down, .key-ok:active { background: var(--green); box-shadow: 0 2px 0 var(--green-d); }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; max-width: 520px; margin: 0 auto; width: 100%; }
.choice {
  aspect-ratio: 1.1; border-radius: 50%; font-size: 64px; font-weight: 900; color: #fff; animation: bubbleIn 0.45s cubic-bezier(.3, 1.6, .5, 1) backwards, floaty2 4s ease-in-out infinite;
  animation-delay: var(--d), calc(var(--d) * 3); transition: transform 0.15s, opacity 0.3s; position: relative;
}
.choice::after { content: ""; position: absolute; top: 14%; left: 22%; width: 22%; height: 14%; border-radius: 50%; background: rgba(255, 255, 255, 0.55); transform: rotate(-30deg); }
.c0 { background: radial-gradient(circle at 35% 30%, #FF9AB8, #FF5D8F 60%, #E0346C); box-shadow: 0 8px 0 #C02759; }
.c1 { background: radial-gradient(circle at 35% 30%, #A8E9FF, #3B9EFF 60%, #1F7AD6); box-shadow: 0 8px 0 #1A63AE; }
.c2 { background: radial-gradient(circle at 35% 30%, #FFE08A, #FFB703 60%, #E09200); box-shadow: 0 8px 0 #B97900; }
.c3 { background: radial-gradient(circle at 35% 30%, #9FF0C5, #2EC27E 60%, #1E9A60); box-shadow: 0 8px 0 #177A4C; }
.choice:active { transform: scale(0.92); }
.choice.right { transform: scale(1.15); animation: none; box-shadow: 0 0 0 10px #fff, 0 0 0 16px var(--green); }
.choice.wrong { animation: shake 0.5s; opacity: 0.5; filter: grayscale(0.7); }
.choice.fade { opacity: 0.25; transform: scale(0.85); animation: none; }
@keyframes bubbleIn { from { transform: scale(0); } }
@keyframes floaty2 { 50% { transform: translateY(-8px); } }

/* temas por mundo */
.theme-add { --c: #FF8A3D; --cd: #D9631A; --cs: #FFE3CC; }
.theme-sub { --c: #2EC27E; --cd: #1E9A60; --cs: #D3F5E3; }
.theme-mul { --c: #8B5CF6; --cd: #6A3FD6; --cs: #E9E0FF; }
.theme-div { --c: #3B9EFF; --cd: #1F7AD6; --cs: #D9ECFF; }
.theme-magic { --c: #FF5D8F; --cd: #E0346C; --cs: #FFE1EC; }

/* ---------- explicaciones ---------- */
.modal-explain { max-width: 860px; }
.explain { text-align: center; }
.explain-head { display: flex; align-items: center; justify-content: center; gap: 14px; }
.explain-q { font-size: 64px; font-weight: 900; margin: 10px 0 14px; }
.explain-q .ans { color: var(--green-d); background: #D3F5E3; padding: 0 14px; border-radius: 16px; }
.explain-visual { display: flex; justify-content: center; margin: 10px 0 16px; }
.explain-steps { text-align: left; font-size: 24px; line-height: 1.45; background: #F7F4FF; border-radius: 24px; padding: 18px 26px 18px 50px; margin: 0 0 22px; }
.explain-steps li { margin: 4px 0; }
.hint-text { font-size: 24px; font-weight: 700; background: #FFF7D6; border-radius: 22px; padding: 16px 22px; margin: 0 0 20px; }
.frames { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.frame { display: grid; grid-template-columns: repeat(5, 54px); grid-template-rows: repeat(2, 54px); border: 4px solid var(--ink); border-radius: 12px; overflow: hidden; background: #fff; }
.cell { border: 2px solid #D9D0F5; display: grid; place-items: center; }
.dot { display: block; width: 70%; aspect-ratio: 1; border-radius: 50%; animation: dotIn 0.3s backwards; animation-delay: var(--d, 0ms); }
.dot-a { background: radial-gradient(circle at 35% 30%, #C7A8FF, #8B5CF6); }
.dot-b { background: radial-gradient(circle at 35% 30%, #FFB3CB, #FF5D8F); }
.dot-x { background: #E4E0EE; position: relative; }
.dot-x::after { content: "✕"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--red); font-weight: 900; font-size: 30px; }
@keyframes dotIn { from { transform: scale(0); } }
.array { display: flex; flex-direction: column; gap: 6px; }
.array-row { display: flex; align-items: center; gap: 14px; animation: dotIn 0.35s backwards; animation-delay: var(--d); }
.array-dots { display: flex; gap: 6px; background: #F3EEFF; padding: 4px 8px; border-radius: 30px; }
.array-dots .dot { width: var(--s); height: var(--s); animation: none; }
.array-count { font-size: 22px; color: var(--purple-d); min-width: 44px; text-align: left; }
.groups { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; max-width: 720px; }
.group { display: flex; flex-wrap: wrap; gap: 6px; width: 120px; padding: 12px; border: 4px dashed var(--blue); border-radius: 50%; aspect-ratio: 1; align-content: center; justify-content: center; animation: dotIn 0.35s backwards; animation-delay: var(--d); }
.group .dot { width: 20px; height: 20px; animation: none; }
.column { display: grid; grid-template-columns: repeat(var(--cols), 74px); font-size: 64px; font-weight: 900; line-height: 1.1; font-variant-numeric: tabular-nums; }
.col-cell { text-align: center; min-height: 0.6em; }
.col-mark { font-size: 28px; color: var(--pink-d); align-self: end; }
.col-op { color: var(--purple); }
.col-line { border-top: 7px solid var(--ink); border-radius: 4px; margin: 6px 0; }
.col-res { color: var(--green-d); }
.split { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center; }
.split-part { background: #F3EEFF; border-radius: 22px; padding: 16px 20px; display: flex; flex-direction: column; font-size: 34px; }
.split-part span { font-size: 28px; color: var(--purple-d); font-weight: 800; }
.split-part.total { background: #D3F5E3; color: var(--green-d); font-size: 48px; }
.split-plus { font-size: 44px; font-weight: 900; }
.skip { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.skip span { background: #D9ECFF; color: #1F7AD6; font-weight: 900; font-size: 30px; border-radius: 18px; padding: 8px 16px; }

/* ---------- resultados ---------- */
.result { display: grid; place-items: center; }
.result-card { background: rgba(255, 255, 255, 0.85); border-radius: 44px; padding: 34px 50px 40px; text-align: center; max-width: 820px; width: 100%; box-shadow: 0 24px 70px rgba(43, 33, 80, 0.18); }
.result-mascot .mascot { margin: 0 auto; }
.result-card h1 { font-size: 56px; color: var(--cd); }
.result-sub { font-size: 24px; color: var(--ink-soft); }
.big-stars { display: flex; justify-content: center; gap: 18px; margin: 10px 0 18px; }
.bs { font-size: 110px; color: #E4DEF2; line-height: 1; transition: transform 0.4s cubic-bezier(.3, 1.8, .5, 1); transform: scale(0.8); }
.bs[data-i="1"] { transform: translateY(-20px) scale(0.8); }
.bs.on { color: var(--yellow); text-shadow: 0 6px 0 var(--yellow-d), 0 0 30px rgba(255, 201, 60, 0.6); transform: scale(1.1) rotate(-6deg); }
.bs.on[data-i="1"] { transform: translateY(-20px) scale(1.25); }
.result-stats { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; margin: 10px 0 16px; }
.result-stats div { background: var(--cs); border-radius: 22px; padding: 12px 20px; display: flex; flex-direction: column; min-width: 150px; }
.result-stats b { font-size: 36px; }
.result-stats span { font-size: 16px; font-weight: 700; color: var(--ink-soft); }
.unlock-banner { background: #D3F5E3; color: var(--green-d); border-radius: 20px; padding: 14px 20px; font-size: 24px; margin: 10px 0; animation: pop 0.5s 1.6s backwards; }
.unlock-banner.crown { background: #FFF4CC; color: #A86F00; }
.result-tip { color: var(--ink-soft); font-size: 20px; }
.speed-score { font-size: 160px; font-weight: 900; color: var(--c); line-height: 1; animation: pop 0.6s; }
.place-list { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 18px 0 26px; text-align: left; }
.place-row { display: flex; align-items: center; gap: 14px; background: #fff; border-radius: 22px; padding: 14px 18px; border-left: 10px solid var(--c); }
.place-row span { font-size: 46px; }
.place-row small { display: block; color: var(--ink-soft); font-size: 18px; font-weight: 700; }

/* ---------- tablas ---------- */
.tables-wrap { display: grid; grid-template-columns: auto 1fr; gap: 30px; align-items: start; }
.tgrid { display: grid; grid-template-columns: repeat(11, 68px); grid-auto-rows: 68px; gap: 6px; background: #fff; padding: 16px; border-radius: 32px; box-shadow: 0 12px 34px rgba(43, 33, 80, 0.12); }
.th { display: grid; place-items: center; font-weight: 900; font-size: 28px; color: var(--purple-d); border-radius: 16px; background: #F3EEFF; }
.th.corner { background: var(--purple); color: #fff; }
.row-h { background: var(--purple); color: #fff; box-shadow: 0 4px 0 var(--purple-d); }
.tc { border-radius: 16px; font-weight: 800; font-size: 24px; display: grid; place-items: center; animation: dotIn 0.3s backwards; animation-delay: var(--d); }
.tc.unseen { background: #F6F4FA; color: #B3ADC8; }
.tc.weak { background: #FFD6D6; color: #C43C3C; }
.tc.learning { background: #FFF0B8; color: #A86F00; }
.tc.mastered { background: #C9F5DD; color: var(--green-d); }
.tc:active { transform: scale(0.9); }
.tables-side { display: flex; flex-direction: column; gap: 18px; }
.legend { background: #fff; border-radius: 26px; padding: 16px 20px; display: grid; gap: 10px; font-size: 20px; font-weight: 700; }
.legend div { display: flex; align-items: center; gap: 12px; }
.legend i { width: 34px; height: 34px; animation: none; }
.legend b { margin-left: auto; }
.table-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 12px; }

/* ---------- stickers ---------- */
.pack-row { display: flex; align-items: center; gap: 30px; background: #fff; border-radius: 36px; padding: 24px 34px; box-shadow: 0 12px 34px rgba(43, 33, 80, 0.1); margin-bottom: 26px; }
.pack-row h2 { font-size: 34px; }
.pack { width: 150px; height: 150px; border-radius: 34px; background: linear-gradient(135deg, #FF9AB8, #A66BFF); display: grid; place-items: center; font-size: 90px; box-shadow: 0 9px 0 #7B4CE0; animation: wiggle 1.8s ease-in-out infinite; cursor: pointer; }
.pack.poor { filter: grayscale(0.6); animation: none; }
.legend-txt { color: #D98E00; }
.album { display: grid; grid-template-columns: repeat(6, 1fr); gap: 18px; }
.sticker { background: #fff; border-radius: 28px; aspect-ratio: 0.9; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; position: relative; box-shadow: 0 6px 0 #E6DEFF; border: 5px solid transparent; }
.sticker.have { border-color: var(--rc); }
.sticker.have.r-legend { background: linear-gradient(135deg, #FFF7D6, #FFE08A); box-shadow: 0 6px 0 #E9A400, 0 0 26px rgba(255, 201, 60, 0.6); }
.sticker.have.r-rare { background: linear-gradient(135deg, #fff, #F1E6FF); }
.sticker.missing { background: rgba(255, 255, 255, 0.55); border: 4px dashed #D9D0F5; box-shadow: none; }
.sticker-emoji { font-size: 68px; line-height: 1; }
.sticker.missing .sticker-emoji { font-size: 50px; color: #CFC8E0; font-weight: 900; }
.sticker-name { font-size: 16px; font-weight: 800; color: var(--ink-soft); }
.sticker-n { position: absolute; top: 8px; right: 10px; background: var(--pink); color: #fff; font-weight: 900; border-radius: 12px; padding: 2px 8px; font-size: 15px; }
.modal-pack { background: transparent; box-shadow: none; overflow: visible; }
.pack-open { display: grid; place-items: center; min-height: 480px; }
.pack-big { font-size: 220px; }
.pack-big.shaking { animation: shakePack 1.3s ease-in; }
@keyframes shakePack { 0% { transform: scale(0.6); } 20% { transform: scale(1) rotate(0); } 30%, 50%, 70%, 90% { transform: rotate(-12deg) scale(1.05); } 40%, 60%, 80% { transform: rotate(12deg) scale(1.1); } 100% { transform: scale(1.6); opacity: 0; } }
.reveal { background: #fff; border-radius: 40px; padding: 40px 60px; text-align: center; position: relative; overflow: hidden; border: 8px solid var(--rc); animation: pop 0.5s; }
.reveal .rays { position: absolute; inset: -50%; background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--rc) 25%, transparent) 0 10deg, transparent 10deg 20deg); animation: spin 8s linear infinite; z-index: 0; }
.reveal > *:not(.rays) { position: relative; }
@keyframes spin { to { transform: rotate(360deg); } }
.reveal-emoji { font-size: 180px; line-height: 1.1; animation: jump 0.7s ease-in-out 2; }
.reveal h2 { font-size: 44px; }
.rarity { font-weight: 900; font-size: 24px; color: var(--ink-soft); margin-bottom: 18px; }

/* ---------- avances ---------- */
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 20px; }
.stat { background: #fff; border-radius: 28px; padding: 20px; text-align: center; box-shadow: 0 8px 24px rgba(43, 33, 80, 0.08); }
.stat b { font-size: 46px; display: block; color: var(--purple-d); }
.stat span { font-size: 17px; color: var(--ink-soft); font-weight: 700; }
.panel { background: #fff; border-radius: 32px; padding: 24px 30px; margin-bottom: 20px; box-shadow: 0 8px 24px rgba(43, 33, 80, 0.08); }
.panel h2 { font-size: 28px; margin-bottom: 12px; }
.panel h3 { font-size: 22px; margin: 16px 0 8px; }
.chart { width: 100%; height: auto; }
.ch-v { font-size: 16px; font-weight: 800; fill: var(--ink); font-family: var(--font); }
.ch-l { font-size: 16px; font-weight: 700; fill: var(--ink-soft); font-family: var(--font); }
.sw { display: inline-block; width: 16px; height: 16px; border-radius: 4px; vertical-align: middle; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.badge { background: #F6F4FA; border-radius: 24px; padding: 14px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 2px; filter: grayscale(1); opacity: 0.55; }
.badge.on { background: linear-gradient(135deg, #FFF7D6, #FFE1EC); filter: none; opacity: 1; box-shadow: 0 5px 0 #FFD58A; }
.badge span { font-size: 50px; }
.badge b { font-size: 18px; }
.badge small { font-size: 14px; color: var(--ink-soft); font-weight: 600; }
.skill-rows { display: grid; gap: 10px; }
.skill-row { display: grid; grid-template-columns: 1.4fr 2fr 70px 100px 130px; align-items: center; gap: 14px; font-size: 20px; font-weight: 700; }
.skill-row.dim { opacity: 0.4; }
.sr-bar { height: 18px; background: var(--cs); border-radius: 10px; overflow: hidden; }
.sr-bar i { display: block; height: 100%; background: var(--c); border-radius: 10px; }
.sr-pct { text-align: right; }
.sr-speed { color: var(--ink-soft); font-size: 18px; }
.sr-stars { font-size: 22px; }

/* ---------- adultos ---------- */
.parents .panel { font-size: 20px; }
.plain { padding-left: 4px; list-style: none; margin: 0; display: grid; gap: 6px; }
.chips { display: flex; gap: 10px; flex-wrap: wrap; }
.chip { background: #FFE9EF; color: var(--pink-d); border-radius: 16px; padding: 8px 14px; font-weight: 800; }
.chip small { color: var(--ink-soft); }
.set { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-bottom: 2px solid var(--line); font-weight: 700; }
.set:last-child { border-bottom: 0; }
.set input[type="checkbox"] { width: 34px; height: 34px; accent-color: var(--purple); }
.set select, .set input:not([type]) { font-size: 22px; padding: 8px 14px; border-radius: 14px; border: 3px solid var(--line); color: var(--ink); -webkit-user-select: text; user-select: text; }

.speed-picks { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; margin-top: 18px; }
.speed-pick { background: linear-gradient(180deg, var(--c), var(--cd)); color: #fff; border-radius: 28px; padding: 20px; display: flex; flex-direction: column; align-items: center; box-shadow: 0 7px 0 rgba(0, 0, 0, 0.2); }
.speed-pick span { font-size: 60px; }
.speed-pick b { font-size: 28px; }
.speed-pick small { font-size: 18px; font-weight: 800; }
.speed-pick:active { transform: translateY(5px); }

.levelup-badge { width: 130px; height: 130px; margin: -30px auto 10px; border-radius: 50%; background: linear-gradient(135deg, var(--yellow), var(--pink)); color: #fff; font-size: 70px; font-weight: 900; display: grid; place-items: center; box-shadow: 0 8px 0 #C02759; animation: pop 0.6s; }

/* ---------- vertical (iPad parado) ---------- */
@media (orientation: portrait) {
  .worlds { grid-template-columns: repeat(2, 1fr); }
  .world-card { min-height: 250px; }
  .hero-mascot .mascot { width: 170px; height: 170px; }
  .play-main { grid-template-columns: 1fr; grid-template-rows: auto 1fr; gap: 26px; align-items: start; }
  .play-right { align-self: start; }
  .problem-card { min-height: 300px; }
  .keypad { max-width: 560px; gap: 18px; }
  .key { aspect-ratio: 1.6; }
  .choices { max-width: 640px; gap: 22px; }
  .choice { aspect-ratio: 1.6; border-radius: 120px; }
  .tables-wrap { grid-template-columns: 1fr; justify-items: center; }
  .tgrid { grid-template-columns: repeat(11, 76px); grid-auto-rows: 76px; }
  .tables-side { width: 100%; }
  .table-btns { grid-template-columns: repeat(4, 1fr); }
  .album { grid-template-columns: repeat(5, 1fr); }
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .skill-row { grid-template-columns: 1.5fr 1.6fr 60px 90px 120px; font-size: 18px; }
}

/* pantallas más chicas (iPad común / mini) */
@media (max-width: 1100px) and (orientation: landscape) {
  .horizontal { font-size: 96px; }
  .tgrid { grid-template-columns: repeat(11, 56px); grid-auto-rows: 56px; }
  .tc { font-size: 20px; }
}
@media (max-width: 900px) {
  .screen { padding-left: 16px; padding-right: 16px; }
  .worlds, .tiles { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .tgrid { grid-template-columns: repeat(11, minmax(0, 1fr)); grid-auto-rows: auto; width: 100%; }
  .tgrid > * { aspect-ratio: 1; font-size: 16px; }
  .album { grid-template-columns: repeat(3, 1fr); }
  .top-pills .pill-goal span { display: none; }
  .hero { flex-direction: column; }
  .skill-row { grid-template-columns: 1fr 1fr 60px; }
  .sr-speed, .sr-stars { display: none; }
  .horizontal { font-size: 72px; } .horizontal.md { font-size: 60px; } .horizontal.sm { font-size: 48px; }
  .vertical { font-size: 64px; }
}

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

/* ---------- ajustes para iPad Pro 12.9 ---------- */
.world .topbar, .tables .topbar, .stickers .topbar, .progress .topbar, .parents .topbar {
  position: sticky; top: 0; z-index: 5; margin: calc(-1 * env(safe-area-inset-top) - 20px) -32px 18px; padding: calc(env(safe-area-inset-top) + 16px) 32px 14px;
  background: rgba(247, 242, 255, 0.82); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.node-mascot { top: 14px; }
@media (min-height: 950px) {
  .home { display: flex; flex-direction: column; }
  .home .hero { margin: 24px 0 40px; }
  .home .world-card { min-height: 320px; }
  .home .world-emoji { font-size: 110px; }
  .home .tiles { margin-top: 36px; }
  .home .tile { padding: 30px 10px; }
  .play .problem-card { min-height: 420px; }
  .play .keypad { max-width: 540px; gap: 20px; }
  .play .key { font-size: 64px; }
  .play .horizontal { font-size: 140px; }
  .play .horizontal.md { font-size: 116px; }
  .play .horizontal.sm { font-size: 90px; }
  .play .vertical { font-size: 112px; }
}
@media (min-height: 950px) and (orientation: landscape) {
  .play .choices { max-width: 580px; }
}
.explain-you { font-size: 22px; font-weight: 800; color: var(--red); margin: 0; }
.chart { max-height: 260px; }
.horizontal { width: max-content; max-width: none; margin: 0 auto; }
.voice-pick { display: flex; gap: 10px; align-items: center; }
.voice-pick select { max-width: 360px; }
.btn-sm { font-size: 18px; padding: 8px 16px; border-radius: 14px; box-shadow: 0 4px 0 #D9D0F5; }

/* ---------- Apple Pencil ---------- */
.ink { display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 560px; margin: 0 auto; }
.ink-pad {
  position: relative; height: 380px; border-radius: 34px; background: #fff;
  background-image: linear-gradient(transparent 62%, var(--cs) 62%, var(--cs) calc(62% + 4px), transparent calc(62% + 4px));
  box-shadow: 0 10px 0 #E0D7F7, 0 16px 30px rgba(43, 33, 80, 0.12); border: 5px dashed var(--c); overflow: hidden;
}
.ink-pad canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.ink-hint { position: absolute; inset: 0; display: grid; place-items: center; font-size: 30px; font-weight: 800; color: var(--c); opacity: 0.55; pointer-events: none; transition: opacity 0.2s; }
.ink-pad.used .ink-hint { opacity: 0; }
.ink-pad.shake { animation: shake 0.5s; }
.ink-btns { display: grid; grid-template-columns: 1fr 2fr; gap: 16px; }
.ink-btns .key { aspect-ratio: auto; height: 110px; }
@media (orientation: portrait) { .ink-pad { height: 360px; } .ink { max-width: 760px; } }

/* ---------- tienda y cofre ---------- */
.hero-mascot { position: relative; padding: 0; }
.hero-mascot:active { transform: scale(0.96); }
.numi-tag { position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%); background: #fff; border-radius: 14px; padding: 4px 12px; font-size: 16px; font-weight: 800; white-space: nowrap; box-shadow: 0 4px 10px rgba(43, 33, 80, 0.12); }
.hero-btns { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.chest { display: flex; flex-direction: column; align-items: center; background: linear-gradient(180deg, #FFE08A, #FFB703); border-radius: 28px; padding: 12px 22px; box-shadow: 0 8px 0 #D98E00, 0 14px 26px rgba(217, 142, 0, 0.35); animation: wiggle 1.4s ease-in-out infinite; }
.chest span { font-size: 54px; line-height: 1; }
.chest b { font-size: 18px; color: #7A4B00; }
.mascot .m-held { animation: bob 2s ease-in-out infinite; }
.tiles { grid-template-columns: repeat(5, 1fr); }
.tile { font-size: 22px; }
.shop-wrap { display: grid; grid-template-columns: 380px 1fr; gap: 30px; align-items: start; }
.shop-numi { position: sticky; top: 120px; background: rgba(255, 255, 255, 0.7); border-radius: 40px; padding: 30px; text-align: center; }
.shop-numi .mascot { margin: 0 auto; }
.shop-items h3 { font-size: 26px; margin: 10px 0 12px; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-bottom: 14px; }
.shop-item { background: #fff; border-radius: 26px; padding: 14px 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; box-shadow: 0 6px 0 #E6DEFF; border: 4px solid transparent; }
.shop-item span { font-size: 56px; }
.shop-item b { font-size: 18px; }
.shop-item small { font-size: 17px; font-weight: 800; color: #D98E00; }
.shop-item.own small { color: var(--purple-d); }
.shop-item.worn { border-color: var(--green); background: #F0FFF7; }
.shop-item.worn small { color: var(--green-d); }
.shop-item:active { transform: scale(0.95); }
@media (orientation: portrait) {
  .shop-wrap { grid-template-columns: 1fr; }
  .shop-numi { position: static; display: flex; align-items: center; gap: 20px; text-align: left; padding: 16px 24px; }
  .shop-numi .mascot { width: 180px; height: 180px; margin: 0; }
  .tiles { grid-template-columns: repeat(5, 1fr); gap: 14px; }
  .tile { font-size: 19px; padding: 16px 6px; }
  .tile span { font-size: 46px; }
}

/* ---------- globos ---------- */
.balloons { display: flex; flex-direction: column; height: 100vh; height: 100dvh; padding-bottom: 0; }
.bl-question { flex: 1; text-align: center; font-size: 64px; font-weight: 900; background: #fff; border-radius: 30px; padding: 6px 20px; box-shadow: 0 8px 0 #E0D7F7; }
.bl-question span { color: var(--pink); }
.bl-sky { position: relative; flex: 1; overflow: hidden; margin: 16px -32px 0; }
.bl-score { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); font-size: 120px; font-weight: 900; color: rgba(139, 92, 246, 0.15); }
.balloon { position: absolute; top: 0; width: 170px; height: 205px; border-radius: 50% 50% 48% 48% / 55% 55% 45% 45%;
  background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.7) 0 9%, transparent 10%), radial-gradient(circle at 40% 35%, color-mix(in srgb, var(--bc) 70%, #fff), var(--bc) 60%, color-mix(in srgb, var(--bc) 80%, #000));
  color: #fff; font-size: 64px; font-weight: 900; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.2); will-change: transform; display: grid; place-items: center; }
.balloon i { position: absolute; bottom: -60px; left: 50%; width: 2px; height: 60px; background: rgba(43, 33, 80, 0.35); }
.balloon::after { content: ""; position: absolute; bottom: -10px; left: 50%; transform: translateX(-50%); border: 10px solid transparent; border-bottom: 14px solid var(--bc); }
.balloon.popped { animation: popB 0.35s forwards; }
.balloon.bad { filter: grayscale(1); }
@keyframes popB { 50% { scale: 1.3; opacity: 0.8; } 100% { scale: 1.6; opacity: 0; } }
.bl-end { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.bl-end h1 { font-size: 56px; color: var(--purple-d); }
.bl-end .mascot { margin: 0 auto; }

/* ---------- misiones ---------- */
.missions { background: rgba(255, 255, 255, 0.85); border-radius: 26px; padding: 12px 18px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: 100%; box-shadow: 0 6px 18px rgba(43, 33, 80, 0.08); position: relative; padding-top: 30px; }
.missions-title { position: absolute; top: 6px; left: 18px; font-size: 15px; color: var(--ink-soft); }
.mission { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.mission > span { font-size: 32px; }
.mission > div { flex: 1; min-width: 0; }
.mission b { display: block; font-size: 15px; line-height: 1.2; }
.mission small { font-weight: 800; color: var(--purple-d); }
.mbar { display: block; height: 8px; border-radius: 6px; background: var(--line); margin-top: 4px; overflow: hidden; }
.mbar i { display: block; height: 100%; background: var(--green); border-radius: 6px; }
.mission.done { opacity: 0.75; }
.hero-right { min-width: 0; }
@media (orientation: landscape) {
  .home .world-card { min-height: 250px; }
  .home .world-emoji { font-size: 96px; }
  .home .hero { margin: 4px 0 20px; }
  .home .tiles { margin-top: 20px; }
  .home .tile { padding: 16px 10px; }
}
@media (orientation: landscape) {
  .home { padding-bottom: calc(env(safe-area-inset-bottom) + 10px); }
  .home .world-card { min-height: 220px; }
}

/* ---------- jefes ---------- */
.boss { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-left: auto; }
.boss-emoji { font-size: 96px; line-height: 1; display: inline-block; animation: bob 1.8s ease-in-out infinite; }
.boss-emoji.hit { animation: bossHit 0.5s; }
.boss-emoji.laugh { animation: wiggle 0.3s 3; }
@keyframes bossHit { 20% { transform: translateX(-16px) rotate(-12deg) scale(0.9); filter: brightness(2); } 60% { transform: translateX(10px) rotate(8deg); } }
.boss-hp { width: 180px; height: 18px; border-radius: 10px; background: #FFD6D6; overflow: hidden; box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1); }
.boss-hp i { display: block; height: 100%; background: linear-gradient(90deg, #FF5D5D, #FF9A3D); border-radius: 10px; transition: width 0.4s; }
.boss b { font-size: 16px; color: var(--ink-soft); }
.play-mascot .boss { order: 2; }
.boss-node { width: 140px; height: 140px; font-size: 76px; background: linear-gradient(180deg, #4B3B8F, #2B2150) !important; }
.boss-node.locked { background: #E4E0EE !important; font-size: 40px; }
.boss-big { font-size: 150px; line-height: 1.1; animation: bob 1.8s ease-in-out infinite; }
.boss-big.defeated { filter: grayscale(0.6); transform: rotate(-20deg); animation: none; opacity: 0.7; }

/* ---------- enseñar la letra ---------- */
.teach-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; align-items: center; margin-top: 20px; }
.teach-left { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.teach-digit { font-size: 220px; font-weight: 900; color: var(--purple); line-height: 1; animation: pop 0.4s; }
.teach-dots { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.teach-dots i { width: 16px; height: 16px; border-radius: 50%; background: var(--line); }
.teach-dots i.on { background: var(--green); }
.teach-dots i.now { background: var(--purple); transform: scale(1.3); }
@media (orientation: portrait) { .teach-wrap { grid-template-columns: 1fr; } .teach-digit { font-size: 160px; } }

/* ---------- problemas con historia ---------- */
.story { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.story-text { font-size: 30px; font-weight: 800; line-height: 1.3; margin: 0; max-width: 620px; }
.story-pic { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center; font-size: 30px; max-width: 640px; }
.st-row { letter-spacing: 2px; word-break: break-all; }
.st-row s { opacity: 0.3; text-decoration: none; filter: grayscale(1); }
.st-box { background: var(--cs); border: 3px dashed var(--c); border-radius: 16px; padding: 4px 8px; }
.story-pic b { font-size: 34px; color: var(--c); }
.story-ans .answer-box { font-size: 72px; }
.story-pic { font-size: 40px; }
.st-box { padding: 6px 10px; }
.play-mascot .js-mascot { cursor: pointer; }

/* ---------- Scribble (escritura de Apple) ---------- */
.scribble-wrap { position: relative; height: 380px; border-radius: 34px; background: #fff; border: 5px dashed var(--c); box-shadow: 0 10px 0 #E0D7F7, 0 16px 30px rgba(43, 33, 80, 0.12); overflow: hidden; }
.scribble { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; outline: none; background: transparent; text-align: center;
  font-size: 160px; font-weight: 900; color: var(--ink); font-family: var(--font); -webkit-user-select: text; user-select: text; caret-color: var(--c); padding: 0 20px; }
.scribble-wrap .ink-hint { z-index: 1; }
.scribble-wrap.used .ink-hint { opacity: 0; }
.scribble-wrap.shake { animation: shake 0.5s; }
@media (orientation: portrait) { .scribble-wrap { height: 360px; } }

/* ---------- cuenta en columna con cajitas para lo que se lleva ---------- */
.vgrid { display: inline-grid; grid-template-columns: 0.75em repeat(var(--n), 0.72em); font-size: 104px; line-height: 1.05; font-weight: 900; margin: 0 auto; font-variant-numeric: tabular-nums; justify-items: center; align-items: end; }
.vgrid .vc-op i { font-style: normal; color: var(--c); }
.vc-carry { width: 0.46em; height: 0.46em; margin-bottom: 0.08em; border: 0.035em dashed var(--c); border-radius: 0.1em; background: color-mix(in srgb, var(--cs) 60%, transparent); }
.vc-line { grid-column: 1 / -1; width: 100%; border: 0; border-top: 0.075em solid var(--ink); border-radius: 4px; margin: 0.08em 0 0.12em; }
.vc-ans { grid-column: 1 / -1; justify-self: end; }
.vc-ans .answer-box { min-width: 1.6em; }
@media (min-height: 950px) { .play .vgrid { font-size: 112px; } }
@media (max-width: 900px) { .vgrid { font-size: 68px; } }

/* ---------- notas sobre la cuenta ---------- */
.problem-card { touch-action: none; }
.notes-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; border-radius: 34px; }
.play-tools { position: relative; z-index: 4; }
.notes-hint { position: absolute; top: 14px; left: 22px; font-size: 16px; font-weight: 800; color: var(--c); opacity: 0.55; pointer-events: none; transition: opacity 0.3s; }
.problem-card.noted .notes-hint { opacity: 0; }
.ldots { display: inline-flex; gap: 6px; vertical-align: middle; margin-left: 6px; }
.ldots i { width: 30px; height: 30px; border-radius: 50%; background: var(--line); display: grid; place-items: center; font-style: normal; font-size: 18px; }
.ldots i.on { background: #FFF1C2; box-shadow: 0 0 0 2px var(--yellow); }
.lc-need { font-weight: 800; }
