/* General body styling for a clean, modern look */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f0f2f5; /* Light grey background */
    color: #333; /* Dark grey text for readability */
    margin: 0;
    padding: 20px; /* Padding for smaller screens */
    box-sizing: border-box;
}

/* The main container for the entire application */
#app-container {
    width: 100%;
    max-width: 800px; /* Set a fixed max-width for the container */
    margin: 0 auto;   /* Center the container horizontally */
}

.page {
    display: none;
    width: 100%;
}

.page.active {
    display: block;
}

/* Homepage Styles */
#homepage {
    background-color: #ffffff;
    border: 1px solid #d9d9d9;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    padding: 24px;
    text-align: center;
}

#homepage h1 {
    color: #1a1a1a;
    margin-top: 0;
    border-bottom: 2px solid #e8e8e8;
    padding-bottom: 16px;
}

#accuracy-display {
    background-color: #fafafa;
    border: 1px solid #e8e8e8;
    border-radius: 6px;
    padding: 10px 15px;
    margin: -10px 0 20px 0;
    font-size: 0.95em;
    color: #595959;
}

.menu {
    display: flex;
    flex-direction: column;
    gap: 25px;
    margin-top: 30px;
}

/* --- MODIFICATION START --- */
/* New styles for menu categories */
.menu-category {
    text-align: left;
}

.category-title {
    margin: 0 0 15px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid #f0f0f0;
    color: #555;
    font-size: 1.2em;
}

.category-items {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}
/* --- MODIFICATION END --- */

/* Use 2 columns for wider screens */
@media (min-width: 600px) {
    .category-items {
        grid-template-columns: 1fr 1fr;
    }
}

.menu-item {
    padding: 15px 20px;
    font-size: 1.0em;
    background-color: #333;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
    text-align: center;
}

.menu-item:hover {
    background-color: #555;
    transform: translateY(-2px);
}

#show-wrong-answers {
    background-color: #d46b08;
}
#show-wrong-answers:hover {
    background-color: #ff8a00;
}

#clear-wrong-answers {
    background-color: #cf1322;
}
#clear-wrong-answers:hover {
    background-color: #f5222d;
}

/* Main container for the quiz */
.quiz-container {
    background-color: #ffffff;
    border: 1px solid #d9d9d9;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    width: 100%;
    padding: 24px;
    box-sizing: border-box;
    position: relative; 
}

.quiz-container h1 {
    text-align: center;
    color: #1a1a1a; 
    margin-top: 0;
    margin-bottom: 24px;
    border-bottom: 2px solid #e8e8e8; 
    padding-bottom: 16px;
}

.question-block {
    display: none; 
    border-bottom: 1px solid #e8e8e8; 
    padding-bottom: 20px;
    margin-bottom: 20px;
}

.question-block.active {
    display: block; 
}

.question-origin {
    font-size: 0.9em;
    font-style: italic;
    color: #888;
    margin-bottom: 16px;
    padding-left: 10px;
    border-left: 3px solid #e8e8e8;
}

.question-text {
    font-size: 1.1em;
    font-weight: bold;
    margin-bottom: 16px;
    line-height: 1.6; 
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option, .tf-option {
    display: block;
    width: 100%;
    padding: 12px 15px;
    background-color: #fafafa; 
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    text-align: left;
    font-size: 1em;
    cursor: pointer;
    transition: background-color 0.3s, border-color 0.3s;
    box-sizing: border-box;
}

.option:hover, .tf-option:hover {
    background-color: #f0f0f0; 
    border-color: #bfbfbf;
}

.option.selected, .tf-option.selected {
    background-color: #e6f7ff; 
    border-color: #91d5ff;
}

.selected.correct, input.correct {
    background-color: #f6ffed !important; 
    border-color: #b7eb8f !important; 
    color: #389e0d !important; 
}

.selected.incorrect, input.incorrect {
    background-color: #fff1f0 !important; 
    border-color: #ffa39e !important; 
    color: #cf1322 !important; 
}

.fill-in-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.fill-in-container input[type="text"] {
    padding: 10px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 1em;
    width: 100%;
    box-sizing: border-box;
}

.check-btn {
    padding: 10px 15px;
    background-color: #333; 
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    align-self: flex-start;
    transition: background-color 0.3s;
    margin-top: 8px;
}
.check-btn:hover {
    background-color: #555; 
}
.check-btn:disabled {
    background-color: #bfbfbf;
    cursor: not-allowed;
}

.feedback {
    margin-top: 16px;
    padding: 12px;
    border-radius: 4px;
    background-color: #f9f9f9;
    border: 1px solid #e8e8e8;
    display: none; 
}

.feedback .answer-label {
    font-weight: bold;
    color: #1a1a1a;
}

.feedback .correct-answer {
    color: #237804; 
    font-weight: bold;
}

.feedback .explanation {
    margin-top: 8px;
    color: #595959; 
    line-height: 1.6;
    white-space: pre-wrap; 
    font-size: 0.95em;
}

.navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 24px;
}

.navigation button {
    padding: 10px 20px;
    background-color: #333;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s;
}

.navigation button:hover {
    background-color: #555;
}

.navigation button:disabled {
    background-color: #bfbfbf;
    cursor: not-allowed;
}

.progress-indicator {
    font-size: 1em;
    color: #595959;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
}

.question-jumper {
    width: 55px;
    padding: 4px;
    text-align: center;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 1em;
    font-family: inherit;
    color: #333;
    -moz-appearance: textfield; 
}

.question-jumper:focus {
    outline: none;
    border-color: #91d5ff;
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}

.question-jumper::-webkit-outer-spin-button,
.question-jumper::-webkit-inner-spin-button {
    -webkit-appearance: none; 
    margin: 0;
}

.back-to-home {
    margin-bottom: 16px;
    text-align: left;
}

.back-to-home button {
    background-color: #f0f2f5;
    color: #555;
    border: 1px solid #d9d9d9;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.3s, color 0.3s;
}
.back-to-home button:hover {
    background-color: #e8e8e8;
    color: #333;
}

.empty-quiz-message {
    text-align: center;
    padding: 40px;
    font-size: 1.1em;
    color: #888;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-backdrop.hidden {
    display: none;
}

.modal-content {
    background-color: #ffffff;
    padding: 25px 30px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    text-align: center;
    width: 90%;
    max-width: 400px;
}

.modal-content h2 {
    margin-top: 0;
    color: #333;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 25px 0;
}

.modal-buttons button {
    padding: 12px 20px;
    font-size: 1em;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    background-color: #333;
    color: white;
    transition: background-color 0.2s;
}

.modal-buttons button:hover {
    background-color: #555;
}

#modal-close-btn {
    background-color: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    margin-top: 10px;
}


/* Shared navigation and layouts for phones and desktops. */
:root { color-scheme: light; --quiz-green: #24664e; --quiz-border: #dce5df; }
*, *::before, *::after { box-sizing: border-box; }
body { background: #f4f6f3; color: #253b32; padding: 24px 18px 40px; font-size: 16px; line-height: 1.6; }
button, input { font-family: inherit; }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
#app-container { display: block; width: 100%; max-width: 800px; min-width: 0; }
.quiz-toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0 0 16px; }
.toolbar-button { display: flex; align-items: center; justify-content: center; min-height: 46px; padding: 10px 16px; border: 1px solid var(--quiz-border); border-radius: 10px; background: white; color: var(--quiz-green); font-size: 15px; font-weight: 600; line-height: 1.4; text-decoration: none; cursor: pointer; }
.toolbar-button:hover { background: #eaf3ed; border-color: #9dbcaa; }
.toolbar-button:focus-visible, button:focus-visible { outline: 3px solid #6ba88a; outline-offset: 3px; }
.back-to-home { display: none; }
.page { min-width: 0; }
#homepage, .quiz-container { padding: 26px; border: 1px solid var(--quiz-border); border-radius: 16px; box-shadow: 0 4px 18px #25473608; }
#homepage h1, .quiz-container h1 { font-size: 26px; line-height: 1.4; color: #253b32; border-bottom: 1px solid var(--quiz-border); margin: 0 0 22px; padding-bottom: 18px; overflow-wrap: anywhere; }
#accuracy-display:empty { display: none; }
#accuracy-display { margin: 0 0 20px; background: #edf5ef; border: 0; text-align: left; }
.menu { gap: 25px; margin-top: 22px; }
.category-title { font-size: 16px; color: #60756b; border: 0; padding: 0; margin-bottom: 12px; }
.category-items { gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.menu-item { min-height: 58px; padding: 16px; background: #edf5ef; border: 1px solid #d6e6db; border-radius: 10px; color: #285740; font-size: 16px; line-height: 1.55; text-align: left; overflow-wrap: anywhere; }
.menu-item:hover { transform: none; background: #e0eee5; }
#show-wrong-answers { background: #fff5e6; border-color: #efd9b7; color: #885b21; }
#show-wrong-answers:hover { background: #ffefd6; }
#clear-wrong-answers { background: #fcf0ef; border-color: #eccfcd; color: #a34640; }
#clear-wrong-answers:hover { background: #fae8e6; }
.question-text { font-size: 18px; line-height: 1.85; font-weight: 600; margin: 0 0 20px; overflow-wrap: anywhere; }
.option, .tf-option { min-height: 50px; padding: 14px 16px; background: #f8faf8; border-color: var(--quiz-border); border-radius: 10px; color: #2c4035; line-height: 1.65; overflow-wrap: anywhere; }
.option.selected, .tf-option.selected { background: #e5f2eb; border-color: #70a58b; }
.check-btn { min-height: 46px; padding: 12px 20px; border-radius: 10px; font-size: 15px; background: var(--quiz-green); }
.check-btn:hover { background: #194c39; }
.feedback { border-radius: 10px; padding: 16px; overflow-wrap: anywhere; }
.navigation { gap: 12px; flex-wrap: wrap; }
.navigation button { min-height: 44px; border-radius: 10px; padding: 10px 18px; background: var(--quiz-green); }
.question-jumper { min-height: 40px; border-radius: 7px; }
.modal-content { width: calc(100% - 32px); padding: 24px; border-radius: 16px; }
.modal-content h2 { font-size: 21px; }
.modal-buttons { gap: 12px; }
.modal-buttons button { border-radius: 10px; background: var(--quiz-green); min-height: 48px; }
@media (max-width: 600px) {
    body { padding: 14px 12px 28px; }
    #app-container { display: block; min-height: 0; }
    .quiz-toolbar { gap: 10px; margin-bottom: 12px; }
    .toolbar-button { min-height: 44px; font-size: 15px; }
    #homepage, .quiz-container { width: 100%; padding: 20px 16px; border-radius: 13px; }
    #homepage h1, .quiz-container h1 { font-size: 23px; margin-bottom: 20px; padding-bottom: 16px; text-align: left; }
    .category-items { grid-template-columns: minmax(0, 1fr); gap: 10px; }
    .menu { margin-top: 18px; gap: 24px; }
    .menu-item { min-height: 54px; padding: 14px 16px; font-size: 15px; }
    .question-text { font-size: 17px; line-height: 1.8; }
    .option, .tf-option { padding: 13px 14px; font-size: 16px; }
    .options-container { gap: 10px; }
    .check-btn { width: 100%; }
    .navigation { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 20px; }
    .progress-indicator { grid-column: 1 / -1; grid-row: 1; justify-content: center; min-height: 42px; }
    .navigation button { width: 100%; padding: 10px 8px; font-size: 15px; }
    .feedback .explanation { font-size: 14px; line-height: 1.85; }
}
