* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background-image: url("https://play.rosebud.ai/assets/ace.jpg?3ZFR");
    background-size: cover; /* Cover the entire viewport */
    background-position: center center; /* Center the image */
    background-repeat: no-repeat; /* Do not repeat the image */
    background-attachment: fixed; /* Keep the background fixed during scroll */
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative; /* Needed for the overlay */
    /* animation: gradientShift 8s ease infinite; // Removed gradient animation */
}
body::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.4); /* Dark overlay */
    z-index: -1; /* Place it behind the content but above the background image */
}
/* @keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
} */

#game-container {
    width: 90%;
    max-width: 800px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
    position: relative; /* Ensure game container is above the body's ::before pseudo-element */
    z-index: 1;
}

#header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.3);
    padding: 15px 20px;
    border-radius: 15px;
    color: white;
    font-weight: bold;
}

#question-counter {
    display: flex;
    align-items: center;
    gap: 10px;
}

.counter-circle {
    width: 40px;
    height: 40px;
    background: linear-gradient(45deg, #667eea, #764ba2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 18px;
}

#timer-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}

#timer-bar {
    width: 200px;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

#timer-bar::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #FFC107, #FF5722);
    border-radius: 4px;
    transition: width 0.1s linear;
    width: 100%;
}

#score-display {
    font-size: 18px;
    background: linear-gradient(45deg, #f093fb, #f5576c);
    padding: 8px 15px;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}
#header-right-side {
    display: flex;
    align-items: center;
    gap: 15px; /* Space between score and instructions button */
}
#instructions-btn {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease, transform 0.3s ease;
    padding: 0; /* Remove default button padding */
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
#instructions-btn:hover {
    background-color: rgba(255, 255, 255, 0.35);
    transform: scale(1.1);
}

#flag-display {
    text-align: center;
    margin-bottom: 30px;
}

#flag-container {
    display: inline-block;
    background: rgba(0, 0, 0, 0.8);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    border: 3px solid rgba(255, 255, 255, 0.3);
}

#current-flag {
    width: 300px; /* Adjust as needed */
    height: 200px; /* Adjust as needed */
    object-fit: contain; /* Ensures the image fits well without distortion */
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    background: #f0f0f0; /* Fallback background */
    display: block; /* Changed from flex to block for img */
    margin: 0 auto; /* Center the image if flag-container is wider */
}
#fact-text-display {
    text-align: center;
    margin-bottom: 20px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 15px;
    color: white;
    font-size: 1.3em; /* Larger text for facts */
    line-height: 1.6;
    min-height: 100px; /* Ensure some space even for short facts */
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    border: 3px solid rgba(255, 255, 255, 0.3);
}
#current-fact-text {
    max-width: 90%;
}
#options-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 20px;
}

.option-btn {
    padding: 15px 20px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    background: linear-gradient(45deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.7));
    color: #333;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.option-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.3);
    background: linear-gradient(45deg, #fff, #f0f0f0);
}

.option-btn.correct {
    background: linear-gradient(45deg, #4CAF50, #45a049);
    color: white;
    border-color: #2e7d32;
}

.option-btn.incorrect {
    background: linear-gradient(45deg, #f44336, #d32f2f);
    color: white;
    border-color: #c62828;
}

.option-btn:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}
.option-btn.facts-mode-option {
    padding: 10px; /* Adjust padding for image content */
    height: 80px; /* Fixed height for consistency with images */
    display: flex;
    align-items: center;
    justify-content: center;
}
.option-btn.facts-mode-option img {
    display: block;
    border-radius: 5px; /* Slight rounding for flag images */
}
#start-screen, #results-screen {
    text-align: center;
    color: white;
    padding: 40px;
}

#start-screen h1, #results-screen h1 {
    font-size: 3em;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    background: linear-gradient(45deg, #667eea, #764ba2, #f093fb, #f5576c);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#start-screen p {
    font-size: 1.2em;
    margin-bottom: 15px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}
#start-screen img#start-screen-image {
    display: block;
    width: 80%;
    max-width: 400px;
    max-height: 250px;
    object-fit: contain;
    margin: 25px auto;
    border-radius: 15px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
}
#difficulty-selection {
    margin: 25px auto;
    padding: 15px;
    background: rgba(0,0,0,0.15);
    border-radius: 12px;
    max-width: 350px;
}
#difficulty-selection p {
    font-size: 1.1em;
    font-weight: bold;
    margin-bottom: 10px;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}
.difficulty-options {
    display: flex;
    justify-content: space-around;
    align-items: center;
}
.difficulty-options label {
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background-color 0.3s ease, color 0.3s ease;
    font-size: 0.95em;
    color: rgba(255,255,255,0.8);
    background-color: rgba(255,255,255,0.1);
    border: 1px solid transparent;
}
.difficulty-options label:hover {
    background-color: rgba(255,255,255,0.2);
    color: #fff;
}
.difficulty-options input[type="radio"] {
    display: none; /* Hide the actual radio button */
}
.difficulty-options input[type="radio"]:checked + label {
    background: linear-gradient(45deg, #ffd700, #ffcc00); /* Yellow gradient */
    color: #333; /* Darker text for yellow background */
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    border-color: rgba(255,215,0,0.5); /* Goldish border */
    transform: scale(1.05); /* Slightly enlarge selected */
    animation: difficultySelected 0.3s ease-out;
}
@keyframes difficultySelected {
    from {
        transform: scale(1);
        opacity: 0.7;
    }
    to {
        transform: scale(1.05);
        opacity: 1;
    }
}
#start-btn, #play-again-btn {
    padding: 15px 40px;
    font-size: 20px;
    font-weight: bold;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    margin-top: 10px; /* Adjusted margin due to difficulty selector */
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}
#show-high-scores-btn {
    padding: 12px 30px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    background: linear-gradient(45deg, #4ecdc4, #55b7d5);
    color: white;
    margin-top: 15px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
    transition: all 0.3s ease;
}
#start-btn:hover, #play-again-btn:hover, #show-high-scores-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.4);
}
#show-high-scores-btn:hover {
    background: linear-gradient(45deg, #55b7d5, #66cfaa);
}

.hidden {
    display: none !important;
}

#results-screen div {
    margin: 15px 0;
    font-size: 1.3em;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

#final-score {
    font-size: 2em;
    font-weight: bold;
    color: #ffeaa7;
}
#leaderboard-section {
    margin-top: 30px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 15px;
    text-align: center;
}
#leaderboard-section h2 {
    font-size: 1.8em;
    margin-bottom: 15px;
    color: #ffeaa7;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}
.leaderboard-display-list {
    list-style: none;
    padding: 0;
    margin: 0 auto 20px auto;
    max-width: 350px;
    min-width: 300px;
    font-size: 1.1em;
    max-height: 300px; /* Added for modals if list is long */
    overflow-y: auto; /* Added for modals */
}
.leaderboard-display-list li {
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    margin-bottom: 8px;
    transition: background-color 0.3s ease;
    display: flex;
    justify-content: space-between;
    text-align: left;
}
.leaderboard-display-list li:nth-child(odd) {
    background: rgba(255, 255, 255, 0.15);
}
.leaderboard-display-list li:hover {
    background: rgba(255, 255, 255, 0.25);
}
.leaderboard-display-list::-webkit-scrollbar {
    width: 8px;
}
.leaderboard-display-list::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 4px;
}
.leaderboard-display-list::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
    border-radius: 4px;
}
#name-input-container {
    margin-top: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}
#name-input-container p {
    margin-bottom: 10px;
    font-size: 1.1em;
}
#player-name-input {
    padding: 10px 15px;
    font-size: 1em;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    text-align: center;
    width: 200px;
    margin-right: 10px;
    text-transform: uppercase;
}
#player-name-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}
#submit-score-btn {
    padding: 10px 20px;
    font-size: 1em;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: linear-gradient(45deg, #4CAF50, #66bb6a);
    color: white;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}
#submit-score-btn:hover {
    background: linear-gradient(45deg, #66bb6a, #81c784);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}
#submit-score-btn:disabled {
    background: #aaa;
    cursor: not-allowed;
    opacity: 0.7;
}
.modal-view {
    position: fixed; /* Changed to fixed to cover viewport */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000; /* Ensure it's on top */
    padding: 20px;
}
.modal-content {
    background: rgba(30, 30, 50, 0.85); /* Darker, more distinct modal bg */
    backdrop-filter: blur(15px) saturate(150%);
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    color: white;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    max-width: 500px;
    width: 90%;
}
#instructions-text-content {
    text-align: left;
    line-height: 1.6;
    margin-bottom: 20px;
}
#instructions-text-content p {
    margin-bottom: 12px;
    font-size: 1.05em;
}
#instructions-text-content strong {
    color: #ffeaa7; /* Highlight key terms */
}
.modal-content h2 {
    font-size: 2em;
    margin-bottom: 20px;
    color: #ffeaa7;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.4);
}
.modal-close-btn {
    padding: 12px 30px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    background: linear-gradient(45deg, #f093fb, #f5576c);
    color: white;
    margin-top: 20px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
    transition: all 0.3s ease;
}
.modal-close-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.35);
    background: linear-gradient(45deg, #f5576c, #f093fb);
}
#score-bonus-indicator {
    color: #FFD700; /* Bright yellow for bonus */
    font-weight: bold;
    font-size: 0.9em;
    padding: 4px 8px;
    background: rgba(34, 139, 34, 0.85); /* Dark green, semi-transparent */
    border-radius: 5px;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.4);
    margin-left: 5px; /* Space it from score if next to it */
    /* Animation applied when not hidden */
}
#score-bonus-indicator:not(.hidden) {
    animation: fadeInOutBonus 1.5s ease-in-out forwards;
}
#score-bonus-indicator.hidden {
    display: none !important;
    opacity: 0; /* Ensure it's fully transparent when hidden */
}
@keyframes fadeInOutBonus {
  0% { opacity: 0; transform: translateY(8px) scale(0.9); }
  15% { opacity: 1; transform: translateY(0) scale(1.05); }
  85% { opacity: 1; transform: translateY(0) scale(1.05); }
  100% { opacity: 0; transform: translateY(-8px) scale(0.9); }
}
@media (max-width: 600px) {
    #game-container {
        width: 95%;
        padding: 15px;
    }
    
    #header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    #header-right-side { /* Adjust for bonus indicator on mobile */
        flex-wrap: wrap; /* Allow wrapping if space is tight */
        justify-content: center;
    }
    #score-bonus-indicator {
        font-size: 0.8em; /* Slightly smaller on mobile */
        padding: 3px 6px;
        margin-top: 5px; /* Place it below score on new line if wrapped */
        width: fit-content; /* Take only needed width */
        order: 1; /* Try to place it after score */
    }
    #score-display { order: 0; }
    #instructions-btn { order: 2; }
    
    #timer-bar {
        width: 150px;
    }
    
    #current-flag {
        width: 250px; /* Adjust for smaller screens */
        height: 167px; /* Adjust for smaller screens */
    }
    
    #options-container {
        grid-template-columns: 1fr;
    }
    
    #start-screen h1, #results-screen h1 {
        font-size: 2em;
    }
    #leaderboard-section h2 {
        font-size: 1.5em;
    }
    #leaderboard-list {
        font-size: 1em;
    }
    #player-name-input {
        width: 150px;
        margin-right: 0;
        margin-bottom: 10px;
    }
    
    #name-input-container {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
}