/* =====================================================================
   Celebrate — shared cinematic result screens for every game
   ---------------------------------------------------------------------
   Replaces the basic win/loss popup with a themed celebration per
   game: themed accent colors, emoji particle rain, eased amount
   count-up and a quick themed lose card.
   z-index: above EVERYTHING, including the mobile immersive layers
   (board 9900 < sheet 9950 < exit 9960 < modal 9980 < popup 9999).
   ===================================================================== */

.celebrate {
    --c-accent: #ffd700;
    --c-accent2: #ff9639;
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(8, 7, 20, .84);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    overflow: hidden;
    padding: calc(14px + env(safe-area-inset-top, 0px)) 14px calc(14px + env(safe-area-inset-bottom, 0px));
}

.celebrate.show {
    display: flex;
    animation: celebrateFade .3s ease;
}

@keyframes celebrateFade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* rotating radial rays behind the content (wins only) */
.celebrate-rays {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 150vmax;
    height: 150vmax;
    transform: translate(-50%, -50%);
    background: repeating-conic-gradient(rgb(255 255 255 / 6%) 0deg 9deg, transparent 9deg 18deg);
    -webkit-mask-image: radial-gradient(circle, #000 0%, transparent 62%);
    mask-image: radial-gradient(circle, #000 0%, transparent 62%);
    animation: celebrateRays 22s linear infinite;
    pointer-events: none;
    opacity: .9;
}

@keyframes celebrateRays {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

.celebrate-inner {
    position: relative;
    z-index: 1;
    text-align: center;
    max-width: 620px;
    animation: celebratePop .5s cubic-bezier(.2, 1.7, .4, 1);
}

@keyframes celebratePop {
    0%   { transform: scale(.35); opacity: 0; }
    100% { transform: scale(1);   opacity: 1; }
}

/* big game icon with a pulsing aura */
.celebrate-icon {
    font-size: clamp(56px, 12vw, 96px);
    line-height: 1;
    margin-bottom: 10px;
    filter: drop-shadow(0 8px 22px rgb(0 0 0 / 50%));
    animation: celebrateIconBounce 1.6s cubic-bezier(.3, 1.6, .4, 1) infinite;
}

@keyframes celebrateIconBounce {

    0%, 100% {
        transform: translateY(0) scale(1);
    }

    40% {
        transform: translateY(-10px) scale(1.06);
    }

    60% {
        transform: translateY(2px) scale(.98);
    }
}

.celebrate-title {
    font-size: clamp(30px, 7vw, 56px);
    font-weight: 900;
    letter-spacing: 3px;
    text-transform: uppercase;
    background: linear-gradient(180deg, #fff7dd 0%, var(--c-accent) 55%, var(--c-accent2) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 4px 20px rgb(0 0 0 / 45%));
    animation: celebrateTitlePulse 1.4s ease-in-out infinite;
}

@keyframes celebrateTitlePulse {

    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.045); }
}

/* multiplier badge (×14.50) — Scratch-style chip between title and amount */
.celebrate-mult {
    display: none;
    margin: 10px auto 0;
    width: fit-content;
    padding: 5px 18px;
    border-radius: 999px;
    font-size: clamp(15px, 3vw, 20px);
    font-weight: 900;
    letter-spacing: 1px;
    font-variant-numeric: tabular-nums;
    color: #17152b;
    background: linear-gradient(135deg, var(--c-accent), var(--c-accent2));
    box-shadow: 0 4px 16px rgb(0 0 0 / 45%), 0 0 18px var(--c-accent);
    animation: celebratePop .45s cubic-bezier(.2, 1.7, .4, 1);
}

.celebrate-amount {
    font-size: clamp(34px, 8vw, 62px);
    font-weight: 900;
    color: #fff;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 28px var(--c-accent);
    line-height: 1.2;
    margin-top: 4px;
}

.celebrate-amount small {
    font-size: .45em;
    color: var(--c-accent);
}

.celebrate-message {
    margin-top: 8px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: rgb(255 255 255 / 88%);
    text-transform: uppercase;
}

.celebrate-replay {
    margin-top: 22px;
    display: inline-block;
    border: 0;
    cursor: pointer;
    font-weight: 800;
    font-size: 15px;
    letter-spacing: 1px;
    color: #17152b;
    background: linear-gradient(135deg, var(--c-accent), var(--c-accent2));
    padding: 12px 34px;
    border-radius: 999px;
    box-shadow: 0 8px 22px rgb(0 0 0 / 45%), 0 0 24px var(--c-accent);
    transition: transform .18s ease, filter .18s ease;
    -webkit-tap-highlight-color: transparent;
}

.celebrate-replay:hover {
    transform: translateY(-2px) scale(1.03);
    filter: brightness(1.08);
}

.celebrate-replay:active {
    transform: scale(.97);
}

.celebrate-close {
    margin-top: 14px;
    font-size: 11px;
    letter-spacing: 1.5px;
    color: rgb(255 255 255 / 50%);
    animation: celebrateHint 1.6s ease-in-out infinite;
}

@keyframes celebrateHint {

    0%, 100% { opacity: .4; }
    50%      { opacity: 1; }
}

/* ---------------- lose variant: quick themed card ---------------- */

.celebrate.celebrate--lose .celebrate-rays {
    opacity: .18;
}

.celebrate.celebrate--lose .celebrate-icon {
    animation: none;
    filter: grayscale(.2) drop-shadow(0 8px 22px rgb(0 0 0 / 50%));
}

.celebrate.celebrate--lose .celebrate-title {
    background: linear-gradient(180deg, #ffd9d9 0%, #ff7a7a 55%, #b32626 100%);
    -webkit-background-clip: text;
    background-clip: text;
    animation: none;
}

.celebrate.celebrate--lose .celebrate-inner {
    animation: celebrateLoseIn .4s ease;
}

@keyframes celebrateLoseIn {
    0%   { transform: scale(.85); opacity: 0; }
    100% { transform: scale(1);   opacity: 1; }
}

/* ---------------- particle rain ---------------- */

.celebrate-particle {
    position: absolute;
    top: -8%;
    pointer-events: none;
    animation: celebrateFall linear forwards;
    filter: drop-shadow(0 3px 6px rgb(0 0 0 / 40%));
}

@keyframes celebrateFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }

    85% {
        opacity: 1;
    }

    100% {
        transform: translateY(108vh) rotate(var(--cr, 540deg));
        opacity: 0;
    }
}

.celebrate-confetti {
    position: absolute;
    width: 8px;
    height: 13px;
    border-radius: 3px;
    top: -4%;
    pointer-events: none;
    animation: celebrateFall linear forwards;
}

/* Scratch-style golden coin/star rain behind the content */
.celebrate-coin {
    position: absolute;
    top: -6%;
    pointer-events: none;
    z-index: 0;
    animation: celebrateFall linear forwards;
    filter: drop-shadow(0 3px 6px rgb(0 0 0 / 40%));
}

/* ---------------- win tiers: the screen escalates like Scratch & Win ---- */

.celebrate.celebrate--tier-2 .celebrate-title {
    font-size: clamp(34px, 8vw, 64px);
}

.celebrate.celebrate--tier-3 .celebrate-title {
    font-size: clamp(40px, 9.5vw, 78px);
}

.celebrate.celebrate--tier-4 .celebrate-title {
    font-size: clamp(44px, 11vw, 92px);
}

.celebrate.celebrate--tier-3 .celebrate-amount,
.celebrate.celebrate--tier-4 .celebrate-amount {
    text-shadow: 0 0 34px var(--c-accent), 0 0 70px var(--c-accent2);
}

/* golden vignette for the huge tiers (jackpot / legendary) */
.celebrate.celebrate--tier-4::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    box-shadow: inset 0 0 130px 26px rgb(255 215 0 / 28%);
}

.celebrate.celebrate--tier-4 .celebrate-mult {
    animation: celebratePop .45s cubic-bezier(.2, 1.7, .4, 1),
               celebrateTitlePulse 1s ease-in-out .45s infinite;
}

/* small screens: tighter everything */
@media (max-width: 575px) {
    .celebrate-replay {
        padding: 11px 28px;
        font-size: 14px;
    }
}

/* respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {

    .celebrate-rays,
    .celebrate-icon,
    .celebrate-title,
    .celebrate-mult,
    .celebrate-close {
        animation: none;
    }
}
