/* Spin & Win — premium transparent prize wheel
   ----------------------------------------------------------------------------
   Shared. */

#swOverlay {
    --sw-accent:    #00C896;
    --sw-accent-2:  #009E78;
    --sw-gold:      #FFD66B;
    --sw-gold-deep: #E8A93C;
    --sw-ink:       #0D1B2A;

    position: fixed;
    inset: 0;
    z-index: 2147483600;            /* above every offcanvas / PhonePe iframe sits higher only on demand */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 18px calc(24px + env(safe-area-inset-bottom, 0px));
    /* Fully transparent base — blends into the page behind. */
    background: transparent;
    opacity: 0;
    visibility: hidden;
    transition: opacity .34s ease, visibility 0s linear .34s;
    -webkit-tap-highlight-color: transparent;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    overscroll-behavior: contain;
    touch-action: manipulation;
}

/* Faint scrim — kept subtle so the wheel "blends"; deepens on celebrate. */
#swOverlay::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(120% 90% at 50% 38%,
            rgba(8, 14, 24, .26) 0%,
            rgba(8, 14, 24, .44) 55%,
            rgba(6, 10, 18, .62) 100%);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity .5s ease, backdrop-filter .5s ease;
    pointer-events: none;
}

#swOverlay.sw-open {
    opacity: 1;
    visibility: visible;
    transition: opacity .34s ease;
}
#swOverlay.sw-open::before { opacity: 1; }
#swOverlay.sw-celebrate::before {
    background:
        radial-gradient(120% 90% at 50% 40%,
            rgba(6, 11, 20, .42) 0%,
            rgba(5, 9, 16, .66) 60%,
            rgba(3, 6, 12, .82) 100%);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
}

/* ── Close (X) ───────────────────────────────────────────────────────────── */
.sw-close {
    position: absolute;
    top: calc(14px + env(safe-area-inset-top, 0px));
    right: 16px;
    width: 42px; height: 42px;
    display: grid; place-items: center;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 50%;
    background: rgba(255, 255, 255, .12);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    color: #fff;
    font-size: 20px; line-height: 1;
    cursor: pointer;
    z-index: 6;
    transition: transform .18s ease, background .18s ease;
}
.sw-close:hover  { background: rgba(255, 255, 255, .2); }
.sw-close:active { transform: scale(.9); }
.sw-close:focus-visible { outline: 3px solid var(--sw-gold); outline-offset: 2px; }

/* ── Headline ────────────────────────────────────────────────────────────── */
.sw-head {
    text-align: center;
    margin-bottom: 18px;
    transform: translateY(8px);
    opacity: 0;
    transition: transform .5s cubic-bezier(.16,1,.3,1) .08s, opacity .5s ease .08s;
}
#swOverlay.sw-open .sw-head { transform: none; opacity: 1; }
/* .sw-eyebrow is now the ONLY headline element (DB-driven spinner_title) —
   .sw-title (a separate, hard-coded <h2>) was removed. */
.sw-eyebrow {
    display: block;
    margin: 0 0 4px;
    font-size: clamp(20px, 5.5vw, 28px);
    font-weight: 900; letter-spacing: -.4px;
    color: #fff;
    text-shadow: 0 2px 18px rgba(0,0,0,.45);
}
.sw-sub {
    margin: 0;
    font-size: 13px; font-weight: 600;
    color: rgba(255, 255, 255, .78);
}

/* ── Wheel stage ─────────────────────────────────────────────────────────── */
.sw-stage {
    position: relative;
    width: min(86vw, 62vh, 360px);
    aspect-ratio: 1 / 1;
    display: grid;
    place-items: center;
    transform: scale(.86);
    opacity: 0;
    transition: transform .56s cubic-bezier(.16,1,.3,1) .04s, opacity .5s ease .04s;
}
#swOverlay.sw-open .sw-stage { transform: scale(1); opacity: 1; }

/* Stage ⇄ reward-card visibility sync (syncSpinnerStageVisibility in
   js/spin-win.js): while the reward card is shown the stage fades out
   without a layout shift (opacity + transform only). */
#swOverlay .sw-stage[aria-hidden="true"] {
    opacity: 0;
    transform: scale(.94);
    pointer-events: none;
}

/* Ambient glow behind the wheel — breathes while idle. */
.sw-glow {
    position: absolute;
    inset: -14%;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 50%,
        color-mix(in srgb, var(--sw-accent) 60%, transparent) 0%,
        color-mix(in srgb, var(--sw-accent) 22%, transparent) 38%,
        transparent 68%);
    filter: blur(6px);
    animation: swGlow 3.6s ease-in-out infinite;
    pointer-events: none;
}
@keyframes swGlow {
    0%, 100% { opacity: .55; transform: scale(.96); }
    50%      { opacity: .9;  transform: scale(1.04); }
}

/* Floating particles around the wheel. */
.sw-particles { position: absolute; inset: -8%; pointer-events: none; overflow: visible; }
.sw-particle {
    position: absolute;
    width: 7px; height: 7px; border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #fff, var(--sw-gold) 60%, transparent 72%);
    opacity: .0;
    will-change: transform, opacity;
    animation: swFloat var(--d, 6s) ease-in-out var(--delay, 0s) infinite;
}
@keyframes swFloat {
    0%   { opacity: 0;   transform: translate3d(0,0,0) scale(.6); }
    15%  { opacity: .9; }
    50%  { opacity: .8;  transform: translate3d(var(--mx, 12px), var(--my, -18px), 0) scale(1); }
    85%  { opacity: .25; }
    100% { opacity: 0;   transform: translate3d(0, var(--my2, -36px), 0) scale(.7); }
}

/* ── Rim + lights ────────────────────────────────────────────────────────── */
.sw-rim {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    /* metallic gold rim */
    background:
        conic-gradient(from 0deg,
            #F6D27A, #B9852F, #FFE8A8, #C9952F, #FBDC8C, #A9761F, #F6D27A);
    box-shadow:
        0 18px 50px rgba(0, 0, 0, .5),
        inset 0 0 0 2px rgba(255, 255, 255, .25),
        inset 0 -8px 22px rgba(0, 0, 0, .35),
        inset 0 8px 22px rgba(255, 255, 255, .35);
    padding: 13px;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}
.sw-rim-inner {
    position: relative;
    width: 100%; height: 100%;
    border-radius: 50%;
    background: #0c1622;
    box-shadow: inset 0 0 0 3px rgba(0,0,0,.5);
    overflow: hidden;
}
/* small glowing bulbs around the rim (top/left % set by JS) */
.sw-bulbs { position: absolute; inset: 0; border-radius: 50%; pointer-events: none; z-index: 5; }
.sw-bulb {
    position: absolute;
    width: 8px; height: 8px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle at 40% 40%, #fff, var(--sw-gold) 55%, var(--sw-gold-deep) 100%);
    box-shadow: 0 0 8px rgba(255, 214, 107, .95);
    animation: swBulb 1.4s ease-in-out infinite;
}
@keyframes swBulb {
    0%, 100% { opacity: .35; }
    50%      { opacity: 1; }
}

/* ── Wheel (rotating) ────────────────────────────────────────────────────── */
.sw-wheel {
    position: absolute;
    inset: 6px;                       /* thin dark bezel between wheel + gold rim */
    border-radius: 50%;
    transform: rotate(0deg);
    will-change: transform;
    z-index: 2;
}
.sw-wheel.sw-breathe { animation: swBreathe 3.4s ease-in-out infinite; }
@keyframes swBreathe {
    0%, 100% { transform: rotate(var(--rot, 0deg)) scale(1); }
    50%      { transform: rotate(var(--rot, 0deg)) scale(1.012); }
}
.sw-wheel-canvas {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    border-radius: 50%;
    display: block;
}

/* Segment labels (DOM, crisp) rotated to each slice centre. Each .sw-seg fills
   the wheel and is rotated about its centre; the inner label sits near the top
   edge, so rotation carries it to that slice's direction. */
.sw-seg {
    position: absolute;
    inset: 0;
    transform-origin: 50% 50%;
    pointer-events: none;
}
.sw-seg-inner {
    position: absolute;
    top: 7.5%; left: 50%;
    transform: translateX(-50%);
    /* width is set inline per build (js/spin-win.js layoutLabels) from the
       actual chord width available at this segment count/wheel size — no
       fixed value here so it adapts to any N automatically. */
    text-align: center;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .55);
}
/* font-size/width/height for .sw-seg-ico(-img) are set inline per build too
   (N-aware, shrinks as segment count grows) — this rule only supplies the
   visual treatment that doesn't need to vary. */
.sw-seg-ico { line-height: 1; filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }
/* DB-driven icon_img segments — object-fit: contain guarantees no
   stretching at any source aspect ratio regardless of inline size. */
.sw-seg-ico-img {
    display: inline-block;
    object-fit: contain;
    vertical-align: middle;
}
@media (min-resolution: 2dppx) { .sw-seg-ico-img { image-rendering: -webkit-optimize-contrast; } }
/* Container for 1-N pre-wrapped, pre-measured lines (js/spin-win.js
   fitLabelText/layoutLabels) — font-size/line-height/margin-top/max-width
   are all set inline per build since they depend on label length. */
.sw-seg-lbl {
    display: block;
    margin-left: auto; margin-right: auto;
    font-weight: 900; letter-spacing: -.2px;
}
.sw-seg-lbl-line {
    display: block;
    white-space: nowrap;   /* each line was pre-validated to fit at its font size */
}

/* ── Center hub / SPIN button ────────────────────────────────────────────── */
.sw-hub {
    position: absolute;
    top: 50%; left: 50%;
    width: 30%; height: 30%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: none;
    cursor: pointer;
    z-index: 4;
    display: grid; place-items: center;
    color: #fff;
    background:
        radial-gradient(circle at 50% 30%, rgba(255,255,255,.45), rgba(255,255,255,0) 45%),
        linear-gradient(160deg, var(--sw-accent), var(--sw-accent-2));
    box-shadow:
        0 10px 26px rgba(0, 0, 0, .45),
        inset 0 2px 6px rgba(255, 255, 255, .55),
        inset 0 -8px 16px rgba(0, 0, 0, .28),
        0 0 0 6px rgba(255, 255, 255, .14);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    transition: transform .12s cubic-bezier(.34,1.56,.64,1), box-shadow .2s ease;
}
.sw-hub::after {                      /* glossy top highlight */
    content: "";
    position: absolute; left: 14%; right: 14%; top: 10%; height: 40%;
    border-radius: 50%;
    background: linear-gradient(180deg, rgba(255,255,255,.6), rgba(255,255,255,0));
    pointer-events: none;
}
.sw-hub-txt {
    font-size: clamp(13px, 3.6vw, 17px);
    font-weight: 900; letter-spacing: .5px;
    line-height: .95; text-align: center;
    z-index: 1;
    text-shadow: 0 1px 2px rgba(0,0,0,.35);
}
.sw-hub-txt small { display:block; font-size: .62em; font-weight: 800; opacity: .9; letter-spacing: 1px; }
.sw-hub.sw-pulse { animation: swHubPulse 2.1s ease-in-out infinite; }
@keyframes swHubPulse {
    0%, 100% { box-shadow: 0 10px 26px rgba(0,0,0,.45), inset 0 2px 6px rgba(255,255,255,.55), inset 0 -8px 16px rgba(0,0,0,.28), 0 0 0 6px rgba(255,255,255,.14); }
    50%      { box-shadow: 0 10px 30px rgba(0,0,0,.5),  inset 0 2px 6px rgba(255,255,255,.55), inset 0 -8px 16px rgba(0,0,0,.28), 0 0 0 12px color-mix(in srgb, var(--sw-accent) 30%, transparent); }
}
.sw-hub:active        { transform: translate(-50%, -50%) scale(.9); }
.sw-hub.sw-press      { transform: translate(-50%, -50%) scale(.88); }
.sw-hub:focus-visible { outline: 3px solid var(--sw-gold); outline-offset: 4px; }
.sw-hub:disabled      { cursor: default; }
.sw-hub.sw-spinning .sw-hub-txt { opacity: .85; }

/* ── Pointer (top) ───────────────────────────────────────────────────────── */
.sw-pointer {
    position: absolute;
    top: -3%; left: 50%;
    width: 13%;
    transform: translateX(-50%);
    z-index: 5;
    filter: drop-shadow(0 6px 10px rgba(0,0,0,.5));
    transform-origin: 50% 18%;
}
.sw-pointer.sw-tick { animation: swTick .12s ease; }
@keyframes swTick {
    0% { transform: translateX(-50%) rotate(0deg); }
    50%{ transform: translateX(-50%) rotate(-9deg); }
    100%{transform: translateX(-50%) rotate(0deg); }
}

/* ── Spin-state caption ──────────────────────────────────────────────────── */
.sw-caption {
    margin-top: 20px;
    min-height: 20px;
    font-size: 13px; font-weight: 700;
    color: rgba(255,255,255,.82);
    text-align: center;
    letter-spacing: .2px;
    transition: opacity .3s ease;
}

/* ── Reward popup ────────────────────────────────────────────────────────── */
.sw-reward {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 7;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.sw-reward.sw-show { opacity: 1; visibility: visible; pointer-events: auto; }

.sw-reward-card {
    position: relative;
    width: min(88vw, 340px);
    padding: 30px 24px 24px;
    border-radius: 26px;
    text-align: center;
    background: linear-gradient(165deg, rgba(255,255,255,.16), rgba(255,255,255,.06));
    border: 1px solid rgba(255,255,255,.28);
    -webkit-backdrop-filter: blur(22px) saturate(150%);
    backdrop-filter: blur(22px) saturate(150%);
    box-shadow:
        0 30px 70px rgba(0,0,0,.55),
        inset 0 1px 0 rgba(255,255,255,.4);
    transform: scale(.4);
    opacity: 0;
}
.sw-reward.sw-show .sw-reward-card { animation: swRewardIn .72s cubic-bezier(.18,1.5,.4,1) forwards; }
@keyframes swRewardIn {
    0%   { transform: scale(.4);  opacity: 0; }
    55%  { transform: scale(1.12); opacity: 1; }
    78%  { transform: scale(.97); }
    100% { transform: scale(1);   opacity: 1; }
}

/* glow pulse behind the reward */
.sw-reward-card::before {
    content: "";
    position: absolute;
    inset: -30% -30% auto -30%;
    height: 130%;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 30%,
        color-mix(in srgb, var(--sw-gold) 60%, transparent), transparent 62%);
    filter: blur(12px);
    z-index: -1;
    animation: swGlow 2.6s ease-in-out infinite;
}

.sw-reward-badge {
    width: 96px; height: 96px;
    margin: 0 auto 14px;
    border-radius: 50%;
    display: grid; place-items: center;
    font-size: 46px; line-height: 1;
    background:
        radial-gradient(circle at 50% 32%, rgba(255,255,255,.6), rgba(255,255,255,0) 50%),
        linear-gradient(160deg, var(--sw-gold), var(--sw-gold-deep));
    box-shadow:
        0 12px 30px rgba(232,169,60,.55),
        inset 0 2px 6px rgba(255,255,255,.7),
        inset 0 -8px 16px rgba(0,0,0,.18);
    animation: swBadgePop 2.4s ease-in-out infinite;
}
@keyframes swBadgePop {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50%      { transform: scale(1.06) rotate(-3deg); }
}
.sw-reward-won {
    font-size: 12px; font-weight: 800; letter-spacing: 2px; text-transform: uppercase;
    color: var(--sw-gold);
    margin-bottom: 4px;
}
.sw-reward-value {
    font-size: clamp(30px, 9vw, 42px);
    font-weight: 900; letter-spacing: -1px;
    color: #fff;
    line-height: 1.04;
    text-shadow: 0 3px 16px rgba(0,0,0,.4);
}
.sw-reward-desc {
    margin: 8px auto 0;
    max-width: 260px;
    font-size: 13.5px; font-weight: 600;
    color: rgba(255,255,255,.84);
    line-height: 1.45;
}
.sw-reward-actions { margin-top: 22px; display: flex; flex-direction: column; gap: 10px; }
.sw-btn-claim {
    width: 100%;
    padding: 15px;
    border: none; border-radius: 16px;
    font-size: 15px; font-weight: 900; letter-spacing: .3px;
    color: var(--sw-ink);
    background: linear-gradient(180deg, var(--sw-gold), var(--sw-gold-deep));
    box-shadow: 0 12px 26px rgba(232,169,60,.5), inset 0 1px 0 rgba(255,255,255,.6);
    cursor: pointer;
    transition: transform .16s ease, filter .16s ease;
}
.sw-btn-claim:hover  { filter: brightness(1.05); }
.sw-btn-claim:active { transform: scale(.96); }
.sw-btn-claim:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.sw-btn-dismiss {
    background: none; border: none;
    color: rgba(255,255,255,.7);
    font-size: 13px; font-weight: 700;
    cursor: pointer; padding: 6px;
}
.sw-btn-dismiss:hover { color: #fff; }
.sw-btn-dismiss:focus-visible { outline: 2px solid rgba(255,255,255,.6); outline-offset: 2px; border-radius: 8px; }

/* ── Confetti / sparkle canvas ───────────────────────────────────────────── */
.sw-fx-canvas {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 6;
}

/* radial celebration ring */
.sw-burst {
    position: absolute;
    top: 50%; left: 50%;
    width: 40px; height: 40px;
    margin: -20px;
    border-radius: 50%;
    border: 3px solid var(--sw-gold);
    opacity: 0;
    pointer-events: none;
    z-index: 3;
}
.sw-burst.sw-go { animation: swBurst .9s ease-out forwards; }
@keyframes swBurst {
    0%   { opacity: .9; transform: scale(.2); }
    100% { opacity: 0;  transform: scale(11); }
}

/* Spin & Win — ENTRY TRIGGER (placed inside the host offcanvas) A premium
   glassy banner the user taps to open the wheel. Shared by both pages;
   themed via the same --sw-accent vars (set inline by the host). */
.sw-trigger {
    --sw-accent:    #00C896;
    --sw-accent-2:  #009E78;
    --sw-gold:      #FFD66B;
    --sw-gold-deep: #E8A93C;

    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin: 0 0 12px;
    padding: 13px 14px;
    border: none;
    border-radius: 18px;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
    color: #fff;
    background: linear-gradient(120deg, var(--sw-accent-2), var(--sw-accent) 55%, #0E2B40);
    box-shadow: 0 10px 26px rgba(0, 158, 120, .28), inset 0 1px 0 rgba(255,255,255,.25);
    -webkit-tap-highlight-color: transparent;
    transition: transform .16s ease, box-shadow .2s ease, filter .2s ease;
    font-family: inherit;
}
.sw-trigger::before {                 /* sweeping shine */
    content: "";
    position: absolute;
    top: 0; left: -60%;
    width: 45%; height: 100%;
    background: linear-gradient(100deg, transparent, rgba(255,255,255,.35), transparent);
    transform: skewX(-18deg);
    animation: swShine 3.6s ease-in-out infinite;
    pointer-events: none;
}
@keyframes swShine {
    0%, 62%  { left: -60%; }
    100%     { left: 130%; }
}
.sw-trigger:hover  { filter: brightness(1.04); }
.sw-trigger:active { transform: scale(.98); }
.sw-trigger:focus-visible { outline: 3px solid var(--sw-gold); outline-offset: 2px; }

.sw-trigger-ico {
    flex-shrink: 0;
    width: 42px; height: 42px;
    display: grid; place-items: center;
    border-radius: 50%;
    font-size: 23px; line-height: 1;
    background: radial-gradient(circle at 50% 35%, rgba(255,255,255,.55), rgba(255,255,255,0) 55%),
                linear-gradient(160deg, var(--sw-gold), var(--sw-gold-deep));
    box-shadow: 0 6px 14px rgba(232,169,60,.5), inset 0 1px 0 rgba(255,255,255,.6);
    animation: swTriggerSpin 6s linear infinite;
}
@keyframes swTriggerSpin { to { transform: rotate(360deg); } }
.sw-trigger-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; position: relative; z-index: 1; }
.sw-trigger-title {
    font-size: 14.5px; font-weight: 900; letter-spacing: -.2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sw-trigger-sub {
    font-size: 11.5px; font-weight: 600; color: rgba(255,255,255,.85);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sw-trigger-cta {
    flex-shrink: 0;
    position: relative; z-index: 1;
    font-size: 12px; font-weight: 900; letter-spacing: 1px;
    padding: 8px 13px; border-radius: 12px;
    color: var(--sw-ink, #0D1B2A);
    background: #fff;
    box-shadow: 0 4px 10px rgba(0,0,0,.18);
}
.sw-trigger.sw-trigger-won {
    background: linear-gradient(120deg, #0E2B40, var(--sw-accent-2) 70%);
}
.sw-trigger.sw-trigger-won .sw-trigger-ico {
    animation: none;
    background: radial-gradient(circle at 50% 35%, rgba(255,255,255,.55), rgba(255,255,255,0) 55%),
                linear-gradient(160deg, var(--sw-accent), var(--sw-accent-2));
}

@media (prefers-reduced-motion: reduce) {
    .sw-trigger::before, .sw-trigger-ico { animation: none !important; }
}

/* ── Reduced motion ──────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    #swOverlay, #swOverlay * {
        animation-duration: .001s !important;
        animation-iteration-count: 1 !important;
        transition-duration: .12s !important;
    }
    .sw-glow, .sw-particle, .sw-bulb, .sw-hub.sw-pulse, .sw-wheel.sw-breathe,
    .sw-badge, .sw-reward-card::before, .sw-reward-badge { animation: none !important; }
}
