#july-flag {
    position: fixed;
    top: -200px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100000;
    cursor: pointer;
    font-size: 120px;
    filter: drop-shadow(0 0 30px rgba(178, 34, 52, 0.8));
    transition: filter 0.2s ease, transform 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    display: none;
}

#july-flag:hover {
    filter: drop-shadow(0 0 50px rgba(255, 80, 80, 1));
    transform: translateX(-50%) scale(1.12);
}

#july-flag.show {
    display: block;
    animation: julyFlagFall 6s linear forwards;
}

@keyframes julyFlagFall {
    0% {
        top: -200px;
        opacity: 0;
        transform: translateX(-50%) rotate(-10deg) scale(0.7);
    }

    5% {
        opacity: 1;
        transform: translateX(-50%) rotate(0deg) scale(1);
    }

    90% {
        opacity: 1;
    }

    100% {
        top: calc(100vh + 200px);
        opacity: 0;
        transform: translateX(-50%) rotate(10deg) scale(0.8);
    }
}

#july-flag.clicked {
    animation: julyFlagExplode 0.6s ease-out forwards;
    pointer-events: none;
}

@keyframes julyFlagExplode {
    0% {
        transform: translateX(-50%) translateY(-50%) scale(1);
        opacity: 1;
    }

    50% {
        transform: translateX(-50%) translateY(-50%) scale(1.6);
        opacity: 0.6;
    }

    100% {
        transform: translateX(-50%) translateY(-50%) scale(0);
        opacity: 0;
    }
}

#july-flag.missed {
    display: none;
}

#july-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    pointer-events: none;
    display: none;
}

#july-overlay.active {
    display: block;
    pointer-events: auto;
}

.july-confetti-piece {
    position: fixed;
    width: 10px;
    height: 20px;
    top: -20px;
    z-index: 100001;
    opacity: 0;
    animation: julyConfettiFall var(--fall-duration, 3s) var(--fall-delay, 0s) ease-in forwards;
    border-radius: 2px;
}

@keyframes julyConfettiFall {
    0% {
        top: -20px;
        opacity: 1;
        transform: rotate(0deg) translateX(0px);
    }

    25% {
        opacity: 1;
        transform: rotate(180deg) translateX(var(--sway, 30px));
    }

    50% {
        transform: rotate(360deg) translateX(calc(var(--sway, 30px) * -0.5));
    }

    75% {
        transform: rotate(540deg) translateX(var(--sway, 30px));
    }

    100% {
        top: 110vh;
        opacity: 0.6;
        transform: rotate(720deg) translateX(calc(var(--sway, 30px) * -1));
    }
}

#july-text {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    z-index: 100002;
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: clamp(28px, 6vw, 72px);
    font-weight: bold;
    color: transparent;
    background: linear-gradient(135deg,
            #b22234, #ffffff, #3c3b6e, #ff4444, #ffffff, #b22234);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    background-clip: text;
    text-align: center;
    white-space: nowrap;
    text-shadow: none;
    opacity: 0;
    display: none;
    animation: none;
    filter: drop-shadow(0 0 20px rgba(178, 34, 52, 0.6)) drop-shadow(0 2px 10px rgba(0, 0, 0, 0.5));
}

#july-text.show {
    display: block;
    animation: julyTextAppear 0.8s 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
        julyColorShift 3s 1s ease-in-out infinite;
}

@keyframes julyTextAppear {
    0% {
        transform: translate(-50%, -50%) scale(0) rotate(-10deg);
        opacity: 0;
    }

    100% {
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
        opacity: 1;
    }
}

@keyframes julyColorShift {

    0%,
    100% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }
}

#july-text::before,
#july-text::after {
    content: '🎆';
    position: absolute;
    font-size: 0.5em;
    animation: julySparkleFloat 2s ease-in-out infinite;
}

#july-text::before {
    top: -20px;
    left: -30px;
    animation-delay: 0s;
}

#july-text::after {
    bottom: -20px;
    right: -30px;
    animation-delay: 1s;
}

@keyframes julySparkleFloat {

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

    50% {
        transform: translateY(-10px) scale(1.3);
        opacity: 0.6;
    }
}

#july-shockwave {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 3px solid rgba(178, 34, 52, 0.9);
    transform: translate(-50%, -50%) scale(0);
    z-index: 100000;
    pointer-events: none;
    display: none;
}

#july-shockwave.active {
    display: block;
    animation: julyShockwaveExpand 0.8s ease-out forwards;
}

@keyframes julyShockwaveExpand {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
        border-width: 4px;
    }

    100% {
        transform: translate(-50%, -50%) scale(80);
        opacity: 0;
        border-width: 1px;
    }
}

.july-firework {
    position: fixed;
    z-index: 100001;
    pointer-events: none;
}

.july-firework-particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    animation: julyFireworkBurst 1.2s ease-out forwards;
}

@keyframes julyFireworkBurst {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translate(var(--fx, 50px), var(--fy, -50px)) scale(0);
        opacity: 0;
    }
}

#july-dimmer {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(0, 0, 40, 0.3) 0%, rgba(0, 0, 20, 0.75) 100%);
    z-index: 99998;
    opacity: 0;
    display: none;
    transition: opacity 0.5s ease;
}

#july-dimmer.show {
    display: block;
    opacity: 1;
}

#july-flag.july-fade-out,
#july-overlay.july-fade-out,
#july-text.july-fade-out,
#july-dimmer.july-fade-out {
    animation: julyFadeOutAll 1.5s ease-out forwards !important;
}

@keyframes julyFadeOutAll {
    to {
        opacity: 0;
    }
}
