/* Gamificacion: juegos de adivinar letras (despegue, estrellas, rompecabezas). Mucho movimiento para
   proyectar: fondo vivo alrededor, casillas que caen y rebotan, teclado que responde, sacudida al
   fallar y confeti al completar. Respeta prefers-reduced-motion. */

.gml { position: relative; display: flex; flex-direction: column; gap: 14px; outline: none; isolation: isolate; }
.gml:focus-visible { box-shadow: 0 0 0 3px var(--gv-acc); border-radius: 18px; }

/* Fondo vivo: burbujas y destellos que suben sin parar alrededor del juego */
.gml-fondo { position: absolute; inset: -40px; z-index: -1; overflow: hidden; pointer-events: none; }
.gml-fondo span { position: absolute; bottom: -60px; left: calc(var(--i) * 5.6%); width: calc(10px + (var(--i) * 7px) % 34px); aspect-ratio: 1; border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, .9), color-mix(in srgb, var(--gv-acc) 70%, transparent) 60%, transparent 70%);
    opacity: .55; animation: gml-sube calc(7s + (var(--i) * 1.3s) % 6s) linear infinite; animation-delay: calc(var(--i) * -1.1s); }
.gml-fondo span:nth-child(3n) { border-radius: 4px; transform: rotate(45deg); background: color-mix(in srgb, #FF6B57 70%, transparent); }
.gml-fondo span:nth-child(4n) { background: color-mix(in srgb, #5BC0FF 70%, transparent); }
@keyframes gml-sube { from { transform: translateY(0) rotate(0); } to { transform: translateY(-140vh) rotate(540deg); } }

.gml-items { display: flex; flex-wrap: wrap; gap: 8px; }
.gml-chip { display: inline-flex; align-items: center; gap: 4px; border: 2px solid var(--gv-line); background: var(--gv-card); color: var(--gv-ink); border-radius: 999px; padding: 6px 14px; font: 700 15px 'Figtree', sans-serif; cursor: pointer; transition: transform .15s; }
.gml-chip:hover { transform: translateY(-2px); }
.gml-chip.actual { border-color: var(--gv-acc); box-shadow: 0 0 0 4px color-mix(in srgb, var(--gv-acc) 30%, transparent); animation: gml-late 1.6s ease-in-out infinite; }
.gml-chip.hecha { background: #3BB273; color: #fff; border-color: #3BB273; }
.gml-chip.perdida { opacity: .55; text-decoration: line-through; }
.gml-chip .material-symbols-rounded { font-size: 18px; }
@keyframes gml-late { 50% { transform: scale(1.06); } }

.gml-escena { display: grid; grid-template-columns: minmax(220px, 34%) minmax(0, 1fr); gap: 22px; align-items: start; }
.gml-visual { min-width: 0; }
.gml-juego { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.gml-pista { margin: 0; font: 600 clamp(18px, 1.8vw, 26px) 'Figtree', sans-serif; color: var(--gv-ink); display: flex; align-items: center; gap: 8px; animation: gml-entra .5s cubic-bezier(.2, 1.4, .4, 1); }
.gml-pista .material-symbols-rounded { color: #FFC145; font-size: 1.3em; animation: gml-foco 2s ease-in-out infinite; }
@keyframes gml-foco { 50% { transform: rotate(-12deg) scale(1.15); } }
@keyframes gml-entra { from { opacity: 0; transform: translateY(14px); } }

/* Molde: cada palabra no se corta; cada letra una casilla que cae y rebota al descubrirse */
.gml-molde { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: flex-end; }
.gml-palabra { display: inline-flex; gap: 6px; }
.gml-casilla { width: clamp(34px, 3.4vw, 56px); height: clamp(44px, 4.4vw, 70px); display: grid; place-items: center; border-radius: 10px; background: rgba(255, 255, 255, .1);
    border-bottom: 5px solid var(--gv-acc); font: 800 clamp(24px, 2.6vw, 42px) 'Figtree', sans-serif; color: var(--gv-ink); }
.gml-casilla.llena { background: #fff; color: #1B1440; animation: gml-cae .55s cubic-bezier(.2, 1.6, .35, 1) both; animation-delay: calc(var(--d) * 35ms); }
.gml-casilla.fiesta { animation: gml-ola 1s ease-in-out both; animation-delay: calc(var(--d) * 70ms); background: #3BB273; color: #fff; border-color: #1E7A4A; }
.gml-signo { font: 800 clamp(24px, 2.6vw, 42px) 'Figtree', sans-serif; color: var(--gv-ink); align-self: flex-end; }
@keyframes gml-cae { 0% { transform: translateY(-60px) scale(.4) rotate(-20deg); opacity: 0; } 70% { transform: translateY(6px) scale(1.12); opacity: 1; } 100% { transform: none; } }
@keyframes gml-ola { 40% { transform: translateY(-16px) scale(1.15); } }
.gml-molde.es-frase .gml-casilla { width: clamp(26px, 2.4vw, 40px); height: clamp(36px, 3.2vw, 54px); font-size: clamp(18px, 1.9vw, 30px); }

.gml-datos { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.gml-dato { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--gv-card); color: var(--gv-ink); font: 600 15px 'Figtree', sans-serif; }
.gml-dato.con-error { animation: gml-golpe .45s ease; color: #FF6B57; }
.gml-dato .material-symbols-rounded { font-size: 18px; }
.gml-pista-btn { display: inline-flex; align-items: center; gap: 6px; border: none; border-radius: 999px; padding: 8px 16px; background: #FFC145; color: #1B1440; font: 800 15px 'Figtree', sans-serif; cursor: pointer; transition: transform .15s; }
.gml-pista-btn:hover:not(:disabled) { transform: translateY(-2px) rotate(-2deg); }
.gml-pista-btn:disabled { opacity: .45; cursor: default; }
@keyframes gml-golpe { 30% { transform: scale(1.25); } }

/* Teclado: responde al pulsar, verde si estaba, rojo si no */
.gml-teclado { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 8px; }
.gml-tecla { height: clamp(40px, 4vw, 58px); border: none; border-radius: 12px; background: var(--gv-card); color: var(--gv-ink); font: 800 clamp(17px, 1.7vw, 24px) 'Figtree', sans-serif; cursor: pointer;
    box-shadow: 0 4px 0 rgba(0, 0, 0, .25); transition: transform .08s, box-shadow .08s; }
.gml-tecla.vocal { outline: 2px dashed color-mix(in srgb, var(--gv-acc) 60%, transparent); outline-offset: -4px; }
.gml-tecla:hover:not(:disabled) { transform: translateY(-2px); }
.gml-tecla:active:not(:disabled), .gml-tecla.pulsada { transform: translateY(3px) scale(.94); box-shadow: 0 1px 0 rgba(0, 0, 0, .25); }
.gml-tecla.pulsada { animation: gml-pulso .35s ease; }
.gml-tecla.bien { background: #3BB273; color: #fff; }
.gml-tecla.mal { background: #FF6B57; color: #fff; opacity: .7; }
.gml-tecla:disabled { cursor: default; }
.gml-tecla:disabled:not(.bien):not(.mal) { opacity: .35; }
@keyframes gml-pulso { 0% { transform: scale(.85); } 60% { transform: scale(1.12); } }

.gml-aviso { margin: 0; min-height: 1.4em; font: 800 clamp(18px, 1.8vw, 26px) 'Figtree', sans-serif; color: var(--gv-ink); animation: gml-entra .35s ease; }
.gml-aviso.es-bien { color: #3BB273; }
.gml-aviso.es-mal { color: #FF6B57; }
.gml--sacude .gml-molde, .gml--sacude .gml-aviso { animation: gml-sacude .45s ease; }
@keyframes gml-sacude { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }

.gml-fin { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 16px; background: var(--gv-card); animation: gml-entra .5s cubic-bezier(.2, 1.4, .4, 1); }
.gml-fin b { font: 800 22px 'Figtree', sans-serif; }
.gml-fin span { color: var(--gv-sub); }

/* Confeti al completar */
.gml-confeti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 5; }
.gml-confeti i { position: absolute; top: -20px; left: calc(var(--i) * 2.5%); width: 12px; height: 18px; border-radius: 3px; background: hsl(calc(var(--i) * 37deg) 90% 60%);
    animation: gml-confeti calc(1.6s + (var(--i) * .07s) % .9s) cubic-bezier(.25, .6, .4, 1) forwards; animation-delay: calc((var(--i) * 41ms) % 400ms); }
@keyframes gml-confeti { to { transform: translateY(110vh) rotate(calc(360deg + var(--i) * 47deg)); opacity: .2; } }

/* ----- Cohete (despegue) ----- */
.gmc { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px; border-radius: 22px; background: linear-gradient(180deg, rgba(20, 16, 70, .75), rgba(60, 40, 140, .55)); overflow: hidden; min-height: 360px; }
.gmc-cielo { position: absolute; inset: 0; pointer-events: none; }
.gmc-cielo i { position: absolute; top: calc((var(--i) * 37%) % 90%); left: calc((var(--i) * 23%) % 95%); width: 4px; height: 4px; border-radius: 50%; background: #fff; animation: gmc-brillo calc(1.2s + var(--i) * .2s) ease-in-out infinite; }
@keyframes gmc-brillo { 50% { opacity: .15; transform: scale(.5); } }
.gmc-cohete { position: relative; width: min(100%, 220px); height: auto; animation: gmc-flota 3s ease-in-out infinite; transform-origin: 50% 80%; }
.gmc-cohete.brinca { animation: gmc-brinca .6s cubic-bezier(.2, 1.6, .4, 1), gmc-flota 3s ease-in-out .6s infinite; }
.gmc-cohete.tiembla { animation: gmc-tiembla .5s ease, gmc-flota 3s ease-in-out .5s infinite; }
.gmc .pz { opacity: .12; transition: opacity .4s; }
.gmc .pz.on { opacity: 1; animation: gmc-pieza .6s cubic-bezier(.2, 1.6, .4, 1); transform-box: fill-box; transform-origin: center; }
.gmc-llama { opacity: 0; transform-box: fill-box; transform-origin: top; }
.gmc.es-ganada .gmc-llama { opacity: 1; animation: gmc-fuego .15s ease-in-out infinite alternate; }
.gmc.es-ganada .gmc-cohete { animation: gmc-despega 2.2s cubic-bezier(.5, 0, .7, .4) .3s forwards; }
.gmc-humo { position: absolute; bottom: 70px; left: 50%; width: 0; height: 0; }
.gmc.es-ganada .gmc-humo i { position: absolute; width: 50px; height: 50px; border-radius: 50%; background: rgba(255, 255, 255, .8); left: calc(-25px + (var(--i) - 3) * 22px); animation: gmc-humo 1.6s ease-out forwards; animation-delay: calc(var(--i) * .08s); }
.gmc.es-perdida .gmc-cohete { filter: grayscale(.7); animation: gmc-cae 1s ease forwards; }
.gmc-tanque { position: relative; display: flex; gap: 6px; }
.gmc-tanque span { width: 18px; height: 30px; border-radius: 6px; background: linear-gradient(180deg, #FFE08A, #FFB020); box-shadow: 0 0 10px rgba(255, 193, 69, .7); }
.gmc-tanque span.vacio { background: rgba(255, 255, 255, .15); box-shadow: none; }
.gmc-tanque span.recien { animation: gmc-gasta .6s ease; }
.gmc-leyenda { position: relative; margin: 0; font: 800 20px 'Figtree', sans-serif; color: #fff; }
.gmc.es-ganada .gmc-leyenda { animation: gml-golpe .6s ease 2; color: #FFC145; }
@keyframes gmc-flota { 50% { transform: translateY(-8px) rotate(1.5deg); } }
@keyframes gmc-brinca { 40% { transform: translateY(-22px) scale(1.06); } }
@keyframes gmc-tiembla { 20%, 60% { transform: translateX(-8px) rotate(-4deg); } 40%, 80% { transform: translateX(8px) rotate(4deg); } }
@keyframes gmc-pieza { from { transform: scale(.2) rotate(-30deg); opacity: 0; } }
@keyframes gmc-fuego { to { transform: scaleY(1.35) scaleX(.85); } }
@keyframes gmc-despega { 20% { transform: translateY(6px); } 100% { transform: translateY(-140%); } }
@keyframes gmc-humo { from { transform: scale(.3); opacity: .9; } to { transform: scale(2.2) translateY(30px); opacity: 0; } }
@keyframes gmc-cae { to { transform: translateY(10px) rotate(-14deg); } }
@keyframes gmc-gasta { 0% { transform: scale(1.3); background: #FF6B57; } }
.gmc.es-chica { min-height: 220px; }
.gmc.es-chica .gmc-cohete { width: 120px; }

@media (max-width: 900px) {
    .gml-escena { grid-template-columns: minmax(0, 1fr); }
    .gml-teclado { grid-template-columns: repeat(7, minmax(0, 1fr)); }
}
.gml--cel .gml-escena { grid-template-columns: minmax(0, 1fr); gap: 12px; }
.gml--cel .gml-teclado { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.gml--cel .gml-casilla { width: 30px; height: 40px; font-size: 22px; }

@media (prefers-reduced-motion: reduce) {
    .gml *, .gmc * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
    .gml-fondo { display: none; }
}
