/* ==========================================================================
   Ruleta premiada. Todo lo que se mueve usa transform u opacity (compositor).
   ========================================================================== */

/* ---------- Diálogo ---------- */
dialog.wheelm {
  width: min(1000px, calc(100% - 28px)); max-width: none; max-height: calc(100vh - 28px); max-height: calc(100dvh - 28px);
  margin: auto; padding: 0; overflow: auto; overscroll-behavior: contain;
  border: 1px solid #2D4D7C; border-radius: 28px; color: var(--bone);
  background:
    radial-gradient(80% 70% at 12% 0%, rgba(0,144,226,.30), transparent 60%),
    radial-gradient(70% 60% at 100% 100%, rgba(227,24,55,.32), transparent 62%),
    var(--panel);
  box-shadow: 0 50px 120px rgba(0,0,0,.8);
}
dialog.wheelm::backdrop { background: rgba(2,6,12,.84); backdrop-filter: blur(4px); }
dialog.wheelm[open] { animation: pop .36s cubic-bezier(.2,1.2,.3,1); }

.wh {
  position: relative; display: grid; align-items: center;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
  grid-template-areas: "stage head" "stage panel";
  gap: 14px clamp(16px, 3.4vw, 48px);
  padding: clamp(20px, 3.4vw, 44px);
}
.wh__head { grid-area: head; align-self: end; }
.wh__stage { grid-area: stage; }
.wh__panel { grid-area: panel; align-self: start; }

.wh__x { position: absolute; top: 14px; right: 14px; z-index: 6; }
.wh__snd { position: absolute; top: 14px; right: 64px; z-index: 6; }
.wh__snd[aria-pressed="false"] { opacity: .65; }
.wh h2:focus { outline: none; }

.wh h2 { padding-right: 0; font-size: clamp(44px, 6.4vw, 80px); line-height: .86; font-weight: 900; font-style: italic; font-stretch: 62%; text-transform: uppercase; text-shadow: .045em .045em 0 var(--red); }
.wh__sub { margin-top: 14px; max-width: 34ch; font-size: clamp(16px, 1.7vw, 19px); line-height: 1.4; color: #D3E2F6; }
.wh__sub b { color: var(--cheese); }

/* ---------- Rueda ---------- */
.wh__stage { position: relative; width: min(100%, 470px); aspect-ratio: 1; margin-inline: auto; contain: layout; --R: 190px; }
.wh__glow { position: absolute; inset: -14%; border-radius: 50%; background: radial-gradient(closest-side, rgba(255,198,41,.42), rgba(255,198,41,0) 72%); opacity: 0; transition: opacity .5s; pointer-events: none; }
.wh__stage.is-win .wh__glow { opacity: 1; animation: whGlow 1.3s ease-in-out infinite alternate; }
@keyframes whGlow { to { opacity: .45; transform: scale(1.06); } }

.wh__rim { position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle at 30% 18%, #FF6A80 0%, #E31837 38%, #7A0A1F 100%); box-shadow: 0 34px 60px -22px rgba(0,0,0,.85), inset 0 0 0 3px rgba(255,255,255,.16); }
.wh__rotor { position: absolute; inset: 6.8%; overflow: hidden; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 4px rgba(5,11,22,.92); transform: translateZ(0); }
.wh__rotor svg { display: block; width: 100%; height: 100%; }
.seg-hl { opacity: 0; }
.win .seg-hl { animation: segHl .5s ease-in-out 5 alternate; }
@keyframes segHl { to { opacity: .6; } }

/* Focos del borde */
.wh__bulbs { position: absolute; inset: 0; pointer-events: none; }
.wh__bulbs i { position: absolute; left: 50%; top: 50%; width: 3.3%; aspect-ratio: 1; margin: -1.65% 0 0 -1.65%; border-radius: 50%; background: #FFE9A6; box-shadow: 0 0 10px 2px rgba(255,198,41,.95); transform: rotate(var(--a)) translateY(calc(var(--R) * -1)); animation: bulb 1.2s steps(1, end) infinite; }
.wh__bulbs i:nth-child(odd) { animation-delay: -.6s; }
.wh__stage.is-spin .wh__bulbs i { animation: bulbChase .42s linear infinite; animation-delay: calc(var(--i) * -.0175s); }
.wh__stage.is-win .wh__bulbs i { animation: bulbWin .34s steps(1, end) infinite; }
@keyframes bulb { 0% { opacity: 1; } 50% { opacity: .35; } }
@keyframes bulbChase { 0%, 30% { opacity: 1; } 31%, 100% { opacity: .22; } }
@keyframes bulbWin { 0% { opacity: 1; } 50% { opacity: .2; } }

/* Puntero */
.wh__pointer { position: absolute; left: 50%; top: -4.6%; z-index: 4; width: 13%; aspect-ratio: .82; margin-left: -6.5%; transform-origin: 50% 22%; filter: drop-shadow(0 7px 8px rgba(0,0,0,.55)); pointer-events: none; }
.wh__pointer svg { display: block; width: 100%; height: 100%; overflow: visible; }

/* Centro */
.wh__hub { position: absolute; left: 50%; top: 50%; z-index: 3; width: 21%; aspect-ratio: 1; display: grid; place-items: center; translate: -50% -50%; border: 0; border-radius: 50%; background: radial-gradient(circle at 35% 28%, #1E3A62, #050B16 75%); box-shadow: 0 0 0 5px var(--cheese), 0 14px 28px rgba(0,0,0,.65); transition: scale .12s; }
.wh__hub img { width: 62%; height: 62%; }
.wh__hub:not(:disabled):hover { scale: 1.04; }
.wh__hub:not(:disabled):active { scale: .95; }
.wh__hub:disabled { cursor: default; }

/* ---------- Panel ---------- */
.wh__panel { display: grid; justify-items: start; gap: 14px; min-height: 190px; }
.wh__status { font-size: 15px; font-weight: 700; color: var(--cheese); }
.wh__act { display: grid; gap: 10px; width: 100%; max-width: 360px; }
.wh__big { width: 100%; min-height: 56px; font-size: 18px; }
.wh__fine { max-width: 38ch; font-size: 13.5px; line-height: 1.45; color: var(--mute); }
.wh__fine b { color: #fff; }

/* Boleto con el descuento ganado */
.wticket { position: relative; display: inline-flex; align-items: center; gap: 14px; padding: 8px 24px 8px 20px; overflow: hidden; border-radius: 18px; color: #fff; background: linear-gradient(135deg, #0090E2, #0A5FA0); box-shadow: 0 16px 30px -12px rgba(0,144,226,.7); animation: ticketIn .7s cubic-bezier(.2,1.5,.4,1) both; }
.wticket::before, .wticket::after { content: ""; position: absolute; top: 50%; width: 18px; height: 18px; margin-top: -9px; border-radius: 50%; background: var(--panel); }
.wticket::before { left: -9px; }
.wticket::after { right: -9px; }
.wticket__n { font-size: clamp(66px, 9vw, 96px); line-height: .9; font-weight: 900; font-style: italic; font-stretch: 62%; font-variant-numeric: tabular-nums; }
.wticket__n small { margin-left: 2px; font-size: .5em; }
.wticket__l { font-size: 15px; font-weight: 700; line-height: 1.2; }
.wticket--gold { color: #1A1200; background: linear-gradient(135deg, #FFE9A6, #FFC629 55%, #E8A400); box-shadow: 0 18px 40px -10px rgba(255,198,41,.85); }
.wticket--gold .wticket__n { animation: numPop .9s cubic-bezier(.2,1.6,.4,1) .15s both; }
.wticket__s { position: absolute; inset: 0; background: linear-gradient(100deg, transparent 35%, rgba(255,255,255,.8) 50%, transparent 65%); transform: translateX(-120%); animation: shine 1.5s ease-out .55s both; pointer-events: none; }
@keyframes ticketIn { from { opacity: 0; transform: scale(.6) rotate(-6deg); } }
@keyframes numPop { from { transform: scale(.4); } }
@keyframes shine { to { transform: translateX(120%); } }

/* ---------- Entradas fuera del diálogo ---------- */
.dchip { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px 0 10px; border: 0; border-radius: 999px; background: linear-gradient(135deg, #FFE9A6, #FFC629); color: #1A1200; font-size: 17px; font-weight: 900; font-stretch: 80%; box-shadow: 0 8px 20px -8px rgba(255,198,41,.85); }
.dchip[hidden] { display: none; }
.dchip__w, .fab__wheel { border-radius: 50%; background: repeating-conic-gradient(#E31837 0 30deg, #F4F7FB 30deg 60deg, #0090E2 60deg 90deg, #0C1727 90deg 120deg); }
.dchip__w { width: 20px; height: 20px; box-shadow: 0 0 0 2px #1A1200; }
.anim .dchip { animation: chipIn .6s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes chipIn { from { opacity: 0; transform: scale(.5); } }

.fab { position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 65; display: inline-flex; align-items: center; gap: 10px; height: 58px; padding: 0 22px 0 9px; border: 0; border-radius: 999px; background: linear-gradient(135deg, #FFE9A6, #FFC629 58%, #F0A800); color: #1A1200; font-size: 16px; font-weight: 900; box-shadow: 0 16px 36px -10px rgba(255,198,41,.9), 0 0 0 3px rgba(5,11,22,.6); }
.fab[hidden] { display: none; }
.fab::after { content: ""; position: absolute; inset: 0; border-radius: inherit; border: 2px solid #FFC629; opacity: 0; pointer-events: none; }
.anim .fab::after { animation: fabRing 2.2s ease-out 1s infinite; }
@keyframes fabRing { 0% { opacity: .85; transform: scale(1); } 100% { opacity: 0; transform: scale(1.35, 1.6); } }
.fab__wheel { width: 40px; height: 40px; box-shadow: 0 0 0 3px #1A1200; }
.anim .fab__wheel { animation: spinSlow 9s linear infinite; }
@keyframes spinSlow { to { transform: rotate(360deg); } }
.fab__n { position: absolute; top: -7px; right: -3px; min-width: 25px; height: 25px; display: grid; place-items: center; border-radius: 99px; background: var(--red); color: #fff; font-size: 13px; box-shadow: 0 0 0 3px var(--ink); }

/* Insignia "Gira" en las pizzas (antes de ganar el descuento) */
button.off { padding: 0; border: 0; background: none; color: #fff; cursor: pointer; }
.off--spin b { font-size: 15px; }
.off--spin::after { content: ""; position: absolute; width: 47px; height: 47px; border: 2px solid var(--red-hot); border-radius: 10px; opacity: 0; transform: rotate(45deg); }
.anim .off--spin::after { animation: ringPulse 2.1s ease-out infinite; }
@keyframes ringPulse { 0% { opacity: .9; transform: rotate(45deg) scale(1); } 100% { opacity: 0; transform: rotate(45deg) scale(1.6); } }

/* Los precios "aterrizan" cuando cambia el descuento */
.repriced .price strong { animation: pricePop .8s cubic-bezier(.2,1.6,.4,1) both; }
.repriced .off { animation: badgeIn .7s cubic-bezier(.2,1.7,.4,1) both; }
.repriced .price .save { animation: fade .9s ease-out .2s both; }
@keyframes pricePop { 0% { transform: scale(1.5); color: var(--cheese); } 100% { transform: scale(1); } }
@keyframes badgeIn { from { opacity: 0; transform: scale(.3) rotate(-40deg); } }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  body:has(#bar:not([hidden])) .fab { bottom: calc(86px + env(safe-area-inset-bottom)); }
}
@media (max-width: 720px) {
  dialog.wheelm { width: 100%; height: 100vh; height: 100dvh; max-height: none; border: 0; border-radius: 0; }
  .wh { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "stage" "panel"; align-items: start; align-content: center; min-height: 100vh; min-height: 100dvh; gap: 8px; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
  .wh__head { align-self: start; padding-right: 0; }
  .wh__head h2 { padding-right: 104px; }
  .wh h2 { font-size: clamp(38px, 13vw, 58px); }
  .wh__sub { margin-top: 8px; font-size: 15px; }
  .wh__stage { width: min(88vw, 44vh, 44dvh, 420px); }
  .wh__panel { gap: 10px; min-height: 0; justify-items: center; text-align: center; }
  .wh__act { max-width: none; }
  .wticket { gap: 10px; }
  .wticket__n { font-size: 60px; }
  .wh__fine { font-size: 12.5px; }
  .wh__x, .wh__snd { top: 12px; }
}
@media (max-width: 640px) {
  .dchip { margin-left: auto; height: 36px; padding: 0 12px 0 8px; font-size: 16px; }
  .top.has-chip .cartbtn { margin-left: 0; }
  .fab { right: 14px; width: 60px; height: 60px; padding: 0; justify-content: center; }
  .fab__txt { display: none; }
  .fab__wheel { width: 46px; height: 46px; }
  .off--spin::after { width: 34px; height: 34px; border-radius: 8px; }
}
.sheet .off--spin::after { width: 47px; height: 47px; border-radius: 10px; }
.top.has-chip .cartbtn { margin-left: 0; }

@media (prefers-reduced-motion: reduce) {
  .wh__bulbs i, .wh__stage.is-win .wh__glow, .fab__wheel, .fab::after, .off--spin::after { animation: none !important; }
  .wh__stage.is-win .wh__glow { opacity: 1; }
}
