/* 
  SportyXi - World Cup Theme Effects 
  Realistic Waving Flag, Dynamic Glow, and Match Result Animations
*/

:root {
    --team-glow: rgba(229, 9, 20, 0.2);
    --team-primary: #e50914;
}

/* Background Waving Flag Container */
#bg-flag-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
    background: radial-gradient(circle at 50% 50%, var(--team-glow) 0%, transparent 80%);
    transition: background 1.5s ease;
}

.waving-flag {
    position: absolute;
    width: 120%;
    height: 120%;
    top: -10%;
    left: -10%;
    opacity: 0.05; /* Subtle Watermark */
    object-fit: cover;
    filter: blur(3px) grayscale(50%);
    animation: waveEffect 10s infinite ease-in-out;
    transform-origin: center;
    mix-blend-mode: luminosity;
}

@keyframes waveEffect {
    0%, 100% { transform: scale(1) rotate(0deg) translate(0, 0); }
    25% { transform: scale(1.02) rotate(1deg) translate(15px, -10px); }
    50% { transform: scale(1) rotate(-1deg) translate(-15px, 10px); }
    75% { transform: scale(1.02) rotate(0.5deg) translate(10px, -15px); }
}

/* Selection Modal Styling */
.team-selection-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(11, 12, 16, 0.95);
    backdrop-filter: blur(20px);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    transition: opacity 0.5s ease;
}

.team-selection-card {
    background: linear-gradient(145deg, rgba(255,255,255,0.05), rgba(255,255,255,0.01));
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 32px;
    width: 100%;
    max-width: 900px;
    padding: 50px 40px;
    text-align: center;
    box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.8);
}

.team-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 25px;
    margin-top: 40px;
}

.team-item {
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    padding: 20px 15px;
    border-radius: 24px;
    background: rgba(255,255,255,0.02);
    border: 1px solid transparent;
}

.team-item:hover {
    background: rgba(255,255,255,0.06);
    transform: translateY(-10px) scale(1.05);
    border-color: rgba(255,255,255,0.15);
    box-shadow: 0 15px 30px rgba(0,0,0,0.4);
}

.team-flag-img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 15px;
    filter: drop-shadow(0 8px 16px rgba(0,0,0,0.5));
}

.team-name {
    color: white;
    font-size: 15px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

/* ─── Mobile responsive initial theme popup ─── */
@media (max-width: 768px) {
    .team-selection-overlay {
        padding: 0;
        align-items: flex-end;
    }
    .team-selection-card {
        border-radius: 24px 24px 0 0 !important;
        padding: 24px 16px !important;
        max-height: 95vh;
        width: 100% !important;
        max-width: 100% !important;
    }
    .team-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 10px !important;
        margin-top: 16px !important;
    }
    .team-item {
        padding: 12px 8px !important;
        border-radius: 16px !important;
    }
    .team-flag-img {
        width: 48px !important;
        height: 48px !important;
        margin-bottom: 8px !important;
    }
    .team-name {
        font-size: 10px !important;
        letter-spacing: 0.5px !important;
    }
    /* Hide scrollbar on category buttons */
    .scrollbar-hide::-webkit-scrollbar {
        display: none;
    }
    .scrollbar-hide {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
}

/* Glow Pulses */
.ambient-glow {
    position: fixed;
    width: 70vw;
    height: 70vw;
    max-width: 800px;
    max-height: 800px;
    background: var(--team-glow);
    filter: blur(180px);
    border-radius: 50%;
    z-index: -2;
    opacity: 0.15;
    pointer-events: none;
    animation: glowPulse 12s infinite alternate;
}

@keyframes glowPulse {
    from { opacity: 0.1; transform: scale(0.9); }
    to { opacity: 0.3; transform: scale(1.1); }
}

/* Floating Flag Particles */
.flag-particle {
    position: fixed;
    bottom: -80px;
    width: 60px;
    height: 60px; /* Made square to prevent cutting tall logos */
    border-radius: 0; /* Removed rounding for transparent logos */
    object-fit: contain; /* Changed from cover so it doesn't get cut */
    opacity: 0;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4));
    animation: floatUp linear forwards;
    pointer-events: none;
    z-index: -1;
    border: none; /* Removed border */
    background: transparent;
}

@keyframes floatUp {
    0% { transform: translateY(0) rotate(-5deg) scale(0.7); opacity: 0; }
    8% { opacity: 0.5; }
    50% { transform: translateY(-50vh) rotate(8deg) scale(1); opacity: 0.35; }
    85% { opacity: 0.15; }
    100% { transform: translateY(-105vh) rotate(-5deg) scale(1.1); opacity: 0; }
}

/* Result Animations Overlay */
.match-result-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(10px);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 1s ease;
}

.result-content {
    text-align: center;
    z-index: 2;
    animation: popIn 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Confetti */
.confetti-container {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    overflow: hidden; pointer-events: none; z-index: 1;
}

.confetti-piece {
    position: absolute;
    width: 10px; height: 20px;
    top: -20px;
    opacity: 0;
    animation: fall 4s linear forwards;
}

@keyframes fall {
    0% { top: -20px; transform: rotate(0deg); opacity: 1; }
    100% { top: 100vh; transform: rotate(720deg); opacity: 0; }
}

/* Rain */
.rain-container {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    overflow: hidden; pointer-events: none; z-index: 1;
}

.rain-drop {
    position: absolute;
    width: 2px; height: 50px;
    background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,0.5));
    top: -50px;
    animation: rainFall 0.8s linear infinite;
}

@keyframes rainFall {
    0% { top: -50px; }
    100% { top: 100vh; }
}
