/* ---------- Game night: the shared night sky behind the hub and the games ---------- */
.gn-sky {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden;
  background:
    radial-gradient(120% 55% at 50% 112%, rgba(255, 164, 92, .16), rgba(255, 164, 92, 0) 62%),
    linear-gradient(#130b1c 0%, #1b1126 48%, #24172f 100%);
}
.gn-pan { position: absolute; inset: 0; }
.gn-sky-game .gn-pan { opacity: .65; }
.gn-stars { position: absolute; left: 0; top: 0; width: 2px; height: 2px; border-radius: 50%; }
.gn-stars.tw { animation: gn-twinkle 3.6s ease-in-out -1.3s infinite; }
@keyframes gn-twinkle { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
/* the hub's twinkles (the film's own, see filmSky in games.js): two groups breathing out of step */
.gn-tw { position: absolute; display: block; }
.gn-twg { position: absolute; inset: 0; animation: gn-twg 4.4s ease-in-out infinite; }
.gn-twg.b { animation-duration: 5.6s; animation-delay: -1.2s; }
@keyframes gn-twg { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.gn-spark { position: absolute; width: 14px; height: 14px; margin: -7px; opacity: 0; animation: gn-sparkle 4.2s ease-in-out calc(var(--i) * -1.05s) infinite; }
@keyframes gn-sparkle { 0%, 100% { opacity: 0; transform: scale(.3) rotate(0); } 50% { opacity: 1; transform: scale(1) rotate(45deg); } }
.gn-shoot {
  position: absolute; left: 80vw; top: 9vh; width: 90px; height: 2px; border-radius: 2px; opacity: 0;
  background: linear-gradient(90deg, rgba(255, 246, 236, 0), #fff6ec);
  transform-origin: 0 50%; transform: rotate(156deg); animation: gn-shoot 11s linear 5s infinite;
}
@keyframes gn-shoot {
  0% { opacity: 0; transform: translate(0, 0) rotate(156deg); }
  1.5% { opacity: 1; }
  7% { opacity: 0; transform: translate(-46vw, 20vh) rotate(156deg); }
  100% { opacity: 0; transform: translate(-46vw, 20vh) rotate(156deg); }
}
.gn-bokeh {
  position: absolute; border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--c), .24) 0%, rgba(var(--c), .09) 42%, rgba(var(--c), 0) 70%); opacity: .8;
}
.gn-table { position: absolute; left: 0; right: 0; bottom: 0; height: 30vh; background: linear-gradient(rgba(36, 22, 48, 0), rgba(36, 22, 48, .55)); }

/* string lights along the top of the hub */
.gn-lights { position: absolute; top: 0; left: 50%; width: 100vw; height: 96px; transform: translateX(-50%); pointer-events: none; overflow: hidden; }
.gn-lights svg { position: absolute; left: 0; top: 0; width: 100%; height: 70px; overflow: visible; }
.gn-bulb { position: absolute; width: 10px; height: 17px; margin-left: -5px; transform-origin: 50% 0; rotate: var(--tilt); }
.gn-bulb::before { content: ""; position: absolute; left: 2.5px; top: 0; width: 5px; height: 5px; border-radius: 1px; background: #3b2c4a; }
.gn-bulb b {
  position: absolute; left: 1px; top: 4px; width: 8px; height: 12px;
  border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
  background: radial-gradient(circle at 40% 30%, #fffaf0 0 14%, var(--c) 52%);
}
.gn-bulb::after {
  content: ""; position: absolute; left: 50%; top: 11px; width: 48px; height: 48px; margin: -24px 0 0 -24px; border-radius: 50%;
  background: radial-gradient(circle, var(--c) 0%, rgba(0, 0, 0, 0) 64%); opacity: .32;
}
.gn-bulb:nth-child(3n + 2)::after { opacity: .22; }

/* ---------- Hub ---------- */
#hub { max-width: 54rem; padding-top: 4.7rem; gap: .9rem; }
.gn-head { position: relative; width: 100%; display: flex; flex-direction: column; align-items: center; gap: .15rem; }
.gn-title { font-size: clamp(2.1rem, 9vw, 2.9rem); white-space: nowrap; }
.gn-ch { display: inline-block; }
.gn-ch:nth-child(odd) { color: #fff3e6; }
.gn-swoosh { width: 9.5rem; height: 1rem; margin-top: -.45rem; overflow: visible; }
.gn-swoosh path { stroke-dasharray: 200; stroke-dashoffset: 0; }
.gn-lede { font: 700 1.3rem/1.15 var(--hand); color: var(--muted); max-width: 21rem; margin-top: .2rem; }

/* intro, coming down from the globe's night sky */
/* the sky is fully there on the first frame (the film ends on the same starfield); it only pans */
#hub.intro .gn-pan { animation: gn-tilt 3.2s cubic-bezier(.45, 0, .2, 1) both; }
/* the film fades its twinkles out at the end; here they come back once the sky has settled */
#hub.intro .gn-twg { animation: gn-fadein 1.6s ease 1.4s both, gn-twg 4.4s ease-in-out 3s infinite; }
#hub.intro .gn-twg.b { animation: gn-fadein 1.6s ease 1.8s both, gn-twg 5.6s ease-in-out 3.4s infinite; }
#hub.intro .gn-bokeh { animation: gn-fadein 2s ease 1.2s both; }
#hub.intro .gn-lights { animation: gn-drop 1.6s cubic-bezier(.3, 1.45, .5, 1) .35s both; }
#hub.intro .gn-bulb { animation: gn-on .5s ease calc(1.1s + var(--i) * 75ms) both; }
#hub.intro .gn-ch { animation: gn-write .6s cubic-bezier(.3, 1.6, .5, 1) calc(.5s + var(--i) * 70ms) both; }
#hub.intro .gn-swoosh path { animation: gn-draw .8s ease-out 1.35s both; }
#hub.intro .gn-lede { animation: gn-up .8s ease 1.6s both; }
#hub.intro .gn-host-hub { animation: gn-peek 1.1s cubic-bezier(.3, 1.4, .5, 1) 2.6s both; }
#hub.intro #reset { animation: gn-fadein 1s ease 3.4s both; }
@keyframes gn-fadein { from { opacity: 0; } }
@keyframes gn-tilt { from { transform: translateY(16vh); } }
/* slots scrolled off-screen pause everything inside them (games.js toggles .gn-off) */
.gn-slot.gn-off *, .gn-slot.gn-off *::before, .gn-slot.gn-off *::after { animation-play-state: paused !important; }
@keyframes gn-drop { 0% { transform: translate(-50%, -90px); } 100% { transform: translate(-50%, 0); } }
@keyframes gn-on { from { opacity: .15; } to { opacity: 1; } }
@keyframes gn-write { from { opacity: 0; transform: translateY(.45em) rotate(-14deg) scale(.5); } }
@keyframes gn-draw { from { stroke-dashoffset: 200; } }
@keyframes gn-up { from { opacity: 0; transform: translateY(14px); } }
/* invisible until the peek starts, so the first frame is only the film's sky */
@keyframes gn-peek { 0% { opacity: 0; transform: translateY(46px) rotate(18deg) scale(.6); } 60% { opacity: 1; transform: translateY(-6px) rotate(-8deg); } 100% { transform: none; } }

/* the cards: a 2-up table on phones, 3-up on wide screens */
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; width: 100%; text-align: left; margin-top: .2rem; perspective: 900px; }
.gn-slot { position: relative; min-width: 0; }
.gn-slot-expresso { grid-column: 1 / -1; margin-top: 1.6rem; }
.gn-slot-letter { grid-column: 1 / -1; justify-self: center; width: min(86%, 21rem); margin-top: .3rem; }
@media (min-width: 760px) {
  .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2rem 1rem; }
  .gn-slot-expresso { grid-column: span 2; margin-top: 0; }
}
#hub.intro .gn-slot { animation: gn-cardin .85s cubic-bezier(.25, 1.35, .45, 1) calc(2s + var(--k) * .15s) both; }
#hub.quick .gn-slot { animation: gn-cardin .55s cubic-bezier(.25, 1.35, .45, 1) calc(var(--k) * .05s) both; }
@keyframes gn-cardin { from { opacity: 0; transform: translateY(70px) rotateX(-55deg) scale(.8); } }

.card {
  position: relative; display: block; width: 100%; height: 100%; padding: 0; border: 0; border-radius: 1.1rem;
  background: none; color: var(--cream); font: inherit; text-align: left; cursor: pointer;
}
/* the face is what moves: the button itself stays put, so taps always land */
.gn-face {
  position: relative; display: flex; flex-direction: column; gap: .25rem; height: 100%;
  padding: .7rem .8rem .85rem; border-radius: 1.1rem;
  background: linear-gradient(160deg, #36254b, #251933 75%);
  border: 1.5px solid #503b69;
  box-shadow: 0 16px 22px -16px rgba(0, 0, 0, .9), inset 0 1px 0 rgba(255, 255, 255, .07);
  contain: layout style;
  will-change: transform;  /* its own layer, so the tilt is composited instead of repainting the card */
}
.card:hover .gn-face { border-color: var(--rose); }
.card:active .gn-face { scale: .97; }
.card:focus-visible { outline: none; }
.card:focus-visible .gn-face { outline: 3px solid var(--rose); outline-offset: 3px; }
.gn-shine { position: absolute; left: 4%; top: 2%; width: 62%; height: 62%; pointer-events: none; background: radial-gradient(closest-side, rgba(255, 240, 225, .1), rgba(255, 240, 225, 0)); }
.card .name { display: flex; align-items: center; gap: .5rem; font: 1.22rem/1.15 var(--display); }
.card .desc { color: var(--muted); font-size: .8rem; line-height: 1.3; }
.chip { font: 800 .62rem var(--body); letter-spacing: .1em; text-transform: uppercase; padding: .22rem .5rem; border-radius: 999px; background: var(--line); color: var(--cream); white-space: nowrap; }
.card .chip { position: absolute; top: -.55rem; right: .6rem; z-index: 1; box-shadow: 0 3px 8px -3px rgba(0, 0, 0, .6); }
.chip.solved { background: var(--good); color: var(--night); }
.chip.played { background: var(--near); color: var(--night); }
.chip.stamp { animation: gn-stamp .7s cubic-bezier(.3, 1.6, .5, 1) .55s both; }
@keyframes gn-stamp { from { opacity: 0; transform: scale(2.6) rotate(-24deg); } }

/* ---------- card previews ---------- */
.gn-prev {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 4px;
  height: 3.3rem; margin-bottom: .3rem; border-radius: .7rem; background: rgba(14, 8, 21, .5);
  box-shadow: inset 0 1px 6px rgba(0, 0, 0, .35);
  contain: layout paint;
}
/* between turns a preview rests on its first pose (every loop starts and ends there) */
.gn-slot:not(.pv-on) .gn-prev *, .gn-slot:not(.pv-on) .gn-prev *::before, .gn-slot:not(.pv-on) .gn-prev *::after { animation: none !important; }
.gn-prev i { font-style: normal; }
.pv-t.good { --c: var(--good); } .pv-t.near { --c: var(--near); } .pv-t.miss { --c: #5b4873; }

/* colors fade in on an overlay, so only opacity and transform animate */
.pv-t { position: relative; }
.pv-t::before { content: ""; position: absolute; inset: -1.5px; border-radius: inherit; background: var(--c); opacity: 0; }
/* Wordle: tiles flip to colors */
.pv-wordle .pv-t { width: 20px; height: 20px; border-radius: 4px; border: 1.5px solid #6d5a84; animation: pv-flip 4.6s ease-in-out calc(var(--i) * .16s) infinite; }
.pv-wordle .pv-t::before { animation: pv-col 4.6s ease-in-out calc(var(--i) * .16s) infinite; }
@keyframes pv-flip { 0%, 6% { transform: none; } 11% { transform: rotateX(90deg); } 16% { transform: rotateX(0) scale(1.14); } 20%, 100% { transform: none; } }
@keyframes pv-col { 0%, 11% { opacity: 0; } 11.5%, 80% { opacity: 1; } 88%, 100% { opacity: 0; } }
/* Letroso: letters shuffle places (per-letter keyframes are generated in games.js) */
.pv-letroso .pv-t {
  position: absolute; left: calc(50% - 59px); top: calc(50% - 11px); width: 20px; height: 22px; border-radius: 4px;
  display: grid; place-items: center; font: 800 .72rem var(--body); color: var(--cream); background: #4d3a66;
  animation: 6.4s cubic-bezier(.5, 0, .3, 1.25) infinite;
}
.pv-letroso .pv-t:nth-child(1) { background: var(--good); color: var(--night); }
.pv-letroso .pv-t:nth-child(4) { background: var(--near); color: var(--night); }
/* Contexto: the rank counts down (driven from games.js) */
.pv-contexto { padding: 0 .55rem; }
.pv-row { position: relative; display: flex; justify-content: space-between; align-items: center; width: 100%; height: 26px; padding: 0 4px 0 9px; border-radius: 7px; background: #3a2a4e; overflow: hidden; font: 800 .7rem var(--body); }
.pv-bar { position: absolute; inset: 0; transform-origin: 0 50%; transform: scaleX(.06); background: #c9566f; }
.pv-row.warm .pv-bar { background: var(--near); }
.pv-row.hot .pv-bar { background: var(--good); }
.pv-word { position: relative; min-width: 0; overflow: hidden; white-space: nowrap; color: var(--cream); letter-spacing: .06em; }
.pv-row.warm .pv-word, .pv-row.hot .pv-word { color: var(--night); }
.pv-num { position: relative; min-width: 3.6em; padding: 1px 6px; border-radius: 99px; background: var(--night); color: var(--cream); text-align: center; font-variant-numeric: tabular-nums; }
/* Conexo: mixed-up colored tiles slide home into their groups (per-tile keyframes are generated in games.js) */
.pv-conexo { margin-inline: .2rem; }
.pv-conexo .pv-t {
  position: absolute; width: calc(25% - 6px); height: calc(50% - 6px); margin: 3px; border-radius: 4px; background: var(--c);
  animation: 5.6s cubic-bezier(.5, 0, .3, 1.2) calc(var(--i) * 45ms) infinite;
}
.pv-conexo .pv-t::after { content: ""; position: absolute; left: 24%; right: 24%; top: 50%; height: 3px; margin-top: -1.5px; border-radius: 2px; background: rgba(29, 19, 39, .4); }
.pv-conexo .g1 { --c: var(--g1); } .pv-conexo .g2 { --c: var(--g3); }
/* Expresso: a row of blanks being typed (cream), then revealed in colors */
.pv-expresso { gap: 7px; }
.pv-w { display: flex; gap: 2px; }
.pv-expresso .pv-t { width: 12px; height: 16px; border-radius: 3px; border: 1.5px solid #6d5a84; }
.pv-expresso .pv-t::after { content: ""; position: absolute; inset: -1.5px; border-radius: inherit; background: var(--cream); opacity: 0; animation: pv-typed 5.4s ease calc(var(--i) * .15s) infinite; }
.pv-expresso .pv-t::before { z-index: 1; animation: pv-xcol 5.4s ease calc(var(--i) * .15s) infinite; }
@keyframes pv-typed { 0% { opacity: 0; transform: none; } 2.5% { opacity: 1; transform: translateY(-3px) scale(1.25); } 6%, 62% { opacity: 1; transform: none; } 64.5%, 100% { opacity: 0; transform: none; } }
@keyframes pv-xcol { 0%, 62% { opacity: 0; transform: scaleY(.1); } 66%, 84% { opacity: 1; transform: none; } 92%, 100% { opacity: 0; transform: none; } }
.pv-caret { width: 2px; height: 16px; margin-left: -3px; border-radius: 1px; background: var(--flame); animation: pv-blink 1s steps(2) infinite; }
@keyframes pv-blink { 50% { opacity: 0; } }

/* the orange tabby asleep on the Expresso card */
.gn-napper { position: absolute; right: 74px; top: -35px; width: 80px; z-index: 2; pointer-events: none; }
.gn-cat { display: block; width: 100%; height: auto; overflow: visible; transform-origin: 50% 92%; animation: gn-catbreath 3.4s ease-in-out infinite; }
@keyframes gn-catbreath { 50% { transform: scale(1.015, 1.06); } }
.gn-z { position: absolute; left: 12px; top: 0; font: 700 1rem var(--hand); color: var(--muted); opacity: 0; animation: gn-z 3.6s ease-out calc(var(--i) * 1.2s) infinite; }
@keyframes gn-z { 0% { opacity: 0; transform: translate(0, 0) scale(.6); } 20% { opacity: .9; } 100% { opacity: 0; transform: translate(-16px, -30px) scale(1.25) rotate(-12deg); } }

/* ---------- the letter: a sealed envelope ---------- */
.card.letter-card { border-radius: 1rem; }
.letter-card .gn-face { align-items: center; gap: .1rem; padding: .3rem 0 0; background: none; border: 0; box-shadow: none; }
.letter-card:hover .gn-face { border: 0; }
.gn-envbox { position: relative; display: block; width: 100%; }
.gn-env { display: block; width: 100%; height: auto; overflow: visible; transform-origin: 50% 60%; }
.gn-seal { transform-box: fill-box; transform-origin: 50% 50%; }
.gn-glow {
  position: absolute; left: 50%; top: 42%; width: 116%; height: 150%; pointer-events: none; opacity: 0;
  transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, rgba(255, 196, 110, .75), rgba(255, 170, 90, .38) 38%, rgba(238, 138, 164, .16) 66%, rgba(238, 138, 164, 0));
}
.gn-ribbon {
  position: absolute; left: 50%; top: 31%; transform: translate(-50%, -50%) rotate(-3deg);
  display: flex; align-items: center; gap: .45rem; padding: .32rem 1.35rem .34rem; white-space: nowrap;
  background: linear-gradient(#f39bb2, #e2738f); color: #4a1f33; font: 800 .74rem var(--body); letter-spacing: .08em; text-transform: uppercase;
  clip-path: polygon(0 0, 100% 0, calc(100% - 10px) 50%, 100% 100%, 0 100%, 10px 50%);
}
.gn-hearts { display: inline-flex; gap: 1px; font-size: .85rem; letter-spacing: 0; }
.gn-hearts i { font-style: normal; color: rgba(74, 31, 51, .3); }
.gn-hearts i.on { color: #fff6ee; }
.gn-env-cap { font: 700 1.4rem/1.1 var(--hand); color: var(--muted); }
.gn-env-spark { position: absolute; color: #ffd27a; font-size: 1.35rem; opacity: 0; pointer-events: none; }
.gn-env-spark.s1 { left: 3%; top: 2%; } .gn-env-spark.s2 { right: 2%; top: 18%; animation-delay: .8s !important; } .gn-env-spark.s3 { left: 9%; bottom: 6%; animation-delay: 1.6s !important; }
.letter-card.locked { cursor: default; }
.letter-card.locked .gn-env { opacity: .92; }
.letter-card.open .gn-ribbon { display: none; }
.letter-card.open .gn-glow { animation: gn-glowpulse 2.6s ease-in-out infinite; }
.letter-card.open .gn-env { animation: gn-wiggle 3.2s ease-in-out 1s infinite; }
.letter-card.open .gn-env-spark { animation: gn-sparkle 2.4s ease-in-out infinite; }
.letter-card.open .gn-env-cap { color: var(--flame); }
/* the moment it unlocks: the ribbon slips off and the envelope starts to glow */
.letter-card.unlocking .gn-ribbon { display: flex; animation: gn-untie 1.3s cubic-bezier(.5, 0, .7, .4) .9s both; }
.letter-card.unlocking .gn-glow { animation: gn-fadein 1.2s ease 1.6s both, gn-glowpulse 2.6s ease-in-out 2.8s infinite; }
.letter-card.unlocking .gn-env { animation: gn-wiggle 3.2s ease-in-out 2s infinite; }
.letter-card.going .gn-face { animation: gn-lift .45s cubic-bezier(.3, 1.5, .5, 1) both; }
@keyframes gn-glowpulse { 0%, 100% { opacity: .6; transform: translate(-50%, -50%) scale(.94); } 50% { opacity: 1; transform: translate(-50%, -50%) scale(1.04); } }
@keyframes gn-wiggle { 0%, 58%, 100% { transform: none; } 64% { transform: rotate(-4deg) scale(1.03); } 70% { transform: rotate(3.5deg) scale(1.03); } 76% { transform: rotate(-2.5deg); } 82% { transform: rotate(1.5deg); } 88% { transform: none; } }
@keyframes gn-untie { 0% { transform: translate(-50%, -50%) rotate(-3deg); } 20% { transform: translate(-50%, -58%) rotate(-6deg); } 100% { transform: translate(-30%, 160px) rotate(28deg); opacity: 0; } }
@keyframes gn-lift { 100% { transform: translateY(-10px) scale(1.06); } }

/* ---------- Kuromi, the host ---------- */
.gn-host { position: relative; z-index: 4; pointer-events: none; }
/* on the hub she stands just right of the title, as if she popped up behind it */
/* she shrinks on very narrow phones rather than poke past the right edge */
.gn-host-hub { position: absolute; left: calc(50% + 2.95 * clamp(2.1rem, 9vw, 2.9rem)); top: -30px; width: clamp(40px, calc(50% - 2.95 * clamp(2.1rem, 9vw, 2.9rem)), 62px); }
.gn-host-hub .gn-bubble { right: 30%; bottom: 102%; }
.gn-jump { position: relative; transform-origin: 50% 100%; }
/* a soft lilac backlight, so her black hood reads against the night sky */
.gn-jump::before {
  content: ""; position: absolute; inset: -22% -18% -6%; z-index: -1; pointer-events: none;
  background: radial-gradient(closest-side, rgba(197, 138, 224, .34), rgba(197, 138, 224, .12) 60%, rgba(197, 138, 224, 0));
}
/* beside the open envelope: she peeks out from behind its left edge */
.gn-host-letter { position: absolute; left: -10px; top: 18%; width: 54px; z-index: 3; animation: gn-peekl .9s cubic-bezier(.3, 1.4, .5, 1) .4s both; }
.gn-host-letter .gn-bubble { left: 62%; right: auto; bottom: 98%; border-radius: 1rem 1rem 1rem .2rem; transform-origin: 0 100%; }
/* the letter scene adds .gn-leaving to #hub as its envelope takes over: the envelope's Kuromi and caption step aside */
#hub.gn-leaving .gn-host-letter, #hub.gn-leaving .gn-env-cap { animation: gn-out .2s ease forwards; }
@keyframes gn-out { to { opacity: 0; } }
@keyframes gn-peekl { 0% { opacity: 0; transform: translateX(40px) rotate(18deg) scale(.7); } 60% { opacity: 1; transform: translateX(-4px) rotate(-8deg); } 100% { transform: none; } }
/* she breathes as a whole (cheap), and blinks when games.js toggles .blink */
.gn-k { display: block; width: 100%; height: auto; overflow: visible; transform-origin: 50% 95%; animation: gn-breathe 2.8s ease-in-out infinite; }
.gn-k .eyes { transform-box: fill-box; transform-origin: 50% 50%; }
.blink .gn-k .eyes { transform: scaleY(.12); }
@keyframes gn-breathe { 0%, 100% { transform: none; } 50% { transform: scale(1.03, .97) rotate(-1.5deg); } }
.gn-jump.pop { animation: gn-hop .6s cubic-bezier(.3, 1.4, .5, 1); }
.gn-jump.cheer { animation: gn-cheer 1.15s cubic-bezier(.3, 1.2, .5, 1); }
.gn-jump.bounce { animation: gn-bounce 1.3s ease-in-out; }
.gn-jump.wobble { animation: gn-wobble .7s ease-in-out; }
@keyframes gn-hop { 0% { transform: none; } 30% { transform: translateY(-12px) scale(.95, 1.07); } 60% { transform: scale(1.08, .92); } 80% { transform: scale(.98, 1.02); } 100% { transform: none; } }
@keyframes gn-cheer {
  0% { transform: none; } 14% { transform: scale(1.12, .84); }
  38% { transform: translateY(-34px) rotate(-10deg) scale(.92, 1.1); } 54% { transform: translateY(-38px) rotate(10deg); }
  74% { transform: scale(1.16, .84); } 88% { transform: scale(.96, 1.04); } 100% { transform: none; }
}
@keyframes gn-bounce {
  0%, 100% { transform: none; } 12% { transform: translateY(-14px) scale(.96, 1.05); } 24% { transform: scale(1.06, .94); }
  38% { transform: translateY(-9px); } 50% { transform: scale(1.04, .96); } 62% { transform: translateY(-5px); } 74% { transform: none; }
}
@keyframes gn-wobble { 0%, 100% { transform: none; } 25% { transform: rotate(-10deg); } 50% { transform: rotate(8deg); } 75% { transform: rotate(-4deg); } }
.gn-pops { position: absolute; left: 50%; top: 30%; width: 0; height: 0; }
.gn-pop { position: absolute; left: 0; top: 0; font-style: normal; font-size: 15px; line-height: 1; opacity: 0; animation: gn-popfly 1s cubic-bezier(.2, .8, .3, 1) var(--d) both; }
@keyframes gn-popfly {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.2); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(1.1) rotate(20deg); }
}
.gn-bubble {
  position: absolute; right: 70%; bottom: 96%; margin: 0; white-space: nowrap; pointer-events: none;
  background: var(--cream); color: var(--ink); font: 700 1.2rem/1 var(--hand);
  padding: .32rem .7rem .4rem; border-radius: 1rem 1rem .2rem 1rem;
  box-shadow: 0 6px 14px -8px rgba(0, 0, 0, .7);
  opacity: 0; transform: scale(.3); transform-origin: 100% 100%;
}
.gn-bubble.on { animation: gn-bubble .5s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes gn-bubble { to { opacity: 1; transform: none; } }

/* ---------- Game shell ---------- */
#game { gap: 0; padding-top: 1.1rem; }
.gn-stage { width: 100%; display: flex; flex-direction: column; align-items: center; gap: .8rem; transform-origin: var(--ox, 50%) var(--oy, 30%); }
.gn-stage.gn-in { animation: gn-zoom .55s cubic-bezier(.2, 1.15, .4, 1) both; }
.gn-stage.gn-in #game-root > * { animation: gn-up .5s ease-out calc(.18s + var(--i, 0) * 60ms) backwards; }
@keyframes gn-zoom { from { opacity: 0; transform: scale(.3); } 40% { opacity: 1; } }
/* the header stays pinned to the top, so Kuromi's reactions are always on screen */
.game-head { position: sticky; top: 0; z-index: 6; display: flex; align-items: center; gap: .8rem; width: 100%; padding-block: .55rem .3rem; margin-top: -.55rem; }
.game-head::before {
  content: ""; position: absolute; inset: 0 -16px -1.1rem; z-index: -1; pointer-events: none; opacity: 0; transition: opacity .25s ease;
  background: linear-gradient(rgba(19, 11, 28, .96) 62%, rgba(19, 11, 28, 0));
}
#game.scrolled .game-head::before { opacity: 1; }
.game-head .title { flex: 1; text-align: left; }
.gn-host-game { width: 54px; flex: none; margin: -6px 2px -10px 0; }
/* her bubble never covers the rules: with them folded it hangs over the empty right end of the
   "How to play" bar; with them open, or once the page has scrolled, it sits in the header to her left */
.gn-host-game .gn-bubble { right: 52%; top: 88%; bottom: auto; border-radius: 1rem .2rem 1rem 1rem; transform-origin: 100% 0; font-size: 1.15rem; }
#game:has(.rules[open]) .gn-host-game .gn-bubble, #game.scrolled .gn-host-game .gn-bubble { right: 100%; top: 14%; transform-origin: 100% 50%; }
.rules { width: 100%; text-align: left; background: rgba(43, 29, 58, .85); border: 1px solid rgba(74, 54, 96, .6); border-radius: .8rem; padding: .6rem 1rem; font-size: .92rem; color: var(--muted); }
.rules summary { cursor: pointer; font-weight: 800; color: var(--cream); }
.rules p { margin: .5rem 0; }
#game-root { width: 100%; display: flex; flex-direction: column; align-items: center; gap: .9rem; }
.game-msg { margin: 0; min-height: 1.5em; font-weight: 600; color: var(--flame); }

/* tiles: a typing pop, then a flip that lands with a little bounce */
.board { display: grid; gap: .35rem; }
.trow { display: flex; gap: .35rem; justify-content: center; }
.tile {
  --size: max(2rem, min(3.3rem, calc((100vw - 32px - (var(--cols, 5) - 1) * .35rem) / var(--cols, 5)), calc((100vh - 440px) / 6 - .35rem)));
  width: var(--size); height: var(--size); position: relative;
  display: grid; place-items: center;
  border: 2px solid var(--line); border-radius: .4rem;
  font: 800 calc(var(--size) * .5) var(--body); text-transform: uppercase; color: var(--cream);
  background: rgba(29, 19, 39, .55);
}
.tile.filled { border-color: var(--muted); animation: gn-type .2s cubic-bezier(.3, 1.8, .5, 1); }
.tile.filled.still { animation: none; }
.tile.correct, .tile.present, .tile.absent { border-color: transparent; animation: gn-flip .62s ease both; animation-delay: var(--d, 0s); }
.tile.correct { background: var(--good); color: var(--night); --c: var(--good); --fc: var(--night); }
.tile.present { background: var(--near); color: var(--night); --c: var(--near); --fc: var(--night); }
.tile.absent { background: var(--miss); --c: var(--miss); --fc: var(--cream); }
.tile.gn-wave { animation: gn-wave .55s cubic-bezier(.3, 1.6, .5, 1) var(--w, 0s) both; }
@keyframes gn-type { 0% { transform: scale(.82); } 60% { transform: scale(1.13); } 100% { transform: none; } }
@keyframes gn-flip {
  0% { transform: none; background-color: rgba(29, 19, 39, .55); border-color: var(--muted); color: var(--cream); }
  45% { transform: rotateX(90deg); background-color: rgba(29, 19, 39, .55); border-color: var(--muted); color: var(--cream); }
  46% { transform: rotateX(90deg); background-color: var(--c); border-color: transparent; color: var(--fc); }
  74% { transform: translateY(-4px) scale(1.1); }
  88% { transform: scale(.97); }
  100% { transform: none; background-color: var(--c); border-color: transparent; color: var(--fc); }
}
@keyframes gn-wave { 0%, 100% { transform: none; } 40% { transform: translateY(-14px) scale(1.06); } 70% { transform: translateY(2px) scale(.98); } }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

@supports (height: 100svh) {
  .tile { --size: max(2rem, min(3.3rem, calc((100vw - 32px - (var(--cols, 5) - 1) * .35rem) / var(--cols, 5)), calc((100svh - 440px) / 6 - .35rem))); }
}

/* letroso marks: sized for the longest word on screen (games.js sets --cols, at least 7) */
.tile.sm { --size: min(2.6rem, calc((100vw - 32px - (var(--cols, 12) - 1) * .35rem) / var(--cols, 12))); }
.tile.link-r::after { content: ""; position: absolute; left: 100%; top: 50%; width: .35rem; height: .3rem; margin-top: -.15rem; background: var(--good); }
.tile.edge-start { box-shadow: inset .3rem 0 0 var(--cream); }
.tile.edge-end { box-shadow: inset -.3rem 0 0 var(--cream); }
.tile.edge-start.edge-end { box-shadow: inset .3rem 0 0 var(--cream), inset -.3rem 0 0 var(--cream); }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; justify-content: center; font-size: .8rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
.legend b { display: inline-block; width: .9rem; height: .9rem; border-radius: .2rem; }
.letroso-list { display: flex; flex-direction: column; gap: .35rem; align-items: center; width: 100%; }

/* expresso */
.phrase { display: flex; flex-wrap: wrap; gap: .25rem .55rem; justify-content: center; }
.phrase .word { display: flex; gap: 3px; }
.tile.xs { --size: max(1.15rem, min(2.4rem, calc((min(100vw, 36rem) - 32px - var(--words, 1) * .55rem) / var(--n, 10) - 3px), calc((100vh - 430px) / 8 - .25rem))); border-radius: .28rem; border-width: 1.5px; }
@supports (height: 100svh) {
  .tile.xs { --size: max(1.15rem, min(2.4rem, calc((min(100vw, 36rem) - 32px - var(--words, 1) * .55rem) / var(--n, 10) - 3px), calc((100svh - 430px) / 8 - .25rem))); }
}
.pattern { font-size: .85rem; color: var(--muted); }

/* keyboard */
/* the header and keyboard bands reach the screen edges on a phone (the page gutter is 16px); on wide
   screens they spread a little wider and fade out at the sides, never past the screen (no sideways scroll) */
@media (min-width: 48rem) {
  .game-head::before, .kb::before { left: -6rem; right: -6rem; -webkit-mask-image: linear-gradient(90deg, transparent, #000 6rem, #000 calc(100% - 6rem), transparent); mask-image: linear-gradient(90deg, transparent, #000 6rem, #000 calc(100% - 6rem), transparent); }
}
/* keyboard: pinned to the bottom of the screen, so Enter is always in reach */
.kb {
  position: sticky; bottom: 0; z-index: 5; display: flex; flex-direction: column; gap: .4rem; width: 100%; max-width: 32rem; user-select: none;
  padding: .55rem 0 calc(.5rem + env(safe-area-inset-bottom, 0px));
}
.kb::before {
  content: ""; position: absolute; inset: -.9rem -16px 0; z-index: -1; pointer-events: none;
  background: linear-gradient(rgba(33, 21, 44, 0), rgba(33, 21, 44, .94) 1.6rem);
}
.kb-row { display: flex; gap: .3rem; justify-content: center; }
.key {
  flex: 1 1 0; min-width: 0; height: 3.3rem; border: 0; border-radius: .45rem;
  background: linear-gradient(#625078, #554369); color: var(--cream); font: 800 .95rem var(--body); cursor: pointer;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .25);
  touch-action: manipulation; transition: transform .08s ease;
}
.key:active { transform: translateY(1px) scale(.94); }
.key.wide { flex: 1.6 1 0; font-size: .75rem; }
/* keys take their color as their tile finishes flipping (games.js sets --kd and the color they had before) */
.key.correct { background: var(--good); color: var(--night); animation: gn-keypop .45s ease var(--kd, .7s) backwards; }
.key.present { background: var(--near); color: var(--night); animation: gn-keypop .45s ease var(--kd, .7s) backwards; }
.key.absent { background: #2e2240; color: #8c7a99; animation: gn-keyoff .3s ease var(--kd, .7s) backwards; }
@keyframes gn-keypop { 0% { background: var(--kfrom, #5c4a72); color: var(--kfc, var(--cream)); } 50% { transform: scale(1.12); } }
@keyframes gn-keyoff { 0% { background: var(--kfrom, #5c4a72); color: var(--kfc, var(--cream)); } }

/* contexto */
.ctx-form { display: flex; gap: .5rem; width: 100%; }
.ctx-form input {
  flex: 1; min-width: 0; font: 600 1.05rem var(--body); color: var(--cream);
  background: rgba(43, 29, 58, .9); border: 1.5px solid var(--line); border-radius: .7rem; padding: .75rem 1rem;
}
.ctx-form input:focus { border-color: var(--rose); outline: none; }
.ctx-meta { display: flex; justify-content: space-between; width: 100%; font-size: .85rem; color: var(--muted); }
.ctx-list { display: flex; flex-direction: column; gap: .35rem; width: 100%; }
.ctx-row { position: relative; display: flex; justify-content: space-between; padding: .6rem .9rem; border-radius: .6rem; background: rgba(43, 29, 58, .9); overflow: hidden; font-weight: 600; }
.ctx-row .bar { position: absolute; inset: 0 auto 0 0; width: var(--w); opacity: .9; z-index: 0; transform-origin: 0 50%; }
.ctx-row span { position: relative; z-index: 1; font-variant-numeric: tabular-nums; }
.ctx-row.hot .bar { background: var(--good); }
.ctx-row.warm .bar { background: var(--near); }
.ctx-row.cold .bar { background: #c9566f; }
.ctx-row.hot span, .ctx-row.warm span, .ctx-row.win span { color: var(--night); }
.ctx-row span:last-child { background: var(--night); color: var(--cream) !important; padding: 0 .55rem; border-radius: 999px; }
.ctx-row.last { outline: 2px solid var(--cream); animation: gn-rowin .5s cubic-bezier(.3, 1.4, .5, 1) both; }
.ctx-row.last .bar { animation: gn-bar .8s cubic-bezier(.2, .9, .3, 1) .12s both; }
.ctx-row.win .bar { background: var(--rose); }
@keyframes gn-rowin { from { opacity: 0; transform: translateY(-10px) scale(.94); } }
@keyframes gn-bar { from { transform: scaleX(0); } }
.ctx-tools { display: flex; gap: .6rem; }

/* conexo */
.cx-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .4rem; width: 100%; }
.cx-tile {
  aspect-ratio: 1.25; min-width: 0; border: 0; border-radius: .55rem; padding: .2rem;
  background: linear-gradient(160deg, #36254b, #2a1d3a); color: var(--cream); font: 800 clamp(.72rem, 3.4vw, 1rem) var(--body);
  text-transform: uppercase; cursor: pointer; overflow-wrap: anywhere; line-height: 1.1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), 0 6px 10px -8px rgba(0, 0, 0, .8);
}
.cx-tile.long { font-size: clamp(.6rem, 2.6vw, .88rem); letter-spacing: -.02em; }
.cx-tile.sel { background: var(--cream); color: var(--night); transform: scale(.96); }
.cx-tile.deal { animation: gn-deal .45s cubic-bezier(.3, 1.5, .5, 1) calc(var(--i, 0) * 28ms) backwards; }
.cx-tile.tap { animation: gn-tap .28s ease; }
@keyframes gn-deal { from { opacity: 0; transform: translateY(10px) scale(.5) rotate(-8deg); } }
@keyframes gn-tap { 0% { transform: scale(.88); } 60% { transform: scale(1.05); } }
.cx-solved { grid-column: 1 / -1; border-radius: .55rem; padding: .6rem; color: var(--night); }
.cx-solved.fresh { animation: gn-solved .6s cubic-bezier(.3, 1.5, .5, 1) both; }
@keyframes gn-solved { from { opacity: 0; transform: scale(.85, .3); } }
.cx-solved b { display: block; font-size: .95rem; }
.cx-solved small { font-weight: 600; font-size: .8rem; text-transform: uppercase; }
.cx-tools { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: center; }
.mistakes { font-size: .85rem; color: var(--muted); }

/* result */
.result {
  position: relative; width: 100%; background: var(--cream); color: var(--ink); border-radius: 1rem; padding: 1.3rem 1.2rem;
  display: flex; flex-direction: column; align-items: center; gap: .5rem;
  box-shadow: 0 18px 30px -18px rgba(0, 0, 0, .9);
  animation: gn-result .75s cubic-bezier(.25, 1.4, .45, 1) both;
}
@keyframes gn-result { 0% { opacity: 0; transform: translateY(40px) scale(.7) rotate(-3deg); } 50% { opacity: 1; } 100% { transform: none; } }
.result h3 { margin: 0; font: 400 1.7rem var(--display); animation: gn-h3 .6s cubic-bezier(.3, 1.7, .5, 1) .3s both; }
@keyframes gn-h3 { from { opacity: 0; transform: scale(.4) rotate(-6deg); } }
.result p { margin: 0; }
.result .note { font: 700 1.6rem/1.15 var(--hand); color: #b0566f; animation: gn-up .7s ease .6s both; }
.result .btn { margin-top: .4rem; }
/* Kuromi celebrates inside the result card's top corner, with her bubble in the band above the heading */
.result.won { padding-top: 3.1rem; }
.gn-host-res { position: absolute; right: 12px; top: 8px; width: 48px; z-index: 1; animation: gn-rise-up .6s cubic-bezier(.3, 1.5, .5, 1) .35s both; }
.gn-host-res .gn-jump::before { background: radial-gradient(closest-side, rgba(238, 138, 164, .28), rgba(238, 138, 164, 0)); }
.gn-host-res .gn-bubble { right: 100%; top: 2px; bottom: auto; background: var(--ink); color: var(--cream); border-radius: 1rem .2rem 1rem 1rem; transform-origin: 100% 30%; }
@keyframes gn-rise-up { from { opacity: 0; transform: translateY(40px) scale(.6); } }
.gn-res-deco { position: absolute; left: 50%; top: 0; width: 0; height: 0; pointer-events: none; }
.gn-res-deco i {
  position: absolute; left: 0; top: 0; font-style: normal; font-size: 1.1rem; line-height: 1; color: var(--rose); opacity: 0;
  animation: gn-resburst 1.2s cubic-bezier(.2, .8, .3, 1) calc(.3s + var(--i) * 35ms) both;
}
.gn-res-deco i:nth-child(even) { color: var(--flame); }
.result:not(.won) .gn-res-deco { display: none; }
@keyframes gn-resburst {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.2); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + (var(--i) - 3) * 34px), calc(-50% - 46px + (var(--i) - 3) * (var(--i) - 3) * 4px)) scale(1.1) rotate(20deg); }
}

@media (prefers-reduced-motion: reduce) {
  .gn-shoot, .gn-z { display: none; }
  #hub.quick .gn-slot, .chip.stamp, .gn-res-deco i, .gn-pop { animation-delay: 0s !important; }
}
