body {
    margin: 0;
    font-family: 'Roboto', 'Arial', sans-serif;
    background: url('Background_space.jpg') no-repeat center center fixed;
    background-size: cover;
    color: #ffffff;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    line-height: 1.6;
    position: relative;
    overflow-x: hidden;
}

header {
    background: linear-gradient(90deg, rgba(0, 255, 136, 0.8), rgba(0, 122, 94, 0.8));
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 1;
}

header h1 {
    margin: 0;
    font-size: 2.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 1rem;
    position: relative;
    z-index: 1;
}

.screen {
    width: 100%;
    max-width: 600px;
    text-align: center;
    padding: 2rem;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.hidden {
    display: none;
}

h2 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}

h3 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.flag-selection {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.flag-group {
    background: rgba(0, 0, 0, 0.6);
    padding: 10px;
    border-radius: 10px;
    max-width: 280px; /* Limit width to contain 5 flags */
    overflow: hidden; /* Prevent overflow */
}

.flags {
    display: grid;
    grid-template-columns: repeat(5, 50px); /* Match flag width */
    gap: 5px; /* Reduce gap to fit better */
    justify-content: center;
    position: relative;
    padding: 5px; /* Add internal padding */
}

.flags img {
    width: 50px;
    height: 30px;
    cursor: pointer;
    transition: transform 0.3s ease;
    border: 2px solid transparent;
    position: relative;
    z-index: 1;
    box-sizing: content-box; /* Ensure padding doesn't affect size */
    filter: brightness(70%); /* Default 30% darker for all flags */
}

.flags img:hover {
    transform: scale(1.2);
}

.flags img.selected-source,
.flags img.selected-target {
    filter: brightness(100%); /* Full brightness for selected flag */
    border: 2px solid #00ff88; /* Optional: Add a green border for emphasis */
}

#question-text {
    font-size: 1.6rem;
    font-weight: 500;
    margin: 1.5rem 0;
    line-height: 1.4;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}

#question-number, #feedback, #current-answer, #time-taken, #correct-first {
    font-size: 1.3rem;
    margin: 0.75rem 0;
    color: #e0e0e0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

#answer-input {
    width: 100%;
    max-width: 400px;
    padding: 0.9rem;
    font-size: 1.2rem;
    background-color: rgba(91, 91, 93, 0.8);
    color: #ffffff;
    border: none;
    border-radius: 5px;
    margin: 1rem 0;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

#answer-input:focus {
    background-color: rgba(107, 107, 109, 0.8);
    outline: none;
    box-shadow: 0 0 5px rgba(0, 255, 136, 0.5);
}

#answer-input.correct {
    background-color: #00ff88;
    color: #333;
}

#answer-input.incorrect {
    background-color: #ff4444;
    color: #fff;
}

.quiz-button {
    background-color: #f97316;
    color: white;
    text-transform: uppercase;
    border: none;
    padding: 0.9rem 1.8rem;
    font-size: 1.1rem;
    cursor: pointer;
    border-radius: 5px;
    transition: background-color 0.3s ease, transform 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.quiz-button:disabled {
    background-color: #a1a1a1;
    cursor: not-allowed;
}

.quiz-button:hover:not(:disabled) {
    background-color: #e55f00;
    transform: translateY(-2px);
}

.check-button {
    background: linear-gradient(90deg, #f97316 0%, #e55f00 100%);
}

.check-button:hover {
    opacity: 0.9;
}

.button-group {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 2rem;
}

#score-display p {
    text-align: center;
    font-size: 1.8em;
    font-weight: bold;
    margin: 1.2rem 0;
    color: #00ff88;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}

#result-screen h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1.2rem;
    color: #ffffff;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}

@media (max-width: 480px) {
    header h1 {
        font-size: 2.2rem;
        letter-spacing: 1px;
    }

    h2 {
        font-size: 1.6rem;
        margin-bottom: 1.2rem;
    }

    h3 {
        font-size: 1.1rem;
    }

    .flags {
        grid-template-columns: repeat(3, 50px);
    }

    #question-text {
        font-size: 1.4rem;
        margin: 1.2rem 0;
    }

    #question-number, #feedback, #current-answer, #time-taken, #correct-first {
        font-size: 1.2rem;
        margin: 0.6rem 0;
    }

    #answer-input {
        font-size: 1.1rem;
        padding: 0.8rem;
        max-width: 100%;
    }

    .quiz-button {
        font-size: 1rem;
        padding: 0.8rem 1.5rem;
    }

    .screen {
        padding: 1.5rem;
        margin: 0 0.5rem;
    }

    .button-group {
        gap: 1rem;
        flex-direction: row;
        justify-content: center;
    }

    #result-screen h1 {
        font-size: 2rem;
        margin-bottom: 1.2rem;
    }

    #score-display p {
        font-size: 1.8em;
        margin: 1.2rem 0;
    }
}