body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 20px;
    /* PC: Retain original padding */
    background-color: #f4f4f4;
    /* PC: Retain original background color */
    color: #333;
    /* PC: No flexbox properties directly on body unless needed for centering specific components, container margin auto handles it */
}

.container {
    max-width: 900px;
    /* PC: Retain original max-width */
    margin: 0 auto;
    /* PC: Center the container */
    background: #fff;
    padding: 30px;
    /* PC: Retain original padding */
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    /* PC: Retain original box-shadow */
}

header {
    text-align: center;
    margin-bottom: 30px;
    /* PC: Retain original margin */
    border-bottom: 1px solid #eee;
    padding-bottom: 20px;
    /* PC: Retain original padding */
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: #0056b3;
}

/* Style for the link inside h1 (keeps original look) */
h2 a {
    color: inherit;
    /* Makes the link inherit the color from the h1 */
    text-decoration: none;
    /* Removes the default underline */
}

h2 a:hover,
h2 a:focus {
    color: inherit;
    /* Prevents color change on hover/focus */
    text-decoration: none;
    /* Ensures no underline on hover/focus */
}

ul {
    list-style: disc;
    margin-left: 20px;
    /* PC: Retain original list indentation */
}

/* Hyperlink styling (keep as is) */
.question-link {
    color: #007bff;
    text-decoration: underline;
    cursor: pointer;
    font-weight: bold;
}

.question-link:hover {
    color: #0056b3;
    text-decoration: none;
}

/* Modal Overlay (PC version) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

/* Modal Content Box (PC version) */
.modal-content {
    background-color: #fff;
    padding: 30px;
    /* PC value */
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    width: 90%;
    /* PC value */
    max-width: 600px;
    /* PC value */
    position: relative;
    animation: fadeIn 0.3s ease-out;
    max-height: 80vh;
    overflow-y: auto;
}

/* Modal close button */
.close-button {
    position: absolute;
    top: 10px;
    right: 15px;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-button:hover,
.close-button:focus {
    color: #333;
    text-decoration: none;
    cursor: pointer;
}

/* Modal Question Content */
#modal-question-id {
    font-size: 1.2em;
    font-weight: bold;
    color: #0056b3;
    margin-bottom: 10px;
}

#modal-question-text {
    font-size: 1.1em;
    margin-bottom: 15px;
}

#modal-choices-container {
    margin-bottom: 20px;
}

.choice-item {
    margin-bottom: 10px;
    display: flex;
    align-items: flex-start;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #f9f9f9;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.choice-item:hover {
    background-color: #f0f0f0;
}

.choice-item input[type="radio"],
.choice-item input[type="checkbox"] {
    margin-right: 10px;
    margin-top: 3px;
    flex-shrink: 0;
}

.choice-item label {
    flex-grow: 1;
    cursor: pointer;
}

/* Default button styling (PC version and fallback) */
#submit-answer-button,
#go-to-explanation-button {
    background-color: #007bff;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s ease;
    /* Removed default block display and auto margins here */
    display: inline-flex;
    /* Changed to inline-flex for horizontal alignment */
    justify-content: center;
    /* Center text horizontally */
    align-items: center;
    /* Center text vertically */
    /* Add some default margin for PC version if not in a flex container */
    margin: 5px;
}


#submit-answer-button:hover,
#go-to-explanation-button:hover {
    background-color: #0056b3;
}

#submit-answer-button:disabled,
#go-to-explanation-button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* Specific styling for the new button wrapper */
.modal-buttons {
    display: flex;
    /* Make it a flex container */
    justify-content: left;
    /* Center buttons horizontally */
    gap: 5px;
    /* Space between buttons */
    margin-top: 15px;
    /* Space above the button group */
    flex-wrap: wrap;
    /* Allow buttons to wrap on smaller screens if needed */
}

/* Ensure individual buttons within .modal-buttons don't get extra margins */
.modal-buttons button {
    margin: 0;
    /* Reset specific margins applied elsewhere */
}

/* Revert specific styling for the "Go to Explanation" button if needed */
#go-to-explanation-button {
    background-color: transparent;
    color: #007bff;
    border: 2px solid #007bff;
    /* Ensure no margin-top: 15px specific override from inline style */
}

#go-to-explanation-button:hover {
    background-color: #007bff;
    color: white;
    border-color: #0056b3;
}


.feedback-message {
    margin-top: 15px;
    padding: 10px;
    border-radius: 4px;
    font-weight: bold;
    display: none;
}

.feedback-correct {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.feedback-incorrect {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

#modal-correct-answer {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 2px solid #007bff;
    font-weight: bold;
    color: #28a745;
    font-size: 1.0em;
    display: none;
}


/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* --- Mobile Optimizations (Apply compact styles only for mobile) --- */
@media (max-width: 768px) {
    body {
        padding: 15px;
        /* Mobile: Body padding for overall margin */
        display: flex;
        /* Needed to center the container */
        justify-content: center;
        align-items: flex-start;
        min-height: 100vh;
        box-sizing: border-box;
    }

    .container {
        max-width: 95vw;
        /* Mobile: Still takes up most of the width */
        width: 100%;
        /* Ensure it fills available width */
        padding: 20px;
        /* Mobile: Padding inside the main content container */
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
        /* Slightly lighter shadow for mobile */
    }

    /* Modal adjustments for mobile */
    .modal-overlay {
        /* Increased padding to create a more noticeable gap from screen edges */
        padding: 0 30px;
        /* Increased horizontal padding to 30px */
        box-sizing: border-box;
        /* Ensure padding is included in the width */
    }

    .modal-content {
        /* Revert width to 100% so it fills the padded overlay space, limited by max-width */
        width: 100%;
        max-width: 600px;
        /* Keep max-width to prevent it from getting too wide on tablets */
        padding: 20px;
        /* Padding inside the modal for content around its edges */
    }

    header {
        margin-bottom: 15px;
        /* Mobile: Reduced header margin */
        padding-bottom: 10px;
        /* Mobile: Reduced header padding */
    }

    /* Adjustments for Markdown content within #study-notes-content for mobile */
    /* These reduce spacing for nested syntax elements ONLY on mobile */
    #study-notes-content p {
        margin-bottom: 0.7em;
    }

    #study-notes-content ul,
    #study-notes-content ol {
        margin-left: 15px;
        margin-top: 0.5em;
        margin-bottom: 0.7em;
        padding-left: 0;
    }

    #study-notes-content li {
        margin-bottom: 0.2em;
    }

    #study-notes-content h1,
    #study-notes-content h2,
    #study-notes-content h3,
    #study-notes-content h4,
    #study-notes-content h5,
    #study-notes-content h6 {
        margin-top: 1em;
        margin-bottom: 0.5em;
        line-height: 1.2;
    }

    #study-notes-content pre {
        padding: 8px;
        font-size: 0.95em;
        line-height: 1.3;
        margin-bottom: 1em;
    }

    #study-notes-content code {
        padding: 0.1em 0.3em;
        font-size: 0.95em;
    }

    #study-notes-content blockquote {
        border-left: 4px solid #a8c7ed;
        padding-left: 10px;
        margin: 1em 0;
        font-size: 1em;
    }

    /* Further adjustments for very small screens */
    @media (max-width: 480px) {
        body {
            padding: 10px;
            /* Very small mobile: More outer padding */
        }

        .container {
            padding: 25px;
            /* Very small mobile: More container padding */
        }

        .modal-overlay {
            /* Increased padding to create a more noticeable gap from screen edges */
            padding: 0 20px;
            /* Increased horizontal padding for very small screens */
        }

        .modal-content {
            padding: 15px;
            /* Adjust internal padding for smaller screens */
        }

        /* Markdown content adjustments for smallest screens (can be further tweaked if needed) */
        #study-notes-content ul,
        #study-notes-content ol {
            margin-left: 12px;
            /* Slight adjustment for smallest screens */
        }

        #study-notes-content pre {
            padding: 6px;
            /* Slight adjustment for smallest screens */
        }

        #study-notes-content blockquote {
            padding-left: 8px;
            /* Slight adjustment for smallest screens */
        }
    }
}