/* Pantalla de carga al entrar a un juego (shell.js: cargaStart).
   Una escenita animada por juego que avanza con la carga de verdad (--p va de 0 a 1), el nombre del juego,
   una barrita con el porcentaje y, abajo, un consejo del juego o un dato de la zona que se van turnando.
   Todo es CSS y SVG en línea: no baja nada. Las animaciones mueven solo transform y opacity, así siguen
   fluidas aunque el juego esté armando su escena por detrás. */

.carga {
  position: absolute; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  padding: calc(var(--safe-top) + 20px) 16px calc(var(--safe-bottom) + 20px);
  color: #fff; background: var(--bg, linear-gradient(160deg, #22D3C0 0%, #0F86A0 100%));
  overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none;
  container-type: size;
  animation: cg-fade .16s ease-out both;
}
/* una luz suave detrás de la escena y el borde de abajo un poco más oscuro */
.carga::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(110% 52% at 50% 40%, rgba(255, 255, 255, .24), rgba(255, 255, 255, 0) 64%),
              radial-gradient(90% 40% at 50% 112%, rgba(0, 0, 0, .16), rgba(0, 0, 0, 0) 72%);
}
/* el aviso (por ejemplo, sin conexión) se sigue viendo encima */
.carga:not([hidden]) ~ #toast { z-index: 41; }

.cg-wrap {
  position: relative; display: flex; flex-direction: column; align-items: center; width: 100%; max-width: 340px;
  animation: cg-rise .44s cubic-bezier(.2, .9, .3, 1.15) both;
}
.cg-title {
  margin: 0 0 12px; text-wrap: balance; font-family: var(--display); font-weight: 400; font-size: 38px; line-height: 1; letter-spacing: .01em;
  text-align: center; text-shadow: 0 3px 0 rgba(0, 0, 0, .16);
}
.cg-box { position: relative; width: 288px; height: 196px; flex: none; }
.cg-scene { position: absolute; inset: 0; }
.cg-scene svg { display: block; width: 100%; height: 100%; overflow: visible; }

/* la barrita y el porcentaje: tranquilos, la escena es la que se luce */
.cg-meter { width: 220px; margin-top: 18px; }
.cg-track { display: block; height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .26); overflow: hidden; }
.cg-track i { display: block; height: 100%; border-radius: inherit; background: #fff; transform: scaleX(var(--p, 0)); transform-origin: left center; }
.cg-row { display: flex; justify-content: space-between; align-items: baseline; margin-top: 7px; }
.cg-word { font-size: 15px; font-weight: 700; opacity: .9; }
.cg-pct { font-family: var(--display); font-weight: 400; font-size: 19px; font-variant-numeric: tabular-nums; }
.carga.done .cg-word { animation: cg-pop .3s cubic-bezier(.34, 1.56, .64, 1); }

.cg-tip {
  width: 100%; max-width: 300px; min-height: 92px; margin-top: 16px; text-align: center;
  transition: opacity .22s ease, transform .22s ease;
}
.cg-tip.swap { opacity: 0; transform: translateY(6px); }
.cg-kind {
  display: inline-block; padding: 3px 10px; border-radius: 99px; background: rgba(255, 255, 255, .2);
  font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
}
.cg-kind:empty { display: none; }
.cg-line { margin: 8px 0 0; font-size: 16px; font-weight: 600; line-height: 1.35; text-wrap: balance; text-shadow: 0 1px 0 rgba(0, 0, 0, .1); }

/* salida: un toque de "¡Listo!" y se desvanece mostrando el juego */
.carga.out { opacity: 0; transition: opacity .32s ease; }
.carga.out .cg-wrap { transform: translateY(-12px) scale(1.03); transition: transform .36s ease; }

/* pantallas más grandes (compu, celulares anchos): la escena un poco más grande */
@container (min-width: 350px) and (min-height: 600px) {
  .cg-box { transform: scale(1.16); margin: 16px 0; }
  .cg-title { font-size: 42px; margin-bottom: 16px; }
}
@container (min-width: 410px) and (min-height: 720px) {
  .cg-box { transform: scale(1.3); margin: 28px 0; }
  .cg-title { font-size: 46px; }
}
/* pantallas bajitas */
@container (max-height: 520px) {
  .cg-box { transform: scale(.82); margin: -16px 0; }
  .cg-title { font-size: 32px; margin-bottom: 6px; }
  .cg-tip { min-height: 70px; margin-top: 10px; }
}

/* escenario muy angosto (por ejemplo, el celular acostado) */
@container (max-width: 280px) {
  .cg-box { transform: scale(.66); margin: -33px 0; }
  .cg-title { font-size: 26px; }
  .cg-meter { width: 180px; }
}

@keyframes cg-fade { from { opacity: 0; } }
@keyframes cg-rise { from { opacity: 0; transform: translateY(16px); } }
@keyframes cg-pop { 50% { transform: scale(1.18); } }
@keyframes cg-bob { from { transform: translateY(-3px); } to { transform: translateY(3px); } }
@keyframes cg-roll { to { transform: translateX(-50%); } }

/* agua que ondula: el dibujo es el doble de ancho y se corre a la mitad. Sale un poco de la caja y se desvanece a los costados */
.cg-water {
  position: absolute; left: -28px; right: -28px; bottom: 0; overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 13%, #000 87%, transparent); mask-image: linear-gradient(90deg, transparent, #000 13%, #000 87%, transparent);
}
.cg-water .cg-roll { position: absolute; left: 0; top: 0; bottom: 0; width: 200%; animation: cg-roll 3.4s linear infinite; }
.cg-water.back .cg-roll { animation-duration: 5.2s; animation-direction: reverse; }
.cg-water svg { display: block; width: 100%; height: 100%; }
/* el mar de adelante de Ballenazo y Cubos sigue hasta el fondo de la pantalla, cada vez más hondo */
.cg-water.cg-deep { left: -90px; right: -90px; bottom: -1600px; -webkit-mask-image: none; mask-image: none; }
.cg-water.cg-deep .cg-roll { bottom: auto; height: 24px; }
.cg-water.cg-deep::after { content: ''; position: absolute; left: 0; right: 0; top: 23px; bottom: 0; background: linear-gradient(currentColor, var(--deep, currentColor) 150px); }
.cg-meter, .cg-tip { position: relative; }
/* lo que está "debajo del agua" no se ve por abajo de la caja */
.cg-clip { position: absolute; left: -28px; right: -28px; top: -70px; bottom: 34px; overflow: hidden; }

/* ---------- Madryn Kart: el kart cruza la bandera a cuadros ---------- */
.cg-k .cg-road {
  position: absolute; left: -28px; right: -28px; bottom: 12px; height: 70px; border-radius: 18px; overflow: hidden;
  background: #4E5463; box-shadow: inset 0 -7px 0 rgba(0, 0, 0, .18);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent); mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}
.cg-k .cg-road::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 9px; background: repeating-linear-gradient(90deg, #fff 0 14px, #E63946 14px 28px); }
.cg-k .cg-dash {
  position: absolute; left: 0; top: 38px; width: calc(100% + 48px); height: 5px; border-radius: 3px;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, .78) 0 24px, transparent 24px 48px);
  animation: cg-road .3s linear infinite;
}
.cg-k .cg-flag { position: absolute; right: 4px; bottom: 76px; width: 40px; height: 61px; }
.cg-k .cg-wave-flag { transform-box: fill-box; transform-origin: left center; animation: cg-flag .45s ease-in-out infinite alternate; }
.cg-k .cg-go { position: absolute; left: -6px; bottom: 38px; width: 130px; height: 74px; transform: translateX(calc(var(--p, 0) * 168px)); }
.cg-k .cg-car { position: relative; width: 100%; height: 100%; animation: cg-bump .2s ease-in-out infinite alternate; }
.cg-k .cg-wheel { transform-box: fill-box; transform-origin: center; animation: cg-spin .26s linear infinite; }
.cg-k .cg-puff { position: absolute; left: -4px; bottom: 14px; width: 18px; height: 18px; border-radius: 50%; background: rgba(255, 255, 255, .85); animation: cg-puff .6s ease-out infinite; }
.cg-k .cg-puff.b { animation-delay: -.2s; bottom: 22px; }
.cg-k .cg-puff.c { animation-delay: -.4s; bottom: 9px; }
@keyframes cg-road { to { transform: translateX(-48px); } }
@keyframes cg-flag { from { transform: skewY(-7deg) scaleX(.94); } to { transform: skewY(5deg) scaleX(1); } }
@keyframes cg-bump { from { transform: translateY(0) rotate(0); } to { transform: translateY(-2.5px) rotate(-1.4deg); } }
@keyframes cg-spin { to { transform: rotate(360deg); } }
@keyframes cg-puff { from { transform: translate(0, 0) scale(.4); opacity: .95; } to { transform: translate(-38px, -10px) scale(1.6); opacity: 0; } }

/* ---------- Pingüino de Tombo: camina del nido al mar y, al final, se tira ---------- */
.cg-p .cg-ground { position: absolute; left: -60px; right: -60px; bottom: 0; height: 84px; }
.cg-p .cg-ground svg { display: block; width: 100%; height: 100%; }
.cg-p .cg-bush { position: absolute; left: -2px; bottom: 60px; width: 70px; height: 50px; }
.cg-p .cg-trail {
  position: absolute; left: 44px; bottom: 56px; height: 7px; width: calc(var(--p, 0) * 150px);
  background: radial-gradient(circle, #C49A5C 2.3px, transparent 2.8px) 0 0 / 13px 7px repeat-x;
}
.cg-p .cg-water.cg-mar { left: 150px; right: -60px; color: #2CB7D2; -webkit-mask-image: none; mask-image: none; }
.cg-p .cg-lab { position: absolute; font-family: var(--display); font-size: 16px; line-height: 1; }
.cg-p .cg-lab.l { left: 12px; bottom: 26px; color: #A0703A; }
.cg-p .cg-lab.r { right: 4px; bottom: 12px; color: #fff; }
.cg-p .cg-go { position: absolute; left: 20px; bottom: 60px; width: 60px; height: 76px; transform: translateX(calc(var(--p, 0) * 150px)); }
.cg-p .cg-tombo { width: 100%; height: 100%; transform-origin: 50% 100%; animation: cg-waddle .32s ease-in-out infinite alternate; }
.carga.done .cg-p .cg-tombo { animation: cg-dive .55s cubic-bezier(.4, 0, .7, 1) forwards; }
@keyframes cg-waddle { 0% { transform: rotate(-9deg); } 50% { transform: rotate(0) translateY(-5px); } 100% { transform: rotate(9deg); } }
@keyframes cg-dive { 0% { transform: rotate(0); } 35% { transform: translate(10px, -22px) rotate(35deg); } 100% { transform: translate(44px, 46px) rotate(95deg); opacity: 0; } }

/* ---------- Ballenazo: la ballena salta entre las olas, cada vez más alto ---------- */
.cg-w .cg-water.back, .cg-c .cg-water.back { left: -90px; right: -90px; -webkit-mask-image: none; mask-image: none; }
.cg-w .cg-water.back { color: rgba(255, 255, 255, .26); }
.cg-w .cg-water.front { color: #0F7E96; --deep: #075A6E; }
.cg-w .cg-go { position: absolute; left: 50%; bottom: 6px; width: 132px; height: 87px; margin-left: -66px; transform: translateY(calc((1 - var(--p, 0)) * 24px)); }
.cg-w .cg-whale { width: 100%; height: 100%; animation: cg-breach 2.4s cubic-bezier(.42, 0, .58, 1) infinite; }
.cg-w .cg-drop {
  position: absolute; left: 50%; bottom: 66px; margin-left: -66px; width: 10px; height: 10px; border-radius: 50%; background: #fff;
  box-shadow: 14px -6px 0 -1px #fff, -10px -3px 0 -2px #fff; opacity: 0; animation: cg-splash 2.4s linear infinite;
}
.cg-w .cg-drop.b { margin-left: -44px; animation-name: cg-splash-b; }
.cg-w .cg-drop.c { margin-left: 52px; animation-name: cg-splash-c; }
@keyframes cg-breach {
  0% { transform: translate(-92px, 80px) rotate(-40deg); opacity: 0; }
  10% { opacity: 1; }
  36% { transform: translate(-30px, -50px) rotate(-18deg); }
  52% { transform: translate(0, -74px) rotate(0); }
  70% { transform: translate(36px, -46px) rotate(24deg); }
  90% { opacity: 1; }
  100% { transform: translate(92px, 80px) rotate(48deg); opacity: 0; }
}
@keyframes cg-splash { 0%, 22% { opacity: 0; transform: translate(0, 6px) scale(.6); } 29% { opacity: 1; transform: translate(-8px, -18px) scale(1); } 45%, 100% { opacity: 0; transform: translate(-20px, 8px) scale(.8); } }
@keyframes cg-splash-b { 0%, 25% { opacity: 0; transform: translate(0, 6px) scale(.6); } 32% { opacity: 1; transform: translate(6px, -22px) scale(1); } 49%, 100% { opacity: 0; transform: translate(14px, 6px) scale(.8); } }
@keyframes cg-splash-c { 0%, 78% { opacity: 0; transform: translate(0, 6px) scale(.6); } 86% { opacity: 1; transform: translate(5px, -20px) scale(1.1); } 100% { opacity: 0; transform: translate(14px, 4px) scale(.8); } }

/* ---------- Torre Galesa: caen porciones de torta y la torre crece; la tetera humea ---------- */
.cg-t .cg-plate { position: absolute; left: 50%; bottom: 8px; width: 170px; height: 18px; margin-left: -85px; border-radius: 50%; background: #fff; box-shadow: 0 4px 0 rgba(0, 0, 0, .12), inset 0 -4px 0 #F1E3E8; }
.cg-t .cg-slice {
  position: absolute; left: 50%; width: 104px; height: 18px; border-radius: 6px; opacity: 0; transform: translateY(-52px);
  background: radial-gradient(circle at 22% 70%, #C0392B 2px, transparent 2.5px), radial-gradient(circle at 64% 62%, #2E1A10 1.9px, transparent 2.4px),
              radial-gradient(circle at 84% 76%, #C0392B 1.8px, transparent 2.3px), radial-gradient(circle at 42% 82%, #2E1A10 1.6px, transparent 2.1px), linear-gradient(#FFEBC9 0 5px, #6B3420 5px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .14);
  transition: transform .34s cubic-bezier(.34, 1.56, .64, 1), opacity .1s linear;
}
.cg-t .cg-slice.f1 { background-image: radial-gradient(circle at 30% 64%, #2E1A10 1.9px, transparent 2.4px), radial-gradient(circle at 72% 74%, #C0392B 2px, transparent 2.5px), radial-gradient(circle at 52% 58%, #C0392B 1.6px, transparent 2.1px), linear-gradient(#FFEBC9 0 5px, #8A4628 5px); }
.cg-t .cg-slice.f2 { background-image: radial-gradient(circle at 26% 66%, #fff 1.6px, transparent 2.2px), radial-gradient(circle at 70% 60%, #fff 1.4px, transparent 2px), linear-gradient(#FFF6CF 0 5px, #F2B705 5px); box-shadow: 0 2px 0 rgba(0, 0, 0, .14), 0 0 12px rgba(255, 224, 122, .8); }
.cg-t .cg-slice.in { opacity: 1; transform: none; }
.cg-t .cg-mover { position: absolute; left: 50%; bottom: calc(46px + var(--n, 0) * 18px); transition: bottom .3s ease; }
.cg-t .cg-mover .cg-slice { left: 0; bottom: 0; margin-left: -52px; opacity: 1; transform: none; animation: cg-swing 1.25s ease-in-out infinite alternate; }
.cg-t .cg-pot { position: absolute; right: 0; bottom: 12px; width: 54px; height: 48px; }
.cg-t .cg-pot svg { width: 100%; height: 100%; display: block; }
.cg-t .cg-steam { position: absolute; left: -2px; top: 2px; width: 9px; height: 9px; border-radius: 50%; background: rgba(255, 255, 255, .8); animation: cg-steam 1.6s ease-out infinite; }
.cg-t .cg-steam.b { animation-delay: -.8s; }
@keyframes cg-swing { from { transform: translateX(-70px); } to { transform: translateX(70px); } }
@keyframes cg-steam { from { transform: translate(0, 0) scale(.5); opacity: 0; } 25% { opacity: .9; } to { transform: translate(-8px, -30px) scale(1.7); opacity: 0; } }

/* ---------- Madryn Snake: la víbora de pelotas crece y va a comerse el pescado ---------- */
.cg-s .cg-patch {
  position: absolute; left: -12px; right: -12px; bottom: 14px; height: 120px; border-radius: 60px; background: #F4DCA6;
  background-image: radial-gradient(circle at 14% 30%, rgba(160, 110, 40, .24) 3.5px, transparent 4px), radial-gradient(circle at 40% 80%, rgba(160, 110, 40, .2) 3px, transparent 3.5px),
                    radial-gradient(circle at 72% 22%, rgba(160, 110, 40, .2) 3px, transparent 3.5px), radial-gradient(circle at 90% 74%, rgba(160, 110, 40, .2) 2.5px, transparent 3px);
  box-shadow: inset 0 -8px 0 rgba(160, 110, 40, .14);
}
.cg-s .cg-fish { position: absolute; right: 2px; bottom: 66px; width: 46px; height: 30px; animation: cg-bob .7s ease-in-out infinite alternate; }
.cg-s .cg-fish svg { transition: transform .22s ease, opacity .22s ease; }
.carga.done .cg-s .cg-fish svg { opacity: 0; transform: scale(.2); }
.cg-s .cg-go { position: absolute; left: 124px; bottom: 54px; width: 44px; height: 44px; transform: translateX(calc(var(--p, 0) * 102px)); }
.cg-s .cg-body { position: absolute; inset: 0; }
.cg-s .cg-b {
  position: absolute; bottom: 6px; width: 32px; height: 32px; border-radius: 50%; border: 2.5px solid #167A4C;
  background: linear-gradient(90deg, #2EC27E 0 34%, #fff 34% 66%, #2EC27E 66%);
  scale: 0; transition: scale .26s cubic-bezier(.34, 1.56, .64, 1); animation: cg-slither .76s ease-in-out infinite alternate;
}
.cg-s .cg-b.in { scale: 1; }
.cg-s .cg-head {
  position: absolute; left: 0; bottom: 0; width: 44px; height: 44px; border-radius: 50%; background: #2EC27E; border: 3px solid #167A4C;
  animation: cg-slither .76s ease-in-out infinite alternate;
}
.cg-s .cg-head b { position: absolute; top: 6px; width: 15px; height: 15px; border-radius: 50%; background: radial-gradient(circle at 64% 55%, #1D2433 0 3.4px, #fff 4px); }
.cg-s .cg-head b:first-child { left: 6px; }
.cg-s .cg-head b + b { left: 20px; }
@keyframes cg-slither { from { translate: 0 -7px; } to { translate: 0 7px; } }

/* ---------- Madryn Cubos: los cubos salen del mar uno por uno ---------- */
.cg-c .cg-water.back { color: #8FDDF2; }
.cg-c .cg-water.front { color: #2CB7D2; --deep: #12789A; }
.cg-c .cg-cube { position: absolute; width: 62px; height: 53px; margin-left: 26px; opacity: 0; transform: translateY(84px); transition: transform .5s cubic-bezier(.34, 1.56, .64, 1), opacity .12s linear; }
.cg-c .cg-cube.in { opacity: 1; transform: none; }
.cg-c .cg-cube svg { display: block; width: 100%; height: 100%; animation: cg-bob 1.5s ease-in-out infinite alternate; animation-delay: var(--d, 0s); }
.cg-c .cg-ring { position: absolute; left: 50%; width: 70px; height: 16px; margin-left: -35px; border: 3px solid #fff; border-radius: 50%; opacity: 0; }
.cg-c .cg-cube.in .cg-ring { animation: cg-ring .7s ease-out .12s both; }
@keyframes cg-ring { from { opacity: .95; transform: scale(.4); } to { opacity: 0; transform: scale(1.5); } }

/* ---------- Madryn Box: dos guantes que chocan; la cuerda de arriba se llena ---------- */
.cg-x .cg-floor { position: absolute; left: -8px; right: -8px; bottom: 10px; height: 34px; border-radius: 14px; background: rgba(255, 255, 255, .2); box-shadow: inset 0 -7px 0 rgba(0, 0, 0, .12); }
.cg-x .cg-post { position: absolute; bottom: 34px; width: 14px; height: 122px; border-radius: 7px; background: #fff; }
.cg-x .cg-post.l { left: 8px; box-shadow: inset 0 18px 0 #FFB020; }
.cg-x .cg-post.r { right: 8px; box-shadow: inset 0 18px 0 #FF3D57; }
.cg-x .cg-ropes { position: absolute; left: 18px; right: 18px; bottom: 74px; height: 70px; }
.cg-x .cg-ropes i { position: absolute; left: 0; right: 0; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .34); }
.cg-x .cg-ropes i:nth-child(1) { top: 0; }
.cg-x .cg-ropes i:nth-child(2) { top: 32px; }
.cg-x .cg-ropes i:nth-child(3) { top: 64px; }
.cg-x .cg-ropefill { position: absolute; left: 0; right: 0; top: 0; height: 6px; border-radius: 3px; background: #FFE07A; transform: scaleX(var(--p, 0)); transform-origin: left center; }
.cg-x .cg-glove { position: absolute; top: 22px; left: 50%; width: 106px; height: 75px; }
.cg-x .cg-glove.l { margin-left: -108px; animation: cg-jab-l 1.1s cubic-bezier(.5, 0, .5, 1) infinite; }
.cg-x .cg-glove.r { margin-left: 2px; animation: cg-jab-r 1.1s cubic-bezier(.5, 0, .5, 1) infinite; }
.cg-x .cg-glove svg { width: 100%; height: 100%; display: block; }
.cg-x .cg-glove.r svg { transform: scaleX(-1); }
.cg-x .cg-pow {
  position: absolute; left: 50%; top: 20px; width: 80px; height: 80px; margin-left: -40px; background: #FFE07A; opacity: 0;
  clip-path: polygon(50% 0, 61% 30%, 95% 18%, 72% 46%, 100% 62%, 66% 66%, 72% 100%, 50% 76%, 27% 98%, 34% 66%, 0 70%, 28% 47%, 6% 18%, 40% 30%);
  animation: cg-pow 1.1s ease-out infinite;
}
@keyframes cg-jab-l { 0%, 100% { transform: translateX(-16px) rotate(-4deg); } 36% { transform: translateX(-26px) translateY(2px) rotate(-8deg); } 50% { transform: translateX(6px) translateY(-2px) rotate(3deg); } 62% { transform: translateX(-4px); } }
@keyframes cg-jab-r { 0%, 100% { transform: translateX(16px) rotate(4deg); } 36% { transform: translateX(26px) translateY(2px) rotate(8deg); } 50% { transform: translateX(-6px) translateY(-2px) rotate(-3deg); } 62% { transform: translateX(4px); } }
@keyframes cg-pow { 0%, 44% { opacity: 0; transform: scale(.3) rotate(0); } 52% { opacity: 1; transform: scale(1.1) rotate(8deg); } 72%, 100% { opacity: 0; transform: scale(1.45) rotate(14deg); } }

/* ---------- Madryn Giro: el tablero se mece y la bolita rueda hasta el hoyo con la carga ---------- */
.cg-g .cg-gped {
  position: absolute; left: 50%; bottom: 4px; width: 84px; height: 58px; margin-left: -42px; border-radius: 10px;
  background: linear-gradient(#2F5BD6, #2348A8); clip-path: polygon(34% 0, 66% 0, 100% 100%, 0 100%);
}
.cg-g .cg-gtilt { position: absolute; left: 14px; right: 14px; top: 26px; height: 124px; perspective: 560px; }
.cg-g .cg-gboard {
  position: absolute; inset: 0; border-radius: 18px; background: #F6DDA6; transform-style: preserve-3d;
  box-shadow: inset 0 0 0 10px #2F5BD6, 0 12px 0 #2348A8, 0 22px 26px rgba(0, 0, 0, .18);
  transform: rotateX(40deg) rotateY(-6deg); animation: cg-gtilt 2.4s ease-in-out infinite alternate;
}
.cg-g .cg-gpit, .cg-g .cg-ghole { position: absolute; border-radius: 50%; background: radial-gradient(circle at 40% 36%, #05060A, #141A2C 60%, #3A1F2A); }
.cg-g .cg-gpit { left: 40px; bottom: 12px; width: 30px; height: 30px; box-shadow: 0 0 0 4px #E23B3B; }
.cg-g .cg-ghole { right: 24px; top: 24px; width: 38px; height: 38px; box-shadow: 0 0 0 5px #FFC93C, 0 0 18px 6px rgba(255, 201, 60, .5); transform-style: preserve-3d; }
.cg-g .cg-gflag { position: absolute; left: 22px; bottom: 18px; width: 22px; height: 40px; transform-origin: 50% 100%; transform: rotateX(-62deg); }
.cg-g .cg-gflag .cg-wave-flag { transform-box: fill-box; transform-origin: left center; animation: cg-flag .5s ease-in-out infinite alternate; }
.cg-g .cg-gbar { position: absolute; left: 120px; top: 12px; width: 16px; height: 36px; border-radius: 8px; background: #2F5BD6; box-shadow: 0 3px 0 #2348A8; }
.cg-g .cg-gtrail {
  position: absolute; left: 34px; top: 68px; width: 178px; height: 4px; transform-origin: left center; transform: rotate(-7deg) scaleX(var(--p, 0));
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, .95) 0 6px, transparent 6px 13px); border-radius: 2px;
}
.cg-g .cg-gball {
  position: absolute; left: 22px; top: 56px; width: 26px; height: 26px;
  transform: translate(calc(var(--p, 0) * 176px), calc(var(--p, 0) * -22px)); transition: transform .2s linear;
}
.cg-g .cg-gball i {
  display: block; width: 100%; height: 100%; border-radius: 50%; box-shadow: 0 3px 0 rgba(0, 0, 0, .18);
  background: linear-gradient(170deg, #fff 0 34%, #2E5BE6 34% 56%, #7CC4FF 56% 66%, #fff 66%); animation: cg-spin .7s linear infinite;
}
.carga.done .cg-g .cg-gball i { animation: cg-gdrop .4s ease-in forwards; }
@keyframes cg-gtilt { from { transform: rotateX(42deg) rotateY(-7deg); } to { transform: rotateX(37deg) rotateY(6deg); } }
@keyframes cg-gdrop { to { transform: scale(.45); opacity: 0; } }
/* ---------- Madryn Colores: una plaza que se pinta con la carga y gotas que rebotan ---------- */
.cg-co .cg-grid {
  position: absolute; left: 50%; top: 44px; width: 236px; height: 150px; margin-left: -118px;
  display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(3, 1fr); gap: 7px;
  padding: 8px; border-radius: 16px; background: rgba(255, 255, 255, .22); box-shadow: 0 10px 0 rgba(0, 0, 0, .12);
  transform: perspective(520px) rotateX(46deg); transform-origin: 50% 70%;
}
.cg-co .cg-tile { border-radius: 9px; background: #F6EDDA; box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .08); transition: background-color .18s ease; }
.cg-co .cg-tile.in { background: var(--c); animation: cg-paint .38s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes cg-paint { 0% { transform: scale(.7); } 60% { transform: scale(1.12); } 100% { transform: none; } }
.cg-co .cg-drop {
  position: absolute; left: 50%; top: 0; width: 26px; height: 34px; margin-left: -13px; background: #fff;
  border-radius: 50% 50% 50% 50% / 62% 62% 40% 40%; clip-path: polygon(50% 0, 82% 34%, 100% 62%, 92% 86%, 50% 100%, 8% 86%, 0 62%, 18% 34%);
  animation: cg-drip 1.3s cubic-bezier(.45, 0, .55, 1) infinite;
}
.cg-co .cg-drop.b { width: 16px; height: 21px; margin-left: 46px; animation-delay: -.65s; animation-duration: 1.1s; opacity: .85; }
@keyframes cg-drip { 0% { transform: translate(-70px, 0) scale(1, 1); } 45% { transform: translate(-8px, 96px) scale(1.1, .82); } 55% { transform: translate(6px, 96px) scale(1.15, .7); } 100% { transform: translate(70px, 0) scale(1, 1); } }
/* Orquesta Marina: tres carriles en perspectiva; las notas bajan, se achican de lejos y los botones se prenden al llegar */
.cg-o .cg-lanes { position: absolute; inset: 0; }
.cg-o .cg-hit { position: absolute; left: 14px; right: 14px; top: 148px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .3); overflow: hidden; }
.cg-o .cg-hit b { display: block; height: 100%; background: #fff; transform: scaleX(var(--p, 0)); transform-origin: left center; }
.cg-o .cg-pad { position: absolute; top: 160px; width: 30px; height: 30px; margin-left: -15px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 3px 0 rgba(0, 0, 0, .18); }
.cg-o .cg-pad.p0 { left: 44px; background: #3A86FF; animation: cg-o-pad .9s linear -.072s infinite; }
.cg-o .cg-pad.p1 { left: 144px; background: #FFC93C; animation: cg-o-pad .9s linear -.372s infinite; }
.cg-o .cg-pad.p2 { left: 244px; background: #FF5A5F; animation: cg-o-pad .9s linear -.672s infinite; }
.cg-o .cg-note { position: absolute; top: 0; left: 0; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; border: 3px solid #fff; opacity: 0; }
.cg-o .cg-note.n0 { background: #3A86FF; --x0: 112px; --x1: 44px; animation: cg-o-note 1.8s cubic-bezier(.55, 0, .9, .6) infinite; }
.cg-o .cg-note.n1 { background: #FFC93C; --x0: 144px; --x1: 144px; animation: cg-o-note 1.8s cubic-bezier(.55, 0, .9, .6) .6s infinite; }
.cg-o .cg-note.n2 { background: #FF5A5F; --x0: 176px; --x1: 244px; animation: cg-o-note 1.8s cubic-bezier(.55, 0, .9, .6) 1.2s infinite; }
.cg-o .cg-note.b { animation-delay: -.9s; }
.cg-o .cg-note.n1.b { animation-delay: -.3s; }
.cg-o .cg-note.n2.b { animation-delay: .3s; }
@keyframes cg-o-note {
  0% { opacity: 0; transform: translate(var(--x0), 8px) scale(.45); }
  8% { opacity: 1; }
  92% { opacity: 1; transform: translate(var(--x1), 151px) scale(1); }
  100% { opacity: 0; transform: translate(var(--x1), 151px) scale(1.5); }
}
@keyframes cg-o-pad { 0%, 86% { transform: scale(1); filter: none; } 92% { transform: scale(1.2); filter: brightness(1.3); } 100% { transform: scale(1); filter: none; } }

/* Menos movimiento: la escena queda quieta y solo avanza con la carga */
@media (prefers-reduced-motion: reduce) {
  .carga, .carga *, .carga *::before, .carga *::after { animation: none !important; transition-duration: 0s !important; }
  .carga.out { transition: opacity .2s ease !important; }
  .carga.out .cg-wrap { transform: none; }
  .cg-w .cg-whale { transform: translateY(-58px) rotate(-6deg); }
  .cg-x .cg-glove.l { transform: translateX(-12px); }
  .cg-x .cg-glove.r { transform: translateX(12px); }
  .carga.done .cg-p .cg-tombo { opacity: 1; }
}

/* ---------- Madryn Dino: el pingüino corre al refugio y el Carnotaurus lo sigue mordiendo el aire ---------- */
.cg-d .cg-mesa {
  position: absolute; left: -40px; right: -40px; bottom: 70px; height: 52px; background: rgba(255, 255, 255, .2);
  clip-path: polygon(0 100%, 4% 46%, 16% 46%, 21% 100%, 30% 100%, 35% 18%, 52% 18%, 57% 100%, 63% 100%, 67% 58%, 80% 58%, 84% 100%, 88% 100%, 91% 34%, 100% 34%, 100% 100%);
}
.cg-d .cg-steppe {
  position: absolute; left: -28px; right: -28px; bottom: 10px; height: 66px; border-radius: 18px; overflow: hidden;
  background: #F2CF7E; box-shadow: inset 0 9px 0 #F7DC98, inset 0 -7px 0 rgba(150, 100, 30, .18);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent); mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}
.cg-d .cg-dash {
  position: absolute; left: 0; top: 34px; width: calc(100% + 48px); height: 8px;
  background: radial-gradient(circle, #FBEBC4 3px, transparent 3.6px) 0 0 / 24px 8px repeat-x;
  animation: cg-road .34s linear infinite;
}
.cg-d .cg-hut { position: absolute; right: -6px; bottom: 50px; width: 66px; height: 58px; }
.cg-d .cg-go { position: absolute; left: -14px; bottom: 34px; width: 140px; height: 62px; transform: translateX(calc(var(--p, 0) * 146px)); }
.cg-d .cg-rex { position: absolute; left: 0; bottom: 0; width: 84px; height: 61px; transform-origin: 40% 100%; animation: cg-gallop .36s ease-in-out infinite alternate; }
.cg-d .cg-leg { transform-box: fill-box; transform-origin: 50% 0; animation: cg-step .18s ease-in-out infinite alternate; }
.cg-d .cg-leg.b { animation-direction: alternate-reverse; }
.cg-d .cg-jaw { transform-box: fill-box; transform-origin: 0 0; animation: cg-chomp .3s ease-in-out infinite alternate; }
.cg-d .cg-tombo { position: absolute; left: 100px; bottom: 2px; width: 34px; height: 44px; transform-origin: 50% 100%; animation: cg-dash-run .2s ease-in-out infinite alternate; }
.cg-d .cg-puff { position: absolute; left: 8px; bottom: 0; width: 16px; height: 16px; border-radius: 50%; background: rgba(255, 247, 225, .9); animation: cg-puff .6s ease-out infinite; }
.cg-d .cg-puff.b { animation-delay: -.3s; left: 30px; }
.carga.done .cg-d .cg-tombo { animation: cg-home .42s ease-in forwards; }
.carga.done .cg-d .cg-rex { animation: cg-skid .4s ease-out forwards; }
@keyframes cg-gallop { from { transform: translateY(0) rotate(-2deg); } to { transform: translateY(-5px) rotate(2deg); } }
@keyframes cg-step { from { transform: rotate(-22deg); } to { transform: rotate(22deg); } }
@keyframes cg-chomp { from { transform: rotate(0); } to { transform: rotate(16deg); } }
@keyframes cg-dash-run { from { transform: translateY(0) rotate(-7deg); } to { transform: translateY(-6px) rotate(7deg); } }
@keyframes cg-home { to { transform: translate(18px, -6px) scale(.5); opacity: 0; } }
@keyframes cg-skid { to { transform: translateX(-10px) rotate(-6deg); } }
@media (prefers-reduced-motion: reduce) { .carga.done .cg-d .cg-tombo { opacity: 1; } }
