@font-face {
  font-family: 'Fredoka';
  src: url('../fonts/fredoka-latin.woff2') format('woff2');
  font-weight: 300 700;
  font-display: swap;
}

:root {
  --ink: #2b2d42;
  --muted: #6b6f8a;
  --line: #e4e6f2;
  --card: #ffffff;
  --good: #1fb77a;
  --good-d: #128a59;
  --bad: #ff5a5f;
  --bad-d: #d93a40;
  --gold: #ffbe0b;
  --c: #8338ec;
  --cd: #5f1fc4;
  --soft: #efe4ff;
  --r: 24px;
  --font: 'Fredoka', ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
html { -webkit-text-size-adjust: 100%; }
* { -webkit-tap-highlight-color: transparent; }
body { touch-action: manipulation; overscroll-behavior: none; }
button, .learn-card, .q-text, .chip, .node-row, .world { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, #aee4ff 0%, #d9f2ff 45%, #fff4d6 100%) fixed;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font-family: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:disabled { cursor: default; }
b { font-weight: 600; }

#app { position: relative; z-index: 1; max-width: 980px; margin: 0 auto; padding: calc(20px + env(safe-area-inset-top)) calc(20px + env(safe-area-inset-right)) calc(60px + env(safe-area-inset-bottom)) calc(20px + env(safe-area-inset-left)); }

/* ---------- Cielo ---------- */
#sky { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.cloud { position: absolute; width: 180px; height: 56px; background: #fff; border-radius: 60px; opacity: .8; animation: drift linear infinite; }
.cloud::before, .cloud::after { content: ''; position: absolute; background: #fff; border-radius: 50%; }
.cloud::before { width: 80px; height: 80px; top: -40px; left: 28px; }
.cloud::after { width: 60px; height: 60px; top: -28px; left: 90px; }
.c1 { top: 8%; animation-duration: 70s; }
.c2 { top: 30%; animation-duration: 95s; animation-delay: -40s; transform: scale(.7); }
.c3 { top: 62%; animation-duration: 120s; animation-delay: -80s; transform: scale(.5); opacity: .6; }
@keyframes drift { from { left: -220px; } to { left: 110vw; } }

/* ---------- Básicos ---------- */
.card { background: var(--card); border-radius: var(--r); box-shadow: 0 8px 0 rgba(43, 45, 66, .08), 0 20px 40px rgba(43, 45, 66, .08); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 18px; font-weight: 600; padding: 12px 22px; border-radius: 18px;
  background: #fff; box-shadow: 0 5px 0 var(--line); border: 2px solid var(--line);
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--line); }
.btn.big { font-size: 21px; padding: 15px 28px; border-radius: 20px; }
.btn.primary { background: var(--c); color: #fff; border-color: var(--c); box-shadow: 0 6px 0 var(--cd); }
.btn.primary:active { box-shadow: 0 2px 0 var(--cd); }
.btn.good { background: var(--good); color: #fff; border-color: var(--good); box-shadow: 0 6px 0 var(--good-d); }
.btn.bad { background: var(--bad); color: #fff; border-color: var(--bad); box-shadow: 0 6px 0 var(--bad-d); }
.btn.danger { color: var(--bad-d); border-color: #ffd0d2; box-shadow: 0 5px 0 #ffd0d2; }
.btn.ghost { color: var(--c); }
.icon-btn {
  width: 44px; height: 44px; border-radius: 14px; font-size: 22px; background: #fff;
  box-shadow: 0 4px 0 var(--line); display: inline-grid; place-items: center; transition: transform .08s;
}
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.icon-btn.on { background: #fff3c4; box-shadow: 0 4px 0 #f5d76e; }
.pill { display: inline-flex; align-items: center; gap: 4px; background: #fff; padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: 17px; box-shadow: 0 4px 0 var(--line); }
.pill.coin { background: #fff6d1; box-shadow: 0 4px 0 #f5d76e; }
.link { color: var(--muted); font-size: 15px; text-decoration: underline; text-underline-offset: 3px; }
.muted { color: var(--muted); }
.hl { color: var(--c); font-weight: 700; background: var(--soft); padding: 0 8px; border-radius: 10px; }
.pop { animation: pop .35s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* ---------- Mascota ---------- */
.pet { position: relative; width: var(--s); height: var(--s); flex: none; display: grid; place-items: center; }
.pet-body { font-size: calc(var(--s) * .82); line-height: 1; }
.pet .acc { position: absolute; line-height: 1; }
.pet .acc.head { font-size: calc(var(--s) * .45); top: calc(var(--s) * -.3); left: 50%; transform: translateX(-50%) rotate(-8deg); }
.pet .acc.face { font-size: calc(var(--s) * .42); top: 30%; left: 50%; transform: translateX(-50%); }
.pet .acc.side { font-size: calc(var(--s) * .4); bottom: -4%; right: -18%; }
.pet.bob .pet-body { animation: bob 2.4s ease-in-out infinite; }
.pet.jump { animation: jump .6s ease; }
.pet.sad { filter: saturate(.7); transform: rotate(-6deg); }
@keyframes bob { 50% { transform: translateY(-6px) rotate(3deg); } }
@keyframes jump { 30% { transform: translateY(-16px) scale(1.08); } 60% { transform: translateY(0) scale(.96); } }

/* ---------- Bienvenida ---------- */
.welcome { max-width: 560px; margin: 6vh auto 0; padding: 36px 32px; text-align: center; }
.welcome .logo { font-size: 64px; }
.welcome h1 { font-size: 42px; margin: 6px 0; color: #8338ec; }
.lead { font-size: 19px; color: var(--muted); margin-top: 0; }
.field { display: block; text-align: left; font-weight: 600; font-size: 18px; margin: 24px 0 8px; }
.field input { display: block; width: 100%; margin-top: 8px; font: inherit; font-size: 22px; padding: 14px 18px; border: 3px solid var(--line); border-radius: 18px; outline: none; }
.field input:focus { border-color: #8338ec; }
.field-label { text-align: left; font-weight: 600; font-size: 18px; margin: 18px 0 8px; }
.pet-pick { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 26px; }
.pet-opt { font-size: 38px; width: 64px; height: 64px; border-radius: 18px; background: #f5f6fb; border: 3px solid transparent; transition: transform .1s; }
@media (hover: hover) { .pet-opt:hover { transform: scale(1.08); } }
.pet-opt.sel { border-color: #8338ec; background: #efe4ff; }
.pet-pick.small .pet-opt { width: 50px; height: 50px; font-size: 30px; }

/* ---------- Inicio ---------- */
.home-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.me { display: flex; align-items: center; gap: 14px; }
.me h1 { margin: 0; font-size: 34px; }
.me p { margin: 2px 0 0; color: var(--muted); font-size: 18px; }
.tb-stats { display: flex; align-items: center; gap: 8px; }
.worlds { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.world {
  position: relative; text-align: left; padding: 22px 20px 20px; border-radius: 28px; color: #fff; overflow: hidden;
  background: radial-gradient(circle at 85% 0%, rgba(255, 255, 255, .35), transparent 50%), var(--c);
  box-shadow: 0 8px 0 var(--cd); display: flex; flex-direction: column; gap: 4px; min-height: 230px;
  transition: transform .12s;
}
@media (hover: hover) { .world:hover { transform: translateY(-4px) rotate(-.5deg); } }
.world:active { transform: translateY(4px); box-shadow: 0 3px 0 var(--cd); }
.w-emoji { font-size: 58px; line-height: 1; margin-bottom: auto; filter: drop-shadow(0 4px 0 rgba(0, 0, 0, .12)); }
.w-name { font-size: 28px; font-weight: 700; margin-top: 14px; }
.w-sub { font-size: 15px; opacity: .9; }
.w-bar { height: 12px; background: rgba(255, 255, 255, .3); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.w-bar i { display: block; height: 100%; background: var(--gold); border-radius: 99px; }
.w-stars { font-size: 15px; font-weight: 600; }
.extras { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 20px; }
.extra { display: flex; align-items: center; gap: 14px; text-align: left; background: #fff; padding: 18px 20px; border-radius: 24px; box-shadow: 0 6px 0 var(--line); transition: transform .1s; }
@media (hover: hover) { .extra:hover { transform: translateY(-3px); } }
.extra b { display: block; font-size: 21px; }
.extra small { color: var(--muted); font-size: 15px; }
.x-emoji { font-size: 40px; }
.extra.review { background: linear-gradient(135deg, #f3e8ff, #fff); box-shadow: 0 6px 0 #dcc6ff; }
.extra.review.empty { opacity: .75; }
.home-foot { text-align: center; margin-top: 30px; }

/* ---------- Barra superior ---------- */
.topbar { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 12px; margin-bottom: 18px; }
.tb-title { font-size: 26px; font-weight: 700; }

/* ---------- Mapa de asignatura ---------- */
.unit-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.unit-tabs button { padding: 8px 16px; border-radius: 14px; background: #fff; font-weight: 600; box-shadow: 0 4px 0 var(--line); }
.unit-tabs button.sel { background: var(--c); color: #fff; box-shadow: 0 4px 0 var(--cd); }
.unit-banner {
  background: var(--c); color: #fff; border-radius: 26px; padding: 18px 24px; box-shadow: 0 7px 0 var(--cd);
  display: grid; grid-template-columns: 1fr auto; align-items: center;
}
.unit-banner small { font-size: 15px; opacity: .9; grid-column: 1; }
.unit-banner h2 { margin: 0; font-size: 28px; grid-column: 1; }
.unit-banner span { grid-column: 2; grid-row: 1 / 3; font-weight: 700; font-size: 20px; background: rgba(255, 255, 255, .2); padding: 8px 14px; border-radius: 16px; }
.path { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 30px 0 20px; }
.node-row { display: flex; flex-direction: column; align-items: center; transform: translateX(var(--dx)); }
.node {
  width: 92px; height: 92px; border-radius: 50%; background: #fff; box-shadow: 0 8px 0 var(--line), inset 0 0 0 6px var(--soft);
  display: grid; place-items: center; transition: transform .12s;
}
@media (hover: hover) { .node:hover { transform: scale(1.07); } }
.node:active { transform: translateY(5px); box-shadow: 0 3px 0 var(--line), inset 0 0 0 6px var(--soft); }
.node.done { background: var(--c); box-shadow: 0 8px 0 var(--cd), inset 0 0 0 6px rgba(255, 255, 255, .25); }
.node.speed { background: #ffe66d; box-shadow: 0 8px 0 #e0b400, inset 0 0 0 6px rgba(255, 255, 255, .4); }
.node.boss { width: 116px; height: 116px; background: #3d3a63; box-shadow: 0 8px 0 #25233f, inset 0 0 0 6px rgba(255, 255, 255, .15); }
.node.boss .n-emoji { font-size: 60px; }
.node.locked { filter: grayscale(.8); opacity: .75; }
.n-emoji { font-size: 44px; line-height: 1; }
.n-label { margin-top: 10px; font-weight: 600; font-size: 17px; background: #fff; padding: 4px 12px; border-radius: 12px; box-shadow: 0 3px 0 var(--line); text-align: center; max-width: 240px; }
.n-stars { font-size: 20px; letter-spacing: 2px; margin-top: 2px; }
.n-stars i { font-style: normal; color: #d6d8e6; }
.n-stars i.on { color: var(--gold); text-shadow: 0 2px 0 #d99a00; }

/* ---------- Aprende ---------- */
.learn { padding: 26px 28px; max-width: 760px; margin: 0 auto; }
.learn-head { display: flex; align-items: center; gap: 14px; }
.learn-head h2 { margin: 0; font-size: 30px; }
.learn-head small { color: var(--c); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.learn-head .listen { margin-left: auto; }
.l-emoji { font-size: 54px; width: 80px; height: 80px; display: grid; place-items: center; background: var(--soft); border-radius: 24px; flex: none; }
.learn-list { list-style: none; padding: 0; margin: 22px 0; display: grid; gap: 12px; }
.learn-list li { background: var(--soft); border-radius: 18px; padding: 14px 18px; font-size: 19px; line-height: 1.45; }
.learn-list .sign { width: 44px; height: 40px; vertical-align: middle; margin-right: 6px; }
.learn-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.bubble-wrap { display: flex; align-items: center; gap: 10px; }
.bubble { background: #fff8dc; border: 2px solid #f5d76e; padding: 10px 14px; border-radius: 16px; font-size: 16px; max-width: 280px; }
.pv-mini { display: inline-grid; grid-template-columns: repeat(3, 38px); text-align: center; border-radius: 10px; overflow: hidden; margin-right: 10px; vertical-align: middle; border: 2px solid var(--c); }
.pv-mini.four { grid-template-columns: repeat(4, 38px); }
.pv-mini span { background: var(--c); color: #fff; font-weight: 600; font-size: 14px; padding: 2px 0; }
.pv-mini b { background: #fff; font-size: 20px; padding: 2px 0; }

/* ---------- Partida ---------- */
.play { max-width: 820px; margin: 0 auto; }
.play-top { display: grid; grid-template-columns: 44px 1fr auto; gap: 14px; align-items: center; margin-bottom: 16px; }
.progress { height: 20px; background: rgba(255, 255, 255, .8); border-radius: 99px; overflow: hidden; box-shadow: inset 0 2px 0 rgba(0, 0, 0, .06); }
.progress .bar { height: 100%; width: 0; background: var(--c); border-radius: 99px; transition: width .4s ease; box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .12), inset 0 4px 0 rgba(255, 255, 255, .35); }
.play-stat { display: flex; gap: 6px; align-items: center; min-width: 60px; justify-content: flex-end; }
.pill.combo { background: #ffe8d6; box-shadow: 0 4px 0 #ffc49b; animation: pop .3s; }
.pill.timer.low { background: #ffe0e0; color: var(--bad-d); animation: pulse 1s infinite; }
.heart { font-size: 26px; transition: transform .3s, filter .3s; }
.heart.lost { filter: grayscale(1); opacity: .35; transform: scale(.8); }
@keyframes pulse { 50% { transform: scale(1.08); } }

.q-card { padding: 26px 28px 28px; min-height: 360px; }
.q-area.enter { animation: slidein .35s ease; }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.q-area.flash-ok { animation: flashok .45s; }
.q-area.flash-bad { animation: shake .4s; }
@keyframes flashok { 50% { transform: scale(1.02); } }
.q-prompt { display: flex; gap: 12px; align-items: flex-start; }
.speak-btn { flex: none; width: 44px; height: 44px; border-radius: 14px; background: var(--soft); font-size: 22px; transition: transform .1s; }
@media (hover: hover) { .speak-btn:hover { transform: scale(1.08); } }
.q-text { font-size: 25px; font-weight: 500; line-height: 1.35; padding-top: 4px; flex: 1; }
.q-text small { display: block; font-size: 17px; color: var(--muted); margin-top: 4px; }
.q-visual { margin: 18px 0 4px; display: flex; justify-content: center; }
.sentence { margin-top: 12px; font-size: 24px; background: var(--soft); padding: 14px 18px; border-radius: 16px; }
.sentence b { color: var(--c); text-decoration: underline wavy; text-underline-offset: 5px; }
.big-num { font-size: 1.25em; font-weight: 700; color: var(--c); }
.big-num.center { display: block; text-align: center; font-size: 46px; margin: 14px 0 0; letter-spacing: .02em; }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 24px; }
.options.n3 { grid-template-columns: 1fr; }
.options.short.n3, .options.big-sym.n3 { grid-template-columns: repeat(3, 1fr); }
.options.short.n2, .options.big-sym.n2, .options.tf { grid-template-columns: 1fr 1fr; }
.opt {
  position: relative; display: flex; align-items: center; gap: 12px; text-align: left;
  font-size: 21px; padding: 16px 18px; min-height: 68px; background: #fff; border: 3px solid var(--line);
  border-radius: 20px; box-shadow: 0 5px 0 var(--line); transition: transform .08s, border-color .15s;
}
@media (hover: hover) { .opt:hover:not(:disabled) { border-color: var(--c); transform: translateY(-2px); } }
.opt:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--line); }
.opt .key { flex: none; width: 28px; height: 28px; border-radius: 9px; border: 2px solid var(--line); font-size: 14px; display: grid; place-items: center; color: var(--muted); }
.opt-t { flex: 1; }
.options.short .opt, .options.big-sym .opt, .options.nums .opt { justify-content: center; text-align: center; }
.options.short .opt-t, .options.nums .opt-t { font-size: 30px; font-weight: 600; }
.options.big-sym .opt-t { font-size: 44px; font-weight: 700; }
.options.short .key, .options.big-sym .key, .options.nums .key { position: absolute; left: 12px; top: 12px; }
.options.tf .opt-t { font-size: 24px; font-weight: 600; text-align: center; }
.options.signs.n3 { grid-template-columns: repeat(3, 1fr); }
.options.signs .opt { justify-content: center; padding: 18px 10px; }
.options.signs .sign { width: 90px; height: 80px; }
.options.signs .opt-t { text-align: center; }
.options.signs .key { position: absolute; left: 12px; top: 12px; }
.fb-answer .sign { width: 54px; height: 48px; vertical-align: middle; }
.opt.right { background: #dcf7ea; border-color: var(--good); box-shadow: 0 5px 0 var(--good); animation: pop .3s; }
.opt.wrong { background: #ffe3e3; border-color: var(--bad); box-shadow: 0 5px 0 var(--bad); animation: shake .4s; }
.opt:disabled:not(.right):not(.wrong) { opacity: .55; }

/* Número con teclado */
.num-display { margin: 22px auto 16px; width: 260px; height: 76px; border: 3px solid var(--line); border-radius: 20px; display: flex; align-items: center; justify-content: center; font-size: 44px; font-weight: 700; background: #fafbff; }
.num-display .caret { width: 3px; height: 44px; background: var(--c); margin-left: 3px; animation: blink 1s steps(1) infinite; }
.num-display.right { border-color: var(--good); background: #dcf7ea; }
.num-display.wrong { border-color: var(--bad); background: #ffe3e3; }
.num-display.right .caret, .num-display.wrong .caret { display: none; }
@keyframes blink { 50% { opacity: 0; } }
.keypad { display: grid; grid-template-columns: repeat(3, 76px); gap: 10px; justify-content: center; }
.keypad button { height: 62px; font-size: 28px; font-weight: 600; background: #fff; border: 3px solid var(--line); border-radius: 18px; box-shadow: 0 4px 0 var(--line); }
.keypad button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.keypad .kp-ok { background: var(--good); border-color: var(--good); color: #fff; box-shadow: 0 4px 0 var(--good-d); }
.keypad .kp-del { color: var(--muted); }

/* Bloques de valor posicional */
.pv-board { display: grid; gap: 10px; margin-top: 20px; }
.pv-board.n3 { grid-template-columns: repeat(3, 1fr); }
.pv-board.n4 { grid-template-columns: repeat(4, 1fr); }
.pv-col { border-radius: 18px; background: #f7f8fd; border: 2px solid var(--line); display: flex; flex-direction: column; overflow: hidden; }
.pv-head { text-align: center; padding: 6px; color: #fff; }
.pv-head b { display: block; font-size: 22px; }
.pv-head small { font-size: 12px; opacity: .95; }
.pv-UM .pv-head { background: #8338ec; }
.pv-C .pv-head { background: #1fb77a; }
.pv-D .pv-head { background: #ff5d8f; }
.pv-U .pv-head { background: #ffae00; }
.pv-pieces { flex: 1; min-height: 150px; padding: 10px; display: flex; flex-wrap: wrap; gap: 5px; align-content: flex-start; justify-content: center; }
.piece { display: block; border-radius: 3px; animation: pop .25s; }
.piece-U { width: 14px; height: 14px; background: #ffbe0b; box-shadow: inset -2px -2px 0 rgba(0, 0, 0, .15); }
.piece-D { width: 14px; height: 56px; background: repeating-linear-gradient(180deg, #ff5d8f 0 4.6px, #d8356b 4.6px 5.6px); }
.piece-C { width: 46px; height: 46px; background: repeating-linear-gradient(90deg, transparent 0 3.6px, rgba(0, 0, 0, .18) 3.6px 4.6px), repeating-linear-gradient(180deg, #1fb77a 0 3.6px, #128a59 3.6px 4.6px); }
.piece-UM { width: 44px; height: 44px; background: #8338ec; box-shadow: 5px -5px 0 #a76bff, 5px 0 0 #5f1fc4; margin: 6px 6px 0 0; background-image: repeating-linear-gradient(90deg, transparent 0 3.4px, rgba(0, 0, 0, .18) 3.4px 4.4px), repeating-linear-gradient(180deg, transparent 0 3.4px, rgba(0, 0, 0, .18) 3.4px 4.4px); }
.pv-ctrl { display: flex; align-items: center; justify-content: space-between; padding: 8px; background: #fff; border-top: 2px solid var(--line); }
.pv-btn { width: 44px; height: 44px; border-radius: 14px; font-size: 26px; font-weight: 700; background: var(--soft); color: var(--c); box-shadow: 0 3px 0 var(--line); }
.pv-btn.plus { background: var(--c); color: #fff; box-shadow: 0 3px 0 var(--cd); }
.pv-btn:active { transform: translateY(2px); }
.pv-n { font-size: 28px; font-weight: 700; }
.pv-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; padding: 12px 16px; border-radius: 18px; background: #f7f8fd; border: 2px solid transparent; }
.pv-foot.right { background: #dcf7ea; border-color: var(--good); }
.pv-foot.wrong { background: #ffe3e3; border-color: var(--bad); }
.pv-total { font-size: 20px; }
.pv-num { font-size: 32px; color: var(--c); }

/* Cuerpo */
.body-wrap { display: flex; justify-content: center; gap: 20px; margin-top: 10px; align-items: center; }
.body-svg { height: min(500px, 62vh); width: auto; }
.body-wrap.name .options { grid-template-columns: 1fr; flex: 1; max-width: 320px; margin: 0; }
.bdot { cursor: pointer; }
.bdot .hit { fill: transparent; }
.bdot .d { fill: #fff; stroke: var(--c); stroke-width: 3; transition: r .15s; }
@media (hover: hover) { .bdot:hover .d { fill: var(--soft); r: 9; } }
.bdot.focus .d { fill: var(--gold); stroke: #e08a00; animation: throb 1s infinite; }
.bdot.right .d { fill: var(--good); stroke: var(--good-d); r: 9; }
.bdot.wrong .d { fill: var(--bad); stroke: var(--bad-d); r: 9; }
.body-wrap.done .bdot { pointer-events: none; }
@keyframes throb { 50% { r: 11; } }

/* Tarjetas (ordenar, clasificar, unir) */
.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 18px; }
.chip {
  font-size: 19px; padding: 12px 16px; background: #fff; border: 3px solid var(--line); border-radius: 16px;
  box-shadow: 0 4px 0 var(--line); transition: transform .1s, border-color .1s, opacity .2s; line-height: 1.2;
}
.chip small { display: block; font-size: 14px; color: var(--muted); }
@media (hover: hover) { .chip:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--c); } }
.chip.sel { border-color: var(--c); background: var(--soft); transform: translateY(-3px) scale(1.03); }
.chip.used { opacity: 0; pointer-events: none; transform: scale(.6); }
.hint { text-align: center; color: var(--muted); font-size: 15px; margin: 14px 0 0; }
.order-slots { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 22px; }
.slot { min-width: 120px; min-height: 64px; border: 3px dashed var(--line); border-radius: 16px; display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-size: 18px; }
.slot-n { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--line); display: grid; place-items: center; font-weight: 700; font-size: 15px; }
.slot-t small { display: block; font-size: 13px; color: var(--muted); }
.slot.filled { border-style: solid; border-color: var(--good); background: #eefbf4; animation: pop .25s; }
.slot.filled .slot-n { background: var(--good); color: #fff; }
.buckets { display: grid; gap: 12px; margin-top: 20px; }
.buckets.n2 { grid-template-columns: 1fr 1fr; }
.buckets.n3 { grid-template-columns: repeat(3, 1fr); }
.bucket { border: 3px dashed var(--c); border-radius: 20px; background: var(--soft); min-height: 150px; padding: 10px; cursor: pointer; transition: transform .1s, background .1s; }
.bucket.over { background: #fff; transform: scale(1.02); }
@media (hover: hover) { .bucket:hover { background: #fff; transform: scale(1.02); } }
.bucket.glow { animation: glow .5s; }
@keyframes glow { 50% { box-shadow: 0 0 0 6px rgba(31, 183, 122, .35); } }
.bucket-h { text-align: center; font-weight: 700; font-size: 20px; color: var(--cd); margin-bottom: 8px; }
.bucket-in { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.bucket-in .chip { font-size: 15px; padding: 6px 10px; box-shadow: none; border-color: var(--good); background: #eefbf4; }
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-top: 20px; }
.mcol { display: flex; flex-direction: column; gap: 10px; }
.chip.m { width: 100%; }
.chip.matched { border-color: var(--mc); background: color-mix(in srgb, var(--mc) 18%, white); box-shadow: 0 4px 0 var(--mc); }

/* Visuales de preguntas */
.gap-word { font-size: 52px; font-weight: 600; letter-spacing: .03em; display: flex; align-items: center; gap: 14px; }
.gw-emoji { font-size: 60px; }
.gap { display: inline-block; min-width: 1.1em; text-align: center; color: var(--c); border-bottom: 5px solid var(--c); margin: 0 3px; line-height: 1; }
.sign-board { display: inline-block; margin-top: 10px; padding: 10px 18px; background: #2b2d42; color: #fff; border-radius: 10px; font-weight: 600; letter-spacing: .08em; font-size: 24px; }
.sign-board .gap { color: var(--gold); border-color: var(--gold); }
.sign-big .sign { width: 160px; height: 145px; }
.secret { font-size: 30px; font-weight: 600; background: #2b2d42; color: #7cf5c4; padding: 16px 24px; border-radius: 16px; font-family: ui-monospace, Menlo, monospace; text-align: center; }
.emoji-big { font-size: 110px; line-height: 1; }
.cmp { display: flex; align-items: center; gap: 22px; font-size: 52px; font-weight: 700; }
.cmp-q { width: 80px; height: 80px; border: 4px dashed var(--c); border-radius: 20px; display: grid; place-items: center; color: var(--c); }
.road-sign { background: #1d6f3e; color: #fff; border: 4px solid #fff; outline: 3px solid #1d6f3e; border-radius: 12px; padding: 10px 18px; min-width: 240px; font-size: 22px; }
.road-sign div, .book-index div { display: flex; justify-content: space-between; gap: 30px; }
.book-index { background: #fff8e1; border: 3px solid #f0d58c; border-radius: 14px; padding: 10px 20px; min-width: 260px; font-size: 20px; }
.book-index h4 { margin: 0 0 6px; text-align: center; }
.price-tags { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.price-tags span { background: #f7f8fd; border: 2px solid var(--line); padding: 8px 12px; border-radius: 14px; font-size: 19px; }

/* Feedback */
.feedback { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 18px calc(20px + env(safe-area-inset-right)) calc(22px + env(safe-area-inset-bottom)) calc(20px + env(safe-area-inset-left)); animation: up .25s ease; }
.feedback.good { background: #d7f7e8; border-top: 4px solid var(--good); }
.feedback.bad { background: #ffe1e1; border-top: 4px solid var(--bad); }
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
.fb-inner { max-width: 820px; margin: 0 auto; display: flex; align-items: center; gap: 16px; }
.fb-text { flex: 1; font-size: 18px; }
.fb-title { font-size: 26px; display: block; }
.feedback.good .fb-title { color: var(--good-d); }
.feedback.bad .fb-title { color: var(--bad-d); }
.fb-answer { margin-top: 4px; }
.fb-explain { margin-top: 6px; background: rgba(255, 255, 255, .7); padding: 8px 12px; border-radius: 12px; line-height: 1.4; }
.fb-explain .sign { width: 44px; height: 40px; vertical-align: middle; }
.play { padding-bottom: 150px; }

/* Jefe final */
.arena { display: flex; align-items: center; gap: 18px; background: linear-gradient(135deg, #3d3a63, #5b3f8c); border-radius: 24px; padding: 14px 22px; margin-bottom: 14px; color: #fff; box-shadow: 0 6px 0 #25233f; }
.boss { position: relative; font-size: 70px; line-height: 1; animation: bob 2s ease-in-out infinite; }
.boss .boom { position: absolute; inset: 0; display: grid; place-items: center; font-size: 60px; opacity: 0; }
.boss.hit { animation: bosshit .5s; }
.boss.hit .boom { animation: boom .5s; }
@keyframes bosshit { 20% { transform: translateX(10px) rotate(8deg); filter: brightness(2); } 50% { transform: translateX(-8px) rotate(-6deg); } }
@keyframes boom { 0% { opacity: 1; transform: scale(.4); } 100% { opacity: 0; transform: scale(1.6); } }
.boss-info { flex: 1; }
.boss-info b { font-size: 22px; }
.hp { height: 18px; background: rgba(255, 255, 255, .2); border-radius: 99px; margin-top: 6px; overflow: hidden; }
.hp i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ff5a5f, #ff9f1c); border-radius: 99px; transition: width .5s; }
.play.hurt { animation: hurt .45s; }
@keyframes hurt { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } 30% { filter: hue-rotate(-40deg) saturate(2); } }

/* Desafío rápido */
.track { position: relative; height: 56px; background: linear-gradient(90deg, #1b1f4b, #3a2f7a); border-radius: 20px; margin-bottom: 14px; overflow: hidden; box-shadow: 0 5px 0 #11133a; }
.track::before { content: ''; position: absolute; inset: 0; background-image: radial-gradient(#fff 1px, transparent 1.5px); background-size: 28px 28px; opacity: .5; }
.rocket { position: absolute; left: 0; top: 8px; font-size: 38px; transition: left .4s cubic-bezier(.3, 1.4, .5, 1); transform: rotate(45deg); }
.goal { position: absolute; right: 10px; top: 8px; font-size: 36px; animation: pulse 1.2s infinite; }

/* Resultados */
.results { max-width: 560px; margin: 4vh auto 0; text-align: center; padding: 34px 28px; }
.results h1 { font-size: 34px; margin: 10px 0; }
.r-pet { display: flex; justify-content: center; }
.r-stars { display: flex; justify-content: center; gap: 10px; margin: 10px 0; }
.rs { font-size: 70px; color: #e3e5f0; transform: scale(.4); animation: star .5s var(--d) forwards cubic-bezier(.2, 1.6, .4, 1); }
.rs:nth-child(2) { font-size: 90px; margin-top: -14px; }
.rs.on { color: var(--gold); text-shadow: 0 5px 0 #d99a00; }
@keyframes star { to { transform: scale(1); } }
.r-line { font-size: 19px; color: var(--muted); }
.r-coins { display: inline-block; font-size: 28px; font-weight: 700; background: #fff6d1; padding: 8px 20px; border-radius: 99px; box-shadow: 0 4px 0 #f5d76e; margin: 6px 0 22px; }
.r-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

/* Tienda */
.shop-hero { display: flex; flex-direction: column; align-items: center; padding: 34px 20px 20px; text-align: center; }
.shop-hero p { color: var(--muted); font-size: 18px; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-top: 18px; }
.shop-item { background: #fff; border-radius: 22px; padding: 18px 10px; display: flex; flex-direction: column; align-items: center; gap: 4px; box-shadow: 0 6px 0 var(--line); border: 3px solid transparent; transition: transform .1s; }
@media (hover: hover) { .shop-item:hover { transform: translateY(-3px); } }
.shop-item.on { border-color: var(--good); }
.shop-item.poor { opacity: .6; }
.si-e { font-size: 50px; }
.si-n { font-weight: 600; font-size: 17px; }
.si-p { font-size: 15px; color: var(--muted); font-weight: 600; }
.shop-item.owned .si-p { color: var(--good-d); }

/* Padres */
.parents { padding: 24px; }
.ptable { width: 100%; border-collapse: collapse; font-size: 15px; }
.ptable th { text-align: left; color: var(--muted); font-weight: 600; border-bottom: 2px solid var(--line); padding: 8px 6px; }
.ptable td { border-bottom: 1px solid var(--line); padding: 8px 6px; }
.ptable .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.ptable td:nth-child(3) { color: var(--gold); letter-spacing: 1px; }
.ptable .off { color: #e3e5f0; }
.acc { font-weight: 700; padding: 2px 8px; border-radius: 8px; }
.acc.hi { background: #dcf7ea; color: var(--good-d); }
.acc.mid { background: #fff3c4; color: #a57900; }
.acc.lo { background: #ffe3e3; color: var(--bad-d); }
.mlist { list-style: none; padding: 0; display: grid; gap: 8px; }
.mlist li { display: grid; grid-template-columns: 56px 1fr; gap: 2px 10px; background: #f7f8fd; padding: 10px 12px; border-radius: 12px; }
.mlist .mw { color: var(--bad-d); font-weight: 700; grid-row: span 2; }
.mlist small { color: var(--muted); }
.p-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }

/* Aviso */
.toast { position: fixed; left: 50%; top: calc(20px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 50; background: #2b2d42; color: #fff; padding: 14px 22px; border-radius: 18px; font-size: 18px; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); animation: pop .3s; max-width: 90vw; text-align: center; transition: opacity .4s, transform .4s; }
.toast.out { opacity: 0; transform: translate(-50%, -20px); }

/* Confeti */
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
#confetti i { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { transform: translate(var(--x), 110vh) rotate(var(--r)); } }

/* ---------- Pantallas estrechas ---------- */
@media (max-width: 760px) {
  #app { padding: 14px 16px 60px; }
  .worlds, .extras { grid-template-columns: 1fr; }
  .world { min-height: 170px; }
  .options { grid-template-columns: 1fr; }
  .buckets.n3 { grid-template-columns: 1fr; }
  .q-text { font-size: 21px; }
  .body-svg { height: 340px; }
  .body-wrap.name { flex-direction: column; }
  .node-row { transform: translateX(calc(var(--dx) * .5)); }
  .pv-board.n4 { grid-template-columns: repeat(2, 1fr); }
  .gap-word { font-size: 38px; }
  .cmp { font-size: 36px; }
}
.feedback svg { max-height: 56px; width: auto; vertical-align: middle; }

/* ===================== Aprendizaje ===================== */

/* Misión del día y siguiente paso */
.mission {
  display: flex; align-items: center; gap: 16px; width: 100%; text-align: left; padding: 18px 22px; margin-bottom: 16px;
  background: linear-gradient(135deg, #ff9f1c, #ff6b6b); color: #fff; box-shadow: 0 8px 0 #d1531f, 0 20px 40px rgba(255, 107, 107, .25);
  transition: transform .1s;
}
.mission:active { transform: translateY(4px); box-shadow: 0 4px 0 #d1531f; }
.mission.done { background: linear-gradient(135deg, #1fb77a, #3a86ff); box-shadow: 0 8px 0 #1d5fd6; }
.mission.intro { background: #fff; color: var(--ink); box-shadow: 0 8px 0 rgba(43, 45, 66, .08); }
.mission > div > b { font-size: 24px; display: block; }
.mission p { margin: 4px 0 0; font-size: 16px; opacity: .95; }
.ms-emoji { font-size: 52px; line-height: 1; }
.ms-go { margin-left: auto; font-size: 30px; background: rgba(255, 255, 255, .25); width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.next-step {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; margin-bottom: 18px; padding: 14px 18px;
  background: #fff; border-radius: 22px; box-shadow: 0 6px 0 var(--line); border-left: 8px solid var(--c);
}
.next-step:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--line); }
.ns-emoji { font-size: 40px; width: 64px; height: 64px; display: grid; place-items: center; background: var(--soft); border-radius: 18px; flex: none; }
.ns-text { display: flex; flex-direction: column; }
.ns-text small { color: var(--c); font-weight: 600; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; }
.ns-text b { font-size: 22px; }
.ns-text em { font-style: normal; color: var(--muted); font-size: 15px; }
.ns-go { margin-left: auto; color: var(--c); font-size: 26px; }

/* Nodos con anillo de dominio */
.node.lesson { position: relative; }
.node.lesson::before {
  content: ''; position: absolute; inset: -8px; border-radius: 50%;
  background: conic-gradient(var(--gold) calc(var(--m, 0) * 1%), rgba(255, 255, 255, .7) 0);
  -webkit-mask: radial-gradient(circle, transparent 46px, #000 47px); mask: radial-gradient(circle, transparent 46px, #000 47px);
}
.n-badge { position: absolute; top: -6px; right: -6px; font-size: 22px; background: #fff; border-radius: 50%; width: 34px; height: 34px; display: grid; place-items: center; box-shadow: 0 3px 0 var(--line); animation: pulse 1.4s infinite; }
.n-state { display: inline-block; font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: 99px; margin-top: 4px; background: #eef0f7; color: var(--muted); }
.n-state.learning { background: #ffe8d6; color: #c25a00; }
.n-state.almost { background: #fff3c4; color: #8a6500; }
.n-state.master { background: #dcf7ea; color: var(--good-d); }
.n-state.due { background: #efe4ff; color: #5f1fc4; }

/* Aprende paso a paso */
.learn-stage { min-height: 220px; display: flex; flex-direction: column; justify-content: center; gap: 16px; margin: 22px 0 10px; }
.learn-card { background: var(--soft); border-radius: 24px; padding: 26px 28px; font-size: 25px; line-height: 1.5; text-align: center; }
.learn-card.enter { animation: slidein .35s ease; }
.learn-card .sign { width: 70px; height: 62px; display: block; margin: 0 auto 8px; }
.learn-card .pv-mini { margin: 0 10px 0 0; }
.learn-dots { display: flex; justify-content: center; gap: 8px; margin-bottom: 18px; }
.learn-dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--line); transition: background .2s, transform .2s; }
.learn-dots i.on { background: var(--c); transform: scale(1.15); }
.learn-foot .link { font-size: 16px; }

/* Pistas y práctica guiada */
.q-card { position: relative; }
.q-tag:empty { display: none; }
.q-tag span { display: inline-block; font-size: 14px; font-weight: 600; color: var(--cd); background: var(--soft); padding: 4px 12px; border-radius: 99px; margin-bottom: 12px; }
.hint-box { background: #fff8dc; border: 2px solid #f5d76e; border-radius: 16px; padding: 12px 16px; font-size: 18px; line-height: 1.45; margin-bottom: 14px; animation: pop .3s; }
.hint-btn { display: block; margin: 20px auto 0; font-size: 17px; font-weight: 600; color: #a57900; background: #fff8dc; border: 2px solid #f5d76e; padding: 10px 20px; border-radius: 99px; }
.hint-btn:active { transform: scale(.96); }
.opt.gone { opacity: .2 !important; text-decoration: line-through; }
.fb-actions { display: flex; align-items: center; gap: 10px; }
.fb-answer.small { font-size: 15px; opacity: .8; }

/* Resultados con dominio */
.mastery-line { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; margin: 6px 0 4px; font-size: 16px; color: var(--muted); }
.mbar { height: 14px; background: #eef0f7; border-radius: 99px; overflow: hidden; }
.mbar i { display: block; height: 100%; background: var(--gold); border-radius: 99px; transition: width .6s; }
.mbar i.hi { background: var(--good); }
.mbar i.mid { background: var(--gold); }
.mbar i.lo { background: var(--bad); }
.mbar.thin { height: 10px; min-width: 90px; }
.r-next { font-size: 16px; color: var(--muted); }
.lchips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 8px 0 12px; }
.lchip { font-size: 14px; font-weight: 600; padding: 6px 12px; border-radius: 99px; }
.lchip.hi { background: #dcf7ea; color: var(--good-d); }
.lchip.mid { background: #fff3c4; color: #8a6500; }
.lchip.lo { background: #ffe3e3; color: var(--bad-d); }

/* Examen */
.exam-res { max-width: 760px; margin: 0 auto; display: grid; gap: 16px; }
.exam-res .card { padding: 22px 24px; }
.exam-res h3 { margin: 0 0 12px; }
.grade-card { text-align: center; }
.grade { font-size: 96px; font-weight: 700; color: var(--c); line-height: 1; }
.verdict { font-size: 28px; font-weight: 600; margin-top: 6px; }
.r-stars.small .rs { font-size: 48px; }
.r-stars.small .rs:nth-child(2) { font-size: 60px; margin-top: -8px; }
.ex-row { display: grid; grid-template-columns: minmax(150px, 1.4fr) 2fr auto 96px; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.ex-name { font-weight: 600; }
.ex-n { font-weight: 700; color: var(--muted); }
.ex-ok { color: var(--good-d); font-weight: 700; text-align: center; }
.btn.small { font-size: 15px; padding: 6px 12px; border-radius: 12px; box-shadow: 0 3px 0 var(--line); }
.ex-wrong ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.ex-wrong li { background: #f7f8fd; border-radius: 12px; padding: 10px 14px; display: flex; flex-direction: column; gap: 4px; }
.ew-q { font-size: 16px; }
.ew-a { color: var(--good-d); font-weight: 600; }
.ew-a .sign { width: 40px; height: 36px; vertical-align: middle; }

/* Puerta parental, padres y ajustes */
.gate { max-width: 520px; margin: 4vh auto 0; padding: 24px; text-align: center; }
.p-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; padding: 18px; }
.p-summary div { display: flex; flex-direction: column; align-items: center; text-align: center; }
.p-summary b { font-size: 34px; color: #8338ec; }
.p-summary span { font-size: 14px; color: var(--muted); }
.parents { display: grid; gap: 16px; }
.parents .card { padding: 22px 24px; }
.parents h3 { margin: 0 0 8px; }
.parents h4 { margin: 18px 0 6px; }
.pill.small { font-size: 13px; padding: 4px 10px; box-shadow: none; background: #f2f3f9; }
.toggle { display: flex; align-items: center; gap: 12px; font-size: 18px; padding: 8px 0; }
.toggle input { width: 26px; height: 26px; accent-color: #8338ec; }

/* Ventana propia */
.modal-bg { position: fixed; inset: 0; z-index: 70; background: rgba(43, 45, 66, .45); display: grid; place-items: center; padding: 20px; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal { max-width: 420px; width: 100%; padding: 26px; text-align: center; }
.modal h3 { font-size: 26px; margin: 0 0 8px; }
.modal p { color: var(--muted); font-size: 18px; margin: 0 0 18px; }
.modal-in { width: 100%; font: inherit; font-size: 22px; padding: 12px 16px; border: 3px solid var(--line); border-radius: 16px; margin-bottom: 18px; outline: none; }
.modal-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

@media (max-width: 760px) {
  .mission > div > b { font-size: 20px; }
  .ms-emoji { font-size: 40px; }
  .learn-card { font-size: 21px; padding: 20px; }
  .p-summary { grid-template-columns: repeat(2, 1fr); }
  .ex-row { grid-template-columns: 1fr auto; }
  .ex-row .mbar { grid-column: 1 / -1; grid-row: 2; }
  .grade { font-size: 72px; }
  .ptable { font-size: 13px; }
}
