/* Kebo — paleta provisional "Fichas" (las fichas de dos colores que se usan para contar en la escuela).
   Paleta definitiva: por decidir (Brújula 12). */
:root {
  --papel: #F2F6FA;
  --cuadricula: #DCE6F0;
  --hoja: #FFFFFF;
  --tinta: #1A2B48;
  --tinta-suave: #51627F;
  --rojo: #E5484D;
  --rojo-hondo: #B9303A;
  --amarillo: #FFC53D;
  --amarillo-hondo: #D99A00;
  --verde: #12875A;
  --verde-fondo: #E2F5EC;
  --azul: #2E6BF0;
  --azul-hondo: #1F4FC0;
  --aviso-fondo: #FFF4D9;
  --borde: #C9D6E4;
  --sombra: 0 2px 0 #C2D0E0;
  --radio: 18px;
  --letra: "Lexend", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --papel: #111A28; --cuadricula: #1B2738; --hoja: #18243A; --tinta: #E9EFF7; --tinta-suave: #A3B2C9;
    --verde: #3DD598; --verde-fondo: #12372A; --azul: #6E9BFF; --azul-hondo: #4A7BEF; --aviso-fondo: #3A2F12;
    --borde: #2B3A52; --sombra: 0 2px 0 #0B111C; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --papel: #111A28; --cuadricula: #1B2738; --hoja: #18243A; --tinta: #E9EFF7; --tinta-suave: #A3B2C9;
  --verde: #3DD598; --verde-fondo: #12372A; --azul: #6E9BFF; --azul-hondo: #4A7BEF; --aviso-fondo: #3A2F12;
  --borde: #2B3A52; --sombra: 0 2px 0 #0B111C; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font: 400 18px/1.5 var(--letra);
  color: var(--tinta);
  background-color: var(--papel);
  /* Cuaderno de cuadrícula: la página es la hoja donde se hacen las cuentas. */
  background-image:
    linear-gradient(var(--cuadricula) 1px, transparent 1px),
    linear-gradient(90deg, var(--cuadricula) 1px, transparent 1px);
  background-size: 28px 28px;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
body[data-estilo="estudio"] { font-size: 17px; background-size: 18px 18px; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--azul); outline-offset: 3px; border-radius: 10px; }

/* Barra superior */
.barra {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--papel) 92%, transparent);
  backdrop-filter: blur(6px);
}
.marca { display: flex; align-items: center; gap: 8px; background: none; border: 0; padding: 4px; font-weight: 800; font-size: 22px; letter-spacing: -0.02em; }
.kebo { width: 34px; height: 34px; }
.kebo-cuerpo { fill: var(--amarillo); }
.kebo-aro { fill: none; stroke: var(--amarillo-hondo); stroke-width: 3; }
.kebo-ojo { fill: #1A2B48; }
.kebo-boca { fill: none; stroke: #1A2B48; stroke-width: 3.4; stroke-linecap: round; }
.barra-der { display: flex; align-items: center; gap: 10px; }
.racha-mini { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.racha-mini .ficha { width: 20px; height: 20px; }
.idioma {
  min-width: 52px; min-height: 40px; padding: 0 12px;
  border: 2px solid var(--borde); border-radius: 999px; background: var(--hoja); font-weight: 600; font-size: 15px;
}

main { max-width: 560px; margin: 0 auto; padding: 8px 16px 40px; outline: none; }
h1, h2 { margin: 0; line-height: 1.15; letter-spacing: -0.02em; }
h1 { font-size: 30px; font-weight: 800; }
h2 { font-size: 22px; font-weight: 700; }
p { margin: 0; }
.suave { color: var(--tinta-suave); }
.pila > * + * { margin-top: 16px; }

/* Botones */
.boton {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 60px; padding: 14px 20px;
  border: 0; border-radius: var(--radio);
  background: #2E6BF0; color: #fff; font-weight: 700; font-size: 20px;
  box-shadow: 0 4px 0 #1F4FC0;
  transition: transform .08s ease, box-shadow .08s ease;
}
.boton:active { transform: translateY(3px); box-shadow: 0 1px 0 #1F4FC0; }
.boton.verde { background: #12875A; color: #fff; box-shadow: 0 4px 0 #0B5C3D; }
.boton.claro { background: var(--hoja); color: var(--tinta); border: 2px solid var(--borde); box-shadow: var(--sombra); }
.boton:disabled { opacity: .45; cursor: default; transform: none; }
.enlace { background: none; border: 0; padding: 10px 4px; color: var(--azul); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

/* Fichas: la racha se cuenta con fichas, como en la mesa de la casa. */
.ficha { width: 36px; height: 36px; flex: none; }
.ficha .cara { fill: var(--hoja); stroke: var(--borde); stroke-width: 3; stroke-dasharray: 5 4; }
.ficha.hecha .cara { fill: var(--amarillo); stroke: var(--amarillo-hondo); stroke-dasharray: none; }
.ficha.hecha .aro { fill: none; stroke: var(--amarillo-hondo); stroke-width: 2.5; }
.ficha.hoy .cara { stroke: var(--rojo); stroke-dasharray: none; }
.ficha .marca-ok { fill: none; stroke: #1A2B48; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }

.racha {
  background: var(--hoja); border: 2px solid var(--borde); border-radius: 24px; box-shadow: var(--sombra);
  padding: 20px;
}
.racha-num { display: flex; align-items: baseline; gap: 10px; }
.racha-num strong { font-size: 64px; font-weight: 800; line-height: 1; letter-spacing: -0.04em; }
.racha-num span { font-size: 20px; font-weight: 600; }
.semana { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 16px; text-align: center; }
.semana .dia { font-size: 13px; color: var(--tinta-suave); }
.semana .ficha { width: 100%; height: auto; aspect-ratio: 1; max-width: 44px; margin: 4px auto 0; display: block; }

.reto-hoy { background: var(--hoja); border: 2px solid var(--borde); border-radius: 24px; padding: 20px; box-shadow: var(--sombra); }
.reto-hoy h2 { margin: 4px 0 6px; }
.meta-hecha { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 14px; background: var(--verde-fondo); font-weight: 600; }

.retos { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.retos button {
  width: 100%; display: flex; align-items: center; gap: 14px; text-align: left;
  padding: 14px 16px; border-radius: 16px; border: 2px solid var(--borde); background: var(--hoja);
}
.retos .estado { width: 34px; height: 34px; flex: none; }
.retos .titulo { font-weight: 600; }
.retos .detalle { font-size: 14px; color: var(--tinta-suave); }
.totales { display: flex; gap: 12px; }
.totales > div { flex: 1; background: var(--hoja); border: 2px solid var(--borde); border-radius: 16px; padding: 12px 14px; }
.totales strong { display: block; font-size: 28px; font-weight: 800; }
.totales span { font-size: 14px; color: var(--tinta-suave); }
.insignias { display: flex; flex-wrap: wrap; gap: 8px; }
.insignia { padding: 8px 12px; border-radius: 999px; background: var(--aviso-fondo); font-size: 15px; font-weight: 600; }

/* Perfiles */
.perfiles { display: grid; gap: 10px; }
.perfil { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 18px; border: 2px solid var(--borde); background: var(--hoja); text-align: left; width: 100%; }
.perfil .avatar { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 22px; color: #1A2B48; background: var(--amarillo); }
.perfil small { display: block; color: var(--tinta-suave); font-size: 14px; }
.campo { display: grid; gap: 6px; font-weight: 600; }
.campo input { min-height: 56px; padding: 0 16px; border-radius: 14px; border: 2px solid var(--borde); background: var(--hoja); font-size: 20px; }
.grados { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grados button { min-height: 72px; border-radius: 16px; border: 2px solid var(--borde); background: var(--hoja); font-weight: 700; padding: 8px; }
.grados button[aria-pressed="true"] { border-color: var(--azul); background: color-mix(in srgb, var(--azul) 12%, var(--hoja)); }

/* Reto */
.reto-cabeza { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.cerrar { width: 44px; height: 44px; flex: none; border-radius: 50%; border: 2px solid var(--borde); background: var(--hoja); font-size: 22px; line-height: 1; }
.avance { flex: 1; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.avance i { height: 12px; border-radius: 6px; background: var(--cuadricula); border: 1px solid var(--borde); }
.avance i.ok { background: var(--verde); border-color: var(--verde); }
.avance i.ahora { background: var(--amarillo); border-color: var(--amarillo-hondo); }
.pregunta { font-size: 26px; font-weight: 700; line-height: 1.25; letter-spacing: -0.01em; }
body[data-estilo="estudio"] .pregunta { font-size: 21px; font-weight: 600; }
.estandar { font-size: 14px; color: var(--tinta-suave); }

.grupos { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; padding: 6px 0; }
.grupo { display: grid; grid-template-columns: repeat(var(--col, 4), 18px); gap: 5px; padding: 10px; border: 2px dashed var(--borde); border-radius: 14px; background: var(--hoja); }
.grupo i { width: 18px; height: 18px; border-radius: 50%; background: var(--rojo); box-shadow: inset 0 -2px 0 var(--rojo-hondo); }

.opciones { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.opcion {
  min-height: 84px; border-radius: 20px; border: 2px solid var(--borde); background: var(--hoja);
  font-size: 32px; font-weight: 800; box-shadow: 0 4px 0 var(--borde);
  transition: transform .08s ease;
}
.opcion:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--borde); }
.opcion.bien { background: var(--verde-fondo); border-color: var(--verde); box-shadow: 0 4px 0 var(--verde); }
.opcion.mal { opacity: .4; text-decoration: line-through; }

.pantalla-num {
  display: flex; align-items: baseline; justify-content: center; gap: 6px;
  min-height: 72px; padding: 10px 16px; border-radius: 16px; border: 2px solid var(--borde); background: var(--hoja);
  font-size: 38px; font-weight: 700; letter-spacing: 0.02em;
}
.pantalla-num .vacio { color: var(--tinta-suave); font-weight: 400; font-size: 20px; }
.pantalla-num .sufijo { font-size: 24px; color: var(--tinta-suave); }
.teclado { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.teclado button { min-height: 56px; border-radius: 14px; border: 2px solid var(--borde); background: var(--hoja); font-size: 24px; font-weight: 600; }
.teclado .borrar { font-size: 18px; }

.respuesta-aviso { border-radius: 18px; padding: 16px; display: grid; gap: 12px; }
.respuesta-aviso.bien { background: var(--verde-fondo); }
.respuesta-aviso.casi { background: var(--aviso-fondo); }
.respuesta-aviso strong { font-size: 22px; }

/* Demuéstralo en casa */
.demuestra { background: var(--hoja); border: 2px solid var(--borde); border-radius: 24px; padding: 22px; box-shadow: var(--sombra); }
.demuestra h1 { font-size: 34px; }
.demuestra .paso { display: grid; gap: 4px; }
.demuestra .paso b { font-size: 15px; color: var(--tinta-suave); font-weight: 600; }
.frase {
  font-size: 24px; font-weight: 700; line-height: 1.3; padding: 16px 18px; border-radius: 18px;
  background: var(--amarillo); color: #1A2B48; position: relative;
}
.frase::after { content: ""; position: absolute; left: 28px; bottom: -12px; border: 12px solid transparent; border-top-color: var(--amarillo); border-bottom: 0; }

/* Resumen */
.resumen { text-align: center; }
.resumen .estrellas { font-size: 56px; font-weight: 800; letter-spacing: -0.03em; }
.voltea { animation: voltea .9s ease .2s both; transform-origin: center; }
@keyframes voltea { 0% { transform: rotateY(0) scale(.6); } 50% { transform: rotateY(90deg) scale(1.15); } 100% { transform: rotateY(0) scale(1); } }
.ficha-grande { width: 120px; height: 120px; margin: 0 auto; display: block; }

.anuncio { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (min-width: 700px) {
  main { padding-top: 24px; }
  h1 { font-size: 36px; }
}

/* ---------- M05: marcador total, mundos, guía, teclado e historial ---------- */
.marcador {
  display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center;
  background: #1A2B48; color: #fff; border-radius: 24px; padding: 18px 20px;
}
.marcador-total { display: grid; justify-items: start; line-height: 1.1; }
.marcador-total span { font-size: 14px; opacity: .8; }
.marcador-total strong { font-size: 56px; font-weight: 800; letter-spacing: -0.04em; color: var(--amarillo); }
.marcador-datos { display: grid; gap: 6px; font-size: 15px; justify-self: end; text-align: right; }
.marcador-datos b { font-size: 20px; }
:root[data-theme="dark"] .marcador, .marcador { box-shadow: 0 3px 0 #0B1426; }

.reto-hoy { border-left: 8px solid var(--c, var(--azul)); }

.mundos { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 520px) { .mundos { grid-template-columns: 1fr 1fr; } }
.mundo {
  width: 100%; height: 100%; display: flex; gap: 14px; align-items: center; text-align: left;
  padding: 14px; border-radius: 20px; border: 2px solid var(--borde); background: var(--hoja); box-shadow: var(--sombra);
}
.mundo-icono {
  flex: none; width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center;
  background: var(--c); color: #fff;
}
.mundo-icono.grande { width: 72px; height: 72px; border-radius: 20px; }
.icono { width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.mundo-icono.grande .icono { width: 44px; height: 44px; }
.mundo-texto { display: grid; gap: 2px; min-width: 0; flex: 1; }
.mundo-texto b { font-size: 19px; }
.mundo-texto > span:not(.barrita) { font-size: 14px; color: var(--tinta-suave); }
.mundo-texto small { font-size: 13px; color: var(--tinta-suave); }
.barrita { display: block; width: 100%; height: 8px; border-radius: 4px; background: var(--cuadricula); overflow: hidden; margin-top: 6px; }
.barrita i { display: block; height: 100%; background: var(--c); border-radius: 4px; }

.atras { padding-left: 0; }
.mundo-cabeza { display: flex; gap: 14px; align-items: center; }
.guia { display: grid; gap: 10px; }
.guia-nombre { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.guia-nombre b { font-size: 18px; color: var(--c); }
.guia-nombre span { font-size: 14px; color: var(--tinta-suave); }
.globo {
  position: relative; background: var(--hoja); border: 2px solid var(--c); border-radius: 18px; padding: 14px 16px; font-size: 18px; line-height: 1.4;
}
.globo::before { content: ""; position: absolute; top: -12px; left: 26px; border: 10px solid transparent; border-bottom-color: var(--c); border-top: 0; }
.retos .detalle { display: block; }
.enlaces { display: flex; flex-wrap: wrap; gap: 4px 18px; }

.opciones.texto { grid-template-columns: 1fr; }
.opciones.texto .opcion { min-height: 64px; font-size: 20px; font-weight: 600; padding: 12px 16px; text-align: left; }
.dato { background: var(--hoja); border-radius: 14px; padding: 12px 14px; border-left: 5px solid var(--c, var(--verde)); display: grid; gap: 4px; }
.dato b { font-size: 15px; color: var(--c, var(--verde)); }
.dato p { font-size: 17px; line-height: 1.45; }

/* Teclado que suena: 8 teclas, una por nota de Do a Do */
.teclado-piano { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; padding: 10px; border-radius: 18px; background: #1A2B48; touch-action: manipulation; }
.tecla {
  --h: calc(var(--n) * 38deg);
  min-height: 150px; border: 0; border-radius: 0 0 12px 12px; background: #fff; color: #1A2B48;
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 10px; font-weight: 700; font-size: 15px;
  box-shadow: inset 0 -10px 0 hsl(var(--h) 75% 58%); transition: transform .06s ease, filter .06s ease; user-select: none; -webkit-user-select: none;
}
.tecla span { pointer-events: none; }
.tecla.sonando { transform: translateY(3px); filter: brightness(.9); box-shadow: inset 0 -4px 0 hsl(var(--h) 75% 50%); }
.tecla.bien { background: var(--verde-fondo); }
.secuencia { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0; }
.secuencia li {
  min-width: 52px; padding: 8px 12px; text-align: center; border-radius: 12px; font-weight: 700;
  border: 2px solid var(--borde); background: var(--hoja); color: var(--tinta-suave);
}
.secuencia li.ahora { border-color: hsl(calc(var(--n) * 38deg) 75% 50%); color: var(--tinta); transform: scale(1.08); }
.secuencia li.ok { background: var(--verde-fondo); border-color: var(--verde); color: var(--tinta); }

.historial { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.intento { display: grid; gap: 2px; padding: 12px 14px; border-radius: 16px; background: var(--hoja); border: 2px solid var(--borde); border-left: 6px solid var(--c); }
.intento-fecha { font-size: 13px; color: var(--tinta-suave); }
.intento span { font-size: 15px; }
.intento .si { color: var(--verde); font-weight: 600; }
.intento .no { color: var(--tinta-suave); }
.resumen .total { font-size: 20px; }

main:focus, main:focus-visible { outline: none; }

/* ---------- M06: control remoto y pantalla de tele ---------- */
button:focus-visible, a.boton:focus-visible, input:focus-visible { outline: 4px solid var(--amarillo); outline-offset: 3px; box-shadow: 0 0 0 7px #1A2B48; }
a.boton { text-decoration: none; }
.tarjeta { background: var(--hoja); border: 2px solid var(--borde); border-radius: 20px; padding: 18px; }
.pasos { margin: 0; padding-left: 22px; display: grid; gap: 10px; }
.direccion { display: block; margin-top: 6px; padding: 10px 12px; border-radius: 10px; background: var(--papel); font-size: 20px; font-weight: 700; word-break: break-all; }
/* En la tele se ve de lejos: todo más grande, dos columnas y el foco muy visible (Brújula 5 y 10). */
html.tele body { font-size: 18px; background-size: 32px 32px; }
html.tele main { max-width: 1240px; padding: 8px 40px 40px; }
html.tele .barra { padding: 10px 40px; }
html.tele h1 { font-size: 32px; }
html.tele h2 { font-size: 22px; }
/* Inicio en dos columnas: a la izquierda marcador, racha y reto de hoy; a la derecha los mundos. */
html.tele .inicio { display: grid; grid-template-columns: 360px 1fr; column-gap: 28px; align-items: start; }
html.tele .inicio > * + * { margin-top: 0; }
html.tele .inicio > h1 { grid-column: 1 / -1; margin-bottom: 12px; }
html.tele .inicio > .marcador, html.tele .inicio > .racha, html.tele .inicio > .reto-hoy { grid-column: 1; margin-bottom: 14px; }
html.tele .inicio > .mundos-sec { grid-column: 2; grid-row: 2 / span 3; }
html.tele .inicio > .insignias-sec, html.tele .inicio > .enlaces { grid-column: 1 / -1; margin-top: 14px; }
html.tele .marcador-total strong { font-size: 44px; }
html.tele .racha { padding: 14px 16px; }
html.tele .racha-num strong { font-size: 44px; }
html.tele .semana .ficha { max-width: 30px; }
html.tele .mundos { grid-template-columns: 1fr 1fr; }
html.tele .mundo { padding: 12px; }
html.tele .opciones { grid-template-columns: repeat(4, 1fr); }
html.tele .opciones.texto { grid-template-columns: 1fr 1fr; }
html.tele .opcion { min-height: 84px; }
html.tele .tecla { min-height: 170px; font-size: 22px; }
html.tele .pregunta { font-size: 28px; }
html.tele .grupo i { width: 22px; height: 22px; }
html.tele button:focus, html.tele a.boton:focus, html.tele input:focus { outline: 6px solid var(--amarillo); outline-offset: 4px; box-shadow: 0 0 0 10px #1A2B48; }
html.tele .tecla:focus { transform: translateY(-6px); }
