/* ============ Fuente local (Nunito variable 600–900) ============ */
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 600 900;
  font-display: swap;
  src: url("fonts/nunito-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 600 900;
  font-display: swap;
  src: url("fonts/nunito-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ============ Tokens ============ */
/* Tema oscuro (por defecto) */
:root {
  color-scheme: dark;
  --bg: #131f24;
  --bg-glass: rgba(19, 31, 36, .86);
  --surface: #1a2a31;
  --surface-hover: #20323a;
  --line: #37464f;
  --text: #f1f7fb;
  --text-strong: #ffffff;
  --text-soft: #dce6ec;
  --muted: #52656d;
  --muted-2: #afafaf;
  --hover: rgba(255, 255, 255, .06);
  --node-locked: #37464f;
  --node-locked-icon: 1;
  --nav-active-bg: rgba(28, 176, 246, .12);
  --nav-active-border: #1899d6;
  --shadow: rgba(0, 0, 0, .45);
  --character-off: grayscale(1) brightness(.45);
  --focus: #84d8ff;
  --bar-label: #946f00;

  --green: #00cd9c;
  --green-dark: #00a47d;
  --pink: #ff86d0;
  --blue: #1cb0f6;
  --blue-dark: #1899d6;
  --blue-light: #84d8ff;
  --orange: #ff9600;
  --red: #ff4b4b;
  --yellow: #ffc800;
  --unit: var(--green);

  --nav-h: 72px;
  --top-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "Nunito", system-ui, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

/* Tema claro (lo activa app.js según la preferencia guardada o la del sistema) */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --bg-glass: rgba(255, 255, 255, .88);
  --surface: #f7f7f7;
  --surface-hover: #f0f0f0;
  --line: #e5e5e5;
  --text: #4b4b4b;
  --text-strong: #3c3c3c;
  --text-soft: #777777;
  --muted: #afafaf;
  --muted-2: #777777;
  --hover: rgba(0, 0, 0, .04);
  --node-locked: #e5e5e5;
  --node-locked-icon: .45;
  --nav-active-bg: #ddf4ff;
  --nav-active-border: #84d8ff;
  --shadow: rgba(0, 0, 0, .14);
  --character-off: grayscale(1) opacity(.3);
  --focus: #1cb0f6;
  --bar-label: #b58b00;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--line) transparent; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-weight: 700;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
/* Transición suave al cambiar de tema (solo mientras dura el cambio) */
html.theme-anim, html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after {
  transition: background-color .3s var(--ease), border-color .3s var(--ease), color .3s var(--ease) !important;
}
::selection { background: color-mix(in srgb, var(--blue) 30%, transparent); }
img { display: block; user-select: none; -webkit-user-drag: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
ul { list-style: none; margin: 0; padding: 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 12px; }

/* ============ Layout base (móvil) ============ */
.app { min-height: 100dvh; }

.main {
  padding: calc(var(--top-h) + 8px) 16px calc(var(--nav-h) + var(--safe-b) + 24px);
}
.path-col { max-width: 592px; margin: 0 auto; }

/* ---- Top bar de stats ---- */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 30;
  height: var(--top-h);
  padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-glass);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.stats { display: flex; align-items: center; justify-content: space-between; gap: 4px; width: 100%; max-width: 592px; margin: 0 auto; }
.stat {
  display: flex; align-items: center; gap: 8px;
  padding: 8px; border-radius: 12px;
  font-size: 15px; font-weight: 800;
  font-variant-numeric: tabular-nums;
  transition: background-color .15s, transform .1s;
}
.stat:hover { background: var(--hover); }
.stat:active { transform: scale(.96); }
.stat img { height: 28px; width: auto; }
.stat--streak { color: var(--orange); }
.stat--gems { color: var(--blue); }
.stat--errors { color: var(--red); }
.stat--errors svg { width: 26px; height: 26px; }
.stat--errors:disabled { color: var(--muted-2); cursor: default; background: none; transform: none; }

/* Botón de tema: sol en oscuro, luna en claro */
.theme-toggle { width: 44px; height: 44px; justify-content: center; padding: 0; color: var(--muted-2); }
.theme-toggle svg { width: 24px; height: 24px; transition: transform .4s var(--ease); }
.theme-toggle:hover svg { transform: rotate(-20deg); }
.theme-toggle .i-moon { display: none; }
:root[data-theme="light"] .theme-toggle .i-sun { display: none; }
:root[data-theme="light"] .theme-toggle .i-moon { display: block; }

/* ---- Navegación ---- */
.nav {
  position: fixed; z-index: 40;
  inset: auto 0 0 0;
  height: calc(var(--nav-h) + var(--safe-b));
  padding: 0 8px var(--safe-b);
  background: var(--bg-glass);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 2px solid var(--line);
}
.nav__logo { display: none; }
.nav__list { display: flex; height: 100%; align-items: center; justify-content: space-around; }
.nav__item a {
  display: flex; align-items: center; gap: 20px;
  padding: 6px; border-radius: 12px;
  border: 2px solid transparent;
  color: var(--muted-2);
  font-size: 15px; letter-spacing: .8px; text-transform: uppercase;
  transition: background-color .15s, border-color .15s, color .15s;
}
.nav__item a:hover { background: var(--hover); }
.nav__item img { width: 32px; height: 32px; transition: transform .2s var(--ease); }
.nav__item a:hover img { transform: scale(1.08); }
.nav__label { display: none; }
.nav__item.is-active a {
  border-color: var(--nav-active-border);
  background: var(--nav-active-bg);
  color: var(--blue);
}

/* ---- Banner de sección ---- */
.banner {
  position: sticky; top: calc(var(--top-h) + 4px); z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 80px;
  padding: 14px 16px;
  margin-bottom: 8px;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(255,255,255,.12), rgba(255,255,255,0) 60%),
    var(--unit);
  border-radius: 16px;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--unit) 70%, #000);
  transition: background-color .3s var(--ease), box-shadow .3s var(--ease);
}
.banner::before {
  /* tapa el contenido que sube por detrás del banner */
  content: ""; position: absolute; z-index: -1;
  left: -16px; right: -16px; top: -20px; height: 20px; background: var(--bg);
}
.banner__eyebrow {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; opacity: .85;
}
.banner__eyebrow svg { width: 16px; height: 16px; }
.banner__title { margin: 4px 0 0; font-size: 19px; line-height: 24px; font-weight: 800; text-shadow: 0 1px 0 rgba(0,0,0,.08); }

/* ============ Camino ============ */
.unit { position: relative; padding-bottom: 32px; overflow-x: clip; }
.unit__header {
  display: flex; align-items: center; gap: 16px;
  margin: 24px 0 8px;
  color: var(--muted);
}
.unit__header::before, .unit__header::after { content: ""; flex: 1; height: 2px; border-radius: 1px; background: var(--line); }
.unit__header h2 { margin: 0; font-size: 17px; line-height: 28px; text-align: center; max-width: 70%; }
.unit:first-child .unit__header { display: none; }

/* Dirección del zigzag: alterna en cada unidad */
.unit { --dir: 1; }
.unit:nth-child(odd) { --dir: -1; }

.unit__nodes { position: relative; display: flex; flex-direction: column; align-items: center; }

/* Zigzag por posición (período de 8, amplitud 70px, medidas del original).
   Al mover o borrar un nodo en el HTML el camino se recalcula solo. */
.unit__nodes > button { position: relative; left: calc(var(--x, 0) * var(--dir) * 1px); margin-top: var(--gap, 11.9px); }
.unit__nodes > button:nth-of-type(8n+2) { --x: 44.884; }
.unit__nodes > button:nth-of-type(8n+3) { --x: 70; --gap: 20.4px; }
.unit__nodes > button:nth-of-type(8n+4) { --x: 44.884; --gap: 20.4px; }
.unit__nodes > button:nth-of-type(8n+6) { --x: -44.884; }
.unit__nodes > button:nth-of-type(8n+7) { --x: -70; --gap: 20.4px; }
.unit__nodes > button:nth-of-type(8n+8) { --x: -44.884; --gap: 20.4px; }
.unit__nodes > button:first-of-type { --gap: 24px; }
/* deja sitio al tooltip "Empezar" bajo el banner sticky */
.unit:first-child .unit__nodes > button.node--active:first-of-type { --gap: 72px; }
.unit__nodes > button.node--jump { --gap: 72px; }
.unit__line { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.unit__line path { fill: none; stroke: var(--line); stroke-width: 10; stroke-linecap: round; }

/* Nodo 3D hexagonal, como learner_app: .node__base es la pared ancha (#hex-wall)
   en --c; ::before es la tapa angosta (#hex-cap) en --lip, el rodete oscuro que
   asoma abajo; ::after es la misma tapa en --c, levantada --lift, con el ícono.
   Los <clipPath> están en index.html (polygon() no admite esquinas redondeadas). */
.node {
  --c: var(--unit);
  --lip: color-mix(in srgb, var(--c) 72%, #000);
  --lift: 7px;
  width: 72px; height: 68px;
  border-radius: 50%;
}
.node:focus-visible { outline-offset: 6px; border-radius: 50%; }
.node__base { position: absolute; inset: 0; z-index: 1; clip-path: url(#hex-wall); background: var(--c); }
.node::before, .node::after {
  content: ""; position: absolute; left: 9.7222%; right: 9.7222%; height: 61.7647%;
  clip-path: url(#hex-cap);
}
.node::before { z-index: 2; bottom: 9px; background: var(--lip); }
.node::after {
  z-index: 3; bottom: 12px;
  box-sizing: border-box; padding: 6px 14px;
  background:
    var(--icon) center / contain no-repeat content-box,
    radial-gradient(circle at 32% 26%, color-mix(in srgb, var(--c), white 30%), var(--c) 62%);
  /* recortado por el mismo clip-path: dibuja un borde que sigue el hexágono */
  box-shadow: inset 0 0 0 2px rgb(0 0 0 / 18%);
  transform: translateY(calc(var(--lift) * -1));
  transition: transform .12s ease, filter .15s;
}
.node:hover::after { filter: brightness(1.06); transform: translateY(calc(var(--lift) * -1 + 2px)); }
.node:active::after { transform: translateY(3px); }
.node--locked { --c: var(--node-locked); --lip: color-mix(in srgb, var(--node-locked) 80%, #000); }
/* velo del color de la cara sobre el ícono = opacity: var(--node-locked-icon) */
.node--locked::after {
  --veil: color-mix(in srgb, var(--c) calc((1 - var(--node-locked-icon)) * 100%), transparent);
  background: linear-gradient(var(--veil), var(--veil)) content-box, var(--icon) center / contain no-repeat content-box, var(--c);
}
.node--jump { --c: var(--pink); }

/* Nodo actual: halo hexagonal que late detrás (como learner_app). Bajado medio
   --lift porque el centro óptico del nodo incluye su rodete. */
.node__halo {
  position: absolute; inset: -9px; z-index: 0;
  clip-path: url(#hex-wall);
  background: var(--c); opacity: .35;
  transform: translateY(3.5px);
  animation: halo-pulse 1.9s ease-out infinite;
  pointer-events: none;
}
@keyframes halo-pulse { from { transform: translateY(3.5px) scale(1); opacity: .5; } to { transform: translateY(3.5px) scale(1.35); opacity: 0; } }

/* Íconos según data-icon y estado */
.node[data-icon="star"] { --icon: url("img/icons/node-star.svg"); }
.node--locked[data-icon="star"] { --icon: url("img/icons/node-star-locked.svg"); }
.node[data-icon="lab"] { --icon: url("img/microscope-white.svg"); }
.node--locked[data-icon="lab"] { --icon: url("img/microscope-locked.svg"); }
.node[data-icon="review"] { --icon: url("img/icons/node-review.svg"); }
.node--locked[data-icon="review"] { --icon: url("img/icons/node-review-locked.svg"); }
.node[data-icon="jump"] { --icon: url("img/icons/node-jump.svg"); }

.chest {
  width: 80px; height: 90px;
  background: url("img/icons/chest.svg") center / contain no-repeat;
  transition: transform .15s var(--ease);
}
.chest--locked { background-image: url("img/icons/chest-locked.svg"); }
:root[data-theme="light"] .chest--locked { opacity: .55; }
.chest:hover { transform: translateY(-2px) rotate(-2deg); }
.chest:active { transform: translateY(4px); }

/* Tooltip "EMPEZAR" / "¿SALTAR AQUÍ?" (va dentro del nodo) */
.tip {
  position: absolute; left: 50%; bottom: calc(100% + 10px); z-index: 5;
  transform: translateX(-50%);
  padding: 12px 14px;
  white-space: nowrap;
  font-size: 15px; font-weight: 800; line-height: 17px; letter-spacing: .6px; text-transform: uppercase;
  color: var(--c);
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 4px 0 var(--line);
  animation: bounce 1.2s ease-in-out infinite;
  pointer-events: none;
}
.tip::after {
  content: ""; position: absolute; left: 50%; top: 100%;
  width: 12px; height: 12px;
  background: var(--bg);
  border-right: 2px solid var(--line); border-bottom: 2px solid var(--line);
  transform: translate(-50%, -5px) rotate(45deg);
}
@keyframes bounce { 0%,100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -6px); } }

/* Personaje: se ubica en el lado opuesto a la curva del zigzag */
.character {
  position: absolute; z-index: 0; pointer-events: none;
  top: 130px; left: calc(50% - 24px * var(--dir));
  transform: translateX(calc((var(--dir) + 1) * -50%));
  width: clamp(104px, 32vw, 180px); height: auto;
  filter: drop-shadow(0 6px 0 var(--hover));
}
.character--dark { filter: var(--character-off); }

/* ============ Popover de lección ============ */
.popover {
  position: absolute; z-index: 50;
  width: min(300px, calc(100vw - 32px));
  padding: 18px;
  border-radius: 16px;
  background: var(--c, var(--green));
  color: #fff;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--c, var(--green)) 72%, #000), 0 16px 32px var(--shadow);
  animation: pop .18s var(--ease);
  transform-origin: var(--arrow, 50%) 0;
}
.popover--fixed { position: fixed; }
.popover--fixed p:last-child { margin-bottom: 0; }
.popover--locked {
  background: var(--surface); border: 2px solid var(--line); color: var(--muted-2);
  box-shadow: 0 4px 0 var(--line), 0 16px 32px var(--shadow);
}
.popover--locked h3 { color: var(--text-strong); }
.popover::before {
  content: ""; position: absolute; top: -8px; left: var(--arrow, 50%);
  width: 16px; height: 16px; background: inherit;
  transform: translateX(-50%) rotate(45deg);
  border-radius: 3px;
}
.popover--locked::before { border-left: 2px solid var(--line); border-top: 2px solid var(--line); top: -9px; }
.popover h3 { margin: 0 0 6px; font-size: 18px; font-weight: 800; }
.popover p { margin: 0 0 16px; font-size: 15px; font-weight: 600; opacity: .9; }
.btn {
  display: block; width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  font-size: 15px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase;
  text-align: center;
  background: #fff; color: var(--c, var(--green));
  box-shadow: 0 4px 0 rgba(0,0,0,.15);
  transition: transform .1s, box-shadow .1s, filter .15s;
}
.btn:hover { filter: brightness(.97); }
.btn:active { transform: translateY(4px); box-shadow: none; }
.btn--disabled { background: var(--line); color: var(--muted); box-shadow: none; pointer-events: none; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.94); } }

/* ============ Lección (medidas y colores de lesson-styles/views/*) ============ */
.lesson {
  --ok: #93d333; --ok-lip: #79b933; --bad: #ff4b4b; --bad-lip: #ea2b2b; --on-btn: #131f24;
  --field: #202f36; --fb-ok: #202f36; --fb-bad: #202f36; --streak: #ffab33;
  width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0;
  background: var(--bg); color: var(--text);
}
:root[data-theme="light"] .lesson { --ok: #58cc02; --ok-lip: #58a700; --bad-lip: #ea2b2b; --on-btn: #fff; --field: #f7f7f7; --fb-ok: #d7ffb8; --fb-bad: #ffdfe0; }
.lesson[open] { display: flex; flex-direction: column; }
.lesson::backdrop { background: var(--bg); }
html:has(.lesson[open]) { overflow: hidden; }
.lesson[data-fase]:not([data-fase="pregunta"]) .lesson__top { visibility: hidden; }
.lesson:not([data-fase="pregunta"]) .lesson__q,
.lesson:not([data-fase="fin"]) .lesson__end,
.lesson:not([data-fase="racha"]) .lesson__streak { display: none; }

/* Barra superior: cerrar, progreso y "N seguidas" */
.lesson__top { display: flex; align-items: center; gap: 24px; width: min(1000px, 100%); margin: 0 auto; padding: 48px 16px 0; }
.lesson__close { display: grid; place-items: center; width: 24px; height: 24px; color: var(--muted); }
.lesson__close svg { width: 18px; height: 18px; }
.lesson__bar { position: relative; flex: 1; height: 16px; border-radius: 8px; background: var(--line); }
.lesson__fill { position: relative; width: 0; height: 100%; border-radius: inherit; background: var(--ok); transition: width .4s var(--ease); }
.lesson__fill::after { content: ""; position: absolute; top: 4px; left: 8px; right: 8px; height: 3px; border-radius: 9999px; background: #fff; opacity: .2; }
.lesson__combo {
  position: absolute; left: 0; bottom: calc(100% + 6px); min-width: max-content;
  font-size: 13px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; text-align: center; color: var(--ok);
  animation: pop .3s var(--ease);
}
.lesson__combo:empty { display: none; }
/* Pista: se paga con gemas */
.lesson__hint {
  flex: none; display: flex; align-items: center; gap: 6px; padding: 6px 10px;
  font-size: 14px; font-weight: 800; color: var(--blue);
  border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 12px;
}
.lesson__hint img { height: 20px; width: auto; }
.lesson__hint:hover { background: var(--hover); }
.lesson__hint:disabled { color: var(--muted); filter: grayscale(1); opacity: .6; cursor: default; background: none; }

.lesson__body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
.lesson__q, .lesson__end, .lesson__streak { width: min(600px, 100%); margin: auto; padding: 24px 16px; }

/* Enunciado: cabecera del tipo de ejercicio + personaje con bocadillo */
.lesson__topic { margin: 0 0 8px; font-size: 14px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: var(--muted-2); }
.lesson__head { margin: 0 0 24px; font-size: 32px; line-height: 40px; font-weight: 800; color: var(--text-strong); }
.lesson__prompt { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.lesson__char { flex: none; width: 96px; height: 96px; object-fit: contain; }
.lesson__bubble {
  position: relative; margin: 0; padding: 10px 14px;
  font-size: 19px; line-height: 26px; font-weight: 600; color: var(--text-strong);
  border: 2px solid var(--line); border-radius: 12px; background: var(--bg);
}
.lesson__bubble::before {
  content: ""; position: absolute; left: -9px; top: 50%; width: 14px; height: 14px;
  border-left: 2px solid var(--line); border-bottom: 2px solid var(--line); background: var(--bg);
  transform: translateY(-50%) rotate(45deg);
}

/* Elegir */
.choices { display: grid; gap: 12px; }
.pairs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.choice {
  padding: 14px 16px; text-align: left; font-size: 19px; line-height: 24px; font-weight: 600;
  border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 12px;
}
.choice:hover { background: var(--hover); }
.choice:disabled { opacity: .35; text-decoration: line-through; pointer-events: none; } /* tachada con una pista */
.choice.is-picked { border-color: var(--blue-dark); color: var(--blue); background: var(--nav-active-bg); }
.choice.is-correct { border-color: var(--ok); color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.choice.is-wrong { border-color: var(--bad); color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
/* Selección múltiple: casilla en cada opción para que se vea que se pueden marcar varias */
.choices--multi .choice { display: flex; align-items: flex-start; gap: 12px; }
.choices--multi .choice::before { content: ""; flex: none; width: 24px; height: 24px; border: 2px solid var(--line); border-radius: 6px; }
.choices--multi .choice:is(.is-picked, .is-correct, .is-wrong)::before {
  border-color: currentColor;
  background: currentColor url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='white' stroke-width='3.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 16px no-repeat;
}

/* Ordenar: renglones + banco de fichas */
.answer {
  display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px 6px;
  min-height: 122px; margin-bottom: 32px; padding-top: 6px;
  background: repeating-linear-gradient(var(--line) 0 2px, transparent 2px 60px);
}
.bank { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.token {
  padding: 12px 16px; font-size: 19px; line-height: 22px; font-weight: 600; color: var(--text);
  border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 12px; background: var(--bg);
}
.token:active { transform: translateY(2px); }
.token:disabled { visibility: hidden; } /* quitada con una pista */
.token.is-used { color: transparent; border-color: var(--line); background: var(--line); pointer-events: none; }
.lesson.is-right .answer .token { color: var(--ok); }
.lesson.is-wrong .answer .token { color: var(--bad); }

/* Completar: frase con hueco + teclas de tildes */
.gapbox {
  min-height: 155px; padding: 10px 12px; font-size: 19px; line-height: 32px; font-weight: 600;
  border: 2px solid var(--line); border-radius: 10px; background: var(--field);
}
.gap {
  max-width: 100%; padding: 0 2px; font: inherit; color: var(--text-strong);
  border: 0; border-bottom: 2px solid var(--line); border-radius: 0; background: none; outline: none;
}
.gap:focus { border-bottom-color: var(--blue); }
.gap.is-correct { color: var(--ok); border-bottom-color: var(--ok); }
.gap.is-wrong { color: var(--bad); border-bottom-color: var(--bad); }
.accents { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 16px; }
.accent {
  min-width: 32px; height: 32px; padding: 0 6px; font-size: 15px; font-weight: 700; color: var(--muted);
  border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 12px;
}
.lesson__ex[inert] .accent { background: var(--line); }

/* Pie: Saltar / feedback / Comprobar-Continuar */
.lesson__foot {
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px;
  min-height: 140px; padding: 16px max(16px, calc((100% - 1000px) / 2)) calc(16px + var(--safe-b));
  border-top: 2px solid var(--line);
}
.lesson__skip, .lesson__check {
  flex: none; width: 150px; height: 50px; padding: 0 16px; border-radius: 16px;
  font-size: 17px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase;
  transition: transform .1s, filter .15s;
}
.lesson__skip { color: var(--muted); border: 2px solid var(--line); box-shadow: 0 2px 0 var(--line); }
.lesson__skip:active { transform: translateY(2px); box-shadow: none; }
.lesson__check { margin-left: auto; background: var(--ok); color: var(--on-btn); box-shadow: 0 4px 0 var(--ok-lip); }
.lesson__check:hover, .lesson__skip:hover { filter: brightness(1.05); }
.lesson__check:active { transform: translateY(4px); box-shadow: none; }
.lesson__check:disabled { background: var(--line); color: var(--muted); box-shadow: none; pointer-events: none; }
.lesson__fb { display: none; align-items: center; gap: 16px; min-width: 0; flex: 1; }
.lesson__fb-icon { flex: none; display: grid; place-items: center; width: 80px; height: 80px; border-radius: 50%; background: var(--bg); }
.lesson__fb-icon::before { content: ""; width: 40px; height: 40px; background: currentColor; -webkit-mask: var(--fb-icon) center / contain no-repeat; mask: var(--fb-icon) center / contain no-repeat; }
.lesson__fb-title { display: block; font-size: 24px; line-height: 30px; font-weight: 800; }
.lesson__fb-text { white-space: pre-line; margin: 4px 0 0; font-size: 17px; line-height: 22px; font-weight: 600; }
.lesson__fb-text:empty { display: none; }
.lesson.is-right, .lesson.is-wrong { --fb-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 12.5l5 5L20 6.5' fill='none' stroke='black' stroke-width='3.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.lesson.is-wrong { --fb-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 6l12 12M18 6L6 18' fill='none' stroke='black' stroke-width='3.6' stroke-linecap='round'/%3E%3C/svg%3E"); }
.lesson.is-right .lesson__foot, .lesson.is-wrong .lesson__foot { border-color: transparent; }
.lesson.is-right .lesson__foot { background: var(--fb-ok); }
.lesson.is-wrong .lesson__foot { background: var(--fb-bad); }
.lesson.is-right .lesson__fb, .lesson.is-wrong .lesson__fb { display: flex; }
.lesson.is-right .lesson__fb { color: var(--ok); }
.lesson.is-wrong .lesson__fb { color: var(--bad); }
.lesson.is-right .lesson__skip, .lesson.is-wrong .lesson__skip,
.lesson[data-fase]:not([data-fase="pregunta"]) .lesson__skip { display: none; }
.lesson.is-wrong .lesson__check { background: var(--bad); box-shadow: 0 4px 0 var(--bad-lip); }

/* Pantalla final: personaje, título, tarjetas de EXP y precisión */
.lesson__end { text-align: center; }
.lesson__end-char { width: 160px; height: 160px; margin: 0 auto 40px; object-fit: contain; animation: pop .5s var(--ease); }
.lesson__end-title { margin: 0 0 16px; font-size: 32px; line-height: 40px; font-weight: 800; color: var(--yellow); }
.lesson__end-sub { margin: 0 0 48px; font-size: 19px; font-weight: 600; color: var(--muted); }
.lesson__cards { display: flex; justify-content: center; gap: 16px; }
.lesson__card { --c: var(--yellow); flex: 0 1 163px; min-width: 0; padding: 0 2px 2px; border-radius: 16px; background: var(--c); }
.lesson__card--acc { --c: var(--ok); }
.lesson__card--gems { --c: var(--blue); }
.lesson__card img { height: 24px; width: auto; }
.lesson__card [data-count="gemas"]::before { content: "+"; }
.lesson__card > span { display: block; padding: 4px 0; font-size: 13px; line-height: 16px; font-weight: 800; text-transform: uppercase; color: var(--on-btn); }
.lesson__card > b {
  display: flex; align-items: center; justify-content: center; gap: 6px; height: 66px;
  border-radius: 14px; background: var(--bg); color: var(--c); font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.lesson__card svg { width: 24px; height: 24px; }
.lesson__card i { font-style: normal; }
.lesson__card [data-count="acc"]::after { content: "%"; }

/* Pantalla de racha (naranja) */
.lesson[data-fase="racha"], .lesson[data-fase="racha"] .lesson__foot { border-color: transparent; background: var(--streak); }
.lesson[data-fase="racha"] .lesson__check { background: #fff; color: var(--streak); box-shadow: 0 4px 0 #ffd8a0; }
.lesson__streak { text-align: center; color: #fff; }
.lesson__flame { width: 100px; height: 100px; margin: 0 auto; animation: latido .6s .5s; }
@keyframes latido { 50% { transform: scale(1.1); } }
.lesson__streak-n {
  display: block; margin-top: 24px; font-size: 104px; line-height: 1; font-weight: 900;
  background: linear-gradient(#fff6c4, #ffe14d); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lesson__streak h2 { margin: 4px 0 40px; font-size: 28px; line-height: 32px; font-weight: 800; color: #fff; }
.lesson__week { width: min(340px, 100%); margin: 0 auto; border: 2px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--text); overflow: hidden; }
.lesson__days { display: grid; grid-template-columns: repeat(7, 1fr); margin: 0; padding: 12px 12px 8px; list-style: none; font-size: 17px; line-height: 25px; font-weight: 800; color: var(--muted); }
.lesson__days .is-done { color: var(--streak); }
.lesson__week-bar { height: 25px; margin: 0 24px 16px; border-radius: 12.5px; background: var(--line); overflow: hidden; }
.lesson__week-bar div { height: 100%; border-radius: inherit; background: linear-gradient(270deg, #fbe56d, var(--streak)); }
.lesson__week p { margin: 0; padding: 12px 16px; border-top: 2px solid var(--line); font-size: 17px; line-height: 24px; font-weight: 600; }
.lesson__week b { color: var(--streak); }

@media (max-width: 700px) {
  .lesson__top { padding-top: 24px; }
  .lesson__head { font-size: 24px; line-height: 30px; }
  .lesson__char { width: 72px; height: 72px; }
  .lesson__foot { min-height: 0; }
  .lesson__skip { display: none; }
  .lesson__check { width: 100%; }
  .lesson__fb { flex-basis: 100%; }
  .lesson__fb-icon { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .lesson__end-char, .lesson__flame, .lesson__combo { animation: none; }
}

/* ============ Panel derecho ============ */
.side-panel { display: none; }
.card {
  padding: 20px 18px;
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: 16px;
}
.card + .card { margin-top: 16px; }
.card__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.card__head h2 { margin: 0; font-size: 20px; font-weight: 800; color: var(--text-strong); }
.card p { margin: 0; color: var(--text-soft); font-size: 16px; line-height: 24px; font-weight: 600; }

.quest { display: flex; gap: 16px; align-items: center; padding: 16px 0; }
.quest + .quest { border-top: 2px solid var(--line); }
.quest.is-done strong::after { content: " ✓"; color: var(--green); }
.quest__icon { width: 48px; flex: none; }
.quest__body { flex: 1; min-width: 0; }
.quest__body strong { display: block; font-size: 16px; line-height: 22px; margin-bottom: 10px; color: var(--text-strong); }
.bar { position: relative; display: flex; align-items: center; }
.bar__track {
  position: relative; flex: 1; height: 16px; border-radius: 8px; background: var(--line); overflow: hidden;
}
.bar__fill { position: absolute; inset: 0 auto 0 0; background: var(--yellow); border-radius: 8px; transition: width .6s var(--ease); }
.bar__fill::after { content: ""; position: absolute; left: 8px; right: 8px; top: 4px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.35); }
.bar__label { position: absolute; inset: 0; display: grid; place-items: center; font-size: 13px; font-weight: 800; color: var(--bar-label); z-index: 1; font-variant-numeric: tabular-nums; }
.bar__track.is-low .bar__label { color: var(--muted-2); }
.bar img { width: 35px; margin-left: -6px; position: relative; z-index: 1; }

.fails { margin: 8px 0 16px; padding: 0; list-style: none; }
.fails li { display: flex; gap: 12px; align-items: baseline; padding: 10px 0; font-size: 15px; line-height: 21px; color: var(--text-soft); }
.fails li + li { border-top: 2px solid var(--line); }
.fails li span { flex: 1; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fails li b { flex: none; color: var(--red); }
.fails .fails__empty { color: var(--muted-2); }
.fails__btn { background: var(--green); color: #fff; }
.fails__btn:disabled { background: var(--line); color: var(--muted); box-shadow: none; pointer-events: none; }


/* ============ Desktop: sidebar + panel derecho ============ */
@media (min-width: 1160px) {
  :root { --rail: 256px; }
  .topbar { display: none; }
  .nav {
    inset: 0 auto 0 0;
    width: var(--rail); height: 100dvh;
    padding: 24px 16px;
    background: var(--bg);
    border-top: 0; border-right: 2px solid var(--line);
  }
  .nav__logo { display: block; padding: 8px 16px 0; margin-bottom: 32px; }
  .nav__list { flex-direction: column; align-items: stretch; gap: 8px; height: auto; }
  .nav__item a { padding: 8px 16px; }
  .nav__label { display: inline; }
  .app { display: flex; justify-content: center; gap: 48px; padding-left: var(--rail); }
  .main { flex: 0 1 592px; padding: 24px 0 40px; }
  .banner { top: 24px; }
  .banner::before { top: -24px; height: 24px; }
  .banner__title { font-size: 21px; }
  .character { width: 200px; }
  .side-panel {
    display: block;
    position: sticky; top: 0; align-self: flex-start;
    flex: 0 0 368px;
    height: 100dvh; overflow-y: auto; scrollbar-width: none;
    padding: 24px 0;
  }
  .side-panel .stats { margin-bottom: 24px; }
}

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

/* ===== Intro 3D (intro.js) ===== */
.intro {
  position: fixed; inset: 0; z-index: 100;
  background: radial-gradient(ellipse at 50% 35%, #1d3a44 0%, #0b1a20 70%);
  color: #f1f7fb; font-family: var(--font);
  transition: opacity .6s ease, visibility .6s;
}
.intro.is-done { opacity: 0; visibility: hidden; pointer-events: none; }
.intro__canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.intro__canvas:active { cursor: grabbing; }
.intro__info { position: absolute; top: max(20px, env(safe-area-inset-top)); left: 20px; right: 20px; pointer-events: none; }
.intro__title { margin: 0; font-size: 22px; font-weight: 800; }
.intro__caption { margin: 4px 0 0; max-width: 34em; font-size: 15px; font-weight: 700; color: #dce6ec; text-shadow: 0 1px 4px rgba(0,0,0,.6); }
.intro__hint {
  position: absolute; left: 50%; bottom: 44px; transform: translateX(-50%); margin: 0;
  font-size: 13px; font-weight: 700; color: #84d8ff; pointer-events: none; transition: opacity .3s; text-shadow: 0 1px 4px rgba(0,0,0,.8);
}
.intro.is-touched .intro__hint { opacity: 0; }
.intro__skip {
  position: absolute; right: 20px; bottom: 28px;
  padding: 10px 18px; border-radius: 12px; border: 2px solid #37464f;
  background: rgba(19,31,36,.7); color: #f1f7fb;
  font: 800 14px var(--font); letter-spacing: .8px; text-transform: uppercase; cursor: pointer;
  box-shadow: 0 2px 0 #37464f;
}
.intro__skip:active { transform: translateY(2px); box-shadow: none; }
.intro__skip:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.intro__bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255,255,255,.08); }
.intro__bar span { display: block; height: 100%; background: var(--green); transform-origin: left; transform: scaleX(0); }

/* ============ Login (login.html) ============ */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login__box { width: 100%; max-width: 375px; display: grid; gap: 12px; }
.login__logo { margin: 0 auto 12px; }
.login h1 { margin: 0 0 12px; text-align: center; font-size: 26px; font-weight: 800; color: var(--text-strong); }
.login label { display: grid; gap: 6px; font-size: 15px; font-weight: 800; color: var(--text-soft); }
.login input {
  padding: 13px 16px; font: inherit; font-size: 17px; color: var(--text-strong);
  border: 2px solid var(--line); border-radius: 12px; background: var(--surface); outline: none;
}
.login input:focus { border-color: var(--blue); }
.login .btn { margin-top: 12px; background: var(--green); color: var(--bg); box-shadow: 0 4px 0 var(--green-dark); }
.login .btn:active { box-shadow: none; }
.login__alt { margin: 8px 0 0; text-align: center; font-size: 15px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase; color: var(--blue); }
