:root {
  --morado: #6A1FB8;
  --morado-2: #7b2ff7;
  --magenta: #D6336C;
  --naranja: #F7931E;
  --amarillo: #FFC93C;
  --verde: #2BB673;
  --azul: #1c7ed6;
  --crema: #FFF8F0;
  --tinta: #2B1250;
  --gris: #7d7193;
  --linea: #ece3f7;
  --card: #fff;
  --radius: 22px;
  --shadow: 0 6px 18px rgba(74, 20, 140, .10);
  --f-text: 'Andika', system-ui, sans-serif;
  --f-title: 'Fredoka', 'Andika', system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: var(--f-text);
  color: var(--tinta);
  background: var(--crema);
  background-image: radial-gradient(circle at 10% 0%, #f3e8ff 0, transparent 40%), radial-gradient(circle at 100% 30%, #ffe8d1 0, transparent 35%);
  background-attachment: fixed;
  min-height: 100vh;
  font-size: 18px;
  line-height: 1.4;
  overscroll-behavior: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; touch-action: manipulation; }
h1, h2, h3, h4 { font-family: var(--f-title); margin: .3em 0; line-height: 1.15; }
a { color: var(--morado); }

#app { max-width: 760px; margin: 0 auto; min-height: 100vh; }
.screen { padding: max(12px, env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom)); animation: enter .25s ease; }
.screen.center, .center { text-align: center; }
.screen.center { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 100vh; }
.splash p { color: var(--gris); }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }

.muted { color: var(--gris); }
.small { font-size: .85em; }
.lead { font-size: 1.15em; max-width: 30ch; margin: 0 auto; }
.note { text-align: center; color: var(--gris); font-size: .85em; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .field { flex: 1; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; margin-top: 10px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 20px; border-radius: 999px; font-family: var(--f-title); font-weight: 600; font-size: 1rem;
  text-decoration: none; transition: transform .08s; min-height: 48px;
}
.btn:active { transform: translateY(2px) scale(.98); }
.btn:disabled { opacity: .55; }
.btn-primary { background: linear-gradient(135deg, var(--morado-2), var(--magenta)); color: #fff; box-shadow: 0 4px 0 #4a1290; }
.btn-orange { background: linear-gradient(135deg, var(--naranja), var(--amarillo)); color: #4a2500; box-shadow: 0 4px 0 #c76a00; }
.btn-ghost { background: #fff; color: var(--morado); border: 2px solid var(--linea); }
.btn-danger { background: #e8590c; color: #fff; }
.btn.danger, .link.danger { color: #c92a2a; }
.btn.sm { padding: 6px 14px; min-height: 38px; font-size: .9rem; }
.btn-lg { font-size: 1.2rem; padding: 14px 28px; min-height: 58px; }
.btn-xl { font-size: 1.4rem; padding: 16px 36px; min-height: 66px; width: 100%; max-width: 380px; }
.link { color: var(--morado); text-decoration: underline; padding: 8px; font-size: .95em; }
.icon-btn { width: 46px; height: 46px; border-radius: 50%; background: #fff; box-shadow: var(--shadow); font-size: 1.5rem; display: grid; place-items: center; color: var(--morado); flex: none; }
.icon-spacer { width: 46px; flex: none; }

/* ---------- Marca ---------- */
.brand { text-align: center; }
.brand h1 { font-size: 2.6rem; margin: 0; letter-spacing: .5px; }
.brand .b1 { background: linear-gradient(90deg, var(--morado-2), var(--magenta)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand .b2 { background: linear-gradient(90deg, var(--naranja), var(--amarillo)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tagline { margin: 0; color: var(--gris); font-family: var(--f-title); }
.hero .brand .owl { width: 84px; height: 84px; }
.hero .brand h1 { font-size: 2rem; }
.by { text-align: center; margin-top: 24px; }
.by img { width: 110px; filter: drop-shadow(0 0 1px rgba(0,0,0,.4)); background: var(--morado); border-radius: 18px; padding: 6px; }
.owl-wrap { display: inline-flex; flex: none; }
.owl { animation: bob 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px); } }

/* ---------- Tarjetas y formularios ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin: 14px 0; }
.form { display: flex; flex-direction: column; gap: 12px; max-width: 420px; margin: 18px auto; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--gris); text-align: left; }
.field input, .field select, input[type=search], .modal input:not([type=checkbox]) {
  width: 100%; padding: 12px 14px; border-radius: 14px; border: 2px solid var(--linea); background: #fff; font-size: 1.05rem; color: var(--tinta);
}
input:focus, select:focus { outline: none; border-color: var(--morado-2); }
.form-msg { color: #c92a2a; margin: 0; min-height: 1.2em; text-align: center; }
.check { display: flex; gap: 8px; align-items: center; margin: 10px 0; }
.check input { width: 22px; height: 22px; }

/* ---------- Mascota ---------- */
.mascot { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.bubble { position: relative; background: #fff; border-radius: 18px; padding: 10px 14px; box-shadow: var(--shadow); font-size: 1.05rem; }
.bubble::before { content: ''; position: absolute; left: -8px; top: 50%; margin-top: -8px; border: 8px solid transparent; border-left: 0; border-right-color: #fff; }

/* ---------- Encabezado ---------- */
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.topbar-title { flex: 1; text-align: center; font-family: var(--f-title); font-weight: 600; font-size: 1.2rem; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: #fff3d6; color: #a15c00; border-radius: 999px; padding: 4px 12px; font-size: .9rem; margin-left: 8px; font-family: var(--f-title); }

/* ---------- Perfiles ---------- */
.kids { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; margin: 16px 0; }
.kid-card { background: #fff; border-radius: var(--radius); padding: 18px 10px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 4px; border: 3px solid transparent; transition: transform .1s; }
.kid-card:active { transform: scale(.96); border-color: var(--morado-2); }
.kid-card.add { border: 3px dashed var(--linea); box-shadow: none; background: transparent; color: var(--gris); }
.kid-avatar { font-size: 3.4rem; line-height: 1; }
.kid-name { font-family: var(--f-title); font-weight: 600; font-size: 1.2rem; }
.kid-stars { color: #d68a00; }
.tools { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 18px; }
.avatar-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
.avatar-opt { font-size: 1.8rem; padding: 4px 0; border-radius: 14px; border: 3px solid transparent; }
.avatar-opt.sel { border-color: var(--morado-2); background: #f3e8ff; }

/* ---------- Mapa ---------- */
.map-actions { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 8px 0 16px; }
.world { border-radius: 28px; padding: 16px; margin: 18px 0; background: linear-gradient(160deg, var(--c1), var(--c2)); color: #fff; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.world::after { content: '< >'; position: absolute; right: 12px; top: 6px; font-family: var(--f-title); font-size: 2.4rem; opacity: .18; font-weight: 700; }
.world.closed { filter: grayscale(.85); opacity: .7; }
.world-head { display: flex; align-items: center; gap: 10px; }
.world-head h2 { font-size: 1.35rem; }
.world-emoji { font-size: 2.2rem; }
.world-lock { margin: 8px 0 0; font-size: .9rem; }
.nodes { display: flex; flex-wrap: wrap; gap: 14px 10px; justify-content: center; margin-top: 12px; }
.node { display: flex; flex-direction: column; align-items: center; gap: 2px; color: #fff; width: 76px; }
.node-circle { width: 70px; height: 70px; border-radius: 50%; background: #fff; color: var(--c1); display: grid; place-items: center; font-family: var(--f-text); font-weight: 700; font-size: 1.6rem; box-shadow: 0 5px 0 rgba(0,0,0,.18); }
.node.eval .node-circle { background: var(--amarillo); }
.node.locked .node-circle { background: rgba(255,255,255,.35); font-size: 1.3rem; }
.node.next .node-circle { animation: pulse 1.4s infinite; outline: 4px solid var(--amarillo); }
@keyframes pulse { 50% { transform: scale(1.08); } }
.node-label { font-size: .75rem; min-height: 1em; font-family: var(--f-title); }
.stars { letter-spacing: 1px; font-size: 1rem; }
.stars .on { color: var(--amarillo); text-shadow: 0 1px 0 #b77b00; }
.stars .off { color: rgba(0,0,0,.18); }
.world .stars .off { color: rgba(255,255,255,.4); }

/* ---------- Introducción ---------- */
.letter-card { display: flex; justify-content: center; gap: 18px; margin: 10px 0; }
.lc { background: #fff; border-radius: 26px; box-shadow: var(--shadow); padding: 8px 22px; display: flex; align-items: baseline; gap: 10px; }
.lc .up { font-size: 4.2rem; color: var(--morado); font-weight: 700; }
.lc .low { font-size: 5rem; color: var(--magenta); font-weight: 700; }
.big-letters { display: flex; justify-content: center; gap: 12px; font-size: 3rem; font-weight: 700; color: var(--morado); flex-wrap: wrap; }
.syl-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 12px 0; }
.syl-chip { background: linear-gradient(135deg, #fff, #f3e8ff); border: 2px solid var(--linea); border-radius: 16px; padding: 8px 16px; font-size: 1.6rem; font-weight: 700; color: var(--morado); }
.tip { display: flex; gap: 10px; align-items: center; text-align: left; background: #fff; border-radius: 20px; padding: 10px 14px; box-shadow: var(--shadow); margin: 12px 0; font-size: 1.05rem; width: 100%; }
.examples { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0 18px; }
.example { background: #fff; border-radius: 18px; padding: 8px 4px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; font-size: 1rem; }
.example .pic { font-size: 2.4rem; }
.example .pic svg { width: 46px; height: 46px; }
.intro > .btn-xl { display: flex; margin: 16px auto 0; }
.pairs { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 14px 0; }
.pair { font-size: 1.4rem; }
.letter-chip { display: inline-block; min-width: 56px; padding: 4px 12px; background: #fff; border-radius: 14px; box-shadow: var(--shadow); font-size: 2.4rem; color: var(--morado); text-align: center; }

/* ---------- Juego ---------- */
.play { display: flex; flex-direction: column; min-height: 100vh; }
.play-top { display: flex; align-items: center; gap: 10px; }
.bar { flex: 1; height: 16px; background: #e9def7; border-radius: 999px; overflow: hidden; }
.bar.small { height: 8px; }
.bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--verde), #8ce99a); border-radius: 999px; transition: width .4s; }
.is-eval .bar-fill { background: linear-gradient(90deg, var(--naranja), var(--amarillo)); }
.ex-area { flex: 1; display: flex; flex-direction: column; position: relative; padding-top: 6px; }
.repeat-btn { align-self: flex-end; background: #fff; border-radius: 999px; padding: 6px 14px; box-shadow: var(--shadow); color: var(--morado); font-family: var(--f-title); font-size: .95rem; }
.ex { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.q-title { font-family: var(--f-title); font-size: 1.45rem; font-weight: 600; text-align: center; }
.target { display: inline-block; background: var(--morado); color: #fff; border-radius: 14px; padding: 0 14px; font-family: var(--f-text); font-size: 2rem; margin-left: 6px; vertical-align: middle; }
.pic-big { background: #fff; border-radius: 30px; box-shadow: var(--shadow); width: 170px; height: 170px; display: grid; place-items: center; }
.pic-big .pic { font-size: 6.4rem; line-height: 1; }
.pic-big .pic svg { width: 130px; height: 130px; }
.speaker-big { width: 130px; height: 130px; border-radius: 50%; background: linear-gradient(135deg, var(--morado-2), var(--magenta)); color: #fff; font-size: 3.6rem; box-shadow: 0 6px 0 #4a1290; animation: pulse 2s infinite; }
.read-word { font-size: 4rem; font-weight: 700; color: var(--morado); background: #fff; border-radius: 26px; padding: 6px 30px; box-shadow: var(--shadow); letter-spacing: 2px; }
.choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; width: 100%; max-width: 520px; }
.choices.n2, .choices.n4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choice { background: #fff; border-radius: 22px; min-height: 84px; box-shadow: 0 5px 0 #ddd0ee; border: 3px solid var(--linea); display: grid; place-items: center; padding: 8px; transition: transform .1s; }
.choice:active { transform: translateY(3px); box-shadow: 0 2px 0 #ddd0ee; }
.choice .syl { font-size: 2.4rem; font-weight: 700; color: var(--tinta); }
.choices.big .syl { font-size: 2.8rem; }
.choice .letter { font-size: 3.2rem; }
.choices.pics .choice { min-height: 120px; }
.choices.pics .pic { font-size: 4.2rem; line-height: 1; }
.choices.pics .pic svg { width: 84px; height: 84px; }
.choice.ok { background: #d3f9d8; border-color: var(--verde); box-shadow: 0 5px 0 #8ce99a; animation: pop .35s; }
.choice.bad { background: #fff4e6; border-color: #ffc078; opacity: .6; animation: shake .4s; }
@keyframes pop { 50% { transform: scale(1.12); } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.shake { animation: shake .4s; }

.word-line { display: flex; gap: 6px; font-size: 3rem; font-weight: 700; }
.wsyl { color: var(--morado); }
.blank { min-width: 90px; text-align: center; border-bottom: 5px dashed var(--naranja); color: var(--naranja); }
.blank.filled { color: var(--verde); border-bottom-color: var(--verde); }

.slots { display: flex; gap: 8px; }
.slot { min-width: 84px; height: 72px; border-radius: 18px; border: 3px dashed #c9b6e4; display: grid; place-items: center; font-size: 2.2rem; font-weight: 700; background: rgba(255,255,255,.6); }
.slot.filled { border: 3px solid var(--verde); background: #ebfbee; color: var(--tinta); animation: pop .3s; }
.tiles { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.tile { min-width: 84px; height: 72px; border-radius: 18px; background: #fff; box-shadow: 0 5px 0 #ddd0ee; border: 3px solid var(--linea); font-size: 2.2rem; font-weight: 700; padding: 0 12px; }
.tile.used { opacity: .25; }

.counter { font-family: var(--f-title); color: var(--gris); }
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; width: 100%; max-width: 400px; }
.cell { aspect-ratio: 1; border-radius: 18px; background: #fff; box-shadow: 0 4px 0 #ddd0ee; border: 3px solid var(--linea); font-size: 2.6rem; font-weight: 700; }
.cell.ok { background: #d3f9d8; border-color: var(--verde); animation: pop .3s; }
.cell.bad { background: #fff4e6; border-color: #ffc078; opacity: .5; animation: shake .4s; }

.lslots { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.lgroup { display: flex; gap: 4px; }
.lslot { width: 44px; height: 58px; border-bottom: 4px solid #c9b6e4; display: grid; place-items: center; font-size: 2.3rem; font-weight: 700; }
.lslot.filled { border-color: var(--verde); }
.keyboard { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 420px; }
.key { width: 58px; height: 62px; border-radius: 16px; background: #fff; box-shadow: 0 4px 0 #ddd0ee; border: 2px solid var(--linea); font-size: 2rem; font-weight: 700; }
.key:active { transform: translateY(2px); }

.feedback { min-height: 76px; margin-top: 10px; }
.feedback .bubble { visibility: hidden; }

/* ---------- Resultados ---------- */
.big-stars .stars { font-size: 3.4rem; }
.big-stars .stars span { display: inline-block; animation: pop .5s backwards; }
.big-stars .stars span:nth-child(2) { animation-delay: .2s; }
.big-stars .stars span:nth-child(3) { animation-delay: .4s; }
.result-actions { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { top: 110%; transform: rotate(720deg) translateX(40px); } }

/* ---------- Papás ---------- */
.wprog { display: grid; grid-template-columns: 1fr 90px 44px; gap: 8px; align-items: center; font-size: .9rem; margin: 6px 0; }
.errs, .hist, .plist { padding: 0; margin: 0; list-style: none; }
.errs li { padding: 6px 0; border-bottom: 1px solid var(--linea); }
.hist li { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; padding: 4px 0; font-size: .9rem; }
.tips ul { padding-left: 20px; margin: 0; }
.tips li { margin: 6px 0; }

/* ---------- Admin ---------- */
.tabs { display: flex; gap: 6px; background: #fff; padding: 6px; border-radius: 999px; box-shadow: var(--shadow); margin-bottom: 12px; }
.tab { flex: 1; padding: 10px 6px; border-radius: 999px; font-family: var(--f-title); font-size: .95rem; }
.tab.sel { background: var(--morado); color: #fff; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: #fff; border-radius: 16px; padding: 10px; text-align: center; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.stat b { font-family: var(--f-title); font-size: 1.3rem; color: var(--morado); }
.stat span { font-size: .75rem; color: var(--gris); }
.stat.wide { box-shadow: none; margin-top: 8px; }
.ucard { margin: 10px 0; }
.pill { font-size: .75rem; border-radius: 999px; padding: 3px 10px; font-family: var(--f-title); }
.pill-ok { background: #d3f9d8; color: #2b8a3e; }
.pill-warn { background: #fff3bf; color: #a15c00; }
.pill-off { background: #f1f3f5; color: #868e96; }
.pill-admin { background: #f3e8ff; color: var(--morado); }
.plist li { padding: 10px 0; border-bottom: 1px solid var(--linea); }
.success { background: #ebfbee; border-radius: 16px; padding: 14px; }
.success pre { white-space: pre-wrap; font-family: var(--f-text); font-size: .95rem; }
.kprog { padding: 8px 0; border-bottom: 1px solid var(--linea); }

/* ---------- Modal y avisos ---------- */
.overlay { position: fixed; inset: 0; background: rgba(43, 18, 80, .45); display: flex; align-items: flex-end; justify-content: center; z-index: 40; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: #fff; width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; border-radius: 26px 26px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); animation: up .25s; }
@keyframes up { from { transform: translateY(40px); } }
.modal-body { display: flex; flex-direction: column; gap: 10px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
@media (min-width: 600px) { .overlay { align-items: center; } .modal { border-radius: 26px; } }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--tinta); color: #fff; padding: 12px 18px; border-radius: 14px; z-index: 60; max-width: 90vw; transition: opacity .4s; }
.toast.out { opacity: 0; }

@media (max-width: 420px) {
  .examples { grid-template-columns: repeat(2, 1fr); }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .choice .syl, .choices.big .syl { font-size: 2.2rem; }
  .read-word { font-size: 3rem; }
  .slot, .tile { min-width: 70px; height: 64px; font-size: 1.9rem; }
  .lc .up { font-size: 3.2rem; } .lc .low { font-size: 4rem; }
}

/* ---------- Juegos de sílabas ---------- */
.seq { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; }
.slots { flex-wrap: wrap; justify-content: center; }
.slot small { font-size: 1.1rem; color: #b9a6d6; font-weight: 400; }
.grid.syl3 { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 340px; }
.grid.syl3 .cell { aspect-ratio: 4 / 3; font-size: 2.2rem; }
.sound-box { min-height: 170px; display: grid; place-items: center; }
button.target { font-weight: 700; }
button.read-word { cursor: pointer; }
.node-circle.small { font-size: 1.15rem; }
.seq.many .slots { gap: 6px; }
.seq.many .slot { min-width: 0; width: 60px; height: 64px; font-size: 1.8rem; }
.seq.many .tile { min-width: 62px; height: 62px; font-size: 1.9rem; }
