:root {
  --bg: #fff8ec;
  --card: #ffffff;
  --ink: #2d2a3e;
  --muted: #6f6a85;
  --line: #ece3d2;
  --green: #2fb67c;
  --green-dark: #1f8f5f;
  --orange: #ff8a3d;
  --yellow: #ffc93c;
  --red: #ff5d6c;
  --blue: #3ea8ff;
  --purple: #8b6cff;
  --gray: #d9d4e4;
  --radius: 22px;
  --shadow: 0 6px 0 rgba(45, 42, 62, .08), 0 12px 28px rgba(45, 42, 62, .08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Fredoka', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

/* ---------- Barra superior ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; max-width: 1040px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; font-size: 1.35rem; font-weight: 500; }
.brand b { color: var(--green); font-weight: 700; }
.brand-icon { font-size: 1.8rem; }
.topbar-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--card);
  box-shadow: var(--shadow); font-size: 1.4rem; display: grid; place-items: center; text-decoration: none;
}

.app { max-width: 1040px; margin: 0 auto; padding: 8px 16px 48px; }

/* ---------- Bloques comunes ---------- */
h1, h2, h3 { margin: 0 0 12px; line-height: 1.15; }
h1 { font-size: clamp(1.9rem, 5vw, 3rem); }
h2 { font-size: clamp(1.4rem, 3.6vw, 2rem); }
p { line-height: 1.5; }
.muted { color: var(--muted); }
.center { text-align: center; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.spacer { height: 16px; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px;
}

.btn {
  border: 0; border-radius: 18px; padding: 14px 26px; font-size: 1.2rem; font-weight: 600;
  background: var(--green); color: #fff; box-shadow: 0 5px 0 var(--green-dark);
  transition: transform .08s, box-shadow .08s; text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; gap: 8px; min-height: 56px;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--green-dark); }
.btn.secondary { background: var(--card); color: var(--ink); box-shadow: 0 5px 0 var(--line); }
.btn.orange { background: var(--orange); box-shadow: 0 5px 0 #d96a22; }
.btn.blue { background: var(--blue); box-shadow: 0 5px 0 #2384d6; }
.btn.purple { background: var(--purple); box-shadow: 0 5px 0 #6a4ed6; }
.btn.small { padding: 8px 16px; min-height: 44px; font-size: 1rem; }
.btn.block { width: 100%; }

.back { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--muted); font-size: 1.1rem; margin-bottom: 12px; }

input[type=text], input[type=number] {
  width: 100%; padding: 14px 16px; border-radius: 16px; border: 3px solid var(--line);
  font-size: 1.3rem; background: #fff; outline: none;
}
input:focus { border-color: var(--green); }

/* ---------- Portada ---------- */
.hero { display: grid; gap: 24px; align-items: center; grid-template-columns: 1.2fr 1fr; padding: 24px 0; }
.hero-art {
  display: grid; grid-template-columns: repeat(3, auto); justify-content: center; gap: 4px 12px;
  font-size: clamp(3rem, 8vw, 5.5rem); line-height: 1.15; animation: float 4s ease-in-out infinite;
}
.hero p { font-size: 1.2rem; }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 24px; }
.feature { text-align: center; }
.feature .emoji { font-size: 2.6rem; }
@keyframes float { 50% { transform: translateY(-10px); } }

/* ---------- Perfiles ---------- */
.players { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; }
.players > .player { width: 160px; }
.player {
  border: 0; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 10px; display: grid; justify-items: center; gap: 6px; font-size: 1.2rem; font-weight: 600;
  transition: transform .12s;
}
.player:hover { transform: translateY(-3px); }
.player .avatar { font-size: 3.6rem; }
.player.add { border: 3px dashed var(--gray); box-shadow: none; background: transparent; color: var(--muted); }
.avatars { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
.avatar-opt { font-size: 2rem; border: 3px solid transparent; background: #fff; border-radius: 14px; padding: 6px 0; }
.avatar-opt.sel { border-color: var(--green); background: #e9f9f1; }
.ages { display: flex; flex-wrap: wrap; gap: 8px; }
.age-opt { border: 3px solid var(--line); background: #fff; border-radius: 14px; padding: 8px 14px; font-size: 1.1rem; }
.age-opt.sel { border-color: var(--green); background: #e9f9f1; }

/* ---------- Mapa de juegos ---------- */
.hub-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.hub-head .avatar { font-size: 3.4rem; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { background: var(--card); border-radius: 999px; padding: 6px 14px; box-shadow: var(--shadow); font-weight: 500; }
.worlds { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.world {
  border: 0; border-radius: 28px; padding: 24px; text-align: left; color: #fff; min-height: 190px;
  display: flex; flex-direction: column; justify-content: space-between; box-shadow: var(--shadow);
  text-decoration: none; position: relative; overflow: hidden; transition: transform .12s;
}
.world:hover { transform: translateY(-4px) rotate(-.5deg); }
.world h3 { font-size: 1.7rem; margin: 0; }
.world p { margin: 4px 0 0; opacity: .95; }
.world .big { position: absolute; right: 14px; bottom: 6px; font-size: 5rem; opacity: .95; }
.world.tablas { background: linear-gradient(135deg, #8b6cff, #3ea8ff); }
.world.granja { background: linear-gradient(135deg, #2fb67c, #ffc93c); }
.world.soon { background: #cfc8de; cursor: default; }

/* ---------- Menús de juego ---------- */
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.mode { text-align: left; border: 0; display: grid; gap: 4px; padding: 20px; }
.mode .emoji { font-size: 2.4rem; }
.mode h3 { margin: 0; font-size: 1.4rem; }
.mode p { margin: 0; color: var(--muted); }
.table-picker { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.table-btn {
  border: 0; border-radius: 18px; padding: 16px 0; font-size: 1.6rem; font-weight: 700; color: #fff;
  box-shadow: 0 5px 0 rgba(0,0,0,.15);
}
.table-btn small { display: block; font-size: .8rem; font-weight: 500; opacity: .9; }
.table-btn:active { transform: translateY(4px); box-shadow: none; }

/* Tablas combinadas: botones que se marcan */
.table-btn.toggle { opacity: .4; transform: scale(.94); transition: opacity .15s, transform .15s; }
.table-btn.toggle.on { opacity: 1; transform: none; outline: 4px solid var(--ink); outline-offset: 2px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.prize-line { background: #fff4d1; border-radius: 14px; padding: 8px 14px; }

/* Pestañas */
.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tab { border: 3px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 16px; font-weight: 600; }
.tab.sel { border-color: var(--green); background: #e9f9f1; }

/* Mapa de dominio 10x10 */
.mastery { display: grid; grid-template-columns: 34px repeat(10, 1fr); gap: 3px; font-size: .85rem; }
.mastery .hd { display: grid; place-items: center; font-weight: 700; color: var(--muted); }
.mastery .cell { aspect-ratio: 1; border-radius: 6px; display: grid; place-items: center; font-size: .72rem; color: rgba(0,0,0,.55); }
/* 12 × 12 (Experto): columnas y letra más chicas para que "144" entre a 375 px. */
.mastery.x12 { grid-template-columns: 26px repeat(12, 1fr); gap: 2px; font-size: .75rem; }
.mastery.x12 .cell { font-size: clamp(.5rem, 2.4vw, .68rem); border-radius: 4px; }
.m-none { background: #eee9f5; }
.m-weak { background: #ffb3ba; }
.m-mid { background: #ffe08a; }
.m-good { background: #8fe0b8; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .9rem; color: var(--muted); margin-top: 10px; }
.legend span::before { content: ''; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; background: var(--c); }

.ranking { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.ranking li { display: flex; align-items: center; gap: 10px; background: #faf6ee; border-radius: 14px; padding: 10px 14px; font-size: 1.1rem; }
.ranking .pos { font-weight: 700; width: 28px; }
.ranking .who { flex: 1; }
.ranking .pts { font-weight: 700; color: var(--green-dark); }
.ranking li.me { background: #e9f9f1; outline: 3px solid var(--green); }

/* ---------- Pantalla de juego ---------- */
.play { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; max-width: 720px; margin: 0 auto; }
.hud { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 600; font-size: 1.15rem; }
.hud .pill { background: var(--card); border-radius: 999px; padding: 6px 14px; box-shadow: var(--shadow); white-space: nowrap; }
.hud .pill.title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.progress { height: 14px; background: #efe7d8; border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--green), var(--yellow)); border-radius: 999px; transition: width .3s; }
.timer > div { background: linear-gradient(90deg, var(--orange), var(--red)); transition: width 1s linear; }

.question {
  background: var(--card); border-radius: 30px; box-shadow: var(--shadow); padding: 26px 16px;
  text-align: center; position: relative; min-height: 170px; display: grid; place-items: center;
}
.question .q { font-size: clamp(3rem, 12vw, 5.2rem); font-weight: 700; letter-spacing: 1px; }
.question .q .ans { color: var(--green); }
.question .hint { color: var(--muted); font-size: 1.15rem; margin-top: 4px; }
.question.pop { animation: pop .35s; }
.question.shake { animation: shake .4s; }
@keyframes pop { 40% { transform: scale(1.06); } }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }

.options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.opt {
  border: 0; border-radius: 24px; padding: 22px 0; font-size: clamp(2rem, 7vw, 2.8rem); font-weight: 700;
  background: var(--card); box-shadow: 0 6px 0 var(--line); transition: transform .08s, background .2s;
}
.opt:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--line); }
.opt.right { background: var(--green); color: #fff; box-shadow: 0 6px 0 var(--green-dark); }
.opt.wrong { background: var(--red); color: #fff; box-shadow: 0 6px 0 #d63d4b; }
.opt:disabled { cursor: default; }

.answer-box { font-size: clamp(2.6rem, 9vw, 3.6rem); font-weight: 700; text-align: center; background: var(--card); border-radius: 20px; padding: 8px; min-height: 76px; box-shadow: inset 0 0 0 3px var(--line); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.key { border: 0; border-radius: 18px; padding: 16px 0; font-size: 1.9rem; font-weight: 700; background: var(--card); box-shadow: 0 5px 0 var(--line); }
.key:active { transform: translateY(4px); box-shadow: none; }
.key.ok { background: var(--green); color: #fff; box-shadow: 0 5px 0 var(--green-dark); }
.key.del { background: #f3eee4; }

.praise {
  position: absolute; top: -18px; left: 50%; transform: translateX(-50%); background: var(--yellow);
  padding: 6px 18px; border-radius: 999px; font-weight: 700; font-size: 1.3rem; white-space: nowrap;
  animation: rise .9s forwards; pointer-events: none;
}
@keyframes rise { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.7); } 25% { opacity: 1; transform: translate(-50%, 0) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -30px); } }
.points-pop { position: absolute; right: 18px; top: 14px; color: var(--green); font-weight: 700; font-size: 1.5rem; animation: rise .9s forwards; }

/* Explicación con puntos: a filas de b */
.dots { display: inline-grid; gap: 4px; margin-top: 12px; }
.dots i { width: 14px; height: 14px; border-radius: 50%; background: var(--purple); display: block; }
.explain { font-size: 1.2rem; color: var(--muted); margin-top: 6px; }

/* ---------- Granja ---------- */
.farm-scene { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; font-size: clamp(2rem, 7vw, 3rem); }
.farm-scene .plus { font-size: 2.4rem; font-weight: 700; color: var(--orange); align-self: center; padding: 0 8px; }
.farm-scene .group { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; max-width: 46%; }
.farm-scene .sleep { opacity: .35; position: relative; }
.farm-scene .sleep::after { content: '💤'; position: absolute; font-size: .45em; right: -6px; top: -6px; opacity: 1; }
.farm-scene .counted { position: relative; animation: pop .3s; }
.farm-scene .counted b { position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%); font-size: .9rem; background: var(--yellow); border-radius: 999px; padding: 0 6px; }
.levels { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.level-btn { border: 3px solid var(--line); background: #fff; border-radius: 18px; padding: 10px 18px; font-size: 1.1rem; font-weight: 600; }
.level-btn.sel { border-color: var(--green); background: #e9f9f1; }
.collection { display: flex; flex-wrap: wrap; gap: 8px; font-size: 2.2rem; }
.collection .locked { filter: grayscale(1) brightness(1.6); opacity: .35; }

/* ---------- Resultado ---------- */
.result { text-align: center; display: grid; gap: 14px; justify-items: center; }
.stars { font-size: 3.4rem; letter-spacing: 6px; }
.stars .off { filter: grayscale(1); opacity: .3; }
.stars span { display: inline-block; animation: pop .5s backwards; }
.stars span:nth-child(2) { animation-delay: .2s; }
.stars span:nth-child(3) { animation-delay: .4s; }
.big-score { font-size: 3rem; font-weight: 700; color: var(--green-dark); }
.prize { font-size: 4rem; animation: float 2s ease-in-out infinite; }

/* ---------- Mi progreso: gráfico diario ---------- */
.daily-chart { margin: 0; }
.daily-chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.daily-chart .axis { stroke: var(--line); stroke-width: 2; }
.daily-chart .bar { fill: var(--green); }
.daily-chart .bar-empty { fill: var(--gray); }
.daily-chart .day { cursor: pointer; outline: none; }
.daily-chart .day:hover .bar, .daily-chart .day.sel .bar, .daily-chart .day:focus-visible .bar { fill: var(--green-dark); }
.daily-chart .day:focus-visible .hit { fill: rgba(47, 182, 124, .08); }
.daily-chart .val { font-size: 13px; font-weight: 700; fill: var(--ink); }
.daily-chart .lbl { font-size: 12px; fill: var(--muted); }
.daily-chart .today .lbl { font-weight: 700; fill: var(--ink); }
.daily-chart .pct { font-size: 11px; fill: var(--ink); }
.chart-detail { color: var(--muted); font-size: .95rem; margin-top: 8px; min-height: 1.4em; }
.chart-table summary { color: var(--muted); cursor: pointer; margin-top: 6px; font-size: .9rem; }
.chart-table table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: .95rem; }
.chart-table th, .chart-table td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); }

/* Mejores y peores tablas */
.best-worst { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.best-worst h3 { font-size: 1.15rem; }
.tlist { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.tlist li { display: flex; align-items: center; gap: 10px; background: #faf6ee; border-radius: 14px; padding: 8px 12px; }
.tlist .tnum { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; color: #fff; }
.tlist .good .tnum { background: var(--green); }
.tlist .bad .tnum { background: var(--orange); }
.tlist .tname { flex: 1; font-weight: 500; }
.tlist .tacc { font-weight: 700; }
.tag { background: #ffe3e6; color: #b3263a; border-radius: 999px; padding: 1px 8px; font-size: .8rem; font-weight: 600; }

/* ---------- Multiplicaciones grandes ---------- */
.world.grandes { background: linear-gradient(135deg, #ff8a3d, #ff5d6c); }
.method { text-align: left; border: 0; display: grid; gap: 4px; padding: 20px; }
.method .num { font-size: 1.6rem; font-weight: 700; color: var(--purple); }
.method h3 { margin: 0; font-size: 1.35rem; }
.method p { margin: 0; color: var(--muted); }
.steps { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; text-align: left; }
.steps li { background: #faf6ee; border-radius: 14px; padding: 10px 14px; font-size: 1.15rem; animation: pop .3s; }
.steps li.cur { outline: 3px solid var(--purple); background: #f2eeff; }
.steps li.ok b { color: var(--green-dark); }
.steps li.bad b { color: var(--red); }
.steps li .hint { display: block; color: var(--muted); font-size: .95rem; margin-top: 2px; }
.lesson-step { font-size: clamp(1.3rem, 4vw, 1.7rem); font-weight: 600; }
.ayudita { color: var(--purple); font-weight: 600; font-size: 1.15rem; min-height: 1.6em; }
.explain-box { background: #fff4d1; border-radius: 16px; padding: 12px 16px; text-align: left; font-size: 1.1rem; line-height: 1.6; margin-top: 10px; }

/* Tiras de papel */
.tiras-card { background: #fffaf0; border: 3px dashed var(--orange); box-shadow: none; }
.tiras-card .num { color: var(--orange); }
.question.tira { min-height: 0; place-items: stretch; text-align: left; }
.enunciado { font-size: clamp(1.1rem, 3.4vw, 1.35rem); line-height: 1.5; margin: 0; font-weight: 500; }
.campos { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.campo { border: 3px solid var(--line); background: var(--card); border-radius: 18px; padding: 8px 12px; display: grid; gap: 2px; text-align: center; }
.campo.active { border-color: var(--purple); background: #f2eeff; }
.campo-label { font-size: .9rem; color: var(--muted); font-weight: 600; }
.campo-val { font-size: clamp(1.8rem, 7vw, 2.4rem); font-weight: 700; min-height: 1.2em; }
.explain-box.good { background: #e9f9f1; }
.nsp { border: 3px solid var(--red); color: #b3263a; }

/* ---------- Formas de multiplicar ---------- */
.world.formas { background: linear-gradient(135deg, #3ea8ff, #2fb67c); }
.board-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; overflow-x: auto; max-width: 100%; }
.board-wrap.preview { padding: 14px; }
.lesson-now { font-size: clamp(1.25rem, 4.2vw, 1.6rem); font-weight: 600; line-height: 1.4; min-height: 3.2em; border-left: 6px solid var(--purple); }
.lesson-history summary { cursor: pointer; font-weight: 600; color: var(--muted); }
.step-now { font-size: clamp(1.3rem, 5vw, 1.8rem); font-weight: 700; margin-top: 12px; color: var(--purple); }
.step-now.bad { color: var(--red); }
.step-now .hint { display: block; color: var(--muted); font-size: 1rem; font-weight: 500; margin-top: 2px; }

/* Cuenta en columna */
.col-board { display: inline-grid; gap: 2px; font-size: clamp(1.9rem, 8vw, 2.6rem); font-weight: 700; font-variant-numeric: tabular-nums; }
.col-row { display: grid; grid-template-columns: repeat(var(--cols), 1.2em); justify-content: end; }
.col-row.line { border-bottom: 4px solid var(--ink); padding-bottom: 3px; margin-bottom: 3px; }
.cell { height: 1.3em; display: grid; place-items: center; border-radius: 10px; }
.carries .cell { height: 1em; font-size: .55em; color: var(--orange); }
.cell.got { color: var(--green-dark); animation: pop .3s; }
.cell.fix { color: var(--red); }
.cell.ph { color: #b9b3c9; }
.cell.sign { color: var(--muted); }
.cell.cur { background: #f2eeff; outline: 3px solid var(--purple); color: var(--purple); }

/* Descomposición */
.dec-board { display: grid; gap: 8px; font-size: clamp(1.3rem, 5.2vw, 1.9rem); font-weight: 600; text-align: left; font-variant-numeric: tabular-nums; }
.dec-line { animation: pop .3s; white-space: nowrap; }
.slot { display: inline-block; min-width: 1.8em; padding: 0 .25em; border-radius: 10px; text-align: center; }
.slot.empty { border-bottom: 3px dashed #d7cdb9; }
.slot.cur { background: #f2eeff; outline: 3px solid var(--purple); color: var(--purple); }
.slot.got { color: var(--green-dark); }
.slot.fix { color: var(--red); }

/* La caja */
.area-board { display: grid; gap: 6px; width: 100%; max-width: 520px; }
.ahead { display: grid; place-items: center; font-weight: 700; font-size: clamp(1.1rem, 4vw, 1.4rem); color: var(--purple); padding: 2px 8px; }
.acell { display: grid; place-items: center; align-content: center; border-radius: 14px; background: #eaf6ff; border: 3px solid #bfe1ff; font-size: clamp(1.25rem, 5vw, 1.8rem); font-weight: 700; text-align: center; line-height: 1.1; }
.acell small { display: block; font-size: .55em; color: var(--muted); font-weight: 600; }
.acell.cur { border-color: var(--purple); background: #f2eeff; color: var(--purple); }
.acell.got { background: #e9f9f1; border-color: #a6e3c6; color: var(--green-dark); animation: pop .3s; }
.acell.fix { background: #ffe9ec; border-color: #ffb8c0; color: var(--red); }
.area-sum { font-size: clamp(1.15rem, 4.5vw, 1.6rem); font-weight: 600; text-align: center; }

/* ---------- Sumas y restas ---------- */
.world.cuentas { background: linear-gradient(135deg, #ffc93c, #ff8a3d); }
.desafio-card { background: #fff6e6; border: 3px dashed var(--orange); box-shadow: none; }
.desafio-card .num { color: var(--orange); }
.cuenta-q { font-size: clamp(1.9rem, 8vw, 3.2rem); }
.escalon-txt { font-weight: 600; margin-top: 4px; }
.hud:has(#vidas) { flex-wrap: wrap; justify-content: center; }
.pl0 { --pl: #1f9d63; } .pl1 { --pl: #2f80d8; } .pl2 { --pl: #7a55e6; } .pl3 { --pl: #e0701f; }

/* Columna: canje de la resta */
.col-board .cell { position: relative; }
.cell.tach { color: #b9b3c9; text-decoration: line-through; text-decoration-thickness: 3px; text-decoration-color: var(--red); }
.carries .cell.canje { color: var(--orange); font-size: .7em; }
.cell .lend { position: absolute; left: -.05em; top: -.05em; font-size: .45em; color: var(--orange); font-weight: 800; }
.carries .cell .lend { font-size: .6em; top: -.35em; left: -.15em; }

/* Flechitas */
.splits { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: center; gap: 6px 14px; }
.split { display: grid; grid-template-columns: repeat(var(--n), auto); justify-content: center; column-gap: 8px; row-gap: 0; text-align: center; font-variant-numeric: tabular-nums; }
.split-num { grid-column: 1 / -1; font-size: clamp(1.6rem, 6.5vw, 2.2rem); font-weight: 700; }
.split-num.ghost { display: none; }
.desarme .split-arrow { display: none; }
.split-arrow { font-size: clamp(1.1rem, 4.5vw, 1.5rem); color: var(--muted); line-height: 1; }
.split-part { font-size: clamp(1.05rem, 4.4vw, 1.4rem); font-weight: 700; color: var(--pl); border-radius: 10px; padding: 0 .2em; }
.split-part.cur { background: #f2eeff; outline: 3px solid var(--purple); color: var(--purple); }
.split-part.got { background: #e9f9f1; }
.split-part.fix { color: var(--red); background: #ffe9ec; }
.split-part.canje { background: #fff1e2; color: var(--orange); }
.split-op { font-size: clamp(1.6rem, 6.5vw, 2.2rem); font-weight: 700; color: var(--muted); align-self: center; }
.desarme { display: grid; justify-items: center; gap: 2px; background: #fffaf0; border-radius: 14px; padding: 4px 10px; }
.desarme-tag { font-size: .8rem; font-weight: 700; color: var(--orange); text-transform: uppercase; letter-spacing: .5px; }
.dec-line[class*="pl"] { border-left: 5px solid var(--pl); padding-left: 8px; }
.dec-line.total { border-top: 3px solid var(--line); padding-top: 6px; white-space: normal; line-height: 1.5; }
.board-wrap > * { max-width: 100%; }
.board-wrap:has(.splits) { align-items: safe center; }
@media (max-width: 480px) { .split { column-gap: 5px; } .splits { column-gap: 8px; } }

/* Sumas parciales */
.parc-board { display: grid; grid-template-columns: auto auto; column-gap: 12px; font-size: clamp(1.5rem, 6.4vw, 2.2rem); font-weight: 700; font-variant-numeric: tabular-nums; }
.prow { display: contents; }
.pnum { text-align: right; padding: 1px 0; }
.prow[class*="pl"] .pnum { color: var(--pl); }
.prow.line .pnum { border-bottom: 4px solid var(--ink); padding-bottom: 3px; }
.prow.line-top .pnum { border-top: 4px solid var(--ink); padding-top: 3px; margin-top: 3px; }
.pnote { font-size: .5em; color: var(--muted); font-weight: 600; align-self: center; white-space: nowrap; }

/* Completar: saltos */
.jumps-q { font-weight: 600; color: var(--muted); text-align: center; }
.jumps { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: center; gap: 4px 2px; font-variant-numeric: tabular-nums; }
.jnode { font-size: clamp(1.3rem, 5.4vw, 1.8rem); font-weight: 700; background: #eaf6ff; border-radius: 12px; padding: 2px 10px; }
.jnode.start { background: #ffe9ec; } .jnode.end { background: #e9f9f1; }
.jump { display: inline-grid; justify-items: center; line-height: 1.1; padding: 0 2px; }
.jarc { font-size: clamp(1rem, 4.2vw, 1.3rem); font-weight: 700; color: var(--orange); }
.jarrow { font-size: 1.3rem; color: var(--muted); }

/* ---------- Padres ---------- */
.kid-report { display: grid; gap: 14px; }
.days { display: flex; gap: 4px; flex-wrap: wrap; }
.days i { width: 18px; height: 18px; border-radius: 5px; background: #eee9f5; display: block; }
.days i.on { background: var(--green); }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat { background: #faf6ee; border-radius: 16px; padding: 12px; }
.stat b { display: block; font-size: 1.6rem; }
.code-box { font-size: 1.8rem; font-weight: 700; letter-spacing: 2px; background: #faf6ee; border-radius: 16px; padding: 10px 16px; display: inline-block; }

/* ---------- Efectos ---------- */
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, calc(100% + 40px)); background: var(--ink); color: #fff;
  padding: 12px 20px; border-radius: 14px; transition: transform .3s, visibility 0s .3s; z-index: 60; max-width: calc(100% - 32px);
  visibility: hidden;
}
.toast.show { transform: translate(-50%, 0); visibility: visible; transition: transform .3s; }

/* ---------- Tablas: racha, escalones y misión ---------- */
.play { position: relative; }
.question .praise { font-size: 1.5rem; padding: 6px 22px; }
.hud .pill.streak { transition: transform .2s, background .2s, color .2s; }
.hud .pill.streak.hot { background: #ffe1c8; color: #b4480b; transform: scale(1.08); }
.hud .pill.streak.fire { background: var(--red); color: #fff; animation: beat .9s ease-in-out infinite; }
.hud .pill.streak.bump { animation: bump .45s; }
.hud .pill.streak.fire.bump { animation: bump .45s, beat .9s ease-in-out .45s infinite; }
.hud .pill.streak.drop { animation: drop .5s; }
@keyframes beat { 50% { transform: scale(1.14); } }
@keyframes bump { 40% { transform: scale(1.45) rotate(-4deg); } }
@keyframes drop { 30% { transform: scale(.7); opacity: .5; } }
.hud .pill.clock { font-variant-numeric: tabular-nums; }
.hud .pill.clock.hurry { background: #ffe3e6; color: #b3263a; }

.tier-banner {
  position: absolute; left: 50%; top: 34px; transform: translateX(-50%); z-index: 5; pointer-events: none;
  background: linear-gradient(135deg, var(--yellow), var(--orange)); color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.18);
  font-size: clamp(1.8rem, 7vw, 2.6rem); font-weight: 700; padding: 6px 26px; border-radius: 999px; white-space: nowrap;
  box-shadow: 0 8px 22px rgba(255, 138, 61, .35); animation: tier 1.3s forwards;
}
.tier-banner.fire { background: linear-gradient(135deg, var(--orange), var(--red)); }
.tier-banner.record { background: linear-gradient(135deg, var(--purple), var(--blue)); }
.tier-banner.info { background: var(--ink); font-size: clamp(1.1rem, 4vw, 1.4rem); }
@keyframes tier {
  0% { opacity: 0; transform: translate(-50%, 12px) scale(.6); }
  18% { opacity: 1; transform: translate(-50%, 0) scale(1.12); }
  30% { transform: translate(-50%, 0) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -24px) scale(.95); }
}

/* Desafío y Contrarreloj: el recuadro de la cuenta tiene alto fijo para que el teclado no salte al fallar. */
.play.timed .question { height: 190px; min-height: 0; overflow: hidden; }
.play.timed .your-answer { margin-top: 0; }
.countdown { font-size: clamp(4rem, 18vw, 7rem); font-weight: 700; color: var(--orange); animation: pop .5s; }
.streak-lost { font-weight: 700; color: #b4480b; background: #ffe1c8; border-radius: 999px; padding: 4px 14px; display: inline-block; margin-bottom: 6px; }
.your-answer { font-size: 1.25rem; margin-top: 4px; }
.your-answer s { color: var(--red); }
.your-answer b { color: var(--green-dark); }
.dot-rows { display: inline-grid; gap: 4px; margin-top: 12px; }
.dot-row { display: flex; align-items: center; gap: 4px; }
.dot-row i { width: 14px; height: 14px; border-radius: 50%; background: var(--purple); display: block; }
.dot-row span { margin-left: 8px; font-size: .95rem; font-weight: 600; color: var(--muted); min-width: 2em; text-align: left; }

.mission { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; border: 3px solid var(--orange); background: #fff7ef; flex-wrap: wrap; }
.mission.ok { border-color: var(--green); background: #f0fbf5; }
.mission-icon { font-size: 2.6rem; }
.mission-text { flex: 1; display: grid; min-width: 180px; }
.mission-text b { font-size: 1.25rem; }
.mission-text span { color: var(--muted); }
.table-btn { position: relative; }
.badge-weak { position: absolute; top: -8px; right: -6px; font-size: 1.3rem; background: #fff; border-radius: 50%; width: 32px; height: 32px; display: grid; place-items: center; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.badge-weak[hidden] { display: none; }

.record-line { color: var(--purple); font-size: 1.1rem; margin: 0; }
.medal-line { background: #fff4d1; border: 3px solid var(--yellow); border-radius: 16px; padding: 8px 14px; font-size: 1.15rem; margin: 0; }
.medals { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 12px; }
.medal { display: grid; justify-items: center; gap: 4px; background: #fff4d1; border-radius: 16px; padding: 12px; text-align: center; }
.medal span { font-size: 2.6rem; }
.medal.locked { background: #f3eee4; }
.medal.locked span { filter: grayscale(1); opacity: .4; }
.medal small { color: var(--muted); }
.all-good { background: #e9f9f1; border-radius: 14px; padding: 10px 14px; font-weight: 600; margin: 0; }
.all-good-go { margin-top: 8px; }
.fail-list.rest { background: #eaf4ff; }
.dot-rows.hint { opacity: .85; margin-top: 8px; }
.dot-rows.hint + .explain { font-size: 1rem; }
.levels-row { margin-top: -4px; }
.tab.small { padding: 4px 12px; font-size: .9rem; }
.play.timed .question .praise { top: 8px; }
.recovered-line { background: #fff4d1; border-radius: 14px; padding: 8px 14px; font-weight: 600; margin: 0; }
.btn.secondary.sel { box-shadow: 0 5px 0 var(--green-dark); border: 3px solid var(--green); }
.tag { white-space: nowrap; }
@media (max-width: 480px) { .play.timed .hud .pill.title { display: none; } }
.cheer { font-weight: 600; color: var(--ink); }
.fail-list { width: 100%; background: #fff7ef; border-radius: 16px; padding: 12px; display: grid; gap: 10px; text-align: left; }
.fact-chip { display: inline-block; background: #fff; border: 2px solid var(--orange); border-radius: 999px; padding: 2px 10px; font-weight: 700; margin: 2px; }
.tlink { display: flex; align-items: center; gap: 10px; width: 100%; text-decoration: none; color: inherit; }
.tlist li:has(.tlink) { padding: 0; }
.tlist .tlink { padding: 8px 12px; }
.tgo { color: var(--orange); font-weight: 700; font-size: .9rem; }

@media (max-width: 720px) {
  .hero { grid-template-columns: 1fr; text-align: center; padding-top: 8px; }
  .hero .row { justify-content: center; }
  .hero-art { order: -1; }
  .features { grid-template-columns: 1fr; }
  .avatars { grid-template-columns: repeat(4, 1fr); }
  .table-picker { grid-template-columns: repeat(3, 1fr); }
  .brand { font-size: 1.15rem; }
  /* El gráfico de 14 días se achica a la mitad en celular: letras más grandes en unidades del SVG. */
  .daily-chart .lbl { font-size: 22px; }
  .daily-chart .pct { font-size: 18px; }
  .daily-chart .val { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Contrarreloj: cronómetro con una decimal, "+5 s" por error y botón bloqueado sin la medalla Leyenda. */
.hud .pill.stopwatch { position: relative; min-width: 6.2em; text-align: center; }
.hud .pill.stopwatch.penalty { animation: penalty .6s; }
@keyframes penalty { 0%, 100% { background: var(--card); } 30% { background: #ffe3e6; color: #b3263a; transform: scale(1.1); } }
.penalty-pop { position: absolute; left: 50%; top: 100%; transform: translateX(-50%); color: var(--red); font-weight: 700; font-size: 1.2rem; pointer-events: none; animation: penaltyPop 1.1s forwards; z-index: 5; }
@keyframes penaltyPop { 0% { opacity: 0; transform: translate(-50%, -6px); } 20% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, 18px); } }
.penalty-note { color: var(--red); font-weight: 600; }
.goal-line { font-size: 1.15rem; font-weight: 600; margin: 0; }
.mode.contra { width: 100%; border: 3px solid var(--purple); }
.mode.contra.locked { border-color: transparent; background: #f3eee4; cursor: not-allowed; }
.mode.contra.locked h3, .mode.contra.locked .emoji { opacity: .55; }
.mission-streak { margin-top: 4px; font-weight: 600; color: #b4480b !important; }
.new-medals { display: grid; gap: 8px; width: 100%; }
.new-medals:empty { display: none; }
.medal-line.new { animation: pop .5s; }
.logro-stats .stat b { font-size: 1.4rem; }
.parent-medals { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.parent-medals li { background: #fff4d1; border-radius: 999px; padding: 4px 12px 4px 8px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.parent-medals li span { font-size: 1.3rem; }
.parent-medals small { color: var(--muted); font-weight: 400; }

/* Recompensas: medidor de 5 seguidas, estrellas ganadas, cofres, títulos, medallero y álbum. */
.hud .pill.meter { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; }
.meter .dots { display: inline-flex; gap: 3px; }
.meter .dots i { width: 9px; height: 9px; border-radius: 50%; background: #e8e1d3; display: block; transition: background .2s, transform .2s; }
.meter .dots i.on { background: var(--yellow); box-shadow: 0 0 0 1px #e0a800 inset; transform: scale(1.1); }
.meter b { font-size: .9rem; }
.hud .pill.meter.pop { animation: bump .5s; }
.hud .pill.meter.drop { animation: drop .5s; }
.meter-pop { position: absolute; left: 50%; top: 100%; transform: translateX(-50%); font-weight: 700; color: #b37f00; white-space: nowrap; pointer-events: none; z-index: 5; animation: penaltyPop 1.1s forwards; }
.rewards { width: 100%; display: grid; gap: 8px; background: #fffaf0; border: 2px dashed var(--yellow); border-radius: 16px; padding: 12px; }
.stars-earned { margin: 0; font-size: 1.3rem; font-weight: 700; }
.stars-earned small { display: block; font-size: .85rem; font-weight: 500; color: var(--muted); }
.rw-row { display: grid; grid-template-columns: 32px 1fr; align-items: center; column-gap: 8px; text-align: left; }
.rw-icon { font-size: 1.5rem; grid-row: span 2; text-align: center; }
.rw-bar { height: 12px; background: #efe8da; border-radius: 999px; overflow: hidden; }
.rw-fill { height: 100%; background: linear-gradient(90deg, var(--yellow), var(--orange)); border-radius: 999px; transition: width .6s; }
.rw-bar-label { font-size: .9rem; color: var(--muted); }
.rw-bar-label b { color: var(--ink); }
.chest-wait { margin: 0; font-weight: 600; }
.chest-open { display: grid; justify-items: center; gap: 4px; }
.chest-open p { margin: 0; }
.chest { font-size: 3rem; animation: chestOpen 1s ease-out; }
@keyframes chestOpen { 0% { transform: scale(.4) rotate(-12deg); } 40% { transform: scale(1.25) rotate(8deg); } 70% { transform: scale(.95) rotate(-4deg); } 100% { transform: scale(1); } }
.stickers-new { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.sticker-new { display: grid; justify-items: center; background: #fff; border: 3px solid var(--yellow); border-radius: 14px; padding: 6px 12px; font-weight: 700; animation: pop .6s; }
.sticker-new span { font-size: 2.4rem; }
.title-up, .album-done { margin: 0; font-weight: 700; color: var(--purple); font-size: 1.15rem; }
.hub-buttons { gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.medallero-top .stat b { font-size: 1.4rem; }
.medallero-top .rw-row { margin-top: 10px; }
.small-note { margin: 10px 0 0; font-size: .9rem; }
.album-count { font-size: 1rem; font-weight: 500; }
.album { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.sticker { display: grid; justify-items: center; gap: 2px; background: #fff4d1; border-radius: 14px; padding: 8px 4px; text-align: center; }
.sticker span { font-size: 2.2rem; line-height: 1.1; }
.sticker small { font-size: .8rem; font-weight: 600; }
.sticker.missing { background: #f3eee4; }
.sticker.missing span { color: #c9bfae; font-weight: 700; }
@media (max-width: 480px) { .hud { gap: 6px; } .hud .pill { padding: 6px 10px; } .hud .pill.meter { padding: 6px 8px; } .meter .dots i { width: 7px; height: 7px; } }
.medallero-top .stat-row { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 480px) { .medallero-top .stat { padding: 10px 8px; font-size: .85rem; } .medallero-top .stat b { font-size: 1.1rem; } }
.sticker.missing { position: relative; }
.sticker.missing .silhouette { filter: brightness(0); opacity: .14; }
.sticker.missing b { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); font-size: 1.3rem; color: #a99e8a; }
.medal-group + .medal-group { margin-top: 16px; }
.medal-group h3 { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin: 0 0 8px; }
.medal-count { font-size: .9rem; font-weight: 600; color: var(--muted); background: #f3eee4; border-radius: 999px; padding: 2px 10px; }

/* Formas de dividir: la cuenta de dividir (dividendo | caja del divisor con el cociente), aproximaciones y partes. */
.world.dividir { background: linear-gradient(135deg, #8b6cff, #ff6cb5); }
.dt-board { display: inline-flex; align-items: flex-start; font-size: clamp(1.7rem, 7.2vw, 2.4rem); font-weight: 700; font-variant-numeric: tabular-nums; }
.dt-left { display: grid; gap: 2px; padding-right: 8px; }
.dt-row { display: grid; grid-template-columns: repeat(var(--cols), 1.05em); }
.dt-row .cell { text-align: center; min-height: 1.15em; }
.dt-row .cell.u { border-bottom: 3px solid var(--ink); }
.dt-row .cell.sign { color: var(--muted); }
.dt-row .cell.got { color: var(--green-dark); }
.dt-row .cell.fix { color: var(--red); }
.dt-row .cell { border-radius: 0; }
.dt-row .cell.bajo { color: var(--orange); }
.dt-row .cell.bajo.nuevo { animation: bajar .5s ease-out; }
@keyframes bajar { from { transform: translateY(-1.2em); opacity: 0; } to { transform: none; opacity: 1; } }
.dt-row .cell.cur, .dt-q.cur { background: #f2eeff; outline: 3px solid var(--purple); color: var(--purple); border-radius: 8px; }
.dt-right { border-left: 4px solid var(--ink); padding-left: 10px; }
.dt-div { border-bottom: 4px solid var(--ink); padding: 0 6px 2px; min-width: 2.2em; }
.dt-coc { display: flex; gap: 2px; padding: 2px 6px 0; min-height: 1.2em; }
.dt-q { min-width: .7em; text-align: center; }
.dt-q.got { color: var(--green-dark); }
.dt-q.fix { color: var(--red); }
.div-fin { display: grid; gap: 2px; text-align: center; font-size: clamp(1rem, 4.2vw, 1.25rem); background: #e9f9f1; border-radius: 14px; padding: 8px 14px; animation: pop .4s; }
.div-fin span { color: var(--muted); font-weight: 600; }
.div-answer { font-size: clamp(1.15rem, 4.8vw, 1.6rem); font-weight: 600; margin-top: 4px; }
.div-answer .ans.asking { background: #f2eeff; outline: 3px solid var(--purple); border-radius: 8px; padding: 0 .3em; }
.apx-board .pnote { font-size: .55em; }
.apx-ch { color: var(--pl); font-weight: 700; }
.split-part.sobra { color: var(--muted); background: #f3eee4; }

/* Descomposición: renglones del reparto (qué entra, qué se separa y cuánto queda). */
.reparto { display: grid; gap: 4px; text-align: left; font-size: clamp(.95rem, 3.9vw, 1.2rem); font-weight: 600; margin: 4px 0 6px; font-variant-numeric: tabular-nums; }
.rep-line { border-left: 4px solid var(--pl, var(--line)); padding: 2px 0 2px 8px; }
.rep-line.muted { color: var(--muted); border-left-color: var(--line); }
.rep-line.nuevo { animation: pop .35s; background: #f6f2ff; border-radius: 0 8px 8px 0; }
