/* ==========================================================================
   Mipplet — Juegos. La sección de diversión: un marco «cosido» como de juguete de
   tela, figuras que flotan alrededor y un acento durazno que solo vive aquí.
   Colores sólidos en claro y en oscuro (nada translúcido: el iPhone se vuelve lento).
   ========================================================================== */

.juegos, .jg-guia {
  --j-fondo: #fff1e7;     /* durazno suave: el fondo del marco */
  --j-costura: #f2b58f;   /* la costura punteada */
  --j-durazno: #f59a6c;   /* el acento cálido de las figuras */
  --j-lavanda: #b9a5f5;
  --j-violeta: #7654d6;
  --j-carta: #ffffff;     /* la tarjeta del juego */
  --j-carta-borde: #ead9fb;
  --j-dato: #f6f1ff;      /* fondo de «Necesitas» */
}
.juegos {
  width: min(100% - 2 * var(--gutter), 680px);
  margin: 0 auto;
  padding-block: var(--s-4) var(--s-16);
}
:root[data-theme="night"] :is(.juegos, .jg-guia) {
  --j-fondo: #2a1b36; --j-costura: #6b4362; --j-durazno: #f2a27f; --j-lavanda: #9a80e6; --j-violeta: #b9a5f5;
  --j-carta: #1d1433; --j-carta-borde: #34285a; --j-dato: #261c40;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="day"]) :is(.juegos, .jg-guia) {
    --j-fondo: #2a1b36; --j-costura: #6b4362; --j-durazno: #f2a27f; --j-lavanda: #9a80e6; --j-violeta: #b9a5f5;
    --j-carta: #1d1433; --j-carta-borde: #34285a; --j-dato: #261c40;
  }
}

/* --- Portada ------------------------------------------------------------------------ */
.jg-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-8) var(--s-6) var(--s-8) var(--s-8);
  border-radius: 30px;
  background: var(--j-fondo);
  overflow: hidden;
}
.jg-hero::after {
  content: "";
  position: absolute;
  inset: 7px;
  border: 2.5px dashed var(--j-costura);
  border-radius: 24px;
  pointer-events: none;
}
.jg-hero__k { font-size: var(--fs-small); font-weight: var(--fw-semi); color: var(--text-2); }
.jg-hero__t { margin-top: 2px; font-size: clamp(2.1rem, 9vw, 2.75rem); font-weight: 800; letter-spacing: -0.035em; line-height: 1; }
.jg-hero__s { margin-top: var(--s-3); font-size: var(--fs-small); color: var(--text-2); line-height: 1.45; max-width: 22rem; }
.jg-hero__s b { color: var(--text); }
.jg-hero__ilu { position: relative; z-index: 1; width: 92px; height: 92px; transform: rotate(8deg); animation: jg-balanceo 5s var(--ease-out) infinite alternate; }

/* Las figuras: estrellas, bolas, un zigzag y una gota, en violeta, lavanda y durazno. */
.jg-confeti { position: absolute; inset: 0; pointer-events: none; }
.jg-f { position: absolute; display: block; animation: jg-flota 6s ease-in-out infinite alternate; }
.jg-f--estrella { width: 18px; height: 18px; background: var(--j-durazno); clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.jg-f--bola { width: 14px; height: 14px; border-radius: 50%; background: var(--j-lavanda); }
.jg-f--gota { width: 13px; height: 13px; border-radius: 50% 50% 50% 0; background: var(--j-violeta); transform: rotate(-45deg); }
.jg-f--zigzag {
  width: 34px; height: 10px; background: var(--j-violeta);
  clip-path: polygon(0 60%, 16% 0, 33% 60%, 50% 0, 66% 60%, 83% 0, 100% 60%, 100% 100%, 83% 40%, 66% 100%, 50% 40%, 33% 100%, 16% 40%, 0 100%);
}
.jg-f--chica { transform: scale(0.7); }
.jg-hero .jg-f:nth-child(1) { top: 18px; right: 120px; animation-delay: -1s; }
.jg-hero .jg-f:nth-child(2) { bottom: 22px; right: 26px; animation-delay: -3s; }
.jg-hero .jg-f:nth-child(3) { top: 22px; right: 30px; animation-duration: 7s; }
.jg-hero .jg-f:nth-child(4) { bottom: 30px; right: 96px; animation-delay: -2s; }
.jg-hero .jg-f:nth-child(5) { top: 46%; right: 132px; animation-delay: -4s; }
.jg-hero .jg-f:nth-child(6) { bottom: 18px; left: 22px; animation-delay: -5s; }
@keyframes jg-flota { from { translate: 0 0; } to { translate: 3px -7px; } }
@keyframes jg-balanceo { from { transform: rotate(8deg) translateY(0); } to { transform: rotate(-4deg) translateY(-4px); } }

/* --- Las áreas: carrusel centrado y sin fin; la del centro es la que se juega -------- */
.jg-cats {
  position: sticky;
  top: var(--top-h, 76px);
  z-index: 20;
  margin: var(--s-5) calc(-1 * var(--gutter)) 0;
  background: var(--bg);
}
.jg-cats__fila {
  display: flex;
  gap: var(--s-2);
  padding: var(--s-2) 0;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 20%, #000 80%, transparent);
  mask-image: linear-gradient(to right, transparent, #000 20%, #000 80%, transparent);
}
.jg-cats__fila::-webkit-scrollbar { display: none; }
.jg-cat {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 52px;
  padding: 6px var(--s-4) 6px 8px;
  border: 0;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border);
  color: var(--text);
  font: inherit;
  font-weight: var(--fw-semi);
  scroll-snap-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--dur-micro) var(--ease-out), box-shadow var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out), transform var(--dur-micro) var(--ease-out);
}
.jg-cat .ilu { width: 36px; height: 36px; }
.jg-cat[aria-selected="true"] { background: var(--primary); color: var(--on-primary); box-shadow: none; transform: scale(1.04); }
.jg-cat:active { transform: scale(0.96); }
.jg-cat:focus-visible { outline-offset: 2px; }
@media (hover: hover) { .jg-cat:not([aria-selected="true"]):hover { background: var(--accent-soft); } }

/* --- El juego ----------------------------------------------------------------------- */
/* Va de borde a borde y recorta a los lados: la tarjeta que se va girando no ensancha la página. */
.jg-zona { position: relative; margin: var(--s-4) calc(-1 * var(--gutter)) 0; padding-inline: var(--gutter); min-height: 420px; overflow-x: clip; }
.jg-juego {
  position: relative;
  padding: 14px;
  border-radius: 30px;
  background: var(--j-fondo);
}
.jg-juego::after {
  content: "";
  position: absolute;
  inset: 7px;
  border: 2.5px dashed var(--j-costura);
  border-radius: 24px;
  pointer-events: none;
}
.jg-carta {
  position: relative;
  z-index: 1;
  display: grid;
  gap: var(--s-4);
  padding: var(--s-6) var(--s-5) var(--s-5);
  border-radius: 22px;
  background: var(--j-carta);
  box-shadow: inset 0 0 0 1px var(--j-carta-borde);
}
.jg-carta__head { display: flex; align-items: center; gap: var(--s-3); }
.jg-carta__cat { display: grid; place-items: center; width: 56px; height: 56px; flex: none; border-radius: 18px; background: var(--j-fondo); }
.jg-carta__cat .ilu { width: 42px; height: 42px; }
.jg-carta__meta { display: grid; gap: 2px; min-width: 0; }
.jg-carta__area { font-size: var(--fs-caption); font-weight: var(--fw-semi); color: var(--accent); letter-spacing: 0.02em; }
.jg-carta__t { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.jg-carta__min { margin-left: auto; align-self: flex-start; flex: none; }
.jg-carta__como { font-size: 1.0625rem; line-height: 1.6; }
.jg-carta__dato { display: grid; gap: 4px; padding: var(--s-3) var(--s-4); border-radius: 16px; background: var(--j-dato); }
.jg-carta__dato dt { font-size: var(--fs-caption); font-weight: var(--fw-bold); color: var(--text-2); }
.jg-carta__dato dd { margin: 0; line-height: 1.5; }
.jg-carta__por { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s-3); align-items: start; color: var(--text-2); line-height: 1.5; font-size: var(--fs-small); }
.jg-carta__por .ilu { width: 26px; height: 26px; }
.jg-carta__acc { display: grid; gap: var(--s-2); margin-top: var(--s-1); }
.jg-hicimos { font-size: 1.0625rem; }
.jg-hicimos .ilu { width: 28px; height: 28px; }

/* ¿Cómo le fue? */
.jg-reac { display: grid; gap: var(--s-3); animation: jg-entra var(--dur-comp) var(--ease-out); }
.jg-reac__t { font-size: 1.125rem; font-weight: var(--fw-bold); text-align: center; }
.jg-reac__ops { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
.jg-reac__op {
  display: flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 56px; padding: var(--s-2) var(--s-3); border: 0; border-radius: 18px;
  background: var(--j-dato); box-shadow: inset 0 0 0 1px var(--j-carta-borde);
  color: var(--text); font: inherit; font-weight: var(--fw-semi); text-align: center; cursor: pointer;
  transition: transform var(--dur-micro) var(--ease-out), background var(--dur-micro) var(--ease-out);
}
.jg-reac__op:first-child { grid-column: 1 / -1; background: var(--primary); color: var(--on-primary); box-shadow: none; }
.jg-reac__op .icon { flex: none; }
.jg-reac__op:active { transform: scale(0.96); }
@media (hover: hover) { .jg-reac__op:not(:first-child):hover { background: var(--accent-soft); } }
.jg-reac__mas { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s-1) var(--s-2); }

.jg-vacio { display: grid; justify-items: center; gap: var(--s-3); padding: var(--s-6) var(--s-4); text-align: center; color: var(--text-2); }
.jg-vacio .ilu { width: 64px; height: 64px; }

/* Cambio de juego: el de ahora sale hacia un lado y el nuevo entra con un rebote suave. */
.jg-juego.is-sale { animation: jg-sale 260ms var(--ease-out) forwards; }
.jg-juego.is-entra { animation: jg-llega 520ms cubic-bezier(0.34, 1.4, 0.64, 1); }
@keyframes jg-sale { to { opacity: 0; transform: translateX(-40px) rotate(-3deg) scale(0.97); } }
@keyframes jg-llega { from { opacity: 0; transform: translateX(46px) rotate(3deg) scale(0.96); } }
@keyframes jg-entra { from { opacity: 0; transform: translateY(8px); } }

/* Confeti al terminar un juego. */
.jg-chispa {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  animation: jg-chispa 900ms cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}
@keyframes jg-chispa {
  0% { opacity: 1; transform: translate(0, 0) rotate(0) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--giro)) scale(0.6); }
}

/* --- La semana y los favoritos ------------------------------------------------------ */
.jg-bloque { display: grid; gap: var(--s-3); margin-top: var(--s-10); }
.jg-bloque__t { font-size: var(--fs-subheading); letter-spacing: var(--ls-snug); }
.jg-bloque__b { margin-top: calc(-1 * var(--s-2)); color: var(--text-2); font-size: var(--fs-small); }
.jg-semana { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); }
.jg-semana__c {
  display: grid; justify-items: center; gap: 2px; padding: var(--s-3) var(--s-2);
  border: 0; border-radius: 18px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--border);
  color: var(--text); font: inherit; cursor: pointer;
}
.jg-semana__c .ilu { width: 34px; height: 34px; }
.jg-semana__c b { font-size: 1.375rem; font-weight: 800; line-height: 1.1; }
.jg-semana__c small { font-size: var(--fs-caption); color: var(--text-2); }
.jg-semana__c.es-cero b { color: var(--text-3); }
.jg-semana__c:active { transform: scale(0.97); }
.jg-favs { display: grid; gap: var(--s-2); margin: 0; padding: 0; list-style: none; }
.jg-fav {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--s-3);
  width: 100%; min-height: 64px; padding: var(--s-2) var(--s-4) var(--s-2) var(--s-2);
  border: 0; border-radius: 18px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--border);
  color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.jg-fav .ilu { width: 40px; height: 40px; }
.jg-fav span { display: grid; gap: 2px; min-width: 0; }
.jg-fav strong { font-weight: var(--fw-semi); }
.jg-fav small { color: var(--text-2); font-size: var(--fs-caption); }
.jg-fav .icon { color: var(--text-3); }
.jg-fav:active { transform: scale(0.99); }
@media (hover: hover) { .jg-fav:hover, .jg-semana__c:hover { background: var(--accent-soft); } }
.jg-aviso { margin-top: var(--s-10); text-align: center; color: var(--text-3); }

/* --- La tarjeta en la Guía ---------------------------------------------------------- */
.jg-guia {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-6) var(--s-5) var(--s-5) var(--s-6);
  border-radius: 28px;
  background: var(--j-fondo);
  overflow: hidden;
}
.jg-guia::after { content: ""; position: absolute; inset: 7px; border: 2.5px dashed var(--j-costura); border-radius: 22px; pointer-events: none; }
.jg-guia__t { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; }
.jg-guia__b { margin-top: var(--s-2); color: var(--text-2); font-size: var(--fs-small); line-height: 1.45; }
.jg-guia__b b { color: var(--text); }
.jg-guia__ilu { width: 72px; height: 72px; transform: rotate(8deg); }
.jg-guia .btn { position: relative; z-index: 1; grid-column: 1 / -1; margin-top: var(--s-2); }
.jg-guia .jg-f:nth-child(1) { top: 16px; right: 92px; }
.jg-guia .jg-f:nth-child(2) { bottom: 76px; right: 18px; }
.jg-guia .jg-f:nth-child(3) { top: 20px; right: 20px; }

@media (prefers-reduced-motion: reduce) {
  .jg-f, .jg-hero__ilu, .jg-juego.is-sale, .jg-juego.is-entra, .jg-reac { animation: none !important; }
}
