:root {
  --fondo: #10151f;
  --fondo2: #1a2233;
  --acento: #4f9d58;
  --acento2: #e4b94f;
  --texto: #f4f7fb;
  --tenue: #97a3b8;
  --ok: #4ade80;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: radial-gradient(120% 90% at 50% 0%, var(--fondo2), var(--fondo));
  color: var(--texto);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  user-select: none;
}

#app { height: 100%; display: flex; flex-direction: column; }

/* ---- escenario del nino ---- */
#escena { flex: 1; display: flex; flex-direction: column; align-items: center;
          justify-content: center; gap: 2vh; position: relative; }

#avatar {
  width: min(45vh, 64vw); height: min(45vh, 64vw);
  position: relative; display: grid; place-items: center;
  --escala-etapa: .92; transform: scale(var(--escala-etapa));
  transition: transform .3s ease;
}
#avatar[data-etapa="2"] { --escala-etapa: .97; }
#avatar[data-etapa="3"] { --escala-etapa: 1; }

#avatar-imagen {
  position: relative; z-index: 1; width: 100%; height: 100%; object-fit: contain;
  transform-origin: 50% 82%; will-change: transform;
  animation: respirar 3.4s ease-in-out infinite;
  filter: drop-shadow(0 1.2vh 1.1vh rgba(0,0,0,.35));
  pointer-events: none;
}
#avatar .aura {
  position: absolute; z-index: 0; width: 72%; height: 72%; border-radius: 50%;
  background: radial-gradient(circle, rgba(104,190,92,.24), rgba(104,190,92,0) 70%);
  opacity: .45; transform: scale(.9); transition: opacity .25s ease;
}

/* La voz solo cambia data-estado; el avatar traduce ese estado a movimiento. */
body[data-estado="escuchando"] #avatar-imagen {
  animation: escuchar 1.55s ease-in-out infinite;
}
body[data-estado="escuchando"] #avatar .aura {
  animation: aura-escucha 1.55s ease-out infinite; opacity: .8;
}
body[data-estado="hablando"] #avatar-imagen {
  animation: hablar-avatar .38s ease-in-out infinite alternate;
}
body[data-estado="hablando"] #avatar .aura { opacity: .7; }
body[data-estado="celebrando"] #avatar-imagen {
  animation: celebrar .5s cubic-bezier(.2,.75,.35,1) 4;
}
body[data-estado="celebrando"] #avatar .aura {
  animation: aura-celebra .5s ease-out 4; opacity: 1;
}

@keyframes respirar {
  0%,100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-.7%) scale(1.012); }
}
@keyframes escuchar {
  0%,100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(1%) scaleX(1.025) scaleY(.985); }
}
@keyframes hablar-avatar {
  from { transform: translateY(0) rotate(-.35deg) scaleX(1) scaleY(.99); }
  to { transform: translateY(-1.1%) rotate(.35deg) scaleX(1.012) scaleY(1.018); }
}
@keyframes celebrar {
  0%,100% { transform: translateY(0) rotate(0) scale(1); }
  45% { transform: translateY(-7%) rotate(-1.2deg) scale(1.04); }
  70% { transform: translateY(-2%) rotate(1.2deg) scale(1.02); }
}
@keyframes aura-escucha {
  from { transform: scale(.78); opacity: .65; }
  to { transform: scale(1.12); opacity: 0; }
}
@keyframes aura-celebra {
  from { transform: scale(.65); opacity: .95; }
  to { transform: scale(1.25); opacity: 0; }
}

/* La letra o el numero del que se esta hablando. Grande de verdad: tiene que
   leerse desde donde esta sentada Maria Jose, no solo desde la silla de Martin. */
#simbolo {
  display: grid; place-items: center;
  min-width: 20vh; height: 20vh; padding: 0 3vh;
  font-size: 15vh; line-height: 1; font-weight: 700;
  /* Las cifras a ancho fijo: si no, "11" y "15" bailan de tamano entre turnos. */
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: #10151f; background: linear-gradient(160deg, #f6e7a8, var(--acento2));
  border-radius: 24px; box-shadow: 0 14px 40px rgba(0,0,0,.45);
  animation: entra-simbolo .35s cubic-bezier(.2,1.3,.4,1) both;
}
@keyframes entra-simbolo {
  from { opacity: 0; transform: scale(.6) rotate(-6deg); }
  to   { opacity: 1; transform: scale(1) rotate(0); }
}

#burbuja {
  min-height: 3.2em; max-width: 88vw; text-align: center;
  font-size: clamp(18px, 3.4vh, 30px); line-height: 1.35;
  padding: 0 4vw; color: var(--texto);
}

#micro {
  width: min(17vh, 26vw); height: min(17vh, 26vw); border-radius: 50%;
  border: none; cursor: pointer;
  background: linear-gradient(160deg, var(--acento2), var(--acento));
  box-shadow: 0 0 0 0 rgba(79,157,88,.55);
  display: grid; place-items: center;
  font-size: min(7vh, 11vw);
  transition: transform .12s ease;
}
#micro:active { transform: scale(.94); }
/* Sin esto, mantener apretado en una pantalla tactil hace scroll o saca el
   menu de "copiar" en vez de abrir el microfono. */
#micro { touch-action: none; }
/* Mientras se sostiene: mas grande y con halo, para que se vea desde lejos
   que en este momento SI lo estan oyendo. */
#micro[data-hablando="1"] {
  transform: scale(1.08);
  box-shadow: 0 0 0 10px rgba(74,222,128,.25), 0 0 34px rgba(74,222,128,.55);
  animation: none;
}
#micro[data-boton="1"] { animation: none; }
/* Microfono apagado: gris y sin latido. Que se note de un vistazo que en este
   momento NADIE lo esta oyendo. */
#micro[data-apagado="1"] {
  background: rgba(255,255,255,.10);
  box-shadow: none; animation: none; filter: grayscale(1);
}
#micro[data-activo="1"] { animation: pulso 1.5s ease-out infinite; }
@keyframes pulso {
  0%   { box-shadow: 0 0 0 0 rgba(79,157,88,.5); }
  100% { box-shadow: 0 0 0 6vh rgba(79,157,88,0); }
}

/* ---- franja del adulto ---- */
#adulto {
  max-height: 24vh; overflow: hidden;
  background: rgba(0,0,0,.28); border-top: 1px solid rgba(255,255,255,.07);
  padding: 10px 14px; font-size: 13px; color: var(--tenue);
  display: flex; gap: 14px; align-items: flex-start;
}
#adulto b { color: var(--texto); font-weight: 600; }
#adulto ul { margin: 4px 0 0; padding-left: 18px; }
/* El guion es lo que Maria Jose lee mientras el tutor habla: se lleva el ancho
 * sobrante. El material es una lista corta y el resumen no existe hasta que la
 * sesion termina — con flex:1 los tres, el guion quedaba en un tercio y el
 * tercio del resumen quedaba vacio toda la sesion. */
#adulto .col { min-width: 0; }
#adulto .col:nth-child(1) { flex: 0 1 24ch; }   /* material */
#adulto .col:nth-child(2) { flex: 1 1 auto; }   /* guion: se queda con el resto */
#terminar {
  background: transparent; border: 1px solid rgba(255,255,255,.2); color: var(--tenue);
  border-radius: 10px; padding: 9px 14px; font-size: 13px; cursor: pointer;
  white-space: nowrap; align-self: center;
}

#resumen { flex: 0 0 auto; font-size: 12px; line-height: 1.5; }
#resumen b { display: block; margin-bottom: 3px; }
#resumen .plata { color: var(--acento2); font-size: 15px; font-weight: 600; }
#resumen .corte { color: #f0a3a3; }
#guion, #material { max-height: 21vh; overflow-y: auto; }
#guion { padding-left: 20px; }
#guion li { margin-bottom: 3px; }
#guion .paso { color: var(--texto); }

.oculto { display: none !important; }

#logo { position: absolute; top: 10px; left: 12px; width: 34px; height: 34px;
        opacity: .35; cursor: pointer; }

#aviso {
  position: absolute; top: 10px; right: 12px; font-size: 12px;
  background: rgba(79,157,88,.16); color: var(--acento2);
  border: 1px solid rgba(79,157,88,.35); border-radius: 999px; padding: 5px 12px;
}

/* ---- la evolucion: el premio visible de lo que Martin logro ---- */
#evolucion {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(120deg, rgba(228,185,79,.22), rgba(79,157,88,.22));
  border: 1px solid rgba(228,185,79,.5); color: var(--acento2);
  border-radius: 999px; padding: 7px 18px; font-size: 15px; font-weight: 600;
  letter-spacing: .3px; white-space: nowrap;
  animation: aparecer-banda .6s ease-out both;
}
@keyframes aparecer-banda {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* La transformacion es una clase aparte y no un data-estado: el estado de la
 * voz lo pisa (el tutor habla mientras se transforma) y el destello se cortaria. */
#avatar.transformando .aura {
  opacity: 1; animation: destello 2.4s ease-out both;
}
#avatar.transformando #avatar-imagen { animation: crecer 2.4s ease-out both; }
@keyframes destello {
  0%   { opacity: .3; transform: scale(.9); }
  35%  { opacity: 1;  transform: scale(1.5); }
  100% { opacity: .5; transform: scale(1); }
}
@keyframes crecer {
  0%   { transform: scale(1); filter: brightness(1); }
  30%  { transform: scale(1.06); filter: brightness(2.2); }
  55%  { transform: scale(.98); filter: brightness(1.4); }
  100% { transform: scale(1); filter: brightness(1); }
}

/* ---- lo que marca Maria Jose al cerrar ---- */
/* Va por encima y no en el flujo: #app es flex con overflow hidden, y una
 * seccion mas al final quedaba cortada por abajo en la tablet horizontal. */
#evaluacion {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  max-height: 82vh; overflow-y: auto;
  background: var(--fondo2); border-top: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 -18px 40px rgba(0,0,0,.45);
  padding: 12px 14px calc(14px + env(safe-area-inset-bottom)); font-size: 14px;
}
#evaluacion b { display: block; color: var(--texto); font-size: 16px; }
#evaluacion .pista { margin: 2px 0 10px; color: var(--tenue); font-size: 12px; }
#lista-evaluacion .fila {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 7px 0; border-bottom: 1px solid rgba(255,255,255,.07);
}
#lista-evaluacion .que { color: var(--texto); line-height: 1.25; }
#lista-evaluacion .que small { display: block; color: var(--tenue); font-size: 11px; }
#lista-evaluacion .marcas { display: flex; gap: 8px; flex: none; }
/* Botones grandes a proposito: se tocan con el nino encima y con prisa. */
#lista-evaluacion .marcas button {
  width: 46px; height: 40px; border-radius: 10px; font-size: 18px;
  background: transparent; color: var(--tenue);
  border: 1px solid rgba(255,255,255,.2); cursor: pointer;
}
#lista-evaluacion button[data-r="logrado"][data-elegido="1"] {
  background: rgba(74,222,128,.2); color: var(--ok); border-color: var(--ok);
}
#lista-evaluacion button[data-r="parcial"][data-elegido="1"] {
  background: rgba(228,185,79,.2); color: var(--acento2); border-color: var(--acento2);
}
#lista-evaluacion button[data-r="no"][data-elegido="1"] {
  background: rgba(255,255,255,.12); color: var(--texto); border-color: rgba(255,255,255,.5);
}
#evaluacion .botones { display: flex; gap: 10px; margin-top: 12px; }
#guardar-evaluacion {
  flex: 1; padding: 12px; border: 0; border-radius: 12px; font-size: 15px; font-weight: 600;
  background: linear-gradient(160deg, var(--acento2), var(--acento));
  color: #10151f; cursor: pointer;
}
#saltar-evaluacion {
  padding: 12px 14px; border-radius: 12px; font-size: 13px; cursor: pointer;
  background: transparent; color: var(--tenue); border: 1px solid rgba(255,255,255,.2);
}

@media (prefers-reduced-motion: reduce) {
  #avatar-imagen, #avatar .aura, #evolucion { animation: none !important; }
  #avatar-imagen { transform: none; }
}
