@keyframes subtle-burning {
    0% { box-shadow: 0 0 25px 8px rgba(255, 69, 0, 0.3); }
    50% { box-shadow: 0 0 28px 10px rgba(255, 99, 71, 0.4); }
    100% { box-shadow: 0 0 25px 8px rgba(255, 69, 0, 0.3); }
}

@keyframes subtle-icy-glow {
    0% { box-shadow: 0 0 25px 8px rgba(173, 216, 230, 0.3); }
    50% { box-shadow: 0 0 28px 10px rgba(173, 216, 230, 0.4); }
    100% { box-shadow: 0 0 25px 8px rgba(173, 216, 230, 0.3); }
}

@keyframes burning {
    0% { box-shadow: 0 0 25px 8px rgba(255, 69, 0, 0.8), 0 0 35px 12px rgba(255, 140, 0, 0.6); }
    50% { box-shadow: 0 0 28px 10px rgba(255, 99, 71, 0.9), 0 0 38px 14px rgba(255, 165, 0, 0.7); }
    100% { box-shadow: 0 0 25px 8px rgba(255, 69, 0, 0.8), 0 0 35px 12px rgba(255, 140, 0, 0.6); }
}

@keyframes icy-glow {
    0% { box-shadow: 0 0 25px 8px rgba(173, 216, 230, 0.8), 0 0 35px 12px rgba(135, 206, 250, 0.6); }
    50% { box-shadow: 0 0 28px 10px rgba(173, 216, 230, 0.9), 0 0 38px 14px rgba(135, 206, 250, 0.7); }
    100% { box-shadow: 0 0 25px 8px rgba(173, 216, 230, 0.8), 0 0 35px 12px rgba(135, 206, 250, 0.6); }
}

@keyframes dark-pulsating-aura {
    0% { box-shadow: 0 0 10px 2px rgba(0, 0, 0, 0.5); }
    50% { box-shadow: 0 0 15px 4px rgba(0, 0, 0, 0.7); }
    100% { box-shadow: 0 0 10px 2px rgba(0, 0, 0, 0.5); }
}

/* Use higher specificity so these always win */
#popup {
    position: absolute;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ccc;
    width: calc(var(--popup-width, 350px) * var(--popup-scale, 1)) !important;
    height: calc(var(--popup-height, 500px) * var(--popup-scale, 1)) !important;
    border-radius: 5px;
    display: none;
    pointer-events: auto;
    z-index: 2000;
    overflow: hidden;
    transform-origin: top left;
}

#popup iframe {
    width: calc(100% / var(--popup-scale, 1)) !important;
    height: calc(100% / var(--popup-scale, 1)) !important;
    border: none;
    border-radius: 5px;
    transform: scale(var(--popup-scale, 1)) !important;
    transform-origin: top left;
}

.pulsating-aura {
    animation: dark-pulsating-aura 2s infinite;
    border-radius: 5px;
}

/* Remove filter-based per-flag glow animation. Instead, draw a small halo via ::after and animate opacity only */
.marker_flag.sunny-glow::after,
.marker_flag.sunny-glow-static::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    /* Use --glow-scale so halo thickness stays constant on zoom */
    width: calc(44px * var(--glow-scale));
    height: calc(44px * var(--glow-scale));
    transform: translate(-50%, -50%);
    border-radius: 50%;
    pointer-events: none;
    /* Soft halo via radial-gradient; no filter, no blur */
    background:
        radial-gradient(ellipse at center,
            rgba(255, 240, 160, 0.85) 0%,
            rgba(255, 210, 60, 0.55) 35%,
            rgba(255, 120, 0, 0.00) 70%);
    will-change: opacity;
    opacity: 0; /* default off unless class below says otherwise */
}

/* Animated pulse (compositor-friendly: opacity only) */
.marker_flag.sunny-glow::after {
    animation: sunny-marker-opacity 1.2s ease-in-out infinite;
    animation-delay: var(--glow-delay, 0s);
}

/* Static (non-animated) halo for overflow flags when we cap the animation count */
.marker_flag.sunny-glow-static::after {
    opacity: 0.32;
}

/* Pause/disable halo while the map is moving to keep interaction smooth */
#map-stage.moving .marker_flag.sunny-glow::after,
#map-stage.moving .marker_flag.sunny-glow-static::after {
    animation: none !important;
    opacity: 0 !important;
}

/* Halo element inserted by JS next to each flag */
.marker-halo {
    position: absolute;
    left: 0; top: 0;
    width: calc(44px * var(--glow-scale));
    height: calc(44px * var(--glow-scale));
    transform: translate(-50%, -50%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 9; /* flags are z-index:10; halo sits underneath the pin, visible around it */
    background:
        radial-gradient(ellipse at center,
            rgba(255, 240, 160, 0.85) 0%,
            rgba(255, 210, 60, 0.55) 35%,
            rgba(255, 120, 0, 0.00) 70%);
    opacity: 0;
    will-change: opacity;
}

/* Animated pulse (opacity-only) */
.marker-halo.animate {
    animation: sunny-marker-opacity 1.2s ease-in-out infinite;
    animation-delay: var(--glow-delay, 0s);
}

/* Static inexpensive halo (for overflow flags beyond the animated cap) */
.marker-halo.static {
    opacity: 0.32;
}

/* Pause halos while the map is moving for smooth interaction */
#map-stage.moving .marker-halo {
    animation: none !important;
    opacity: 0 !important;
}

/* Opacity pulse keyframes (compositor friendly) */
@keyframes sunny-marker-opacity {
    0% { opacity: 0.38; }
    50% { opacity: 0.90; }
    100% { opacity: 0.38; }
}

/* Optional: reduced motion */
@media (prefers-reduced-motion: reduce) {
    .marker-halo.animate {
        animation-duration: 2.0s;
    }
}

/* Reuse "Play NOW" glow behavior for the footer */
.ice-glow {
    box-shadow: 0 0 35px 12px rgba(173, 216, 230, 0.5), 0 0 45px 16px rgba(135, 206, 250, 0.5);
    animation: subtle-icy-glow 2s infinite alternate;
    border-radius: 10px;
    transition: box-shadow 0.3s ease;
}

.ice-glow:hover {
    box-shadow: 0 0 25px 8px rgba(173, 216, 230, 0.8), 0 0 35px 12px rgba(135, 206, 250, 0.6);
    animation: icy-glow 0.5s infinite alternate;
}

@media (prefers-reduced-motion: reduce) {
    .ice-glow { animation-duration: 3s; }
}