body {
    font-family: Arial, sans-serif;
    text-align: center;
    margin: 0;
    background-color: #f0f0f0;
    display: flex;
    flex-direction: column;  /* Stack everything vertically */
    align-items: center; /* Center everything horizontally */
    min-height: 100vh;  /* Full viewport height */
}

/* The content box */
#mathApp {
    background-color: #ffffff;
    border-radius: 15px;
    box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
    padding: 20px;
    width: 90%;
    max-width: 600px;
    min-height: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center; /* Center game content */
}

/* Ensure h1 stays at the top */
h1 {
    margin: 20px 0; 
    text-align: center;
    font-size: 32px;
}

/* Footer stays at the bottom */
footer {
    margin-top: auto;
    padding: 10px;
    font-size: 14px;
    color: #666;
    text-align: center;
}

.menu {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
        "header header"
        "question-count game-mode"
        "feedback-container feedback-container"
        "start-button start-button"
        "footer footer";
    gap: 25px;
    margin: 0;
    
    justify-content: center; /* Centers the grid container horizontally */
    grid-template-rows: auto auto auto auto auto; /* Make each row flexible based on content height */
}

.menu-header {
    grid-area: header;
    margin-bottom: 10px; /* Reduce the margin for the header */
}

.question-count, .game-mode {
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* Align radio buttons to the left */
    gap: 5px; /* Spacing between radio buttons */
}

.menu-item {
    display: flex;
    align-items: center;
    justify-content: flex-start; /* Keep radio buttons aligned to the left */
    margin: 3px 0; /* Reduce margin between items */
}

.menu-item input[type="radio"] {
    margin-right: 10px; /* Space between radio button and label */
}

.question-count {
    grid-area: question-count;
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* Ensure radio buttons align left */
}

.game-mode {
    grid-area: game-mode;
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* Ensure radio buttons align left */
}

.feedback-container {
    grid-area: feedback-container;
    display: flex;
    justify-content: center;
    margin: 5px 0; /* Reduce space before/after feedback toggle */
}

.start-button {
    grid-area: start-button;
    display: inline-block; /* Makes button width adjust to text size */
    margin: 10px auto; /* Center the button horizontally */
    padding: 10px 20px; /* Ensures it has some internal padding */
    font-size: 16px;
    background-color: #4CAF50;
    color: white;
    border: none;
    cursor: pointer;
    border-radius: 5px;
    height: 40px; /* Control the button height explicitly */
    line-height: 20px; /* Align text vertically */
}

.start-button:hover {
    background-color: #45a049;
}

.math-question {
    text-align: center;
    font-size: 24px;
    margin: 20px;
}

.question-text {
    font-weight: bold;
}

.answer-input {
    font-size: 18px;
    width: 60px;
    text-align: center;
    margin-left: 10px;
}

/* Hide number input arrows (spinner) for Chrome, Safari, Edge, Opera */
.answer-input::-webkit-outer-spin-button,
.answer-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Hide number input spinner for Firefox */
.answer-input {
    appearance: textfield;
    -moz-appearance: textfield;
}

.feedback-text {
    text-align: center;
    color: red;
    font-size: 18px;
    margin-top: 10px;
}




/* Media Query for Portrait Mode (Mobile Devices) */
@media screen and (max-width: 1024px) {
    #mathApp {
        width: 40%;  /* Make the box half the width */
        min-width: 250px; /* Ensure it's not too small */
    }
   
    .menu {
        display: block; /* Remove the grid layout */
        margin: 0 10px; /* Add some margin around the menu */
    }

    .menu-header {
        margin-bottom: 5px; /* Smaller margin for header */
    }

    .question-count, .game-mode, .feedback-container {
        display: block; /* Stack the items in a column */
        margin-bottom: 10px; /* Add some spacing between each section */
        width: 100%; /* Make the sections take up the full width */
    }

    .menu-item {
        margin: 5px 0; /* Small margin between radio buttons */
        justify-content: flex-start; /* Keep radio buttons aligned to the left */
    }

    .start-button {
        width: auto; /* Let the button width adjust to the text size */
        height: 50px; /* Adjust the button height */
    }

    .footer {
        margin-top: 20px;
    }
}
