:root {
  --bg: #e6f7f8;
  --bg2: #c9eef1;
  --card: #ffffff;
  --text: #16324f;
  --muted: #5b7083;
  --accent: #ff6f91;
  --accent-soft: #ffe0e9;
  --primary: #0e7490;
  --primary-2: #0891b2;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --ko: #dc2626;
  --ko-soft: #fee2e2;
  --warn: #f59e0b;
  --water1: #7dd3fc;
  --water2: #0e7490;
  --radius: 18px;
  --shadow: 0 6px 18px rgba(14, 116, 144, .15);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1f2a; --bg2: #0f2a38; --card: #15344a; --text: #e6f4f8; --muted: #9fb7c6;
    --accent-soft: #4a2533; --ok-soft: #12361f; --ko-soft: #3d1717; --shadow: 0 6px 18px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Nunito', system-ui, sans-serif;
  background: linear-gradient(180deg, var(--bg), var(--bg2)) fixed;
  color: var(--text);
  min-height: 100vh;
  font-size: 18px;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; cursor: pointer; }
main { max-width: 1360px; margin: 0 auto; padding: 16px 16px 60px; }

/* ---------- barra superior ---------- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; gap: 12px; align-items: center; padding: 10px 16px; background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: blur(8px); box-shadow: var(--shadow); }
.home-btn { border: 0; background: var(--bg2); border-radius: 12px; font-size: 22px; padding: 6px 10px; }
.xpbox { flex: 1; min-width: 0; }
.xpline { display: flex; justify-content: space-between; font-weight: 800; font-size: 14px; gap: 8px; }
.xpline span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xpbar { height: 14px; background: var(--bg2); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.xpbar > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #ffb86b); border-radius: 99px; transition: width .8s cubic-bezier(.2,.9,.3,1.2); }
.week { display: flex; gap: 3px; }
.week span { width: 10px; height: 10px; border-radius: 50%; background: var(--bg2); }
.week span.on { background: var(--accent); }

/* ---------- tarjetas y botones ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin: 14px 0; }
.btn { border: 0; border-radius: 16px; padding: 14px 22px; font-weight: 800; font-size: 19px; background: var(--primary); color: #fff; box-shadow: 0 4px 0 #075566; transition: transform .08s; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #075566; }
.btn.big { width: 100%; padding: 18px; font-size: 22px; }
.btn.pink { background: var(--accent); box-shadow: 0 4px 0 #c94a6c; }
.btn.ghost { background: var(--bg2); color: var(--text); box-shadow: 0 4px 0 color-mix(in srgb, var(--bg2) 60%, #000); }
.btn.small { padding: 8px 14px; font-size: 16px; }
.btn[disabled] { opacity: .5; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; }
.muted { color: var(--muted); }
h1, h2, h3 { margin: .3em 0; line-height: 1.15; }
h1 { font-size: 28px; font-weight: 900; }
h2 { font-size: 23px; font-weight: 900; }

/* ---------- acuario y mascota ---------- */
.aquarium { position: relative; border-radius: 26px; overflow: hidden; background: linear-gradient(180deg, var(--water1), var(--water2)); min-height: 290px; display: flex; align-items: flex-end; justify-content: center; padding-top: 30px; box-shadow: var(--shadow); }
.aquarium::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 34px; background: #e9d8a6; border-top: 4px solid #d4b483; }
.aquarium .pet { position: relative; z-index: 2; margin-bottom: 8px; }
.bubble-up { position: absolute; bottom: 20px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid rgba(255,255,255,.7); animation: rise 6s linear infinite; z-index: 1; }
@keyframes rise { from { transform: translateY(0); opacity: 0; } 10% { opacity: 1; } to { transform: translateY(-300px); opacity: 0; } }
.decor { position: absolute; bottom: 22px; z-index: 1; font-size: 34px; }
.decor-planta { left: 10px; } .decor-piedras { left: 34%; font-size: 26px; } .decor-cofre { right: 14px; }
.decor-castillo { right: 70px; font-size: 44px; } .decor-burbujas { left: 22%; bottom: 120px; } .decor-luces { left: 45%; top: 10px; bottom: auto; }
.speech { position: relative; background: var(--card); border-radius: 20px; padding: 14px 18px; box-shadow: var(--shadow); font-size: 19px; font-weight: 700; margin: 14px 0; }
.speech::before { content: ''; position: absolute; top: -12px; left: 50%; border: 12px solid transparent; border-top: 0; border-bottom-color: var(--card); transform: translateX(-50%); }
.float { animation: float 3.5s ease-in-out infinite; }
.swim { animation: float 3s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-10px); } }
.wobble { animation: wobble 2.2s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes wobble { 0%, 60%, 100% { transform: rotate(0); } 70% { transform: rotate(-6deg); } 80% { transform: rotate(5deg); } 90% { transform: rotate(-3deg); } }
.pet .gill { transform-origin: 150px 90px; animation: gill 2.4s ease-in-out infinite; }
@keyframes gill { 50% { transform: scale(1.04); } }
.pet .tail { transform-origin: 185px 180px; animation: tail 2s ease-in-out infinite; }
@keyframes tail { 50% { transform: rotate(-5deg); } }
.evolve .pet { animation: evolve 2.4s ease-in-out; }
@keyframes evolve { 0% { filter: brightness(1); transform: scale(1); } 40% { filter: brightness(3) blur(2px); transform: scale(1.15) rotate(8deg); } 60% { filter: brightness(3) blur(3px); transform: scale(.9) rotate(-8deg); } 100% { filter: brightness(1); transform: scale(1); } }
.mini-pet { position: fixed; right: 10px; bottom: 6px; z-index: 5; pointer-events: none; }
.mini-pet .pet { width: 110px; height: 88px; }

/* ---------- inicio ---------- */
.home-actions { display: grid; gap: 12px; margin-top: 12px; }
.stage-req { font-size: 15px; color: var(--muted); text-align: center; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { background: var(--bg2); border-radius: 99px; padding: 4px 12px; font-size: 14px; font-weight: 800; }

/* ---------- mapa ---------- */
@keyframes glow { 50% { box-shadow: 0 0 0 6px #fbbf2455; } }

/* ---------- hoja modal ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 680px; border-radius: 26px 26px 0 0; padding: 22px 18px 28px; max-height: 88vh; overflow: auto; animation: up .25s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.example { background: var(--bg); border-radius: 14px; padding: 12px 14px; margin: 10px 0; }

/* ---------- ejercicios ---------- */
.ex-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 800; font-size: 15px; color: var(--muted); }
.progress { height: 10px; border-radius: 99px; background: var(--bg2); overflow: hidden; margin: 8px 0 4px; }
.progress > div { height: 100%; background: var(--primary-2); transition: width .4s; }
.question { font-size: 22px; font-weight: 800; line-height: 1.35; }
.question .big { font-size: 38px; font-weight: 900; display: inline-block; margin: 6px 0; }
.choices { display: grid; gap: 10px; margin-top: 14px; }
.choice { border: 3px solid var(--bg2); background: var(--card); color: var(--text); border-radius: 16px; padding: 14px; font-size: 20px; font-weight: 800; text-align: left; }
.choice.sel-ok { border-color: var(--ok); background: var(--ok-soft); }
.choice.sel-ko { border-color: var(--ko); background: var(--ko-soft); }
.listen-btns { margin-top: 12px; align-items: center; justify-content: center; gap: 14px; }
.listen-play { font-size: 54px; line-height: 1; padding: 16px 34px; border-radius: 28px; }
.listen-slow { font-size: 32px; padding: 14px 20px; }
.listen-opts .choice { font-size: 30px; text-align: center; padding: 16px; }
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.match-col { display: grid; gap: 10px; align-content: start; }
.match-btn { border: 3px solid var(--bg2); background: var(--card); color: var(--text); border-radius: 16px; padding: 14px 8px; font-size: 24px; font-weight: 800; min-height: 64px; transition: transform .1s, background .2s; }
.match-btn.sel { border-color: var(--primary-2); background: var(--accent-soft); transform: scale(1.04); }
.match-btn.done { border-color: var(--ok); background: var(--ok-soft); color: var(--text); opacity: 1; }
.match-btn.wrong { border-color: var(--ko); background: var(--ko-soft); animation: codeShake .45s ease; }
.answer-row { display: flex; gap: 10px; margin-top: 14px; }
.answer { flex: 1; min-width: 0; font: inherit; font-size: 26px; font-weight: 800; padding: 12px 14px; border-radius: 14px; border: 3px solid var(--bg2); background: var(--card); color: var(--text); }
textarea.answer { font-size: 21px; min-height: 92px; resize: vertical; }
.answer:focus { outline: none; border-color: var(--primary-2); }
.keys { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.keys button { border: 0; background: var(--bg2); color: var(--text); border-radius: 10px; padding: 8px 12px; font-weight: 800; font-size: 18px; min-width: 44px; }
.feedback { border-radius: 16px; padding: 14px 16px; margin-top: 14px; font-size: 18px; line-height: 1.45; }
.feedback.ok { background: var(--ok-soft); }
.feedback.ko { background: var(--ko-soft); }
.feedback.hint { background: #fef3c7; color: #6b4a00; }
.ex-foot { display: flex; gap: 10px; margin-top: 16px; }
.ex-foot .btn { flex: 1; }
.timer { font-variant-numeric: tabular-nums; }
.reading-text { background: var(--bg); border-radius: 16px; padding: 14px 16px; font-size: 19px; line-height: 1.6; max-height: 46vh; overflow: auto; font-weight: 600; }
.reading-text p { margin: 0 0 .8em; }
.words { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.words span { padding: 3px 8px; border-radius: 8px; font-weight: 800; }
.words .w-ok { background: var(--ok-soft); }
.words .w-ko { background: var(--ko-soft); }
.words .w-ko s { opacity: .7; margin-right: 4px; }
.xp-pop { position: fixed; left: 50%; top: 35%; transform: translateX(-50%); font-size: 34px; font-weight: 900; color: var(--accent); pointer-events: none; animation: pop 1s ease-out forwards; z-index: 30; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 20px) scale(.6); } 30% { opacity: 1; transform: translate(-50%, 0) scale(1.15); } to { opacity: 0; transform: translate(-50%, -60px); } }
.breathe { width: 140px; height: 140px; border-radius: 50%; margin: 50px auto; background: radial-gradient(circle, #a5f3fc, #0891b2); animation: breathe 4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.4); } }

/* ---------- visuales matemáticos ---------- */
.blocks { --cell: 14px; --line: rgba(0,0,0,.28); display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; margin: 12px 0; }
.b-group { background: var(--bg2); color: var(--text); border-radius: 10px; padding: 8px; max-width: 100%; }
.b-head { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text); margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--muted); }
.b-pieces { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: flex-end; }
.b-set { display: flex; gap: 4px; align-items: flex-end; flex-wrap: nowrap; }
.b-h, .b-t, .b-o { display: block; flex: none; border-radius: 2px; background-size: var(--cell) var(--cell); box-shadow: 0 0 0 1px var(--line); }
.b-h { width: calc(var(--cell) * 10); height: calc(var(--cell) * 10); background-color: #60a5fa; background-image: linear-gradient(to right, var(--line) 1px, transparent 1px), linear-gradient(to bottom, var(--line) 1px, transparent 1px); }
.b-t { width: var(--cell); height: calc(var(--cell) * 10); background-color: #fbbf24; background-image: linear-gradient(to bottom, var(--line) 1px, transparent 1px); }
.b-o { width: var(--cell); height: var(--cell); background-color: #34d399; }
.b-mini { --cell: 4px; flex: none; }
.b-mini.b-h { width: 20px; height: 20px; background-size: 2px 2px; }
.b-mini.b-t { width: 5px; height: 20px; background-size: 5px 2px; }
.b-mini.b-o { width: 5px; height: 5px; }
@media (max-width: 400px) { .blocks { --cell: 12px; } .b-set { gap: 3px; } }
.dots, .groups { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; font-size: 22px; }
.grp { border: 2px dashed var(--muted); border-radius: 12px; padding: 4px 6px; }
.tenframe { display: grid; grid-template-columns: repeat(5, 38px); gap: 4px; margin: 10px 0; }
.tenframe span { width: 38px; height: 38px; border: 2px solid var(--muted); border-radius: 6px; }
.tenframe span.on::after { content: ''; display: block; margin: 5px; height: 24px; border-radius: 50%; background: var(--accent); }
.column { font-family: ui-monospace, Menlo, monospace; font-size: 34px; line-height: 1.2; margin: 8px 0; font-weight: 700; }
.money { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.money .bill { background: #bbf7d0; color: #14532d; border: 2px solid #16a34a; border-radius: 6px; padding: 8px 14px; font-weight: 900; }
.money .coin { background: #fde68a; color: #713f12; border: 2px solid #ca8a04; border-radius: 50%; width: 52px; height: 52px; display: grid; place-items: center; font-weight: 900; font-size: 15px; }
.clock, .pie, .shape { display: block; margin: 8px 0; color: var(--text); }
.shape text, .clock text { fill: currentColor; }

/* ---------- varios ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 800; z-index: 40; max-width: 92vw; }
.center { text-align: center; }
.stack > * + * { margin-top: 10px; }
.pick3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.pick3 button { border: 3px solid var(--bg2); background: var(--card); color: var(--text); border-radius: 18px; padding: 10px; font-weight: 800; }
.pick3 button:hover { border-color: var(--accent); }
.subject-list { display: grid; gap: 10px; }
.subject-item { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 16px; background: var(--card); box-shadow: var(--shadow); border: 0; color: var(--text); font-weight: 800; font-size: 18px; text-align: left; }
.subject-item .ic { font-size: 28px; }
.subject-item .st { margin-left: auto; font-size: 14px; color: var(--muted); }
.subject-item[disabled] { opacity: .55; cursor: default; }
input.name { font: inherit; font-size: 24px; padding: 12px; border-radius: 14px; border: 3px solid var(--bg2); width: 100%; text-align: center; font-weight: 800; background: var(--card); color: var(--text); }
@media (max-width: 520px) {
  body { font-size: 17px; }
  .question .big { font-size: 32px; }
  .mini-pet { display: none; }
}
[hidden] { display: none !important; }
/* avisos de cambio */
.transition { animation: up .3s ease-out; }
.transition .tr-icon { font-size: 56px; animation: float 2.5s ease-in-out infinite; }
.reading-badge { margin: 10px 0 0; padding: 8px 14px; border-radius: 12px; background: var(--bg2); font-weight: 800; font-size: 15px; }
.reading-badge.new { background: #fef3c7; color: #6b4a00; animation: glow 1.8s ease-in-out 2; }
/* palabras tocables */
.w { cursor: pointer; border-radius: 4px; }
.w:hover { background: var(--accent-soft); }
.w.gl { text-decoration: underline dotted 2px; text-underline-offset: 4px; text-decoration-color: var(--accent); }
.word-sheet a.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.note { font-size: 14px; }
/* la caja del dictado ocupa todo el ancho */
textarea.answer { display: block; width: 100%; margin-top: 12px; }
.ex-foot { flex-wrap: wrap; }
.ex-foot .help-btn { flex: 1 1 100%; }
.example .blocks, .example .dots, .example .tenframe, .example .groups, .example .money, .example svg { margin: 6px auto 10px; }

.lang-badge { display: inline-block; text-transform: uppercase; font-weight: 900; padding: 1px 6px; border-radius: 6px; font-size: 0.75em; vertical-align: middle; margin-left: 6px; letter-spacing: .03em; line-height: 1.3; border: 1px solid rgba(0,0,0,.25); }
.lang-ca { background: repeating-linear-gradient(to bottom, #FCDD09 0 3px, #DA121A 3px 4px, #FCDD09 4px 8px); color: #3b0a0a; text-shadow: 0 0 3px #fff, 0 0 2px #fff; }
.lang-es { background: #C60B1E; color: #fff; }
.lang-en { background: #012169; color: #fff; }

.btn.big.done { background: var(--ok, #3fa56b); color: #fff; opacity: .9; }
.card.mission-done { border: 2px solid var(--ok, #3fa56b); }
.streak-ok { font-weight: 700; }

/* ---------- ¿Quién eres? / código / alta ---------- */
.auth { max-width: 560px; margin: 0 auto; }
.auth-title { text-align: center; font-size: 30px; margin: 10px 0; }
.who-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-top: 14px; }
.who-card { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 170px; padding: 14px; border: 3px solid var(--bg2); border-radius: 22px; background: var(--card); color: var(--text); box-shadow: var(--shadow); font-weight: 900; font-size: 24px; }
.who-card:active { transform: scale(.97); border-color: var(--accent); }
.who-card svg { max-width: 100%; height: auto; }
.code-slots { display: flex; justify-content: center; gap: 12px; margin: 14px 0; }
.code-slot { width: 72px; height: 72px; display: flex; align-items: center; justify-content: center; font-size: 42px; border-radius: 18px; background: var(--card); border: 3px dashed var(--bg2); }
.code-slot.on { border-style: solid; border-color: var(--accent); }
.code-slots.shake { animation: codeShake .45s ease; }
@keyframes codeShake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-10px); } 50% { transform: translateX(10px); } 75% { transform: translateX(-6px); } }
.code-pad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.code-pad.lock { opacity: .6; pointer-events: none; }
.code-key { aspect-ratio: 1; min-height: 64px; font-size: 36px; border: 3px solid var(--bg2); border-radius: 18px; background: var(--card); color: var(--text); box-shadow: 0 4px 0 var(--bg2); }
.code-key:active { transform: translateY(3px); box-shadow: none; border-color: var(--accent); }
.code-key.del { background: var(--accent-soft); font-size: 30px; }
.choice-grid { display: grid; gap: 12px; margin-top: 12px; }
.choice-grid.small { grid-template-columns: repeat(3, 1fr); }
.btn.choice { width: 100%; padding: 18px; font-size: 22px; }

/* ---------- Escenas por especie (el fondo se elige en app.js según la especie; antes de eclosionar, "nido" neutro) ---------- */
.aquarium.bg-nido { background: linear-gradient(180deg, #fdf2e9, #fbe3cf); }
.aquarium.bg-nido::after { background: #f0d9a8; border-top-color: #dcbf86; }
.aquarium.bg-prado { background: linear-gradient(180deg, #bfe6ff, #e4f6ff 70%); }
.aquarium.bg-prado::after { background: #8fd18b; border-top: 4px solid #6cbb6c; }
.cloud { position: absolute; left: -90px; width: 80px; height: 26px; border-radius: 30px; background: #fff; opacity: .85; z-index: 0; animation: drift 38s linear infinite; }
.cloud::before, .cloud::after { content: ''; position: absolute; background: #fff; border-radius: 50%; }
.cloud::before { width: 34px; height: 34px; left: 12px; top: -16px; }
.cloud::after { width: 26px; height: 26px; left: 38px; top: -10px; }
@keyframes drift { to { transform: translateX(520px); } }
.spark { position: absolute; bottom: 50px; z-index: 1; font-size: 18px; animation: twinkle 2.6s ease-in-out infinite; }
.twinkle { animation: twinkle 2.2s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.twinkle.d2 { animation-delay: .7s; } .twinkle.d3 { animation-delay: 1.4s; }
@keyframes twinkle { 0%, 100% { opacity: .35; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.15); } }
.pet .aura { animation: twinkle 3.2s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.pet .uni-tail { transform-box: fill-box; transform-origin: 0% 100%; animation: tail 2.4s ease-in-out infinite; }
.pet .uni-wing { transform-box: fill-box; transform-origin: 0% 100%; animation: flap 2.8s ease-in-out infinite; }
@keyframes flap { 50% { transform: rotate(-6deg); } }
.pet .egg-glow { animation: eggpulse 1.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes eggpulse { 50% { opacity: .55; transform: scale(1.05); } }

/* ---------- Minijuego del huevo ---------- */
.quiz-egg { display: flex; justify-content: center; }
.quiz-egg.pop svg { animation: eggpop .5s ease-out; }
@keyframes eggpop { 0% { transform: scale(.88) rotate(-4deg); } 60% { transform: scale(1.06) rotate(3deg); } 100% { transform: scale(1); } }
.quiz-dots { display: flex; justify-content: center; gap: 6px; margin: 6px 0; }
.quiz-dots span { width: 10px; height: 10px; border-radius: 50%; background: var(--bg2); }
.quiz-dots span.on { background: var(--accent); transform: scale(1.25); } .quiz-dots span.done { background: var(--ok); }
.quiz-opts { grid-template-columns: 1fr 1fr; }
.quiz-opts.n2, .quiz-opts.n3 { grid-template-columns: 1fr; }
.quiz-opt { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 18px; text-align: center; }
.quiz-opt .qe { font-size: 40px; line-height: 1.1; }
.quiz-opts.n2 .quiz-opt, .quiz-opts.n3 .quiz-opt { flex-direction: row; justify-content: center; gap: 14px; font-size: 22px; }
.color-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 14px; justify-items: center; }
.color-dot { width: 64px; height: 64px; border-radius: 50%; border: 4px solid #fff; background: var(--c); box-shadow: var(--shadow); cursor: pointer; }
.color-dot.rainbow { background: conic-gradient(#ff8fa3, #ffb86b, #ffe58a, #9be7a6, #8ecbff, #c3a6ff, #ff8fa3); }
.color-dot:active { transform: scale(.92); }

/* Fondos de escena por especie (generado desde BG_CSS de cada pets/<id>.js) */
/* dragon */
.aquarium.bg-volcan { background: linear-gradient(180deg, #ffd6a8, #ffb6a0 55%, #ffe3c2); }
.aquarium.bg-volcan::after { background: linear-gradient(180deg, #a9897d, #8c6f66); border-top: 4px solid #ff9f62; box-shadow: inset 0 6px 14px -6px #ffb36b; }
/* zorro */
.aquarium.bg-bosque { background: linear-gradient(180deg, #ffe7bf, #f9d7a0 60%, #fdeccc); }
.aquarium.bg-bosque::after { background: radial-gradient(circle at 12% 60%, #e07a2f 0 4px, transparent 5px), radial-gradient(circle at 38% 40%, #f0b24a 0 4px, transparent 5px), radial-gradient(circle at 66% 65%, #c9572a 0 4px, transparent 5px), radial-gradient(circle at 88% 45%, #e8a13a 0 4px, transparent 5px), #b58450; border-top: 4px solid #8f6334; }
/* buho */
.aquarium.bg-noche { background:
  radial-gradient(circle at 82% 20%, #fff6d4 0 15px, rgba(255,246,212,.38) 16px 30px, rgba(255,246,212,0) 44px),
  radial-gradient(2px 2px at 12% 18%, #fff 0 60%, transparent 100%), radial-gradient(1.6px 1.6px at 30% 34%, #fff 0 60%, transparent 100%),
  radial-gradient(2.2px 2.2px at 46% 12%, #fff 0 60%, transparent 100%), radial-gradient(1.6px 1.6px at 62% 30%, #fff 0 60%, transparent 100%),
  radial-gradient(2px 2px at 70% 10%, #fff 0 60%, transparent 100%), radial-gradient(1.6px 1.6px at 90% 44%, #fff 0 60%, transparent 100%),
  radial-gradient(1.8px 1.8px at 20% 52%, #fff 0 60%, transparent 100%), radial-gradient(1.6px 1.6px at 8% 38%, #fff 0 60%, transparent 100%),
  linear-gradient(180deg, #121f4d, #2b3c80 78%); }
.aquarium.bg-noche::after { background: repeating-linear-gradient(90deg, #6b4a32 0 46px, #5d3f2a 46px 50px); border-top: 4px solid #8a6544; border-radius: 18px 18px 0 0; }
/* gato */
.aquarium.bg-casa { background:
  linear-gradient(#fff,#fff) 10% 24px / 4px 84px no-repeat,
  linear-gradient(#fff,#fff) 10% 62px / 74px 4px no-repeat,
  linear-gradient(#c9ecff,#eaf8ff) 10% 28px / 74px 84px no-repeat,
  linear-gradient(#fff,#fff) calc(10% - 5px) 22px / 84px 94px no-repeat,
  linear-gradient(180deg, #ffe7c7, #ffd3a5); }
.aquarium.bg-casa::after { background: radial-gradient(ellipse 130px 15px at 50% 15px, #e8707a 0 94%, transparent 100%), repeating-linear-gradient(90deg, #c98f56 0 58px, #b57c45 58px 60px); border-top: 5px solid #a8693a; }
/* ornitorrinco */
.aquarium.bg-rio { background:
  linear-gradient(#8a6a3e,#8a6a3e) 86% 100% / 4px 96px no-repeat, linear-gradient(#6f9a45,#6f9a45) 89% 100% / 4px 120px no-repeat, linear-gradient(#8a6a3e,#8a6a3e) 93% 100% / 4px 84px no-repeat,
  radial-gradient(ellipse 62% 44% at 0% 100%, #4aa8dc 0 94%, transparent 100%),
  linear-gradient(180deg, #c8ecff, #e9f8e2 72%); }
.aquarium.bg-rio::after { left: 34%; height: 36px; border-radius: 22px 0 0 0; background: #b99265; border-top: 6px solid #78b650; }
/* delfin */
.aquarium.bg-mar { background: linear-gradient(180deg, #bfe8ff 0%, #e6f7ff 36%, #6fd6dc 37%, #34b9cc 100%); }
.aquarium.bg-mar::after { height: 38px; background: radial-gradient(circle at 16px -4px, #7fe0ea 17px, transparent 18px) 0 0 / 32px 20px repeat-x, #1fa3c0; border-top: 0; }
/* marmota */
.aquarium.bg-montana { background:
  linear-gradient(to bottom right, transparent 50%, #fff 50%) left 112px bottom 120px / 28px 34px no-repeat,
  linear-gradient(to bottom left, transparent 50%, #fff 50%) left 140px bottom 120px / 28px 34px no-repeat,
  linear-gradient(to bottom right, transparent 50%, #b9c8e0 50%) left 40px bottom 34px / 100px 120px no-repeat,
  linear-gradient(to bottom left, transparent 50%, #a8b9d6 50%) left 140px bottom 34px / 100px 120px no-repeat,
  linear-gradient(to bottom right, transparent 50%, #fff 50%) right 64px bottom 101px / 24px 29px no-repeat,
  linear-gradient(to bottom left, transparent 50%, #fff 50%) right 88px bottom 101px / 24px 29px no-repeat,
  linear-gradient(to bottom right, transparent 50%, #c6d4ea 50%) right 8px bottom 34px / 80px 96px no-repeat,
  linear-gradient(to bottom left, transparent 50%, #b4c4de 50%) right 88px bottom 34px / 80px 96px no-repeat,
  linear-gradient(180deg, #9fd4ff, #e6f5ff 75%); }
.aquarium.bg-montana::after { height: 40px; background: #9ad46f; border-top: 4px solid #6fb653; }

/* ---------- Ordena la frase ---------- */
.order-line, .order-bank { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px; border-radius: 14px; }
.order-line { min-height: 58px; margin: 6px 0 12px; background: #fff; border: 2px dashed var(--primary); align-items: center; }
.order-bank { min-height: 52px; justify-content: center; }
.tile { font: inherit; font-weight: 800; font-size: 18px; padding: 10px 14px; min-height: 44px; border-radius: 12px; border: 2px solid #cbd5e1; background: #f8fafc; color: inherit; cursor: pointer; touch-action: manipulation; box-shadow: 0 2px 0 #cbd5e1; }
.tile.on { background: #ecfeff; border-color: var(--primary); box-shadow: 0 2px 0 var(--primary); }
.tile:disabled { opacity: .75; cursor: default; }

/* ======================================================================
   Aprovechar el ancho: móvil 1 columna; tablet/escritorio 2 columnas
   ====================================================================== */
.aquarium > svg.pet { max-width: 100%; height: auto; }
.speech p, .feedback, .example, .reading-text, .tr-text { max-width: 78ch; }
.center .speech, .center .feedback { margin-left: auto; margin-right: auto; }

@media (min-width: 700px) {
  body { font-size: clamp(18px, 0.9vw + 10px, 22px); }
  main { padding: 20px 24px 70px; }
  .topbar { padding: 10px max(24px, calc((100vw - 1360px) / 2 + 24px)); }
  h1 { font-size: clamp(28px, 2.2vw, 38px); }
  h2 { font-size: clamp(23px, 1.8vw, 30px); }
  .aquarium { min-height: clamp(290px, 38vw, 560px); }
  .aquarium > svg.pet { width: min(78%, 520px); }
  .decor { font-size: clamp(34px, 3.4vw, 56px); }
  .speech { font-size: clamp(19px, 1.5vw, 24px); }
  .question { font-size: clamp(22px, 1.7vw, 28px); }
  .choice { font-size: clamp(20px, 1.5vw, 24px); padding: 18px; }
  .btn { font-size: clamp(19px, 1.4vw, 23px); }
  .reading-text { font-size: clamp(19px, 1.4vw, 23px); }
  .feedback { font-size: clamp(18px, 1.3vw, 22px); }
  .keys button { min-height: 52px; min-width: 52px; font-size: 22px; }
  .tile { font-size: clamp(18px, 1.4vw, 24px); min-height: 52px; }
  .match-btn { min-height: 76px; font-size: clamp(24px, 2vw, 32px); }
  .mini-pet .pet { width: 130px; height: auto; }
  .sheet { max-width: 860px; }
  .toast { font-size: 20px; }
}

/* rejillas que crecen */
.choices { grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.listen-opts { grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.match-grid { gap: clamp(14px, 3vw, 40px); }
.match-col { grid-template-columns: 1fr; }
.pick3 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); }
.pick3 button { min-height: 56px; font-size: 17px; }
.who-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr)); }
.who-card svg { width: min(100%, 220px); }
.choice-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }
.choice-grid.small { grid-template-columns: repeat(auto-fill, minmax(min(30%, 120px), 1fr)); }
.quiz-opts, .quiz-opts.n2, .quiz-opts.n3 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.color-grid { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
.subject-list { grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }

/* pantallas de alta / código: más anchas */
@media (min-width: 700px) {
  .auth { max-width: 860px; }
  .auth-title { font-size: clamp(30px, 3vw, 44px); }
  .code-slot { width: 88px; height: 88px; font-size: 52px; }
  .code-pad { grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 14px; }
  .code-key { min-height: 84px; font-size: 44px; }
  .color-dot { width: 80px; height: 80px; }
  .quiz-egg svg { width: min(100%, 360px); height: auto; }
}

/* ---- 2 columnas (≥ 900px) ---- */
.home-layout, .intro-layout, .reading-layout, .rinco-layout, .quiz-layout { display: block; }
.back-wide { display: none; }

@media (min-width: 900px) {
  .home-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 32px; align-items: center; min-height: calc(100vh - 180px); }
  .home-scene .aquarium { min-height: clamp(380px, 52vh, 640px); }
  .home-side .speech { margin-top: 0; }
  .home-side .speech::before { top: 50%; left: -12px; transform: translateY(-50%); border: 12px solid transparent; border-left: 0; border-right-color: var(--card); }
  .home-side .center { text-align: center; }
  .home-actions .btn.big { padding: 22px; font-size: clamp(22px, 1.8vw, 28px); }

  .intro-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 32px; align-items: start; }
  .intro-side { position: sticky; top: 90px; }
  .intro-side .row > div { flex: 0 0 200px !important; }
  .intro-side .row .pet { width: 200px; height: auto; }
  .intro-main .speech { margin-top: 0; }
  .intro-main .speech::before { display: none; }

  .ex-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); column-gap: 36px; align-items: start; padding: 28px 32px; }
  .ex-card > .question { grid-column: 1; grid-row: 1 / span 12; position: sticky; top: 90px; }
  .ex-card > :not(.question) { grid-column: 2; }
  .ex-card > .question .big { font-size: clamp(38px, 4vw, 64px); }
  .ex-card > .question svg { max-width: 100%; height: auto; }
  .ex-card > .order-line, .ex-card > .order-bank { grid-column: 2; }

  .reading-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 28px; align-items: start; }
  .reading-layout > .card { margin: 14px 0; }
  .reading-card { position: sticky; top: 90px; }
  .reading-text { max-height: max(260px, calc(100vh - 340px)); }

  .rinco-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 32px; align-items: start; }
  .rinco-scene { position: sticky; top: 90px; }
  .rinco-scene .aquarium { min-height: clamp(420px, 62vh, 700px); }
  .rinco-scene .back-wide { display: block; margin-top: 16px; width: 100%; }
  .back-narrow { display: none; }

  .quiz-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 36px; align-items: center; min-height: 60vh; }
  .quiz-main .speech::before { display: none; }
  .auth:has(.quiz-layout) { max-width: 1100px; }
  .transition { max-width: 900px; margin-left: auto; margin-right: auto; }
}
.match-grid, .order-line, .order-bank { width: 100%; }
.card .words { max-width: 100%; }
@media (min-width: 1500px) { .home-layout { min-height: calc(100vh - 200px); } }
@media (min-width: 900px) {
  .tenframe { grid-template-columns: repeat(5, clamp(38px, 4vw, 64px)); gap: 6px; }
  .tenframe span { width: clamp(38px, 4vw, 64px); height: clamp(38px, 4vw, 64px); }
  .tenframe span.on::after { margin: 18%; height: 64%; }
  .dots, .groups { font-size: 30px; }
  .column { font-size: clamp(34px, 3vw, 52px); }
}
@media (max-width: 520px) { .ex-foot .btn { padding: 12px 10px; font-size: 17px; white-space: nowrap; } }
