@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }
body { overflow: hidden; background-color: #000; font-family: 'Outfit', sans-serif; }
#map { width: 100vw; height: 100vh; }

.hidden-element { display: none !important; }

.ad-banner {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 320px;
    height: 50px;
    background: rgba(10, 15, 25, 0.85);
    border: 1px dashed rgba(0, 243, 255, 0.4);
    border-top: none;
    border-radius: 0 0 8px 8px;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(0, 243, 255, 0.5);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 2px;
    backdrop-filter: blur(5px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    pointer-events: auto;
}

#top-bar {
    position: absolute;
    top: 65px;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 1rem;
    z-index: 10;
    pointer-events: none; /* Let clicks pass through except on children */
}
#top-bar > * {
    pointer-events: auto;
}
.score-pill {
    background: rgba(10, 12, 18, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 243, 255, 0.3);
    padding: 10px 24px;
    border-radius: 30px;
    color: #fff;
    font-weight: 600;
    font-size: 1.1rem;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(0, 243, 255, 0.1);
}
#score, #high-score { color: #00f3ff; font-weight: 800; font-size: 1.3rem; margin-left: 8px;}

#ui-card {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 800px;
    background: linear-gradient(135deg, rgba(12, 16, 26, 0.9) 0%, rgba(5, 8, 12, 0.95) 100%);
    backdrop-filter: blur(24px);
    border: 1px solid rgba(0, 243, 255, 0.15);
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    color: #fff;
    z-index: 10;
    transition: all 0.3s ease;
}

.game-console {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    position: relative;
}

.country-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 0 1rem;
    width: 50%;
}

.flag-img {
    width: 90px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 0.75rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.1);
}

.country-name {
    font-size: 1.6rem;
    font-weight: 600;
    margin-bottom: 1rem;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.data-section {
    height: 60px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pop-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.pop-label {
    font-size: 0.75rem;
    color: #a0aabf;
    letter-spacing: 2px;
    margin-bottom: 0.25rem;
}

.pop-value {
    font-size: 2.2rem;
    font-weight: 800;
    color: #00f3ff;
}

.vs-circle {
    width: 44px;
    height: 44px;
    background: #00f3ff;
    color: #000;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1rem;
    box-shadow: 0 0 20px rgba(0,243,255,0.5);
    flex-shrink: 0;
    margin: 0 1rem;
}

.controls-container {
    display: flex;
    flex-direction: row; /* Side-by-side */
    gap: 12px;
    width: 100%;
}

.guess-btn {
    flex: 1;
    padding: 14px 0;
    border: none;
    border-radius: 8px;
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.guess-btn.up {
    background: rgba(0, 255, 136, 0.1);
    color: #00ff88;
    border: 2px solid #00ff88;
}
.guess-btn.up:hover {
    background: #00ff88;
    color: #000;
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.4);
}

.guess-btn.down {
    background: rgba(255, 60, 60, 0.1);
    color: #ff3c3c;
    border: 2px solid #ff3c3c;
}
.guess-btn.down:hover {
    background: #ff3c3c;
    color: #000;
    box-shadow: 0 0 20px rgba(255, 60, 60, 0.4);
}

/* Correct/Incorrect animations */
.result-correct { color: #00ff88 !important; animation: pulseWin 0.5s; }
.result-wrong { color: #ff3c3c !important; animation: pulseLose 0.5s; }

@keyframes pulseWin { 0% { transform: scale(1); } 50% { transform: scale(1.1); } 100% { transform: scale(1); } }
@keyframes pulseLose { 0% { transform: translateX(0); } 25% { transform: translateX(-10px); } 75% { transform: translateX(10px); } 100% { transform: translateX(0); } }

#game-over-overlay, #loading-overlay {
    position: absolute;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    flex-direction: column;
    color: #fff;
}

/* Main Menu Overlay */
#main-menu-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: radial-gradient(circle at center, rgba(5, 8, 12, 0.2), rgba(2, 4, 8, 0.8));
    backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
}

.menu-box {
    background: rgba(10, 15, 25, 0.6);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 0;
    padding: 0;
    position: relative;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 0 50px rgba(0, 243, 255, 0.1);
}

.menu-brackets {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    border: 1px solid rgba(0, 243, 255, 0.1);
}
.menu-brackets::before, .menu-brackets::after {
    content: ''; position: absolute; width: 40px; height: 40px;
    border-color: #00f3ff; border-style: solid;
}
.menu-brackets::before {
    top: 0; left: 0; border-width: 3px 0 0 3px;
}
.menu-brackets::after {
    bottom: 0; right: 0; border-width: 0 3px 3px 0;
}

.menu-content {
    padding: 4rem 3rem;
    position: relative;
    z-index: 2;
    background: linear-gradient(180deg, rgba(0,243,255,0.05) 0%, transparent 100%);
    border-top: 1px solid rgba(0, 243, 255, 0.5);
    border-bottom: 1px solid rgba(0, 243, 255, 0.5);
    text-align: center;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
    z-index: 2;
}

.game-title {
    font-size: 3.5rem;
    font-weight: 900;
    color: #fff;
    margin-bottom: 1rem;
    line-height: 1.1;
    letter-spacing: 2px;
}
.title-accent {
    color: transparent;
    -webkit-text-stroke: 2px #00f3ff;
    text-shadow: 0 0 20px rgba(0,243,255,0.3);
}

.menu-divider {
    width: 50px; height: 4px; background: #00f3ff; margin: 0 auto 1.5rem;
    box-shadow: 0 0 10px #00f3ff;
}

.game-subtitle {
    color: #a0aabf;
    font-size: 0.9rem;
    letter-spacing: 6px;
    margin-bottom: 2rem;
    text-transform: uppercase;
}

.menu-high-score {
    background: rgba(0, 243, 255, 0.1);
    border: 1px solid rgba(0, 243, 255, 0.3);
    padding: 10px 20px;
    border-radius: 20px;
    display: inline-block;
    color: #fff;
    font-size: 0.9rem;
    letter-spacing: 2px;
    margin-bottom: 3rem;
    box-shadow: 0 0 15px rgba(0,243,255,0.1);
}
#menu-high-score-val { color: #00f3ff; font-weight: 800; font-size: 1.1rem; }

.hero-btn {
    background: rgba(0, 243, 255, 0.1);
    color: #00f3ff;
    border: 2px solid #00f3ff;
    box-shadow: 0 0 15px rgba(0,243,255,0.2);
    transition: all 0.3s ease;
}
.hero-btn:hover {
    background: #00f3ff;
    color: #000;
    box-shadow: 0 0 30px rgba(0,243,255,0.6);
    transform: scale(1.05);
}
.hero-btn .btn-text { position: relative; z-index: 2; }

.outlined-btn {
    background: transparent;
    border: 2px solid rgba(0, 243, 255, 0.4);
    color: #00f3ff;
    padding: 14px 32px;
    font-size: 1rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
    width: 100%;
}

.outlined-btn:hover {
    background: rgba(0, 243, 255, 0.1);
    border-color: #00f3ff;
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.2);
}

.gold-outlined-btn {
    background: transparent;
    border: 2px solid rgba(255, 215, 0, 0.6);
    color: #ffd700;
    padding: 14px 32px;
    font-size: 1rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
    width: 100%;
}

.gold-outlined-btn:hover {
    background: rgba(255, 215, 0, 0.1);
    border-color: #ffd700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
    transform: scale(1.05);
}

.icon-buttons-row {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 0.5rem;
}

.icon-round-btn {
    background: transparent;
    border: 2px solid rgba(0, 243, 255, 0.4);
    color: #fff;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.icon-round-btn:hover {
    background: rgba(0, 243, 255, 0.1);
    border-color: #00f3ff;
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.2);
    transform: scale(1.1);
}

.coffee-btn {
    border-color: rgba(255, 215, 0, 0.5); /* Gold ring */
}

.coffee-btn:hover {
    background: rgba(255, 215, 0, 0.1) !important;
    border-color: #ffd700 !important;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3) !important;
}

/* Game Over Screen */
.game-over-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

.game-over-box {
    background: rgba(15, 18, 25, 0.95);
    border: 1px solid rgba(255, 60, 60, 0.4);
    border-top: 4px solid #ff3c3c;
    padding: 3rem;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(255, 60, 60, 0.15);
}

.submit-score-box {
    background: rgba(15, 18, 25, 0.95);
    border: 1px solid rgba(255, 215, 0, 0.4);
    border-top: 4px solid #ffd700;
    padding: 3rem;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(255, 215, 0, 0.15);
    width: 90%;
    max-width: 500px;
}

.go-header {
    font-size: 3rem;
    font-weight: 800;
    color: #ff3c3c;
    letter-spacing: 2px;
    margin-bottom: 2rem;
    text-transform: uppercase;
    text-shadow: 0 0 20px rgba(255, 60, 60, 0.4);
}

.go-comparison {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2.5rem;
    background: rgba(0,0,0,0.3);
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.05);
}

.go-country {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 150px;
}

.go-flag {
    width: 60px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

.go-country h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    text-align: center;
    line-height: 1.2;
}

.go-pop-label {
    font-size: 0.65rem;
    color: #a0aabf;
    letter-spacing: 2px;
    margin-bottom: 0.2rem;
}

.go-pop-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: #00f3ff;
}

.go-pop-value.wrong-pop {
    color: #ff3c3c;
}

.go-vs {
    display: flex;
    align-items: center;
    justify-content: center;
}

.go-symbol {
    font-size: 2rem;
    color: #fff;
    font-weight: 300;
    opacity: 0.5;
}

.go-score-container {
    margin-bottom: 2rem;
}

.go-score-label {
    font-size: 0.8rem;
    color: #a0aabf;
    letter-spacing: 2px;
    margin-bottom: 0.2rem;
}

.go-score-value {
    font-size: 3.5rem;
    font-weight: 800;
    color: #fff;
    line-height: 1;
}

.play-btn {
    background: #00f3ff;
    color: #000;
    border: none;
    padding: 16px 40px;
    font-size: 1.2rem;
    font-weight: 800;
    border-radius: 30px;
    cursor: pointer;
    font-family: 'Outfit';
    transition: all 0.2s ease;
}
.play-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(0,243,255,0.4);
}

.loader-spinner {
    width: 40px; height: 40px;
    border: 3px solid rgba(0,243,255,0.2);
    border-top-color: #00f3ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

.mapboxgl-ctrl-bottom-left, .mapboxgl-ctrl-bottom-right { display: none !important; }

/* Radar Map Marker */
.radar-marker {
    width: 80px;
    height: 80px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.radar-core {
    width: 14px;
    height: 14px;
    background: #00f3ff;
    border-radius: 50%;
    box-shadow: 0 0 15px #00f3ff, 0 0 30px #00f3ff;
    z-index: 2;
    transition: all 0.3s cubic-bezier(0.1, 0.8, 0.3, 1);
}
.radar-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 2px solid rgba(0, 243, 255, 0.8);
    border-radius: 50%;
    animation: radarPulse 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
    pointer-events: none;
}

/* Explosion Sparks (Now Rings) */
.spark {
    position: absolute;
    width: 20px;
    height: 20px;
    border: 3px solid #00ff88;
    border-radius: 50%;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(1);
    opacity: 0;
    pointer-events: none;
    z-index: 1;
}

/* Explosion State */
.radar-marker.explode .spark:nth-of-type(1) {
    animation: blastWave 0.6s ease-out forwards;
}
.radar-marker.explode .spark:nth-of-type(2) {
    animation: blastWave 0.6s ease-out 0.15s forwards;
}
.radar-marker.explode .spark:nth-of-type(3) {
    animation: blastWave 0.6s ease-out 0.3s forwards;
}
.radar-marker.explode .radar-core {
    animation: corePop 0.6s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}
.radar-marker.explode .radar-ring {
    opacity: 0; /* hide the normal ring */
}

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

@keyframes corePop {
    0% { transform: scale(1); background: #00f3ff; box-shadow: 0 0 15px #00f3ff; }
    30% { transform: scale(3); background: #00ff88; box-shadow: 0 0 20px #00ff88, 0 0 50px #00ff88; opacity: 1; }
    100% { transform: scale(0); opacity: 0; }
}

@keyframes radarPulse {
    0% { transform: scale(0.1); opacity: 1; }
    100% { transform: scale(1); opacity: 0; border-width: 0px; }
}

/* UI Swiping Transitions */
.swipe-out {
    animation: swipeOut 0.4s cubic-bezier(0.55, 0.085, 0.68, 0.53) forwards;
}
.swipe-in {
    animation: swipeIn 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}
@keyframes swipeOut {
    to { transform: translateX(-60px); opacity: 0; }
}
@keyframes swipeIn {
    from { transform: translateX(60px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Timer Bar */
.timer-bar-container {
    width: 80%;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    position: absolute;
    top: -16px;
    left: 50%;
    transform: translateX(-50%);
    overflow: hidden;
    display: flex;
    justify-content: center;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.5);
}
.timer-bar {
    width: 100%;
    height: 100%;
    background: #00f3ff;
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.8);
    border-radius: 10px;
    /* Transitions are handled via JS for perfect control */
}
.timer-bar.warning {
    background-color: #ff0055 !important;
    box-shadow: 0 0 25px rgba(255, 0, 85, 1) !important;
}

/* Base Overlay */
.overlay-base {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: radial-gradient(circle at center, rgba(5, 8, 12, 0.7), rgba(2, 4, 8, 0.95));
    backdrop-filter: blur(15px);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
}

/* Leaderboard Styles */
.leaderboard-box {
    max-width: 600px;
    padding: 3rem 2rem;
}
.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px;
}
.leaderboard-list::-webkit-scrollbar { width: 6px; }
.leaderboard-list::-webkit-scrollbar-track { background: rgba(0,243,255,0.05); border-radius: 10px; }
.leaderboard-list::-webkit-scrollbar-thumb { background: rgba(0,243,255,0.3); border-radius: 10px; }

.lb-item {
    display: flex;
    align-items: center;
    background: rgba(20, 25, 35, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 16px 20px;
}
.lb-item.top-3 {
    background: rgba(255, 215, 0, 0.05);
    border-color: rgba(255, 215, 0, 0.3);
}
.lb-rank {
    font-size: 1.5rem;
    font-weight: 900;
    width: 40px;
    color: #a0aabf;
}
.lb-item.top-3 .lb-rank {
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255,215,0,0.5);
}
.lb-details {
    flex: 1;
    text-align: left;
    display: flex;
    flex-direction: column;
}
.lb-name {
    font-size: 1.2rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: 1px;
}
.lb-date {
    font-size: 0.7rem;
    color: #a0aabf;
}
.lb-score {
    font-size: 1.8rem;
    font-weight: 900;
    color: #00f3ff;
}
.lb-item.top-3 .lb-score {
    color: #ffd700;
}

.player-input {
    background: rgba(0,0,0,0.5);
    border: 2px solid rgba(0, 243, 255, 0.4);
    color: #fff;
    padding: 16px;
    font-size: 1.5rem;
    font-weight: 800;
    font-family: 'Outfit', sans-serif;
    border-radius: 8px;
    text-align: center;
    width: 100%;
    margin-top: 1rem;
    text-transform: uppercase;
    outline: none;
    transition: all 0.3s ease;
}
.player-input:focus {
    border-color: #00f3ff;
    box-shadow: 0 0 20px rgba(0,243,255,0.3);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    #ui-card {
        width: 96%;
        bottom: 15px;
    }
    
    .game-console {
        flex-direction: row; /* Keep side-by-side to save massive vertical space */
        padding: 16px 8px;
        gap: 0;
    }
    
    .country-card {
        width: 50%;
        padding: 0 4px;
        justify-content: flex-start;
    }
    
    .flag-img {
        width: 60px;
        height: 40px;
        margin-bottom: 8px;
    }
    
    .country-name {
        font-size: 1.1rem;
        height: 34px; /* Allow 2 lines of text */
        margin-bottom: 8px;
        line-height: 1.1;
    }
    
    .data-section {
        height: 50px; /* Reduced height since buttons are side-by-side again */
        align-items: center;
    }
    
    .pop-wrapper {
        justify-content: center;
    }
    
    .pop-label {
        font-size: 0.6rem;
        margin-bottom: 2px;
    }
    
    .pop-value {
        font-size: 1.35rem; /* Shrink to fit big numbers */
    }
    
    .vs-circle {
        margin: 0 4px;
        width: 32px;
        height: 32px;
        font-size: 0.75rem;
    }
    
    .controls-container {
        flex-direction: row; /* Side-by-side to save maximum height */
        gap: 6px;
    }
    
    .guess-btn {
        padding: 8px 2px;
        font-size: 0.85rem; /* Slightly smaller to fit side-by-side */
    }
    
    #top-bar {
        top: 10px;
        width: 95%;
        justify-content: center;
        gap: 8px;
    }
    
    .score-pill {
        padding: 6px 14px;
        font-size: 0.8rem;
    }
    
    #score, #high-score {
        font-size: 1rem;
    }
    
    .game-over-box {
        padding: 1.5rem 1rem;
        width: 95%;
    }
    
    .go-header {
        font-size: 2.2rem;
        margin-bottom: 1.5rem;
    }
    
    .go-comparison {
        gap: 0.5rem;
        padding: 1rem 0.5rem;
    }
    
    .go-country {
        width: 110px;
    }
    
    .go-country h3 {
        font-size: 0.9rem;
    }
    
    .go-pop-value {
        font-size: 1.1rem;
    }
    
    .go-score-value {
        font-size: 2.5rem;
    }
}
