/* =========================================================
   Juegos para aprender (js/juegos.js)
   ========================================================= */
.juego { justify-content: flex-start; gap: 16px; }
.juego > :not(.aula-fondo) { position: relative; z-index: 1; }
.juego [hidden] { display: none !important; }
.juego-barra { width: 100%; display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; }
.juego-niveles { display: inline-flex; gap: 4px; padding: 5px; border-radius: 999px; background: var(--papel); box-shadow: inset 0 0 0 2px var(--borde); }
.juego-nivel { min-height: 44px; padding: 6px 16px; border: 0; border-radius: 999px; background: none; font: inherit; font-weight: 800; color: var(--tinta); cursor: pointer; }
.juego-nivel[aria-pressed="true"] { background: var(--acento); color: #38251F; }
.juego-nivel:focus-visible { outline: 3px solid var(--foco); outline-offset: 2px; }
.juego-estrellas:empty { visibility: hidden; }
.juego-estrellas { display: inline-flex; gap: 4px; padding: 6px 12px; border-radius: 999px; background: var(--papel); box-shadow: inset 0 0 0 2px var(--borde); }
.juego-estrella svg { width: 30px; height: 30px; display: block; fill: var(--cielo-2); stroke: var(--borde); stroke-width: 1.2; transition: transform .3s; }
.juego-estrella--ganada svg { fill: var(--oro); stroke: var(--oro-borde); }
@media (prefers-reduced-motion: no-preference) { .juego-estrella--ganada:last-of-type svg, .juego-estrella--ganada svg { animation: juego-brilla .5s ease-out; } }
@keyframes juego-brilla { 40% { transform: scale(1.35) rotate(12deg); } }

.juego-inicio { flex: 1; display: grid; place-items: center; align-content: center; gap: 18px; }
.juego-inicio__nina { width: min(220px, 50vw); }
.juego-inicio__boton { min-height: 70px; font-size: 1.5rem; padding-inline: 44px; }
.juego-zona { flex: 1; width: 100%; display: flex; flex-direction: column; align-items: center; gap: clamp(12px, 2vw, 22px); }
.juego-cabeza { display: flex; align-items: center; gap: 14px; justify-content: center; max-width: 100%; }
.juego-nina { width: clamp(70px, 10vw, 110px); flex: none; }
.juego-pregunta { margin: 0; font-family: var(--f-titulo); font-weight: 700; font-size: clamp(1.5rem, 3.4vw, 2.4rem); line-height: 1.15; text-align: center; }
.juego-repetir { flex: none; }

.juego-escena { width: 100%; display: flex; justify-content: center; }
.juego-opciones { display: flex; flex-wrap: wrap; gap: clamp(10px, 2vw, 22px); justify-content: center; width: 100%; }
.juego-opcion {
  min-width: clamp(90px, 14vw, 150px); min-height: clamp(90px, 14vw, 150px); padding: 10px 14px; border: 0; border-radius: 26px;
  background: var(--papel); color: var(--tinta); box-shadow: inset 0 0 0 3px var(--borde), 0 5px 0 var(--sombra-boton);
  display: grid; place-items: center; gap: 4px; cursor: pointer; font: inherit; transition: transform .15s;
}
.juego-opcion:hover { transform: translateY(-2px); }
.juego-opcion:focus-visible { outline: 4px solid var(--foco); outline-offset: 3px; }
.juego-opcion--dibujo svg { width: clamp(70px, 12vw, 130px); height: auto; }
.juego-opcion--bien { box-shadow: inset 0 0 0 5px #3E9C68, 0 5px 0 #2D7A50; background: #E4F6EA; }
.juego-opcion--mal { opacity: .35; }
@media (prefers-reduced-motion: no-preference) {
  .juego-opcion--bien { animation: juego-salta .5s ease-out; }
  .juego-opcion--mal { animation: juego-no .4s ease-in-out; }
}
@keyframes juego-salta { 40% { transform: translateY(-12px) scale(1.06); } }
@keyframes juego-no { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
:root[data-theme="dark"] .juego-opcion--bien { background: #1F4A36; }
.juego-numero, .juego-letra { font-family: var(--f-titulo); font-weight: 700; font-size: clamp(2.6rem, 6vw, 4.2rem); line-height: 1; }
.juego-puntos { display: flex; gap: 5px; }
.juego-puntos i { width: 12px; height: 12px; border-radius: 50%; background: var(--tinta); }

/* Contar */
.juego-monton { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; max-width: 720px; padding: 14px 20px; border-radius: 26px; background: color-mix(in srgb, var(--papel) 80%, transparent); }
.juego-monton__cosa svg { width: clamp(56px, 8vw, 90px); height: auto; transform: rotate(var(--giro, 0deg)); display: block; }
.juego-monton--muchos .juego-monton__cosa svg { width: clamp(46px, 6.4vw, 72px); }
.juego-opciones--anchas .juego-opcion { min-width: min(320px, 44%); }
.juego-grupo { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; max-width: 260px; }
.juego-grupo svg { width: clamp(36px, 5vw, 54px); height: auto; }

/* Letras */
.juego-palabra { display: flex; align-items: center; gap: clamp(14px, 3vw, 36px); padding: 14px 26px; border-radius: 26px; background: color-mix(in srgb, var(--papel) 85%, transparent); }
.juego-palabra__dibujo svg { width: clamp(110px, 16vw, 180px); height: auto; display: block; }
.juego-palabra__texto { font-family: var(--f-texto); font-weight: 700; font-size: clamp(2.4rem, 6vw, 4.4rem); letter-spacing: .08em; }
.juego-palabra__hueco { display: inline-block; min-width: 1em; text-align: center; color: #3E9C68; border-bottom: 5px solid currentColor; margin-right: .06em; }

/* Series */
.juego-serie { display: flex; flex-wrap: wrap; gap: clamp(4px, 1vw, 10px); justify-content: center; padding: 14px 18px; border-radius: 26px; background: color-mix(in srgb, var(--papel) 85%, transparent); }
.juego-serie__ficha { width: clamp(52px, 8vw, 96px); aspect-ratio: 1; display: grid; place-items: center; }
.juego-serie__ficha svg { width: 100%; height: 100%; }
.juego-serie__hueco { border: 4px dashed var(--tinta-2); border-radius: 20px; font-family: var(--f-titulo); font-weight: 700; font-size: clamp(1.8rem, 4vw, 3rem); color: var(--tinta-2); }
.juego-serie__hueco--lleno { border-color: #3E9C68; border-style: solid; }

/* Sonidos */
.juego-sonido__bocadillo {
  display: inline-block; padding: 14px 30px; border-radius: 40px; background: var(--papel); box-shadow: var(--sombra), inset 0 0 0 3px var(--borde);
  font-family: var(--f-titulo); font-weight: 700; font-size: clamp(1.8rem, 4.5vw, 3rem);
}

/* Memoria */
.memoria { display: grid; gap: clamp(8px, 1.5vw, 16px); grid-template-columns: repeat(3, 1fr); width: min(100%, 560px); }
.memoria--8 { grid-template-columns: repeat(4, 1fr); width: min(100%, 680px); }
.memoria--12 { grid-template-columns: repeat(4, 1fr); width: min(100%, 680px); }
@media (min-width: 900px) { .memoria--12 { grid-template-columns: repeat(6, 1fr); width: min(100%, 980px); } }
.memoria__carta {
  position: relative; aspect-ratio: 1; padding: 0; border: 0; border-radius: 20px; cursor: pointer; perspective: 600px; background: none;
}
.memoria__dorso, .memoria__cara {
  position: absolute; inset: 0; border-radius: inherit; display: grid; place-items: center; backface-visibility: hidden;
  transition: transform .4s var(--lento);
}
.memoria__dorso { background: linear-gradient(160deg, var(--celeste-3), var(--celeste-4)); box-shadow: inset 0 0 0 3px var(--borde), 0 5px 0 var(--sombra-boton); padding: 18%; }
.memoria__dorso svg { width: 100%; height: auto; }
.memoria__cara { background: var(--papel); box-shadow: inset 0 0 0 3px var(--borde), 0 5px 0 var(--sombra-boton); transform: rotateY(180deg); padding: 10%; }
.memoria__cara svg { width: 100%; height: 100%; }
.memoria__carta--abierta .memoria__dorso { transform: rotateY(180deg); }
.memoria__carta--abierta .memoria__cara { transform: rotateY(0); }
.memoria__carta--pareja .memoria__cara { box-shadow: inset 0 0 0 5px #3E9C68, 0 5px 0 #2D7A50; }
.memoria__carta:focus-visible { outline: 4px solid var(--foco); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .memoria__dorso, .memoria__cara { transition: none; } }

/* Pantalla completa (pizarra digital) */
.juego:fullscreen { justify-content: flex-start; }
.juego:fullscreen .juego-pregunta { font-size: clamp(2rem, 6vh, 4rem); }
.juego:fullscreen .juego-opcion { min-width: 20vh; min-height: 20vh; }
.juego:fullscreen .juego-opcion--dibujo svg { width: 17vh; }
.juego:fullscreen .juego-numero, .juego:fullscreen .juego-letra { font-size: 10vh; }
.juego:fullscreen .juego-monton__cosa svg { width: 11vh; }
.juego:fullscreen .juego-serie__ficha { width: 12vh; }
.juego:fullscreen .juego-palabra__dibujo svg { width: 24vh; }
.juego:fullscreen .juego-palabra__texto { font-size: 10vh; }
.juego:fullscreen .memoria { width: min(100%, 130vh); }
.juego:fullscreen .juego-inicio__nina { width: min(42vh, 50vw); }
.juego:fullscreen .juego-inicio__boton { min-height: 9vh; font-size: clamp(1.5rem, 3.6vh, 2.4rem); padding-inline: 6vh; }
.juego:fullscreen .juego-nivel { font-size: clamp(1rem, 2.2vh, 1.4rem); min-height: 5.4vh; }
.juego:fullscreen .juego-nina { width: clamp(90px, 13vh, 150px); }

.juego-niveles-lista { margin: 10px 0 0; padding-left: 1.2em; }
.juego-niveles-lista li { margin-bottom: 4px; }
@media (max-width: 560px) {
  .juego-cabeza { flex-direction: column; gap: 6px; }
  .juego-nina { width: 64px; }
  .juego-palabra { flex-direction: column; }
}
.juego-repetir { width: 52px; height: 52px; border-radius: 50%; display: inline-grid; place-items: center; border: 0; background: var(--papel); color: var(--tinta); box-shadow: inset 0 0 0 2px var(--borde), 0 3px 0 var(--sombra-boton); cursor: pointer; }
.juego-repetir svg { width: 26px; height: 26px; }

/* Palabras que riman */
.juego-opcion__palabra { font-weight: 800; font-size: clamp(.95rem, 1.6vw, 1.2rem); line-height: 1; }
.juego-rima .juego-palabra__texto { letter-spacing: .02em; }
.juego:fullscreen .juego-opcion__palabra { font-size: 2.6vh; }

/* Puzzles de Nina (js/juegos-mas.js) */
.puzzle { position: relative; width: 100%; display: flex; flex-wrap: wrap; gap: clamp(14px, 3vw, 32px); justify-content: center; align-items: center; }
.puzzle__tablero {
  position: relative; width: min(100%, 420px); aspect-ratio: 1; flex: none; border-radius: 18px; overflow: hidden;
  background: var(--papel); box-shadow: inset 0 0 0 3px var(--borde), 0 5px 0 var(--sombra-boton);
}
.puzzle__guia { position: absolute; inset: 0; opacity: .3; filter: saturate(.5); pointer-events: none; }
.puzzle__tablero--nivel4 .puzzle__guia { opacity: .16; filter: grayscale(1); }
.puzzle__tablero--nivel5 .puzzle__guia { opacity: 0; }
.puzzle__guia svg, .puzzle__pieza svg { width: 100%; height: 100%; display: block; }
.puzzle__hueco { position: absolute; padding: 0; border: 0; background: none; box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--tinta-2) 45%, transparent); cursor: default; }
.puzzle__hueco[hidden] { display: none; }
.puzzle__tablero--eligiendo .puzzle__hueco { cursor: pointer; box-shadow: inset 0 0 0 3px var(--enlace); }
.puzzle__hueco--cerca { background: color-mix(in srgb, #3E9C68 22%, transparent); box-shadow: inset 0 0 0 4px #3E9C68; }
.puzzle__hueco:focus-visible { outline: 4px solid var(--foco); outline-offset: -4px; }
.puzzle__bandeja { flex: 1 1 260px; max-width: 560px; min-height: 120px; display: flex; flex-wrap: wrap; gap: clamp(8px, 1.6vw, 16px); justify-content: center; align-content: center; padding: 10px; border-radius: 22px; background: color-mix(in srgb, var(--papel) 55%, transparent); box-shadow: inset 0 0 0 2px var(--borde); }
.puzzle__bandeja:empty { display: none; }
.puzzle__sitio { display: block; flex: none; }
.puzzle__pieza {
  position: relative; flex: none; width: var(--pw, 100px); height: var(--ph, 100px); padding: 0; border: 0; border-radius: 10px; overflow: hidden;
  background: var(--papel); box-shadow: 0 0 0 3px #FFFFFF, 0 6px 14px rgba(29, 42, 77, .25); cursor: grab; touch-action: none;
  transform: rotate(var(--giro, 0deg)); transition: transform .15s;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.puzzle__bandeja .puzzle__pieza { width: calc(var(--pw, 100px) * var(--eb, 1)); height: calc(var(--ph, 100px) * var(--eb, 1)); }
.puzzle--6, .puzzle--9 { --eb: .75; }
@media (max-width: 700px) { .puzzle, .puzzle--6, .puzzle--9 { --eb: .62; } .puzzle { gap: 12px; } .puzzle__tablero { width: min(100%, 300px); } .puzzle__bandeja { min-height: 90px; padding: 8px; } }
.puzzle__pieza:hover { transform: rotate(0) scale(1.03); }
.puzzle__pieza:focus-visible { outline: 4px solid var(--foco); outline-offset: 4px; }
.puzzle__pieza--elegida { transform: rotate(0) scale(1.06); box-shadow: 0 0 0 4px var(--acento), 0 0 0 7px var(--tinta), 0 8px 18px rgba(29, 42, 77, .3); }
.puzzle__pieza--arrastrando { position: absolute; z-index: 5; cursor: grabbing; transform: scale(1.06); box-shadow: 0 0 0 3px #FFFFFF, 0 14px 26px rgba(29, 42, 77, .35); transition: none; }
.puzzle__pieza--vuelve { transition: left .25s ease-out, top .25s ease-out; }
.puzzle__pieza--puesta { position: absolute; z-index: 1; border-radius: 0; transform: none; box-shadow: none; cursor: default; }
.puzzle__pieza--puesta:hover { transform: none; }
@media (prefers-reduced-motion: no-preference) {
  .puzzle__pieza--puesta { animation: puzzle-clic .3s ease-out; }
  .puzzle__pieza--no { animation: juego-no .4s ease-in-out; }
  .puzzle__tablero--completo { animation: juego-salta .6s ease-out; }
}
@keyframes puzzle-clic { 50% { filter: brightness(1.15); } }
.puzzle__tablero--completo { box-shadow: inset 0 0 0 5px #3E9C68, 0 5px 0 #2D7A50; }
.puzzle__tablero--completo .puzzle__pieza--puesta { z-index: 0; }
.juego:fullscreen .puzzle { --eb: .7; }
.juego:fullscreen .puzzle__tablero { width: min(54vh, 46vw); }
.juego:fullscreen .puzzle__bandeja { max-width: 44vw; }
@media (min-width: 900px) { .puzzle { flex-wrap: nowrap; } }

/* ¿Qué falta? */
.falta { position: relative; padding: 10px; }
.falta__fila { display: flex; flex-wrap: wrap; gap: clamp(8px, 2vw, 22px); justify-content: center; padding: 16px 20px; border-radius: 26px; background: color-mix(in srgb, var(--papel) 85%, transparent); min-height: clamp(110px, 16vw, 170px); align-items: center; }
.falta__cosa { width: clamp(64px, 12vw, 130px); aspect-ratio: 1; display: grid; place-items: center; }
.falta__cosa svg { width: 100%; height: 100%; }
.falta__fila--5 .falta__cosa { width: clamp(56px, 10vw, 118px); }
.falta__cosa--hueco { border: 4px dashed var(--tinta-2); border-radius: 20px; font-family: var(--f-titulo); font-weight: 700; font-size: clamp(1.8rem, 4vw, 3rem); color: var(--tinta-2); }
@media (prefers-reduced-motion: no-preference) { .falta__cosa--vuelve { animation: juego-salta .5s ease-out; } }
.falta__cosa--vuelve { border-radius: 20px; box-shadow: inset 0 0 0 4px #3E9C68; }
.falta__nube { position: absolute; inset: -42px -26px -14px; display: grid; place-items: center; pointer-events: none; transform: translateX(-130%); opacity: 0; visibility: hidden; }
.falta__nube-forma { position: absolute; inset: 0; width: 100%; height: 100%; filter: drop-shadow(0 6px 0 var(--sombra-boton)); }
.falta__nube-forma path { fill: #FFFFFF; stroke: #B7CCDD; stroke-width: 4; vector-effect: non-scaling-stroke; }
:root[data-theme="dark"] .falta__nube-forma path { fill: #E9EEF8; }
.falta__nube-nina { position: relative; width: min(34%, 180px); margin-top: 6%; }
.falta__nube--entra { transform: none; opacity: 1; visibility: visible; transition: transform .7s cubic-bezier(.2, .8, .3, 1.1), opacity .3s; }
.falta__nube--sale { transform: translateX(130%); opacity: 0; visibility: visible; transition: transform .65s ease-in, opacity .6s ease-in; }
@media (prefers-reduced-motion: reduce) { .falta__nube--entra, .falta__nube--sale { transition: opacity .3s; transform: none; } }
.falta__ya { min-height: 60px; font-size: 1.25rem; padding-inline: 30px; }
.juego:fullscreen .falta__cosa { width: 17vh; }
.juego:fullscreen .falta__fila { min-height: 22vh; }

/* Grande, mediano, pequeño */
.tam { display: flex; align-items: flex-end; justify-content: center; width: clamp(80px, 13vw, 150px); aspect-ratio: 1; }
.tam svg { width: calc(var(--t, 1) * 100%); height: auto; display: block; }
.juego-opcion.tam-opcion { padding: 12px; align-items: end; }
.tam-opcion--4 .tam, .tam-orden--4 .tam { width: clamp(58px, 11vw, 132px); }
.tam-opcion--usada { visibility: hidden; }
.tam-opciones { gap: clamp(8px, 1.6vw, 18px); }
.tam-orden { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.tam-fila { display: flex; gap: clamp(6px, 1.4vw, 14px); align-items: flex-end; padding: 12px 16px; border-radius: 26px; background: color-mix(in srgb, var(--papel) 85%, transparent); }
.tam-hueco { display: flex; align-items: flex-end; justify-content: center; border: 4px dashed var(--borde); border-radius: 18px; padding: 6px; }
.tam-hueco .tam { width: clamp(70px, 12vw, 140px); }
.tam-orden--4 .tam-hueco .tam { width: clamp(52px, 10vw, 124px); }
.tam-hueco:empty { min-width: clamp(70px, 12vw, 140px); aspect-ratio: 1; }
.tam-orden--4 .tam-hueco:empty { min-width: clamp(52px, 10vw, 124px); }
.tam-hueco--lleno { border-style: solid; border-color: #3E9C68; }
@media (prefers-reduced-motion: no-preference) { .tam-hueco--lleno { animation: juego-salta .4s ease-out; } }
.tam-fila--bien { box-shadow: inset 0 0 0 4px #3E9C68; }
.tam-guia { display: flex; align-items: center; gap: 10px; font-weight: 800; color: var(--tinta-2); }
.tam-guia svg { width: clamp(80px, 16vw, 160px); height: 24px; }
.juego:fullscreen .tam { width: 18vh; }
.juego:fullscreen .tam-opcion--4 .tam, .juego:fullscreen .tam-orden--4 .tam, .juego:fullscreen .tam-hueco .tam { width: 15vh; }
.juego:fullscreen .tam-hueco:empty { min-width: 15vh; }
@media (max-width: 560px) {
  .tam-fila { padding: 8px; }
  .falta__fila { padding: 12px; }
}

/* ---------------------------------------------------------
   Premio al acabar la ronda (js/juegos.js → premio):
   estrellas grandes en lugar de la última pregunta
   --------------------------------------------------------- */
.juego-premio {
  display: grid; justify-items: center; gap: 10px; text-align: center;
  padding: clamp(18px, 3vw, 30px) clamp(22px, 5vw, 56px); border-radius: 30px;
  background: var(--papel); box-shadow: inset 0 0 0 3px var(--oro-borde, var(--borde)), 0 6px 0 var(--sombra-boton);
  max-width: 100%;
}
.juego-premio__estrellas { display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(4px, 1.2vw, 12px); }
.juego-premio__estrella svg { width: clamp(46px, 9vw, 84px); height: auto; display: block; fill: var(--oro); stroke: var(--oro-borde); stroke-width: 1; }
.juego-premio__titulo { margin: 0; font-family: var(--f-titulo); font-weight: 700; font-size: clamp(1.6rem, 4vw, 2.6rem); line-height: 1.1; }
.juego-premio__detalle { margin: 0; font-weight: 700; color: var(--tinta-suave, inherit); font-size: 1.1rem; }
.juego-otra { min-height: 64px; font-size: 1.35rem; padding-inline: 40px; }
@media (prefers-reduced-motion: no-preference) {
  .juego-premio { animation: juego-premio-entra .45s cubic-bezier(.2, 1.4, .4, 1) both; }
  .juego-premio__estrella { animation: juego-premio-estrella .5s cubic-bezier(.2, 1.6, .4, 1) both; animation-delay: calc(var(--i) * .12s + .15s); }
}
@keyframes juego-premio-entra { from { transform: scale(.85); opacity: 0; } }
@keyframes juego-premio-estrella { from { transform: scale(0) rotate(-40deg); opacity: 0; } }
