/* ============================================================================
   ATRAPA EL SABOR — Wong / Cuisine & Co
   El escenario mide 1080 x 1920 (la mesa de trabajo del arte de Mágica) y se
   escala completo con transform, así el layout calca las coordenadas del arte.
   ========================================================================== */

@font-face {
  font-family: 'Degular';
  src: url('../assets/fonts/degular-semibold.woff2?v=4') format('woff2');
  font-weight: 600; font-display: block;
}
@font-face {
  font-family: 'MyriadPro';
  src: url('../assets/fonts/myriadpro-regular.woff2?v=4') format('woff2');
  font-weight: 400; font-display: swap;
}

:root {
  --rojo:  #EF1F26;
  --rojo-o:#c8151b;
  --blanco:#ffffff;
  /* Degular Demo no trae ¡ ! / ¿ ? — igual que en el arte, los toma Myriad */
  --display: 'Degular', 'MyriadPro', system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%; overflow: hidden; background: #0b0b0b;
  font-family: var(--display);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none; touch-action: none;
}

/* En pantallas más altas que 9:16 sobran franjas arriba y abajo: se pintan del
   color de la pantalla activa para que el encuadre se vea intencional. */
#viewport { position: fixed; inset: 0; background: var(--rojo); transition: background .45s ease; }
#viewport.is-dark { background: #141414; }

#stage {
  position: absolute; left: 50%; top: 50%;
  width: 1080px; height: 1920px;
  margin: -960px 0 0 -540px;      /* se centra por margen, no por layout:
                                     así el scale() no arrastra el encuadre */
  transform-origin: center center;
  background: var(--rojo);
  overflow: hidden;
  isolation: isolate;
}

/* ─────────────────────────── pantallas ─────────────────────────── */
.screen {
  position: absolute; inset: 0; z-index: 1;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .3s ease, visibility .3s;
}
.screen.is-active { opacity: 1; visibility: visible; pointer-events: auto; z-index: 2; }
/* La pantalla saliente NO se desvanece: se queda opaca por debajo hasta que la
   entrante termina de aparecer. Si ambas se cruzan a media opacidad se ven las
   dos superpuestas. */
.screen.is-leaving { opacity: 1; visibility: visible; transition: none; }
/* cada pantalla es su propio contexto de apilado: así el velo del fondo puede ir
   en z-index -1 (encima del color de fondo, debajo de todo el contenido) */
.screen { isolation: isolate; }
.screen--store, .screen--result { background: #000; }

/* Fondo de tienda + velo. El desenfoque viene horneado en el .webp: hacerlo con
   filter: blur() obligaba a Chrome a mantener y re-rasterizar una capa del
   tamaño del escenario, y en iOS eso tumbaba la pestaña por memoria. */
.screen--store::before, .screen--result.is-lose::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: url('../assets/bg-store.webp?v=4') center/cover no-repeat;
}
.screen--result.is-lose::before { background-image: url('../assets/bg-aisle.webp?v=4'); }
.screen--store::after, .screen--result.is-lose::after {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(180deg, rgba(0,0,0,.62), rgba(0,0,0,.42) 45%, rgba(0,0,0,.72));
}
.screen--result.is-win { background: var(--rojo); }


/* ─────────────────────────── botones ─────────────────────────── */
.btn {
  position: absolute; left: 50%; transform: translateX(-50%);
  width: 550px; height: 141px; border: 0; border-radius: 999px;
  background: var(--rojo); color: #fff;
  font: 600 91px/1 var(--display); letter-spacing: .5px;
  cursor: pointer; overflow: hidden;
  box-shadow: 0 14px 0 rgba(0,0,0,.18), 0 22px 44px rgba(0,0,0,.34);
  transition: transform .16s cubic-bezier(.34,1.7,.5,1), box-shadow .16s, filter .16s;
  animation: btnIn .5s .35s backwards cubic-bezier(.2,1.5,.4,1);
}
.btn > span { position: relative; z-index: 2; display: block; transform: translateY(-4px); white-space: nowrap; }
.btn--light { background: #fff; color: var(--rojo); }
/* sheen y halo se animan con transform/opacity, que van por el compositor;
   animar 'left' o el spread de box-shadow obliga a recalcular en cada frame */
.btn::before {                       /* brillo que barre el botón */
  content: ''; position: absolute; top: -60%; left: 0;
  width: 45%; height: 220%; z-index: 1;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent);
  animation: sheen 3.4s 1.2s infinite;
}
.btn--light::before { background: linear-gradient(90deg, transparent, rgba(239,31,38,.16), transparent); }
.btn::after {                        /* halo latiendo */
  content: ''; position: absolute; inset: 0; border-radius: inherit; z-index: 0;
  border: 3px solid rgba(255,255,255,.8); animation: halo 2.6s 1s infinite;
}
.btn:hover  { transform: translateX(-50%) translateY(-6px) scale(1.03); filter: brightness(1.04); box-shadow: 0 20px 0 rgba(0,0,0,.18), 0 30px 54px rgba(0,0,0,.4); }
.btn:active { transform: translateX(-50%) translateY(8px) scale(.98); box-shadow: 0 4px 0 rgba(0,0,0,.2), 0 8px 18px rgba(0,0,0,.3); transition-duration: .06s; }
.btn .ripple {
  position: absolute; z-index: 1; border-radius: 50%; pointer-events: none;
  background: rgba(255,255,255,.5); transform: translate(-50%,-50%) scale(0);
  animation: ripple .55s ease-out forwards;
}
.btn--light .ripple { background: rgba(239,31,38,.28); }

@keyframes sheen  { 0%,72% { transform: translateX(-160%) rotate(18deg) } 100% { transform: translateX(290%) rotate(18deg) } }
@keyframes halo   { 0% { opacity: .55; transform: scale(1) } 70%,100% { opacity: 0; transform: scale(1.28) } }
@keyframes ripple { to { transform: translate(-50%,-50%) scale(1); opacity: 0 } }
@keyframes btnIn  { from { opacity: 0; transform: translateX(-50%) translateY(60px) scale(.85) } }

/* ─────────────────────────── carga ─────────────────────────── */
[data-screen="load"] { display: grid; place-content: center; justify-items: center; gap: 60px; }
.load-logo img { width: 300px; animation: pop .8s cubic-bezier(.2,1.6,.4,1), float 3s 1s ease-in-out infinite; }
.load-bar { width: 420px; height: 14px; border-radius: 99px; background: rgba(255,255,255,.28); overflow: hidden; }
.load-bar i { display: block; height: 100%; width: 0; border-radius: 99px; background: #fff; transition: width .3s ease; }
.load-txt { color: #fff; font-size: 40px; opacity: .85; letter-spacing: .5px; }

@keyframes pop   { from { opacity: 0; transform: scale(.4) } }
@keyframes float { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-16px) } }

/* ─────────────────────────── portada ─────────────────────────── */
.sp-logo { position: absolute; left: 336px; top: 248px; width: 408px; }
.sp-word {
  position: absolute; left: 0; right: 0; top: 600px;
  text-align: center; color: #fff; font-size: 161px; line-height: 1; letter-spacing: 1px;
}
.sp-pill {
  position: absolute; left: 102px; top: 790px; width: 842px; height: 194px;
  background: #fff; border-radius: 999px; display: grid; place-items: center;
}
.sp-pill span { color: var(--rojo); font-size: 150px; line-height: 1; transform: translateY(-6px); letter-spacing: 1px; }
.sp-cart { position: absolute; left: 53px; top: 1128px; width: 940px; }
.sp-skip {
  position: absolute; left: 50%; bottom: 62px; transform: translateX(-50%);
  background: none; border: 0; color: rgba(255,255,255,.85); font: 600 40px var(--display);
  letter-spacing: 1px; cursor: pointer; animation: blink 1.8s 1.6s infinite backwards;
}
@keyframes blink { 0%,100% { opacity: .35 } 50% { opacity: 1 } }

.screen.is-active .sp-logo { animation: dropIn .8s cubic-bezier(.2,1.5,.4,1) backwards; }
.screen.is-active .sp-word { animation: dropIn .8s .18s cubic-bezier(.2,1.5,.4,1) backwards; }
.screen.is-active .sp-pill { animation: pillIn .75s .34s cubic-bezier(.2,1.6,.4,1) backwards; }
.screen.is-active .sp-cart { animation: cartRoll 1.05s .5s cubic-bezier(.2,1.15,.35,1) backwards; }

@keyframes dropIn   { from { opacity: 0; transform: translateY(-90px) scale(.85) } }
@keyframes pillIn   { from { opacity: 0; transform: scaleX(.2) } }
@keyframes cartRoll { from { opacity: 0; transform: translateX(-680px) rotate(-16deg) } }

/* ─────────────────────────── reto ─────────────────────────── */
.in-pill {
  position: absolute; left: 353px; top: 102px; width: 374px; height: 95px;
  background: #fff; color: var(--rojo); border-radius: 999px;
  display: grid; place-items: center; font-size: 74px; line-height: 1;
  animation: dropIn .6s cubic-bezier(.2,1.5,.4,1) backwards;
}
.in-pill::after { content: ''; position: absolute; inset: 0; border-radius: inherit; box-shadow: 0 0 0 0 rgba(255,255,255,.6); animation: halo 3s 1s infinite; }
.in-step {
  position: absolute; right: 64px; top: 118px; color: rgba(255,255,255,.75);
  font-size: 44px; letter-spacing: 1px;
}
.in-step b { font-size: 58px; color: #fff; }
.in-dish { position: absolute; left: 171px; top: 228px; width: 738px; height: 492px; display: grid; place-items: center; }
.in-dish img { max-width: 100%; max-height: 100%; animation: dishIn 1s .12s cubic-bezier(.2,1.4,.4,1) backwards, float 5s 1.1s ease-in-out infinite; }
.in-title {
  position: absolute; left: 0; right: 0; top: 742px; text-align: center;
  color: #fff; font-size: 85px; line-height: .96; font-weight: 600;
}
.in-title span { display: block; animation: upIn .6s .3s backwards cubic-bezier(.2,1.4,.4,1); }
.in-title span:last-child { animation-delay: .38s; }

.in-box {
  position: absolute; left: 123px; top: 995px; width: 797px; height: 539px;
  border: 3px solid rgba(255,255,255,.9); border-radius: 46px;
  display: flex; flex-direction: column; justify-content: center; gap: 56px; padding: 0 46px;
  animation: boxIn .7s .42s backwards cubic-bezier(.2,1.3,.4,1);
}
.in-rule { display: flex; align-items: center; gap: 34px; animation: upIn .55s backwards cubic-bezier(.2,1.4,.4,1); }
.in-rule:nth-child(1) { animation-delay: .58s; }
.in-rule:nth-child(2) { animation-delay: .70s; }
.in-rule p { color: #fff; font-size: 64px; line-height: .84; letter-spacing: .5px; }
.in-rule .ico { width: 92px; flex: 0 0 92px; fill: none; stroke: #fff; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.in-rule .ico .fill { fill: #fff; stroke: none; }
.in-rule:nth-child(1) .ico { width: 74px; flex-basis: 74px; }
[data-screen="intro"] .btn { top: 1618px; }

@keyframes dishIn { from { opacity: 0; transform: scale(.5) rotate(-22deg) } }
@keyframes upIn   { from { opacity: 0; transform: translateY(46px) } }
@keyframes boxIn  { from { opacity: 0; transform: scale(.9) } }

/* ─────────────────────────── juego ─────────────────────────── */
.pl-timebar { position: absolute; top: 0; left: 0; right: 0; height: 10px; background: rgba(255,255,255,.22); z-index: 6; }
.pl-timebar i { display: block; height: 100%; width: 100%; background: #fff; transform-origin: left; }
.pl-timebar.is-low i { background: #ffd400; }

.pl-timer {
  position: absolute; right: 36px; top: 66px; display: flex; align-items: center; gap: 14px;
  color: #fff; font-size: 63px; line-height: 1; text-shadow: 0 4px 18px rgba(0,0,0,.5);
}
.pl-timer #plTime { min-width: 84px; text-align: right; display: inline-block; }
.ico-clock { width: 62px; height: 68px; fill: none; stroke: #fff; stroke-width: 7; stroke-linecap: round; }
.ico-clock .fill { fill: #fff; stroke: none; }
.ico-clock .hand { transform-origin: 50px 58px; transition: transform .9s linear; }
.pl-timer.is-low { color: #ffd400; animation: tick .5s infinite; }
.pl-timer.is-low .ico-clock { stroke: #ffd400; }
.pl-timer.is-low .ico-clock .fill { fill: #ffd400; }
@keyframes tick { 0%,100% { transform: scale(1) } 50% { transform: scale(1.12) } }

.pl-title {
  position: absolute; left: 0; right: 0; top: 190px; text-align: center;
  color: #fff; font-size: 121px; line-height: .79; text-shadow: 0 8px 30px rgba(0,0,0,.55);
}
.pl-title span { display: block; }
.pl-banner {
  position: absolute; left: 176px; top: 445px; width: 724px; height: 143px; z-index: 4;
  background: var(--rojo); border-radius: 22px; color: #fff; font-size: 43px;
  display: grid; place-items: center; text-align: center; line-height: 1.05;
  box-shadow: 0 16px 40px rgba(0,0,0,.42);
  animation: bannerIn .6s .25s backwards cubic-bezier(.2,1.4,.4,1);
}
@keyframes bannerIn { from { opacity: 0; transform: translateY(-40px) scale(.9) } }

/* Sin z-index a propósito: si el anaquel creara contexto de apilado, el círculo
   arrastrado no podría pasar por encima del carrito y habría que subir el
   anaquel entero — que es justo lo que taparía el carrito. */
.pl-board { position: absolute; left: 104px; top: 442px; width: 861px; height: 1186px; }
.pl-shelf { width: 100%; height: 100%; object-fit: fill; }
.pl-slots { position: absolute; inset: 0; }

/* cada producto: círculo blanco de 169 px sobre el anaquel */
.slot {
  position: absolute; width: 169px; height: 169px; border-radius: 50%;
  background: #fff; display: grid; place-items: center; cursor: grab;
  box-shadow: 0 10px 22px rgba(0,0,0,.42), inset 0 -6px 14px rgba(0,0,0,.06);
  touch-action: none; user-select: none;
  transition: transform .18s cubic-bezier(.34,1.6,.5,1), box-shadow .18s;
  animation: slotIn .5s backwards cubic-bezier(.2,1.6,.4,1);
}
/* el packshot va recortado: se limita para que quepa dentro del círculo */
.slot img {
  max-width: 136px; max-height: 136px; object-fit: contain; pointer-events: none;
}
.slot::after {
  content: ''; position: absolute; inset: -7px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,.55); opacity: 0; transform: scale(.85);
  transition: opacity .2s, transform .2s;
}
.slot:hover { transform: translateY(-8px) scale(1.06); box-shadow: 0 18px 30px rgba(0,0,0,.5); }
.slot:hover::after { opacity: 1; transform: scale(1); }
.slot.is-drag { cursor: grabbing; z-index: 30; transform: scale(1.24); box-shadow: 0 30px 50px rgba(0,0,0,.55); transition: none; }
.slot.is-gone { pointer-events: none; }   /* ya está en el carrito */
.slot.is-wrong { animation: wrong .5s; }
.slot.is-idle  { animation: slotIdle 3.4s ease-in-out infinite; }
@keyframes slotIn   { from { opacity: 0; transform: scale(.2) rotate(-30deg) } }
@keyframes slotIdle { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-6px) } }
@keyframes wrong    { 0%,100% { transform: translateX(0) } 15% { transform: translateX(-16px) rotate(-5deg) } 35% { transform: translateX(14px) rotate(4deg) } 55% { transform: translateX(-10px) } 75% { transform: translateX(8px) } }

.pl-hint {
  position: absolute; left: 0; right: 0; top: 1140px; text-align: center; z-index: 4;
  color: #fff; font-size: 28px; line-height: 1.02; letter-spacing: 1.5px;
  text-shadow: 0 3px 12px rgba(0,0,0,.7); transition: opacity .4s;
}
.pl-hint .arrow { display: block; margin: 12px auto 0; width: 40px; fill: none; stroke: #fff; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; animation: bob 1.5s ease-in-out infinite; }
.pl-hint.is-off { opacity: 0; }
@keyframes bob { 0%,100% { transform: translateY(0); opacity: .65 } 50% { transform: translateY(12px); opacity: 1 } }

.pl-cart { position: absolute; left: 76px; top: 1202px; width: 761px; height: 507px; z-index: 4; }
/* El resalte de "suéltalo aquí" es un resplandor detrás del carrito, no un marco
   punteado (un rectángulo no calza con una foto en 3D y se lee como un error).
   Va con degradados, no con filter: en iOS cada filtro es una capa más que
   mantener en memoria y aquí es donde se caía la pestaña. */
.pl-cart {
  background: radial-gradient(ellipse 44% 11% at 46% 90%, rgba(0,0,0,.5), transparent 72%);
  transition: transform .2s;
}
.pl-cart::before {
  content: ''; position: absolute; inset: -8% -6% 4%;
  background: radial-gradient(closest-side, rgba(255,232,120,.62), rgba(255,212,0,.22) 55%, transparent 78%);
  opacity: 0; transition: opacity .2s;
}
.pl-cart .pl-cart-img { width: 100%; position: relative; z-index: 2; }
.pl-cart.is-over::before { opacity: 1; }

/* ── los productos atrapados, dentro de la canasta ──
   Van en la capa de abajo: la foto del carrito los tapa donde hay tubo y los
   deja ver entre las rejas. El que asoma por encima del borde se ve entero. */
.pl-cart-load { position: absolute; inset: 0; z-index: 1; pointer-events: none; }

.cart-item {
  position: absolute; width: 112px; height: 186px;
  display: grid; place-items: end center;      /* todos apoyados en el piso */
  animation: cartDrop .5s cubic-bezier(.2,1.5,.4,1) backwards;
}
/* sombra de apoyo con degradado, NO con filter: drop-shadow (ver README) */
.cart-item::before {
  content: ''; position: absolute; left: 4%; right: 4%; bottom: -4px; height: 28px;
  background: radial-gradient(closest-side, rgba(0,0,0,.6), transparent 76%);
}
.cart-item img { position: relative; max-width: 108px; max-height: 186px; object-fit: contain; }
@keyframes cartDrop { from { opacity: 0; transform: translateY(-90px) scale(1.4) rotate(-14deg) } }

/* el zangoloteo al soltar mueve las tres capas juntas, no solo la foto */
.pl-cart.is-over  { transform: scale(1.07) translateY(-10px); }
.pl-cart.is-hit   { animation: cartHit .5s cubic-bezier(.2,1.6,.4,1); }
@keyframes cartHit { 0% { transform: scale(1) } 30% { transform: scale(1.16) translateY(-18px) } 60% { transform: scale(.96) } 100% { transform: scale(1) } }

.pl-score {
  position: absolute; left: 416px; top: 1721px; width: 248px; height: 109px; z-index: 5;
  background: var(--rojo); border-radius: 999px; color: #fff; font-size: 77px;
  display: grid; place-items: center; white-space: nowrap; line-height: 1;
  box-shadow: 0 14px 30px rgba(0,0,0,.45); transition: transform .2s;
}
.pl-score b { font-weight: 600; }
.pl-score.is-pop { animation: scorePop .5s cubic-bezier(.2,1.8,.4,1); }
@keyframes scorePop { 0% { transform: scale(1) } 40% { transform: scale(1.28) } 100% { transform: scale(1) } }

.pl-fx { position: absolute; inset: 0; pointer-events: none; z-index: 40; }
.fx-float {
  position: absolute; transform: translate(-50%,-50%); font-size: 62px; color: #fff;
  text-shadow: 0 6px 20px rgba(0,0,0,.5); animation: floatUp 1.05s ease-out forwards; white-space: nowrap;
}
.fx-float.is-bad { color: #ffd400; }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%,-50%) scale(.5) } 25% { opacity: 1; transform: translate(-50%,-90%) scale(1.15) } 100% { opacity: 0; transform: translate(-50%,-190%) scale(1) } }

.fx-spark { position: absolute; width: 18px; height: 18px; border-radius: 50%; background: #fff; transform: translate(-50%,-50%); animation: spark .8s ease-out forwards; }
@keyframes spark { to { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.2) } }

.pl-flash { position: absolute; inset: 0; z-index: 45; pointer-events: none; background: rgba(239,31,38,.42); animation: flash .45s ease-out forwards; }
@keyframes flash { to { opacity: 0 } }

/* ─────────────────────────── resultado ─────────────────────────── */
#confetti { position: absolute; left: 0; top: 0; width: 1080px; height: 1920px; z-index: 50; pointer-events: none; }
.rs-title {
  position: absolute; left: 0; right: 0; top: 214px; text-align: center;
  color: #fff; font-size: 143px; line-height: .79; z-index: 6;
}
.rs-title span { display: block; animation: titleIn .7s backwards cubic-bezier(.2,1.5,.4,1); }
.rs-title span:last-child { animation-delay: .1s; }
@keyframes titleIn { from { opacity: 0; transform: translateY(-70px) scale(.7) } }

.rs-lead, .rs-count, .rs-kicker {
  position: absolute; left: 0; right: 0; text-align: center; color: #fff; z-index: 6;
  animation: upIn .6s backwards cubic-bezier(.2,1.4,.4,1);
}
.rs-lead   { top: 540px; font-size: 111px; line-height: .95; animation-delay: .22s; }
.rs-count  { top: 846px; font-size: 111px; line-height: 1; animation-delay: .34s; }
.rs-kicker { top: 1046px; font-size: 111px; line-height: 1; animation-delay: .46s; }
.rs-count b { display: inline-block; animation: countPop .6s .5s backwards cubic-bezier(.2,1.9,.4,1); }
@keyframes countPop { 0% { transform: scale(.3); opacity: 0 } 60% { transform: scale(1.35) } 100% { transform: scale(1) } }

.rs-dish { position: absolute; left: 257px; top: 1179px; width: 512px; height: 440px; display: grid; place-items: center; z-index: 6; }
.rs-dish img { max-width: 100%; max-height: 100%; animation: dishIn .9s .5s backwards cubic-bezier(.2,1.4,.4,1), float 5s 1.4s ease-in-out infinite; }
[data-screen="result"] .btn { top: 1618px; z-index: 7; }
.screen--result.is-lose .rs-dish { display: none; }
.screen--result.is-lose .rs-lead   { top: 520px; }
.screen--result.is-lose .rs-count  { top: 880px; }
.screen--result.is-lose .rs-kicker { top: 1180px; font-size: 101px; line-height: .95; }

/* ─────────────────────────── sonido ─────────────────────────── */
.snd {
  position: absolute; left: 34px; top: 34px; z-index: 60;
  width: 76px; height: 76px; border-radius: 50%; cursor: pointer;
  background: rgba(0,0,0,.28); border: 3px solid rgba(255,255,255,.5);
  display: grid; place-items: center; transition: transform .18s, background .18s;
}
.snd:hover { transform: scale(1.1); background: rgba(0,0,0,.45); }
.snd svg { width: 42px; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; }
.snd svg .fill { fill: #fff; stroke: #fff; stroke-linejoin: round; }
.snd #sndOff { display: none; }
.snd.is-muted #sndOn  { display: none; }
.snd.is-muted #sndOff { display: block; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
