/* Base styles (applied to all screen sizes) */
body {
    font-family: 'Comic Sans MS', cursive, sans-serif;
    background-color: #f9f0ff;
    margin: 0;
    padding: 10px; /* Reduced padding for small screens */
    color: #333;
}

header {
    text-align: center;
    margin-bottom: 20px; /* Reduced margin for small screens */
}

h1 {
    color: #8e44ad;
    font-size: 2em; /* Slightly smaller font size */
}

.welcome {
    font-size: 1em; /* Reduced font size */
    color: #555;
    margin-bottom: 15px; /* Reduced margin */
}

/* Quiz grid layout */
.quiz-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); /* Smaller min width for cards */
    gap: 10px; /* Reduced gap */
    max-width: 100%; /* Full width on small screens */
    margin: 0 auto;
    padding: 0 10px; /* Add padding to prevent edge touching */
}

.quiz-card {
    background-color: white;
    border-radius: 10px;
    padding: 15px; /* Reduced padding */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    text-align: center;
    transition: transform 0.2s;
}

.quiz-card:hover {
    transform: scale(1.03); /* Slightly smaller hover effect */
}

.quiz-card h3 {
    color: #8e44ad;
    margin-top: 0;
    font-size: 1.2em; /* Reduced font size */
}

.quiz-card a {
    display: inline-block;
    margin-top: 10px; /* Reduced margin */
    padding: 8px 15px; /* Reduced padding */
    background-color: #8e44ad;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
    font-size: 0.9em; /* Reduced font size */
}

.quiz-card a:hover {
    background-color: #6c3483;
}

footer {
    text-align: center;
    margin-top: 20px; /* Reduced margin */
    color: #777;
    font-size: 0.8em; /* Reduced font size */
}

/* Apply to all buttons */
button {
    font-family: 'Comic Sans MS', cursive, sans-serif /* Explicitly set font-family */
    !important;
    color: white !important; /* Explicitly set text color */
    padding: 10px;
    background-color: #8e44ad !important;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.2s;
}

/* Hover state for buttons */
button:hover {
    background-color: #6c3483;
}

/* Event and button styles */
#event {
    font-size: 1.2em; /* Reduced font size */
    margin: 15px; /* Reduced margin */
}


/* Base styles (small screens) */
#buttonsContainer {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    justify-content: center;
    margin: 15px auto;
    max-width: 100%;
    padding: 0 10px;
}

/* Media Queries for Larger Screens */
@media (min-width: 768px) {
    #buttonsContainer {
        grid-template-columns: repeat(4, 1fr);
        gap: 15px;
        max-width: 800px;
    }
}


.button {
    flex: 1;
    padding: 8px 15px; /* Reduced padding */
    margin: 3px; /* Reduced margin */
    font-size: 0.9em; /* Reduced font size */
    cursor: pointer;
    background-color: #8e44ad;
    display: flex;
    color: white;
    border: none;
    border-radius: 5px;
    justify-content: center;
    align-items: center;
    min-height: 80px;  /* Fixed height to accommodate flags */
    min-width: 50px;
/*    width: 100%; */
    margin: 5px;
    padding: 5px;
    cursor: pointer;
    /* Add other button styles as needed */
}

.button-content {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    padding: 5px; /* Add padding if needed */
    box-sizing: border-box; /* Include padding in height/width */
}

.button img {
    max-width: 80px;
    max-height: 50px;
    display: block;
}

.button:hover {
    background-color: #6c3483;
}

/* Buttons grid layout */
.buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 columns for small screens */
    gap: 8px; /* Reduced gap */
    margin: 15px auto; /* Reduced margin */
    max-width: 100%; /* Full width on small screens */
    padding: 0 10px; /* Add padding */
}

.buttons3-1 {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 columns for small screens */
    gap: 8px; /* Reduced gap */
    margin: 15px auto; /* Reduced margin */
    max-width: 100%; /* Full width on small screens */
    padding: 0 10px; /* Add padding */
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
    background-color: #deaff1;
    margin: 25% auto; /* Adjusted for small screens */
    padding: 15px; /* Reduced padding */
    border: 1px solid #ccc;
    width: 90%; /* Wider on small screens */
    max-width: 400px; /* Reduced max width */
    border-radius: 5px;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.modal-content h2 {
    color: #8e44ad;
    margin-top: 0;
    font-size: 1.2em; /* Reduced font size */
}

.modal-content button {
    background-color: #8e44ad;
    margin-top: 10px;
    padding: 8px 15px; /* Reduced padding */
    font-size: 0.9em; /* Reduced font size */
}

.modal-content button:hover {
    background-color: #6c3483;
}

/* Word display styles */
#wordDisplay {
    border: 1px solid #ccc;
    padding: 10px; /* Reduced padding */
    margin: 15px auto; /* Reduced margin */
    border-radius: 5px;
    background-color: white;
    text-align: center;
    max-width: 100%; /* Full width on small screens */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    font-size: 1.2em; /* Reduced font size */
}

/* Flag styles */
.flag {
    max-width: 150px; /* Reduced max width */
    height: auto;
    margin: 8px auto; /* Reduced margin */
    display: none;
}


/* Options layout */
.options {
    display: flex;
    flex-direction: column; /* Stack buttons vertically on small screens */
    align-items: center;
    gap: 8px; /* Reduced gap */
    margin: 15px auto; /* Reduced margin */
    max-width: 100%; /* Full width on small screens */
    padding: 0 10px; /* Add padding */
}

.options button {
    margin: 3px; /* Reduced margin */
    font-size: 0.9em; /* Reduced font size */
    cursor: pointer;
    background-color: #8e44ad;
    color: white;
    border: none;
    border-radius: 5px;
    width: 100%;
    max-width: 100%; /* Full width on small screens */
    margin: 0 auto;
    padding: 8px; /* Reduced padding */
}

/* Media Queries for Larger Screens */
@media (min-width: 768px) {
    body {
        padding: 20px;
    }

    h1 {
        font-size: 2.5em;
    }

    .welcome {
        font-size: 1.2em;
    }

    .quiz-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 20px;
        max-width: 1200px;
    }

    .quiz-card {
        padding: 20px;
    }

    .quiz-card h3 {
        font-size: 1.5em;
    }

    .quiz-card a {
        padding: 10px 20px;
        font-size: 1em;
    }

    .buttons {
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
        max-width: 800px;
    }

    .buttons3-1 {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        max-width: 800px;
    }

    .options {
        flex-direction: row;
    }

    .options button {
        max-width: 300px;
    }

    #wordDisplay {
        font-size: 1.5em;
    }

    .flag {
        max-width: 200px;
    }
}

#timer, #score, #turns {
    font-size: 1.2em;
    margin: 0 10px;
    font-weight: bold;
}

.timer-score-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 400px; /* Adjust as needed */
    margin: 0 auto;   /* Center the container */
}

.timer-score-container div {
    margin: 0 10px;  /* Add some spacing between timer and score */
}




/* Fraction styling for buttons */
.button .fraction {
    display: inline-block;
    text-align: center;
    vertical-align: middle;
    line-height: 1.2;
    color: inherit;
    position: relative;
    height: 2em; /* Fixed height for fractions */
    margin: 0 5px; /* Add some margin around fractions */
}

.button .numerator {
    display: block;
    padding-bottom: 2px;
    border-bottom: 1px solid currentColor; /* Use currentColor instead of white */
    color: inherit;
}

.button .denominator {
    display: block;
    color: inherit;
    font-size: 0.8em; /* Slightly smaller denominator */
}

.flag-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    max-height: 50px; /* Match the max-height of the flag images */
    overflow: hidden; /* Prevent overflow */
}

.flag-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* Ensure the flag scales properly */
    display: block;
}


/* Modal for challenge start */
#startChallengeModal {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

/* Media Queries for Larger Screens */
@media (min-width: 768px) {
    #startChallengeModal {
        top: -130px;          /* Position below the header */
    }
}

#startChallengeModal .modal-content {
    background-color: #deaff1;
    margin: 30% auto;
    padding: 20px;
    border: 1px solid #ccc;
    width: 80%;
    max-width: 400px;
    border-radius: 5px;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

#startChallengeModal .modal-content h2 {
    color: #8e44ad;
    margin-top: 0;
}

#startChallengeModal .modal-content button {
    background-color: #8e44ad;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 1em;
    cursor: pointer;
    margin-top: 15px;
}

#startChallengeModal .modal-content button:hover {
    background-color: #6c3483;
}

/* Game Over Modal */
#gameOverModal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
}

#gameOverModal .modal-content {
    background-color: #deaff1;
    margin: 10% auto;
    padding: 20px;
    border: 1px solid #ccc;
    width: 80%;
    max-width: 400px;
    border-radius: 5px;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

#gameOverModal .modal-content h2 {
    color: #8e44ad;
    margin-top: 0;
}

#gameOverModal .modal-content p {
    color: #333;
    margin: 15px 0;
    font-size: 1em;
}

#gameOverModal .modal-content button {
    background-color: #8e44ad;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 1em;
    cursor: pointer;
    margin: 5px;
    width: 100%;
}

#gameOverModal .modal-content button:hover {
    background-color: #6c3483;
}

#gameOverModal .modal-content #cancelButton {
    background-color: #ccc;
}

#gameOverModal .modal-content #cancelButton:hover {
    background-color: #999;
}

.quiz-selector {
    display: flex;
    /* ... rest of your styles ... */
}

/* Back button styling */
#backButton {
    padding: 10px 10px; /* Smaller padding */

    margin-left: 10px;
    max-width: 20%;
    height: auto; /* Let the height adjust to content */
    min-height: unset; /* Remove any fixed minimum height */
}