/* =========================================================================
   Mochi y las tildes — hoja de estilos
   Fondo celeste pastel, colores vivos y tipografia redondeada con buen
   soporte de tildes y de la letra ñ (Fredoka). La letra manuscrita (Pacifico)
   se usa solo en titulos y mensajes, nunca en las palabras que se analizan.
   ========================================================================= */

:root {
  --celeste-claro: #DCF4FD;
  --celeste: #BFE9F7;
  --celeste-hondo: #9CD9EE;

  --rosa: #FF5FA2;
  --rosa-hondo: #D93B7E;
  --verde: #45D2A4;
  --verde-hondo: #23A87E;
  --amarillo: #FFD447;
  --amarillo-hondo: #E0A800;
  --turquesa: #2AC2DC;
  --turquesa-hondo: #1795AC;
  --morado: #A56BE8;
  --morado-hondo: #7B45BC;
  --neutro: #C9DDE6;
  --neutro-hondo: #9BB8C4;

  --tinta: #234B5C;
  --tinta-suave: #4E7C8E;
  --blanco: #FFFFFF;

  --sombra-tarjeta: 0 10px 26px rgba(35, 75, 92, .14);
  --radio: 22px;

  --fuente: 'Fredoka', 'Segoe UI', 'Trebuchet MS', system-ui, sans-serif;
  --fuente-decorativa: 'Pacifico', 'Segoe Script', cursive;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

/* El mismo color de fondo en html evita franjas oscuras al hacer scroll. */
html { background-color: #BFE9F7; }

body {
  font-family: var(--fuente);
  color: var(--tinta);
  background: linear-gradient(175deg, var(--celeste-claro) 0%, var(--celeste) 55%, var(--celeste-hondo) 100%);
  background-attachment: fixed;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

button, input { font-family: inherit; }
button { touch-action: manipulation; }

/* ---------- Burbujas decorativas del fondo ---------- */
.burbujas-fondo {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(circle closest-side at 42% 38%, rgba(255,255,255,.85), rgba(255,183,214,.4) 40%, rgba(160,214,245,.3) 78%, rgba(255,255,255,0) 100%),
    radial-gradient(circle closest-side at 42% 38%, rgba(255,255,255,.85), rgba(190,200,255,.35) 40%, rgba(255,196,224,.28) 78%, rgba(255,255,255,0) 100%),
    radial-gradient(circle closest-side at 40% 34%, rgba(255,255,255,.9), rgba(178,232,247,.4) 40%, rgba(255,205,232,.28) 78%, rgba(255,255,255,0) 100%),
    radial-gradient(circle closest-side at 42% 38%, rgba(255,255,255,.85), rgba(255,222,180,.32) 40%, rgba(180,224,255,.28) 78%, rgba(255,255,255,0) 100%);
  background-repeat: no-repeat;
  background-size: 240px 240px, 150px 150px, 320px 320px, 110px 110px;
  background-position: -60px 12%, 88% 8%, 92% 72%, 8% 78%;
  opacity: .75;
}

/* ---------- Estructura ---------- */
#app {
  position: relative;
  z-index: 1;
  max-width: 1040px;
  margin: 0 auto;
  padding: clamp(10px, 2.4vw, 26px);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.pantalla { display: none; }

.pantalla.activa {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  flex: 1;
  animation: aparecer .28s ease both;
}

@keyframes aparecer {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Titulos ---------- */
.titulo-juego {
  font-family: var(--fuente-decorativa);
  font-size: clamp(2.3rem, 8.5vw, 4.1rem);
  font-weight: 400;
  line-height: 1.15;
  margin: clamp(6px, 3vw, 22px) 0 0;
  text-align: center;
  color: var(--rosa);
  text-shadow: 3px 3px 0 var(--blanco), 6px 6px 0 rgba(42, 194, 220, .35);
}

.subtitulo {
  margin: 0;
  font-size: clamp(.95rem, 3.4vw, 1.2rem);
  font-weight: 500;
  color: var(--tinta-suave);
  text-align: center;
}

.titulo-seccion {
  font-family: var(--fuente-decorativa);
  font-weight: 400;
  font-size: clamp(1.6rem, 6vw, 2.5rem);
  color: var(--turquesa-hondo);
  margin: 6px 0 2px;
  text-align: center;
  text-shadow: 2px 2px 0 var(--blanco);
}

.titulo-fin {
  font-family: var(--fuente-decorativa);
  font-weight: 400;
  font-size: clamp(1.9rem, 7vw, 3rem);
  color: var(--rosa);
  margin: 10px 0 0;
  text-align: center;
  text-shadow: 2px 2px 0 var(--blanco);
}

/* ---------- Botones ---------- */
.boton {
  border: none;
  border-radius: 999px;
  padding: .68em 1.5em;
  font-size: clamp(1rem, 3.6vw, 1.15rem);
  font-weight: 600;
  color: var(--blanco);
  background: var(--turquesa);
  box-shadow: 0 5px 0 var(--turquesa-hondo), 0 8px 16px rgba(35,75,92,.18);
  cursor: pointer;
  transition: transform .1s ease, box-shadow .1s ease, filter .15s ease;
  text-shadow: 0 1px 1px rgba(0,0,0,.12);
}

.boton:hover { filter: brightness(1.06); }

.boton:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--turquesa-hondo), 0 3px 8px rgba(35,75,92,.18);
}

.boton-grande { font-size: clamp(1.15rem, 4.6vw, 1.45rem); padding: .7em 2.1em; }

.boton-rosa      { background: var(--rosa);     box-shadow: 0 5px 0 var(--rosa-hondo),     0 8px 16px rgba(35,75,92,.18); }
.boton-rosa:active { box-shadow: 0 1px 0 var(--rosa-hondo), 0 3px 8px rgba(35,75,92,.18); }
.boton-verde     { background: var(--verde);    box-shadow: 0 5px 0 var(--verde-hondo),    0 8px 16px rgba(35,75,92,.18); }
.boton-verde:active { box-shadow: 0 1px 0 var(--verde-hondo), 0 3px 8px rgba(35,75,92,.18); }
.boton-amarillo  { background: var(--amarillo); box-shadow: 0 5px 0 var(--amarillo-hondo), 0 8px 16px rgba(35,75,92,.18); color: #6B4E00; text-shadow: none; }
.boton-amarillo:active { box-shadow: 0 1px 0 var(--amarillo-hondo), 0 3px 8px rgba(35,75,92,.18); }
.boton-turquesa  { background: var(--turquesa); }
.boton-neutro    { background: var(--neutro);   box-shadow: 0 5px 0 var(--neutro-hondo),   0 8px 16px rgba(35,75,92,.14); color: var(--tinta); text-shadow: none; }
.boton-neutro:active { box-shadow: 0 1px 0 var(--neutro-hondo), 0 3px 8px rgba(35,75,92,.14); }

.fila-botones {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 6px;
}

.boton-icono {
  border: none;
  background: rgba(255,255,255,.75);
  color: var(--tinta-suave);
  border-radius: 50%;
  width: 2.1em;
  height: 2.1em;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(35,75,92,.16);
  transition: transform .12s ease, background .15s ease;
}
.boton-icono:hover { background: var(--blanco); transform: scale(1.08); }

.boton-sonido {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 30;
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 1.3rem;
  line-height: 1;
  background: rgba(255,255,255,.85);
  box-shadow: 0 3px 10px rgba(35,75,92,.2);
  cursor: pointer;
  transition: transform .12s ease;
}
.boton-sonido:hover { transform: scale(1.08); }
.boton-sonido.apagado { filter: grayscale(1); opacity: .55; }

/* ---------- Pantalla de inicio ---------- */
.mochi-inicio {
  width: min(58vw, 250px);
  border-radius: 50%;
  border: 7px solid var(--blanco);
  box-shadow: var(--sombra-tarjeta);
  object-fit: cover;
  aspect-ratio: 1 / 1;
  animation: flotar 4s ease-in-out infinite;
}

@keyframes flotar {
  0%, 100% { transform: translateY(0) rotate(-1.5deg); }
  50%      { transform: translateY(-10px) rotate(1.5deg); }
}

#formulario-nombre {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,.82);
  padding: 18px 22px;
  border-radius: var(--radio);
  box-shadow: var(--sombra-tarjeta);
  width: min(100%, 400px);
}

#formulario-nombre label {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--tinta-suave);
}

#campo-nombre {
  width: 100%;
  border: 3px solid var(--celeste-hondo);
  border-radius: 16px;
  padding: .6em .9em;
  font-size: 1.15rem;
  font-weight: 500;
  text-align: center;
  color: var(--tinta);
  background: var(--blanco);
  outline: none;
  transition: border-color .15s ease;
}
#campo-nombre:focus { border-color: var(--rosa); }

/* ---------- Instrucciones ---------- */
.tarjeta-texto {
  background: rgba(255,255,255,.9);
  border-radius: var(--radio);
  box-shadow: var(--sombra-tarjeta);
  padding: clamp(16px, 4vw, 28px);
  max-width: 720px;
  line-height: 1.55;
  font-size: clamp(.95rem, 3.2vw, 1.05rem);
  font-weight: 400;
}

.tarjeta-texto h3 {
  font-size: 1.15rem;
  color: var(--rosa-hondo);
  margin: 18px 0 6px;
}
.tarjeta-texto h3:first-child { margin-top: 0; }
.tarjeta-texto p { margin: 0 0 8px; }

.lista-reglas { list-style: none; padding: 0; margin: 0; }
.lista-reglas li {
  margin-bottom: 12px;
  padding-left: 4px;
}

.etiqueta {
  display: inline-block;
  border-radius: 999px;
  padding: .18em .8em;
  font-weight: 600;
  font-size: .9rem;
  color: var(--blanco);
  margin-right: 6px;
}
.et-aguda         { background: var(--rosa); }
.et-grave         { background: var(--turquesa); }
.et-esdrujula     { background: var(--verde); }
.et-sobresdrujula { background: var(--morado); }

.ejemplo {
  display: inline-block;
  background: var(--celeste-claro);
  border-radius: 10px;
  padding: .1em .6em;
  margin-left: 4px;
  font-weight: 500;
  color: var(--turquesa-hondo);
}

/* ---------- Tarjetas de nivel ---------- */
.tarjetas-nivel {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  width: 100%;
}

.tarjeta-nivel {
  flex: 1 1 240px;
  max-width: 330px;
  border: none;
  border-radius: var(--radio);
  background: var(--blanco);
  box-shadow: 0 8px 0 var(--celeste-hondo), var(--sombra-tarjeta);
  padding: 22px 18px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: transform .14s ease, box-shadow .14s ease;
  color: var(--tinta);
}
.tarjeta-nivel:hover { transform: translateY(-4px); box-shadow: 0 12px 0 var(--celeste-hondo), var(--sombra-tarjeta); }
.tarjeta-nivel:active { transform: translateY(4px); box-shadow: 0 3px 0 var(--celeste-hondo), var(--sombra-tarjeta); }

.numero-nivel {
  font-family: var(--fuente-decorativa);
  font-size: 2.6rem;
  color: var(--rosa);
  line-height: 1;
}
.nombre-nivel { font-size: 1.25rem; font-weight: 600; color: var(--turquesa-hondo); }
.detalle-nivel { font-size: .95rem; font-weight: 400; color: var(--tinta-suave); }

/* ---------- Marcador del juego ---------- */
.pantalla-juego.activa { gap: 8px; }

.marcador {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 4vw, 28px);
  background: rgba(255,255,255,.8);
  border-radius: 999px;
  padding: 6px clamp(10px, 3vw, 20px);
  box-shadow: var(--sombra-tarjeta);
}

.dato { display: flex; flex-direction: column; align-items: center; line-height: 1.05; }
.dato-etiqueta { font-size: .68rem; font-weight: 500; color: var(--tinta-suave); text-transform: uppercase; letter-spacing: .04em; }
.dato-valor { font-size: clamp(1.05rem, 4.4vw, 1.4rem); font-weight: 700; color: var(--turquesa-hondo); }
.vidas { letter-spacing: 1px; }
.vidas .corazon-perdido { opacity: .25; filter: grayscale(1); }
#salir-1, #salir-2 { margin-left: auto; }

/* ---------- Barra de tiempo ---------- */
.barra-tiempo {
  width: 100%;
  height: 14px;
  background: rgba(255,255,255,.65);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(35,75,92,.14);
}

.relleno-tiempo {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--verde), var(--turquesa));
  transition: background .3s ease;
}
.relleno-tiempo.apurado { background: linear-gradient(90deg, var(--amarillo), #FF9E3D); }
.relleno-tiempo.critico { background: linear-gradient(90deg, #FF8A5B, var(--rosa)); }

/* ---------- Area de juego ---------- */
.area-juego {
  width: 100%;
  flex: 1;
  display: flex;
  gap: clamp(8px, 2.5vw, 22px);
  align-items: stretch;
}

.columna-mochi {
  flex: 0 0 auto;
  width: clamp(96px, 22vw, 210px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.columna-principal {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
}

/* ---------- Mochi y sus animaciones ---------- */
.escenario-mochi {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
}

.mochi {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 26px;
  border: 5px solid var(--blanco);
  box-shadow: var(--sombra-tarjeta);
  opacity: 0;
  transition: opacity .25s ease;
}

.escenario-mochi.contento .mochi-feliz  { opacity: 1; }
.escenario-mochi.apenado .mochi-triste  { opacity: 1; }
.escenario-mochi.contento .mochi-triste { opacity: 0; }
.escenario-mochi.apenado  .mochi-feliz  { opacity: 0; }

.escenario-mochi.celebra { animation: brinco .55s ease; }
@keyframes brinco {
  0%   { transform: translateY(0) scale(1); }
  30%  { transform: translateY(-14px) scale(1.06, .94); }
  55%  { transform: translateY(0) scale(.96, 1.04); }
  75%  { transform: translateY(-6px) scale(1.02, .98); }
  100% { transform: translateY(0) scale(1); }
}

.escenario-mochi.tiembla { animation: temblor .5s ease; }
@keyframes temblor {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px) rotate(-2deg); }
  40% { transform: translateX(6px) rotate(2deg); }
  60% { transform: translateX(-4px) rotate(-1deg); }
  80% { transform: translateX(4px) rotate(1deg); }
}

/* Croqueta que Mochi se come al acertar */
.croqueta {
  position: absolute;
  left: 45%;
  top: -14%;
  width: 18%;
  aspect-ratio: 1 / 1;
  border-radius: 42% 58% 55% 45% / 55% 45% 58% 42%;
  background: radial-gradient(circle at 34% 30%, #F2A96A, #A9541F 72%);
  border: 3px solid #FFF4E4;
  box-shadow: 0 3px 7px rgba(35, 20, 0, .3);
  opacity: 0;
  pointer-events: none;
}
.escenario-mochi.come .croqueta { animation: caer-croqueta .8s ease-in forwards; }
@keyframes caer-croqueta {
  0%   { opacity: 0; transform: translateY(-40%) scale(.5) rotate(0deg); }
  18%  { opacity: 1; transform: translateY(0) scale(1) rotate(60deg); }
  65%  { opacity: 1; transform: translateY(230%) scale(1) rotate(300deg); }
  85%  { opacity: 1; transform: translateY(262%) scale(.9) rotate(345deg); }
  100% { opacity: 0; transform: translateY(266%) scale(.15) rotate(360deg); }
}

/* Lagrima que aparece al fallar */
.lagrima {
  position: absolute;
  left: 41%;
  top: 34%;
  width: 8%;
  height: 11%;
  background: linear-gradient(180deg, #BFE9F7, #56B7DC);
  border-radius: 50% 50% 50% 50% / 68% 68% 32% 32%;
  clip-path: polygon(50% 0%, 88% 62%, 72% 96%, 28% 96%, 12% 62%);
  opacity: 0;
  pointer-events: none;
}
.escenario-mochi.llora .lagrima { animation: caer-lagrima .95s ease-in 2; }
@keyframes caer-lagrima {
  0%   { opacity: 0; transform: translateY(0) scale(.5); }
  20%  { opacity: .95; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(230%) scale(.85); }
}

/* Mano que acaricia a Mochi al acertar en el Nivel 2 */
.mano-caricia {
  position: absolute;
  left: 26%;
  top: -13%;
  width: 50%;
  aspect-ratio: 1 / 1;
  opacity: 0;
  pointer-events: none;
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 120'%3E%3Cg fill='%23F5C293' stroke='%235B3A2E' stroke-width='6' stroke-linejoin='round' stroke-linecap='round'%3E%3Crect x='23' y='40' width='17' height='58' rx='8.5'/%3E%3Crect x='42' y='40' width='17' height='66' rx='8.5'/%3E%3Crect x='61' y='40' width='17' height='63' rx='8.5'/%3E%3Crect x='80' y='40' width='17' height='53' rx='8.5'/%3E%3Crect x='92' y='42' width='16' height='42' rx='8' transform='rotate(24 100 63)'/%3E%3Crect x='19' y='14' width='82' height='44' rx='21'/%3E%3C/g%3E%3C/svg%3E");
}
.escenario-mochi.acaricia .mano-caricia { animation: acariciar 1.15s ease-in-out; }
@keyframes acariciar {
  0%   { opacity: 0; transform: translate(14%, -60%) rotate(12deg); }
  22%  { opacity: 1; transform: translate(6%, 0%) rotate(4deg); }
  40%  { opacity: 1; transform: translate(-8%, 6%) rotate(-6deg); }
  58%  { opacity: 1; transform: translate(8%, 0%) rotate(5deg); }
  76%  { opacity: 1; transform: translate(-6%, 5%) rotate(-5deg); }
  100% { opacity: 0; transform: translate(10%, -55%) rotate(10deg); }
}

/* ---------- Nivel 1: la palabra ---------- */
.instruccion-ronda {
  margin: 0;
  font-size: clamp(.9rem, 3.2vw, 1.05rem);
  font-weight: 500;
  color: var(--tinta-suave);
  text-align: center;
}

.palabra-nivel1 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: rgba(255,255,255,.94);
  border-radius: var(--radio);
  box-shadow: var(--sombra-tarjeta);
  padding: clamp(10px, 3vw, 22px) clamp(8px, 3vw, 20px);
  width: 100%;
  min-height: clamp(90px, 20vw, 140px);
}

.silaba { display: inline-flex; }

.separador-silaba {
  color: var(--celeste-hondo);
  font-size: clamp(1.6rem, 6.5vw, 3rem);
  font-weight: 700;
  padding: 0 .12em;
  align-self: center;
}

.letra {
  font-size: clamp(1.9rem, 8.2vw, 3.6rem);
  font-weight: 600;
  line-height: 1.1;
  color: var(--tinta);
  padding: 0 .02em;
}

.vocal {
  border: none;
  background: transparent;
  border-radius: 14px;
  cursor: pointer;
  padding: .06em .16em;
  color: var(--turquesa-hondo);
  transition: background .14s ease, transform .14s ease, color .14s ease;
}
.vocal:hover { background: var(--celeste-claro); transform: translateY(-3px); }
.vocal:active { transform: translateY(0); }
.vocal.acertada { background: var(--verde); color: var(--blanco); animation: brinco .5s ease; }
.vocal.errada { background: var(--rosa); color: var(--blanco); animation: temblor .45s ease; }
.vocal.correcta-revelada { background: var(--amarillo); color: #6B4E00; }

.palabra-nivel1.bloqueada .vocal { pointer-events: none; }

.boton-sin-tilde { margin-top: 2px; }

/* Marca el boton "No lleva tilde" cuando esa era la respuesta correcta. */
.boton.boton-revelado {
  background: var(--amarillo);
  color: #6B4E00;
  text-shadow: none;
  box-shadow: 0 5px 0 var(--amarillo-hondo), 0 0 0 4px rgba(255, 212, 71, .5);
  animation: latir .5s ease infinite alternate;
}

/* ---------- Retroalimentacion ---------- */
.retroalimentacion {
  width: 100%;
  min-height: 74px;
  border-radius: var(--radio);
  padding: 10px 16px;
  text-align: center;
  font-size: clamp(.88rem, 3.1vw, 1rem);
  font-weight: 500;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  opacity: 0;
  transition: opacity .2s ease;
}
.retroalimentacion.visible { opacity: 1; }
.retroalimentacion.bien { background: rgba(69, 210, 164, .22); color: #17795C; }
.retroalimentacion.mal  { background: rgba(255, 95, 162, .18); color: var(--rosa-hondo); }

.veredicto {
  font-family: var(--fuente-decorativa);
  font-size: clamp(1.15rem, 4.6vw, 1.6rem);
  line-height: 1.1;
}

.retro-oro {
  display: inline-block;
  margin-top: 2px;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--amarillo);
  color: #6B4E00;
  font-weight: 700;
  font-size: .82em;
  box-shadow: 0 2px 0 var(--amarillo-hondo);
}

.palabra-correcta { font-weight: 700; font-size: 1.7em; line-height: 1.15; }
.palabra-correcta .tilde-resaltada {
  color: var(--rosa-hondo);
  text-shadow: 0 0 1px var(--rosa-hondo);
}

/* ---------- Nivel 2: palabra y burbujas ---------- */
.fila-palabra-2 {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  justify-content: center;
}

.palabra-nivel2 {
  font-size: clamp(1.8rem, 7.5vw, 3.2rem);
  font-weight: 600;
  color: var(--tinta);
  background: rgba(255,255,255,.88);
  border-radius: var(--radio);
  box-shadow: var(--sombra-tarjeta);
  padding: .18em .7em;
  text-align: center;
  line-height: 1.25;
  max-width: 100%;
  overflow-wrap: break-word;
}

.boton-voz { font-size: 1.25rem; width: 2.2em; height: 2.2em; flex: 0 0 auto; }

.arena-burbujas {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: clamp(210px, 38vh, 360px);
  max-height: 400px;
  overflow: hidden;
  border-radius: var(--radio);
  background: linear-gradient(180deg, rgba(255,255,255,.35), rgba(255,255,255,.1));
  box-shadow: inset 0 2px 10px rgba(35,75,92,.08);
  touch-action: manipulation;
}

.burbuja {
  position: absolute;
  top: 0;
  left: 0;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
}

.globo {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-weight: 600;
  letter-spacing: .01em;
  color: #2A5566;
  hyphens: manual;
  overflow-wrap: break-word;
  line-height: 1.05;
  background:
    radial-gradient(circle at 30% 26%, rgba(255,255,255,.95) 0 6%, rgba(255,255,255,.35) 14%, rgba(255,255,255,0) 30%),
    radial-gradient(circle at 68% 74%, rgba(255,255,255,.45) 0 10%, rgba(255,255,255,0) 34%),
    radial-gradient(circle at 35% 32%, rgba(255,208,232,.85), rgba(198,224,255,.85) 42%, rgba(214,196,255,.8) 68%, rgba(255,232,214,.75) 88%);
  box-shadow:
    inset -6px -8px 16px rgba(122, 90, 160, .18),
    inset 6px 8px 16px rgba(255,255,255,.55),
    0 6px 16px rgba(35,75,92,.16);
  transition: transform .12s ease, filter .12s ease;
}

.rotulo { padding: 0 12%; }
.burbuja:hover .globo { filter: brightness(1.05); transform: scale(1.05); }
.burbuja:active .globo { transform: scale(.94); }

.burbuja.reventada { pointer-events: none; }
.burbuja.reventada .globo { animation: reventar .35s ease forwards; }
@keyframes reventar {
  0%   { transform: scale(1); opacity: 1; }
  40%  { transform: scale(1.28); opacity: .8; }
  100% { transform: scale(1.6); opacity: 0; }
}

.burbuja.correcta-revelada .globo {
  animation: latir .5s ease infinite alternate;
  box-shadow: inset -6px -8px 16px rgba(122,90,160,.18), inset 6px 8px 16px rgba(255,255,255,.55), 0 0 0 5px var(--verde), 0 6px 16px rgba(35,75,92,.16);
}
@keyframes latir {
  from { transform: scale(1); }
  to   { transform: scale(1.07); }
}

.arena-burbujas.bloqueada .burbuja { pointer-events: none; }

/* ---------- Fin del juego ---------- */
.mochi-fin {
  width: min(46vw, 190px);
  border-radius: 50%;
  border: 6px solid var(--blanco);
  box-shadow: var(--sombra-tarjeta);
  object-fit: cover;
  aspect-ratio: 1 / 1;
}

.mensaje-fin {
  font-family: var(--fuente-decorativa);
  font-size: clamp(1.1rem, 4.4vw, 1.5rem);
  color: var(--turquesa-hondo);
  text-align: center;
  margin: 0;
  max-width: 560px;
}

.resumen {
  display: flex;
  gap: clamp(12px, 5vw, 34px);
  background: rgba(255,255,255,.85);
  border-radius: var(--radio);
  box-shadow: var(--sombra-tarjeta);
  padding: 14px clamp(16px, 5vw, 34px);
}
.dato-resumen { display: flex; flex-direction: column; align-items: center; }
.numero-grande { font-size: clamp(1.5rem, 6vw, 2.2rem); font-weight: 700; color: var(--rosa); line-height: 1.1; }

.aviso-record {
  margin: 0;
  background: var(--amarillo);
  color: #6B4E00;
  font-weight: 600;
  border-radius: 999px;
  padding: .45em 1.4em;
  box-shadow: 0 4px 0 var(--amarillo-hondo);
  animation: brinco .6s ease;
}

/* ---------- Mejores puntajes ---------- */
.pestanas { display: flex; gap: 8px; }

.pestana {
  border: none;
  background: rgba(255,255,255,.6);
  color: var(--tinta-suave);
  font-weight: 600;
  font-size: 1rem;
  padding: .45em 1.3em;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.pestana.activa { background: var(--turquesa); color: var(--blanco); }

.tabla-ranking {
  list-style: none;
  counter-reset: puesto;
  margin: 0;
  padding: 10px;
  width: min(100%, 500px);
  background: rgba(255,255,255,.88);
  border-radius: var(--radio);
  box-shadow: var(--sombra-tarjeta);
}

.tabla-ranking li {
  counter-increment: puesto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: .42em .6em;
  border-radius: 12px;
  font-weight: 500;
}
.tabla-ranking li:nth-child(odd) { background: rgba(191,233,247,.4); }
.tabla-ranking li::before {
  content: counter(puesto);
  flex: 0 0 1.9em;
  height: 1.9em;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--celeste-hondo);
  color: var(--blanco);
  font-weight: 700;
  font-size: .85rem;
}
.tabla-ranking li:nth-child(1)::before { background: var(--amarillo); color: #6B4E00; }
.tabla-ranking li:nth-child(2)::before { background: #C9CFD6; }
.tabla-ranking li:nth-child(3)::before { background: #E0A46B; }
.tabla-ranking li.mio { outline: 3px solid var(--rosa); }

.nombre-ranking { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.puntaje-ranking { font-weight: 700; color: var(--turquesa-hondo); }

.tabla-vacia { text-align: center; color: var(--tinta-suave); padding: 20px; font-weight: 500; }

.nota-ranking {
  font-size: .82rem;
  color: var(--tinta-suave);
  text-align: center;
  max-width: 460px;
  margin: 0;
}

/* ---------- Movil ---------- */
@media (max-width: 640px) {
  /* En vertical, Mochi va arriba y el juego debajo, todo junto y centrado. */
  .area-juego { flex-direction: column; gap: 8px; justify-content: center; }
  .columna-mochi { width: min(38vw, 150px); align-self: center; }
  .columna-principal { flex: 0 1 auto; }
  .area-juego-2 .columna-mochi { width: min(26vw, 104px); }
  .area-juego-2 .columna-principal { flex: 1; }
  .letra { font-size: clamp(1.7rem, 9.5vw, 2.6rem); }
  .marcador { gap: 12px; }
  .retroalimentacion { min-height: 66px; }
  .arena-burbujas { max-height: 46vh; }
}

@media (max-width: 380px) {
  .dato-etiqueta { font-size: .6rem; }
}

/* Pantallas bajas y anchas (tablet acostada): Mochi mas pequeno */
@media (min-width: 641px) and (max-height: 560px) {
  .columna-mochi { width: clamp(90px, 16vw, 140px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}


/* ==========================================================================
   Enganche con los personajes de naturalab.cl
   ========================================================================== */

/* Saludo cuando el jugador entró con su personaje */
#bienvenida-personaje { text-align: center; }

.cara-jugador {
  width: 120px; height: 120px; margin: 0 auto .5rem;
  border-radius: 50%; overflow: hidden;
  background: #fff; border: 4px solid #fff;
  box-shadow: 0 6px 18px rgba(0,0,0,.12);
  display: grid; place-items: center;
}
.cara-jugador svg { width: 100%; height: 100%; }

.hola-jugador { font-size: 1.3rem; margin: 0 0 1rem; }

.aviso-cuenta {
  max-width: 26rem; margin: 1rem auto 0;
  font-size: .95rem; line-height: 1.5; text-align: center;
}
.aviso-cuenta a { display: inline-block; margin-top: .3rem; font-weight: 700; }

/* La figura de cada uno en la lista de mejores puntajes */
.cara-ranking {
  width: 46px; height: 46px; flex: none;
  border-radius: 50%; overflow: hidden; background: rgba(255,255,255,.65);
  display: grid; place-items: center;
}
.cara-ranking svg { width: 100%; height: 100%; }

/* El juego ya numera la lista con su propia medalla (counter "puesto"),
   así que aquí solo se añade la figura. */


/* Cuando se ve el enlace de volver, las pantallas de menú necesitan aire
   arriba para que no les tape el título. Las de juego no, porque ahí el
   enlace se esconde. */
#pantalla-inicio, #pantalla-niveles, #pantalla-instrucciones,
#pantalla-ranking, #pantalla-fin, #pantalla-rango { padding-top: 42px; }

.volver-sitio {
  position: fixed; top: 10px; left: 10px; z-index: 20;
  display: inline-flex; align-items: center;
  min-height: 40px; padding: .4em 1em;
  background: rgba(255,255,255,.85); color: #55606B;
  border-radius: 999px; text-decoration: none;
  font-size: .85rem; font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.volver-sitio:hover { background: #fff; color: #2B3540; }

/* Mientras se juega estorba: la salida es el botón "Parar de jugar" */
.pantalla-juego.activa ~ .volver-sitio,
body:has(.pantalla-juego.activa) .volver-sitio { display: none; }

/* ==========================================================================
   Rangos: Practicante · Mago aprendiz · Experto · Maestro
   ========================================================================== */

/* En la barra de arriba, el rango y cuánto falta para pasarlo */
.dato-rango .dato-etiqueta {
  font-weight: 700; color: var(--rosa, #E8629B); text-transform: none;
  font-size: .78rem; letter-spacing: 0;
}

/* Barra de avance del rango, bajo la del tiempo */
.barra-rango {
  height: 7px; border-radius: 999px; overflow: hidden;
  background: rgba(255,255,255,.55); margin: 4px 0 2px;
}
.relleno-rango {
  height: 100%; width: 0;
  background: linear-gradient(90deg, #7ED8C3, #4FC3E8);
  border-radius: 999px;
  transition: width .35s ease;
}

/* Botón de parar: tiene que verse, la ✕ chiquita no la encontraba nadie */
.boton-parar {
  min-height: 40px; padding: .4em 1em;
  font-size: .82rem;
  background: rgba(255,255,255,.9);
  color: #55606B;
  border: 2px solid rgba(0,0,0,.08);
  border-radius: 999px;
  white-space: nowrap;
}
.boton-parar:hover { background: #fff; color: #2B3540; }

.numero-rango { font-size: 1.15rem; line-height: 1.3; }

@media (max-width: 560px) {
  .boton-parar { padding: .34em .7em; font-size: .76rem; }
  .dato-rango .dato-etiqueta { font-size: .72rem; }
}

/* El rango alcanzado, bajo el nombre en la lista de mejores puntajes */
.rango-ranking {
  display: block;
  font-size: .72rem; font-weight: 600;
  color: #6E7A86; letter-spacing: .01em;
}


/* ==========================================================================
   "Jugando ahora": las caritas de quienes están en el juego en este momento
   ========================================================================== */
.jugando-ahora {
  flex: 0 0 auto;
  align-self: flex-start;
  background: rgba(255,255,255,.62);
  border-radius: 18px;
  padding: 10px 12px;
  min-width: 108px;
  max-width: 140px;
}

.jugando-titulo {
  margin: 0 0 8px;
  font-size: .74rem; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: #6E7A86; text-align: center;
}

.jugando-lista {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 7px;
}

.jugando-uno {
  display: flex; align-items: center; gap: 7px;
  font-size: .8rem; font-weight: 600; color: #4A5560;
}

/* El que está mirando se reconoce a sí mismo */
.jugando-yo {
  background: rgba(255,255,255,.9);
  border-radius: 999px; padding: 2px 8px 2px 2px; margin-left: -2px;
}

.jugando-cara {
  flex: none; width: 34px; height: 34px;
  border-radius: 50%; overflow: hidden;
  background: #EAF4F8;
  display: grid; place-items: center;
}
.jugando-cara svg { width: 100%; height: 100%; }

.jugando-nombre {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* En pantallas angostas se pone en fila arriba, sin nombres, para no robar
   espacio al juego. */
@media (max-width: 780px) {
  .jugando-ahora {
    order: -1; max-width: none; width: 100%;
    padding: 6px 10px;
  }
  .jugando-lista { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 5px; }
  .jugando-nombre { display: none; }
  .jugando-yo { padding: 2px; }
  .jugando-titulo { margin-bottom: 5px; }
}
