.newyear-v2 {
    --newyear-header-bottom: calc(49px + var(--tg-header-top-padding));
    isolation: isolate;
    background: #000;
}

.newyear-v2::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -2;
    pointer-events: none;
    background: url("data/newyear-v2/atmosphere.svg") center / 100% 100% no-repeat;
}

.newyear-scene {
    --newyear-snow: url("data/newyear-v2/snow-referrals.svg");
    position: fixed;
    inset: 0;
    z-index: -1;
    width: 100%;
    margin-inline: auto;
    overflow: hidden;
    pointer-events: none;
}

.newyear-scene::before {
    content: "";
    position: absolute;
    inset: 0;
    opacity: .62;
    background: var(--newyear-snow) center / 100% 100% no-repeat;
}

.newyear-v2:has([data-layer="market"].page-layer--active) .newyear-scene {
    --newyear-snow: url("data/newyear-v2/snow-market.svg");
}

.newyear-v2:has([data-layer="tasks"].page-layer--active) .newyear-scene {
    --newyear-snow: url("data/newyear-v2/snow-tasks.svg");
}

.newyear-v2 .page-main {
    position: relative;
    padding-block-start: 22px;
}

.newyear-v2 .page-header {
    background-color: rgba(24, 20, 13, .5);
    border-color: rgba(255, 255, 255, .12);
}

.newyear-v2 .panel,
.newyear-v2 .market-entry,
.newyear-v2 .bottom-nav__items,
.newyear-v2 .referrals-list:not(:empty) {
    border: .5px solid rgba(255, 255, 255, .3);
    background-color: rgba(255, 255, 255, .10);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

.newyear-v2 .panel,
.newyear-v2 .referrals-list:not(:empty) {
    border-radius: 20px;
}

.newyear-v2 .referrals-list:not(:empty) {
    gap: 0;
    padding: 4px 16px;
}

.newyear-v2 .referrals-list .referral-item {
    padding: 14px 0;
    border: 0;
    border-bottom: .5px solid rgba(255, 255, 255, .24);
    border-radius: 0;
    background: transparent;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

.newyear-v2 .referrals-list .referral-item:last-child {
    border-bottom: 0;
}

.newyear-v2 .giveaway-progress__bar {
    background-color: rgba(255, 255, 255, .10);
}

.newyear-gift {
    position: relative;
    display: grid;
}

.newyear-gift::after {
    content: "";
    position: absolute;
    top: -29.2%;
    left: 49.5%;
    width: 64.2%;
    aspect-ratio: 71.5 / 60;
    transform: rotate(20deg);
    background: url("data/newyear-v2/santa-hat.svg") center / contain no-repeat;
    pointer-events: none;
}

.newyear-lights {
    position: absolute;
    display: block;
    isolation: isolate;
    pointer-events: none;
    background: var(--garland-static) center / 100% 100% no-repeat;
}

.newyear-lights--top {
    --garland-static: url("data/newyear-v2/top-off.svg");
    --garland-phase-one: url("data/newyear-v2/top-1.svg");
    --garland-phase-two: url("data/newyear-v2/top-2.svg");
    --garland-phase-three: url("data/newyear-v2/top-3.svg");
    inset-block-start: calc(var(--newyear-header-bottom) - 4px);
    inset-inline-start: -.32%;
    width: 100.64%;
    aspect-ratio: 395.5 / 40;
    max-height: 41px;
}

.newyear-lights--side {
    --garland-static: url("data/newyear-v2/side-off.svg");
    --garland-phase-one: url("data/newyear-v2/side-1.svg");
    --garland-phase-two: url("data/newyear-v2/side-2.svg");
    --garland-phase-three: url("data/newyear-v2/side-3.svg");
    inset-block: calc(var(--newyear-header-bottom) + 26px) max(32px, calc(var(--bottom-nav-height) - 32px));
    width: min(5.31%, 21px);
}

.newyear-v2:has([data-layer="referrals"].page-layer--active) .newyear-lights--side {
    inset-block-start: calc(var(--newyear-header-bottom) + 90px);
}

.newyear-lights--left {
    left: max(-.87%, -3.5px);
}

.newyear-lights--right {
    right: max(-.87%, -3.5px);
    transform: scaleX(-1);
}

.newyear-v2 :is(#task-rules-modal, #streak-reward-modal) .market-purchase-modal__card {
    position: relative;
    isolation: isolate;
    border-radius: 20px;
    border-color: rgba(255, 255, 255, .3);
}

.newyear-v2 #task-rules-modal .market-purchase-modal__card {
    background: linear-gradient(180deg, #2c2d31, #242428);
}

.newyear-v2 #task-rules-modal [data-task-rules-ok] {
    background: var(--white);
    border-color: var(--white);
    color: var(--f);
}

.newyear-lights--frame {
    --garland-static: url("data/newyear-v2/frame-off.svg");
    --garland-phase-one: url("data/newyear-v2/frame-1.svg");
    --garland-phase-two: url("data/newyear-v2/frame-2.svg");
    --garland-phase-three: url("data/newyear-v2/frame-3.svg");
    inset: -11px;
    z-index: -1;
}

#streak-reward-modal .newyear-lights--frame {
    --garland-static: url("data/newyear-v2/reward-off.svg");
    --garland-phase-one: url("data/newyear-v2/reward-1.svg");
    --garland-phase-two: url("data/newyear-v2/reward-2.svg");
    --garland-phase-three: url("data/newyear-v2/reward-3.svg");
}

@media (prefers-reduced-motion: no-preference) {
    .newyear-lights {
        background-image: none;
    }

    .newyear-lights > span {
        position: absolute;
        inset: 0;
        background: var(--garland-phase) center / 100% 100% no-repeat;
        opacity: 0;
        mix-blend-mode: plus-lighter;
        animation: newyear-glow 1.8s ease-in-out infinite;
    }

    .newyear-lights > span:nth-child(1) {
        --garland-phase: var(--garland-phase-one);
    }

    .newyear-lights > span:nth-child(2) {
        --garland-phase: var(--garland-phase-two);
        animation-delay: -1.2s;
    }

    .newyear-lights > span:nth-child(3) {
        --garland-phase: var(--garland-phase-three);
        animation-delay: -.6s;
    }

    [data-newyear-paused] .newyear-lights > span {
        animation-play-state: paused;
    }
}

@keyframes newyear-glow {
    0%, 11.1111%, 100% { opacity: 1; }
    33.3333%, 77.7778% { opacity: 0; }
}

@media (min-width: 640px) {
    .newyear-scene {
        width: 432px;
    }

    .newyear-lights--top {
        inset-inline-start: calc(16px - .32%);
        width: calc(100.64% - 32px);
    }
}

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .newyear-v2 .panel,
    .newyear-v2 .market-entry,
    .newyear-v2 .bottom-nav__items,
    .newyear-v2 .referrals-list:not(:empty) {
        background-color: #20201c;
    }
}
