.falling-petals {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    user-select: none;
    z-index: 40; /* Above banners/cards, below header (50), dialogs, install and chat. */
    contain: strict;
}
.falling-petals * { pointer-events: none; }

/* Independent fall / sway / tumble clocks keep the motion soft and unsynchronized. */
.falling-petal {
    position: absolute;
    top: 0;
    left: var(--petal-left);
    width: var(--petal-size);
    height: var(--petal-size);
    opacity: 0;
    animation: petal-fall var(--petal-duration) var(--petal-delay) linear infinite;
    will-change: transform, opacity;
}
.petal-sway, .petal-sprite { display: block; position: relative; width: 100%; height: 100%; }
.petal-sway {
    animation: petal-sway var(--petal-sway-duration) var(--petal-delay) ease-in-out infinite alternate;
}
.petal-sprite {
    animation: petal-tumble var(--petal-spin-duration) var(--petal-delay) linear infinite;
}
.petal-sprite img { display: block; width: 100%; height: 100%; object-fit: contain; }

/* Pre-painted warm halos and a rare glint: no animated blur, filter or shadow. */
.falling-petal[data-depth="near"] .petal-sprite::before {
    content: "";
    position: absolute;
    inset: -22%;
    border-radius: 50%;
    background: radial-gradient(circle, rgb(255 193 98 / 22%), rgb(255 171 72 / 8%) 40%, transparent 70%);
}
.falling-petal[data-depth="near"] .petal-sprite::after {
    content: "";
    position: absolute;
    top: 14%;
    right: 12%;
    width: 9px;
    height: 9px;
    background:
        linear-gradient(transparent, #fff4d6, transparent) center / 1px 100% no-repeat,
        linear-gradient(90deg, transparent, #fff4d6, transparent) center / 100% 1px no-repeat;
    opacity: 0;
    animation: petal-glint var(--petal-sway-duration) var(--petal-delay) ease-in-out infinite;
}
.falling-petals[data-paused="true"] *,
.falling-petals[data-paused="true"] *::after { animation-play-state: paused !important; }

@keyframes petal-fall {
    0% { transform: translate3d(0, -12vh, 0); opacity: 0; }
    10%, 86% { opacity: var(--petal-opacity); }
    100% { transform: translate3d(calc(var(--petal-sway) * .65), 112vh, 0); opacity: 0; }
}
@keyframes petal-sway {
    from { transform: translate3d(calc(var(--petal-sway) * -.5), 0, 0) rotate(-9deg); }
    to { transform: translate3d(calc(var(--petal-sway) * .5), 0, 0) rotate(9deg); }
}
@keyframes petal-tumble {
    0% { transform: perspective(180px) rotateZ(var(--petal-turn)) rotateY(25deg); }
    50% { transform: perspective(180px) rotateZ(calc(var(--petal-turn) + 180deg)) rotateY(-35deg); }
    100% { transform: perspective(180px) rotateZ(calc(var(--petal-turn) + 360deg)) rotateY(25deg); }
}
@keyframes petal-glint {
    0%, 62%, 100% { opacity: 0; transform: scale(.35) rotate(0deg); }
    76% { opacity: .85; transform: scale(1) rotate(45deg); }
    90% { opacity: 0; transform: scale(.5) rotate(90deg); }
}
@media (max-width: 640px) {
    .falling-petal { left: var(--petal-mobile-left); width: calc(var(--petal-size) * .8); height: calc(var(--petal-size) * .8); }
    .falling-petal:nth-child(n+11) { display: none; }
    .falling-petal:nth-child(n+11),
    .falling-petal:nth-child(n+11) *,
    .falling-petal:nth-child(n+11) *::after { animation: none !important; will-change: auto; }
}
@media (prefers-reduced-motion: reduce), print {
    .falling-petals { display: none; }
    /* Override the near-sprite glint's more-specific decorative selector too. */
    .falling-petals *, .falling-petals *::after { animation: none !important; will-change: auto; }
}
