/* =========================================================
   LECCIÓN — pantalla de ejercicios, feedback y resultados
   ========================================================= */
.leccion {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column;
  background: var(--fondo);
  animation: aparecer .2s;
}

/* ---------- Cabecera ---------- */
.leccion-top {
  display: flex; align-items: center; gap: 16px;
  width: min(1000px, 100%); margin: 0 auto; padding: calc(24px + env(safe-area-inset-top)) 16px 8px;
}
.leccion-top .barra { flex: 1; }
.vidas { display: flex; align-items: center; gap: 6px; font-size: 20px; color: var(--rojo); min-width: 52px; }
.vidas.pierde { animation: sacudir .35s; }

/* ---------- Cuerpo ---------- */
.leccion-cuerpo { flex: 1; overflow-y: auto; overscroll-behavior: contain; display: flex; justify-content: center; padding: 24px 16px; }
.leccion-contenido { width: min(600px, 100%); display: flex; flex-direction: column; gap: 24px; animation: subir .25s ease-out; }
.ej-etiqueta { color: var(--morado); font-size: 14px; font-weight: 900; text-transform: uppercase; letter-spacing: .8px; display: flex; align-items: center; gap: 6px; }
.ej-pregunta { font-size: 26px; font-weight: 900; line-height: 1.25; }

/* ---------- Pie / feedback ---------- */
.leccion-pie { border-top: 2px solid var(--borde); transition: background .2s; }
.leccion-pie.correcto { background: var(--exito-fondo); border-color: transparent; }
.leccion-pie.incorrecto { background: var(--error-fondo); border-color: transparent; }
.pie-interno {
  width: min(1000px, 100%); margin: 0 auto; padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.pie-interno .btn { min-width: 160px; margin-left: auto; }
.feedback { display: flex; align-items: center; gap: 16px; animation: subir .2s ease-out; }
.feedback-icono {
  flex-shrink: 0; width: 64px; height: 64px; border-radius: 50%;
  display: grid; place-items: center; font-size: 34px; background: var(--superficie);
}
.feedback h3 { font-size: 22px; font-weight: 900; margin-bottom: 4px; }
.feedback p { font-size: 15px; font-weight: 700; line-height: 1.4; }
.leccion-pie.correcto .feedback, .leccion-pie.correcto .feedback h3 { color: var(--exito-texto); }
.leccion-pie.incorrecto .feedback, .leccion-pie.incorrecto .feedback h3 { color: var(--error-texto); }
.leccion-pie.incorrecto .btn { --c: var(--rojo); --c-osc: var(--rojo-oscuro); }

/* ---------- Teoría ---------- */
.teoria-cabecera { display: flex; align-items: flex-end; gap: 16px; }
.mascota { font-size: 72px; line-height: 1; animation: rebote 2.4s ease-in-out infinite; }
.burbuja {
  position: relative; flex: 1;
  padding: 14px 16px; border: 2px solid var(--borde); border-radius: var(--radio);
  font-size: 16px; font-weight: 700; line-height: 1.5;
}
.burbuja::before {
  content: ""; position: absolute; left: -10px; bottom: 18px;
  width: 16px; height: 16px; background: var(--fondo);
  border-left: 2px solid var(--borde); border-bottom: 2px solid var(--borde);
  transform: rotate(45deg);
}
.teoria-puntos { display: grid; gap: 12px; }
.teoria-punto { display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; }
.teoria-punto .emoji { font-size: 30px; flex-shrink: 0; }
.teoria-punto h4 { margin: 0 0 4px; font-size: 16px; font-weight: 900; }
.teoria-punto p { font-weight: 600; color: var(--texto-suave); line-height: 1.45; }
.teoria-punto p b { color: var(--texto); }

/* ---------- Escena con personaje ---------- */
.escena { display: flex; align-items: flex-end; gap: 14px; }
.escena-personaje { font-size: 64px; line-height: 1; }
.escena .burbuja small { display: block; font-size: 12px; color: var(--texto-suave); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 2px; }

/* ---------- Opciones ---------- */
.opciones { display: grid; gap: 12px; }
.opciones.dos-col { grid-template-columns: 1fr 1fr; }
.opcion {
  display: flex; align-items: center; gap: 14px;
  width: 100%; min-height: 60px; padding: 12px 16px;
  border: 2px solid var(--borde); border-radius: var(--radio);
  background: var(--superficie); color: var(--texto);
  box-shadow: 0 4px 0 var(--borde);
  font-size: 17px; font-weight: 700; text-align: left; line-height: 1.3;
  transition: transform .05s, background .15s, border-color .15s;
}
@media (hover: hover) {
  /* En pantallas táctiles el hover se queda «pegado» tras tocar y taparía la selección */
  .opcion:hover:not(:disabled):not(.seleccionada) { background: var(--superficie-2); }
}
.opcion:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--borde); }
.opcion .tecla {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center;
  border: 2px solid var(--borde); color: var(--texto-suave); font-size: 14px;
}
.opcion .emoji { font-size: 26px; flex-shrink: 0; }
.opcion.seleccionada { border-color: var(--sel-borde); background: var(--sel-fondo); color: var(--sel-texto); box-shadow: 0 4px 0 var(--sel-borde); }
.opcion.seleccionada .tecla { border-color: var(--sel-borde); color: var(--sel-texto); }
.opcion.correcta { border-color: var(--ok-borde); background: var(--ok-fondo); color: var(--ok-texto); box-shadow: 0 4px 0 var(--ok-borde); }
.opcion.incorrecta { border-color: var(--mal-borde); background: var(--mal-fondo); color: var(--mal-texto); box-shadow: 0 4px 0 var(--mal-borde); animation: sacudir .3s; }
.opcion:disabled { cursor: default; }
/* Verdadero / falso */
.opcion.tf { flex-direction: column; justify-content: center; gap: 6px; min-height: 120px; font-size: 18px; font-weight: 900; text-align: center; }
.opcion.tf .emoji { font-size: 40px; }
.afirmacion { font-size: 20px; font-weight: 800; line-height: 1.45; padding: 18px 20px; }

/* ---------- Completar ---------- */
.oracion { font-size: 22px; font-weight: 800; line-height: 1.9; padding: 18px 20px; }
.hueco {
  display: inline-block; min-width: 120px; padding: 0 10px; margin: 0 4px;
  border-bottom: 3px solid var(--texto-suave); text-align: center; color: var(--azul);
}
.hueco.lleno { border-bottom-color: var(--azul); }
.opciones.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.opciones.chips .opcion { width: auto; min-height: 50px; padding: 10px 18px; }

/* ---------- Emparejar ---------- */
.emparejar { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.emparejar .columna { display: grid; gap: 12px; align-content: start; }
.emparejar .opcion { justify-content: center; text-align: center; font-size: 15px; min-height: 64px; }
.emparejar .opcion.hecha { opacity: .35; box-shadow: none; transform: none; }

/* ---------- Completar la frase con fichas ---------- */
.oracion-fichas { line-height: 2.5; }
.hueco-ficha {
  display: inline-block; vertical-align: middle;
  min-width: 96px; min-height: 46px; padding: 4px 12px; margin: 2px 0;
  border: 2px dashed var(--texto-suave); border-radius: 12px;
  background: var(--superficie-2); color: var(--sel-texto);
  font: inherit; font-weight: 900; line-height: 1.3;
}
.hueco-ficha.lleno { border-style: solid; border-color: var(--sel-borde); background: var(--sel-fondo); box-shadow: 0 3px 0 var(--sel-borde); }
.hueco-ficha.bien { border-style: solid; border-color: var(--ok-borde); background: var(--ok-fondo); color: var(--ok-texto); box-shadow: 0 3px 0 var(--ok-borde); }
.hueco-ficha.mal { border-style: solid; border-color: var(--mal-borde); background: var(--mal-fondo); color: var(--mal-texto); box-shadow: 0 3px 0 var(--mal-borde); animation: sacudir .3s; }
.hueco-ficha:disabled { cursor: default; }
.banco { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.ficha {
  padding: 10px 16px; border: 2px solid var(--borde); border-radius: 14px;
  background: var(--superficie); color: var(--texto);
  box-shadow: 0 3px 0 var(--borde);
  font-size: 17px; font-weight: 700;
}
.ficha:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--borde); }
.ficha.usada { color: transparent; background: var(--bloqueado); border-color: var(--bloqueado); box-shadow: none; pointer-events: none; }
.ficha:disabled { cursor: default; }

/* ---------- Pantallas finales ---------- */
.final { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 20px; padding: 24px 16px; animation: subir .3s ease-out; }
.final .mascota { font-size: 110px; }
.final h1 { font-size: 30px; font-weight: 900; color: var(--dorado-oscuro); }
.final.sin-vidas h1 { color: var(--rojo); }
.final > p { color: var(--texto-suave); max-width: 420px; line-height: 1.5; }
.resultados { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.resultado {
  --c: var(--dorado);
  width: 130px; border: 2px solid var(--c); border-radius: var(--radio); overflow: hidden;
  background: var(--c);
}
.resultado small { display: block; padding: 6px 4px; color: #fff; font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .6px; }
.resultado b { display: block; padding: 14px 4px; background: var(--superficie); border-radius: 12px; font-size: 22px; font-weight: 900; color: var(--c); }
.resultado.azul { --c: var(--azul); }
.resultado.verde { --c: var(--verde); }
.final-acciones { display: flex; flex-direction: column; gap: 12px; width: min(360px, 100%); }

.confeti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 60; }
.confeti i {
  position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 2px;
  animation: caer linear forwards;
}
@keyframes caer { to { transform: translateY(110vh) rotate(720deg); } }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .ej-pregunta { font-size: 21px; }
  .leccion-top { padding-top: calc(14px + env(safe-area-inset-top)); gap: 12px; }
  .leccion-cuerpo { padding: 16px 16px 24px; }
  .leccion-contenido { gap: 20px; }
  .pie-interno { padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); gap: 14px; }
  .feedback p { font-size: 14px; }
  .opcion { min-height: 56px; }
  .pie-interno { flex-direction: column; align-items: stretch; }
  .pie-interno .btn { width: 100%; margin: 0; }
  .feedback-icono { width: 48px; height: 48px; font-size: 26px; }
  .feedback h3 { font-size: 19px; }
  .mascota { font-size: 56px; }
  .escena-personaje { font-size: 52px; }
  .opcion { font-size: 16px; }
  .opciones.dos-col { grid-template-columns: 1fr 1fr; }
  .oracion { font-size: 19px; }
}
