.reward-celebration {
    --reward-pink: #ec4899;
    --reward-violet: #7c3aed;
    --reward-cyan: #06b6d4;
    --reward-yellow: #facc15;
    position: fixed;
    z-index: 10000;
    inset: 0;
}

.reward-celebration__backdrop {
    position: absolute;
    background:
        radial-gradient(circle at 18% 22%, rgb(236 72 153 / 55%), transparent 31%),
        radial-gradient(circle at 82% 18%, rgb(6 182 212 / 55%), transparent 29%),
        radial-gradient(circle at 72% 82%, rgb(250 204 21 / 50%), transparent 32%),
        linear-gradient(135deg, #312e81, #5b21b6 45%, #9d174d);
    inset: 0;
    animation: reward-backdrop-shift 5s ease-in-out infinite alternate;
}

.reward-celebration__backdrop::before,
.reward-celebration__backdrop::after {
    position: absolute;
    border: 3px solid rgb(255 255 255 / 22%);
    border-radius: 50%;
    content: "";
}

.reward-celebration__backdrop::before {
    width: 42vw;
    height: 42vw;
    top: -18vw;
    right: -10vw;
    animation: reward-orbit 9s linear infinite;
}

.reward-celebration__backdrop::after {
    width: 34vw;
    height: 34vw;
    bottom: -16vw;
    left: -8vw;
    animation: reward-orbit 12s linear infinite reverse;
}

.reward-celebration__confetti {
    position: absolute;
    overflow: hidden;
    pointer-events: none;
    inset: 0;
}

.reward-confetti-piece {
    position: absolute;
    width: var(--reward-confetti-width, 10px);
    height: var(--reward-confetti-height, 18px);
    top: -12vh;
    left: var(--reward-confetti-left);
    border-radius: 3px;
    background-color: var(--reward-confetti-color);
    opacity: 0;
    transform: rotate(var(--reward-confetti-rotation));
    animation: reward-confetti-fall var(--reward-confetti-duration)
        var(--reward-confetti-delay) cubic-bezier(0.16, 0.8, 0.35, 1)
        infinite;
}

.reward-celebration__dialog {
    position: relative;
    display: flex;
    width: min(760px, calc(100% - 32px));
    max-height: calc(100vh - 32px);
    box-sizing: border-box;
    align-items: center;
    flex-direction: column;
    margin: 16px auto;
    padding: 34px;
    overflow-y: auto;
    border: 1px solid rgb(255 255 255 / 50%);
    border-radius: 28px;
    background: rgb(255 255 255 / 94%);
    box-shadow: 0 35px 100px rgb(15 23 42 / 45%);
    text-align: center;
    animation: reward-dialog-enter 650ms cubic-bezier(0.16, 1.25, 0.3, 1)
        both;
}

.reward-celebration__burst {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 84px;
    height: 84px;
    border-radius: 26px;
    background: linear-gradient(
        135deg,
        var(--reward-yellow),
        var(--reward-pink),
        var(--reward-violet)
    );
    color: white;
    font-size: 48px;
    box-shadow:
        0 0 0 12px rgb(124 58 237 / 12%),
        0 18px 42px rgb(124 58 237 / 35%);
    animation: reward-burst 1.4s ease-in-out infinite alternate;
}

.reward-celebration__headline {
    margin-top: 20px;
    color: var(--reward-violet);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.reward-celebration__dialog > h2 {
    margin: 6px 0 18px;
    font-size: clamp(30px, 5vw, 52px);
    line-height: 1;
}

.reward-celebration__level {
    display: grid;
    grid-template-columns: auto auto;
    align-items: center;
    gap: 2px 12px;
    margin-bottom: 18px;
    padding: 12px 20px;
    border-radius: 18px;
    background: linear-gradient(135deg, #eef2ff, #fae8ff);
    color: var(--reward-violet);
    text-align: left;
}

.reward-celebration__level span {
    align-self: end;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.reward-celebration__level strong {
    grid-row: 1 / 3;
    grid-column: 2;
    font-family: "Plus Jakarta Sans", "Inter", sans-serif;
    font-size: 42px;
    line-height: 1;
}

.reward-celebration__level p {
    margin: 0;
    color: var(--color-text);
    font-size: 14px;
    font-weight: 700;
}

.reward-celebration__cards {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.reward-celebration-card {
    --reward-card-accent: #64748b;
    position: relative;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 14px;
    padding: 18px;
    overflow: hidden;
    border: 1px solid color-mix(
        in srgb,
        var(--reward-card-accent) 28%,
        white
    );
    border-radius: 18px;
    background: linear-gradient(
        145deg,
        color-mix(in srgb, var(--reward-card-accent) 13%, white),
        white 58%
    );
    text-align: left;
}

.reward-celebration-card--rare {
    --reward-card-accent: #4f46e5;
}

.reward-celebration-card--epic {
    --reward-card-accent: #7c3aed;
}

.reward-celebration-card--legendary {
    --reward-card-accent: #d97706;
}

.reward-celebration-card__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    border-radius: 16px;
    background-color: white;
    font-size: 30px;
    box-shadow: 0 8px 24px color-mix(
        in srgb,
        var(--reward-card-accent) 24%,
        transparent
    );
}

.reward-celebration-card span:not(.reward-celebration-card__icon) {
    color: var(--reward-card-accent);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.reward-celebration-card h3 {
    margin: 3px 0 4px;
    font-size: 17px;
}

.reward-celebration-card p {
    margin: 0;
    color: var(--color-muted);
    font-size: 12px;
    line-height: 1.4;
}

.reward-celebration-card > strong {
    position: absolute;
    right: 14px;
    bottom: 12px;
    color: var(--reward-card-accent);
    font-family: "JetBrains Mono", monospace;
    font-size: 11px;
}

.reward-celebration__form {
    margin-top: 24px;
}

.reward-celebration__form button {
    min-width: 220px;
    padding: 14px 26px;
    border-radius: 14px;
    background: linear-gradient(
        100deg,
        var(--reward-violet),
        var(--reward-pink)
    );
    box-shadow: 0 12px 30px rgb(124 58 237 / 35%);
    font-size: 16px;
    font-weight: 800;
}

.reward-celebration__form button:hover {
    background: linear-gradient(100deg, #6d28d9, #db2777);
    transform: translateY(-2px);
}

.reward-level-toast {
    position: fixed;
    z-index: 9999;
    display: grid;
    width: min(390px, calc(100% - 32px));
    justify-items: center;
    gap: 18px;
    left: 50%;
    top: 50%;
    box-sizing: border-box;
    padding: 30px 30px 25px;
    border: 1px solid var(--color-accent-border);
    border-radius: 24px;
    background: linear-gradient(155deg, var(--color-accent-light), #fff 62%);
    box-shadow: 0 30px 90px rgb(49 46 129 / 28%);
    text-align: center;
    isolation: isolate;
    transform: translate(-50%, -50%);
    animation: reward-toast-enter 620ms cubic-bezier(0.16, 1, 0.3, 1)
        both;
}

.reward-level-toast::before {
    position: absolute;
    z-index: -1;
    inset: -32px;
    border-radius: 50%;
    background: radial-gradient(circle, rgb(79 70 229 / 20%), transparent 68%);
    content: "";
    filter: blur(10px);
    pointer-events: none;
}

.reward-level-toast--leaving {
    animation: reward-toast-leave 260ms ease-in both;
}

.reward-level-toast__icon {
    position: relative;
    display: flex;
    width: 104px;
    height: 104px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    border: 1px solid var(--color-accent-border);
    border-radius: 50%;
    background: var(--color-surface);
    box-shadow: inset 0 0 0 7px var(--color-accent-light), 0 16px 36px rgb(79 70 229 / 22%);
    color: var(--color-accent-active);
}

.reward-level-toast__icon::before {
    position: absolute;
    inset: -10px;
    border: 2px dashed rgb(79 70 229 / 34%);
    border-radius: inherit;
    content: "";
    animation: reward-level-ring 8s linear infinite;
}

.reward-level-toast__icon > span {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.reward-level-toast__icon > strong {
    font-family: "Plus Jakarta Sans", "Inter", sans-serif;
    font-size: 46px;
    line-height: 0.95;
}

.reward-level-toast__spark {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    background: var(--color-accent);
    box-shadow: 0 0 12px rgb(79 70 229 / 42%);
    transform: rotate(45deg);
    animation: reward-level-spark 1.8s ease-in-out infinite;
}

.reward-level-toast__spark:nth-of-type(1) { top: -18px; left: 9px; }
.reward-level-toast__spark:nth-of-type(2) { top: 7px; right: -23px; animation-delay: 260ms; }
.reward-level-toast__spark:nth-of-type(3) { right: -13px; bottom: 1px; animation-delay: 520ms; }
.reward-level-toast__spark:nth-of-type(4) { bottom: -20px; left: 25px; animation-delay: 780ms; }
.reward-level-toast__spark:nth-of-type(5) { bottom: 15px; left: -22px; animation-delay: 1040ms; }
.reward-level-toast__spark:nth-of-type(6) { top: 4px; left: -13px; animation-delay: 1300ms; }

.reward-level-toast__content {
    display: grid;
    gap: 4px;
}

.reward-level-toast__content span {
    color: var(--color-accent-active);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.reward-level-toast__content strong {
    display: block;
    margin: 0;
    font-family: "Plus Jakarta Sans", "Inter", sans-serif;
    font-size: 25px;
    line-height: 1.12;
}

.reward-level-toast__content p {
    margin: 0;
    color: var(--color-muted);
    font-size: 13px;
    font-weight: 600;
}

.reward-level-toast__close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 9px;
    background-color: transparent;
    color: var(--color-muted);
    font-size: 24px;
    line-height: 1;
}

.reward-level-toast__close:hover {
    background-color: var(--color-surface-secondary);
    color: var(--color-text);
}

.reward-level-toast__timer {
    position: absolute;
    height: 4px;
    right: 18px;
    bottom: 10px;
    left: 18px;
    overflow: hidden;
    border-radius: 999px;
    background-color: var(--color-accent);
    transform-origin: left;
    animation: reward-toast-timer 6s linear both;
}

.reward-level-toast form {
    display: none;
}

body.reward-celebration-open {
    overflow: hidden;
}

@keyframes reward-backdrop-shift {
    from {
        filter: saturate(1);
    }
    to {
        filter: saturate(1.35) hue-rotate(12deg);
    }
}

@keyframes reward-orbit {
    to {
        transform: rotate(360deg) scale(1.08);
    }
}

@keyframes reward-dialog-enter {
    from {
        opacity: 0;
        transform: translateY(60px) scale(0.82) rotate(-2deg);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1) rotate(0);
    }
}

@keyframes reward-burst {
    from {
        transform: rotate(-8deg) scale(0.96);
    }
    to {
        transform: rotate(8deg) scale(1.08);
    }
}

@keyframes reward-confetti-fall {
    0% {
        opacity: 0;
        transform: translate3d(0, -10vh, 0)
            rotate(var(--reward-confetti-rotation));
    }
    8% {
        opacity: 1;
    }
    100% {
        opacity: 1;
        transform: translate3d(var(--reward-confetti-drift), 120vh, 0)
            rotate(calc(var(--reward-confetti-rotation) + 780deg));
    }
}

@keyframes reward-toast-enter {
    from {
        opacity: 0;
        transform: translate(-50%, calc(-50% + 26px)) scale(0.82);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes reward-toast-leave {
    to {
        opacity: 0;
        transform: translate(-50%, calc(-50% - 16px)) scale(0.94);
    }
}

@keyframes reward-level-ring {
    to { transform: rotate(360deg); }
}

@keyframes reward-level-spark {
    0%, 100% { opacity: 0.35; transform: rotate(45deg) scale(0.65); }
    50% { opacity: 1; transform: rotate(45deg) scale(1.18); }
}

@keyframes reward-toast-timer {
    to {
        transform: scaleX(0);
    }
}

@media (max-width: 600px) {
    .reward-celebration__dialog {
        width: calc(100% - 20px);
        max-height: calc(100vh - 20px);
        margin: 10px auto;
        padding: 24px 18px;
        border-radius: 22px;
    }

    .reward-celebration__burst {
        width: 68px;
        height: 68px;
        border-radius: 21px;
        font-size: 38px;
    }

    .reward-celebration__cards {
        grid-template-columns: 1fr;
    }

    .reward-celebration-card {
        padding: 15px;
    }

    .reward-celebration__form,
    .reward-celebration__form button {
        width: 100%;
    }

    .reward-level-toast {
        width: calc(100% - 24px);
        padding-inline: 22px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .reward-celebration__backdrop,
    .reward-celebration__backdrop::before,
    .reward-celebration__backdrop::after,
    .reward-celebration__dialog,
    .reward-celebration__burst,
    .reward-level-toast,
    .reward-level-toast--leaving,
    .reward-level-toast__timer {
        animation: none;
    }

    .reward-level-toast__icon::before,
    .reward-level-toast__spark {
        animation: none;
    }

    .reward-celebration__confetti {
        display: none;
    }
}
