/* General Resets and Base Styles */
html {
  color-scheme: light dark;
  scroll-behavior: smooth;
}
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --body-bg: #f0f2f5;
    --quiz-wrapper-bg: #ffffff;
    --text-color: #1c1e21;
    --secondary-text-color: #555555;
    --hint-text-color: #6c757d;
    --border-color: #dddddd;
    --light-border-color: #eeeeee;
    --accent-color: #007bff;
    --accent-text-color: #ffffff;
    --button-option-bg: #e9ecef;
    --button-option-text: #212529;
    --button-option-border: #ced4da;
    --button-disabled-bg: #cccccc;
    --button-disabled-text: #777777;
    --current-word-bg: #f8f9fa;

    /* Correct/Incorrect colors - these will be used in both light and dark mode */
    --correct-bg: #28a745; /* Green - using a common green */
    --correct-text: #ffffff;
    --correct-border: #218838; /* Darker green for border */
    --incorrect-bg: #dc3545; /* Red - using a common red */
    --incorrect-text: #ffffff;
    --incorrect-border: #c82333; /* Darker red for border */

    --share-button-bg: #17a2b8; /* Example: Teal for share button */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    line-height: 1.6;
    background-color: var(--body-bg);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    padding: 20px 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.3s, color 0.3s;
}

/* Styles for the main quiz wrapper */
#quiz-main-wrapper {
    background-color: var(--quiz-wrapper-bg);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    width: 100%;
    max-width: 500px;
    text-align: center;
    transition: background-color 0.3s;
    margin-top: auto;
    margin-bottom: auto;
}


/* Typography */
#quiz-main-wrapper h1,
#quiz-main-wrapper h2 {
    color: var(--text-color);
    font-weight: 600;
    transition: color 0.3s;
}
#quiz-main-wrapper h1 {
    font-size: clamp(1.5rem, 5vw, 1.875rem);
    margin-bottom: 15px;
}
#quiz-main-wrapper h2 {
    font-size: clamp(1.25rem, 4vw, 1.5rem);
    margin-bottom: 10px;
}
#quiz-main-wrapper p {
    margin-bottom: 10px;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    color: var(--secondary-text-color);
    transition: color 0.3s;
}

/* General Quiz Action Buttons */
.quiz-action-button {
    font-family: inherit;
    background-color: var(--accent-color);
    color: var(--accent-text-color);
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: clamp(0.95rem, 3vw, 1rem);
    font-weight: 600;
    transition: opacity 0.2s ease-in-out, background-color 0.2s ease-in-out, color 0.2s ease-in-out;
    width: 100%;
    max-width: 350px;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.quiz-action-button:hover:not(:disabled) {
    opacity: 0.85;
}
.quiz-action-button:disabled {
    background-color: var(--button-disabled-bg);
    color: var(--button-disabled-text);
    cursor: not-allowed;
    opacity: 0.7;
}

/* Specific style for the share button */
#share-results-btn.quiz-action-button { /* More specific selector */
    background-color: var(--share-button-bg);
}


/* Quiz Area Specifics */
#quiz-screen {
    text-align: left;
}
#question-area p, /* If you have a <p> inside #question-area */
#current-word-element-wrapper p { /* For the prompt text above current-word */
    color: var(--hint-text-color);
    font-size: clamp(0.85rem, 2.5vw, 0.95rem);
    margin-bottom: 8px;
    text-align: center;
    transition: color 0.3s;
}
#current-word { /* This is likely the ID for the question prompt or the word itself */
    font-size: clamp(1.75rem, 7vw, 2.25rem);
    font-weight: 700;
    margin: 10px 0 20px 0;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--current-word-bg);
    color: var(--text-color);
    text-align: center;
    word-break: break-word;
    line-height: 1.4;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

/* Option Buttons */
#options-area {
    margin-bottom: 15px;
}
/* Base style for all buttons within #options-area */
#options-area .option-button { /* Using .option-button class applied by JS */
    font-family: inherit;
    background-color: var(--button-option-bg);
    color: var(--button-option-text);
    border: 1.5px solid var(--button-option-border);
    padding: 12px 15px;
    text-align: left;
    font-weight: 500;
    width: 100%;
    margin-bottom: 8px;
    border-radius: 8px;
    display: block;
    font-size: clamp(0.9rem, 2.8vw, 1rem);
    transition: background-color 0.2s, color 0.2s, border-color 0.2s, opacity 0.2s;
    cursor: pointer;
}
#options-area .option-button:hover:not(:disabled) {
    border-color: var(--accent-color);
    opacity: 1;
}

/* Correct answer styling */
#options-area .option-button.correct-option {
    background-color: var(--correct-bg) !important;
    color: var(--correct-text) !important;
    border-color: var(--correct-border) !important;
    font-weight: 600;
}

/* Incorrect answer styling */
#options-area .option-button.incorrect-option {
    background-color: var(--incorrect-bg) !important;
    color: var(--incorrect-text) !important;
    border-color: var(--incorrect-border) !important;
    font-weight: 600;
}

/* Styling for other option buttons when an answer has been selected (disabled but not correct/incorrect) */
#options-area .option-button:disabled:not(.correct-option):not(.incorrect-option) {
    background-color: var(--button-option-bg);
    color: var(--hint-text-color); /* Make them more faded */
    border-color: var(--button-option-border);
    opacity: 0.6;
    cursor: not-allowed;
}


#feedback-area {
    margin: 15px 0;
    font-weight: bold;
    font-size: clamp(1rem, 3vw, 1.1rem);
    min-height: 1.5em; /* To prevent layout shift */
    text-align: center;
    transition: color 0.3s;
}
/* Correct feedback text styling */
#feedback-area.correct-feedback {
  color: var(--correct-bg);
}
/* Incorrect feedback text styling */
#feedback-area.incorrect-feedback {
  color: var(--incorrect-bg);
}


/* Start and Result Screens */
#start-screen, #result-screen {
    padding-top: 10px;
}

/* Paragraph specific to the start screen introductory text */
#start-screen > p:first-of-type {
    font-size: clamp(1rem, 3vw, 1.1rem);
    margin-bottom: 15px;
    color: var(--text-color);
    font-weight: 500;
}


#quiz-info-message {
    font-size: clamp(0.85rem, 2.5vw, 0.95rem);
    color: var(--hint-text-color);
    margin-top: 10px;
    margin-bottom: 15px !important; /* Keep important if it was overriding something specific */
}

/* Paragraph specific to the "Готовы проверить..." text or similar */
#start-screen > p:last-of-type {
    font-size: clamp(0.95rem, 2.8vw, 1.05rem);
    margin-bottom: 20px;
}


#result-screen p {
    font-size: clamp(1rem, 3vw, 1.05rem);
    margin-bottom: 10px;
}
#result-screen #score,
#result-screen #total-questions {
    font-weight: bold;
    color: var(--accent-color);
    transition: color 0.3s;
}
#result-message {
    font-style: italic;
    color: var(--secondary-text-color);
    margin-bottom: 20px !important; /* Keep important if necessary */
    transition: color 0.3s;
}

/* Quiz Type Selection */
#quiz-type-selection-container { /* The div that wraps the radio buttons and start button */
    margin-bottom: 15px;
}
#quiz-type-selection {
    text-align: left;
    max-width: 100%;
    margin-bottom: 15px; /* Space before the "Confirm and Start" button */
}

.quiz-type-option {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}

.quiz-type-option input[type="radio"] {
    margin-right: 10px;
    accent-color: var(--accent-color); /* Modern way to color radio/checkbox */
    width: 1.15em;
    height: 1.15em;
    cursor: pointer;
    flex-shrink: 0;
}

.quiz-type-option label {
    font-size: clamp(0.9rem, 2.7vw, 1rem);
    color: var(--text-color);
    cursor: pointer;
    word-break: break-word;
    hyphens: auto;
}


/* Dark Mode Styles */
@media (prefers-color-scheme: dark) {
    :root {
        --body-bg:             #121212;
        --quiz-wrapper-bg:     #1e1e1e;
        --text-color:          #e0e0e0;
        --secondary-text-color:#b0b0b0;
        --hint-text-color:     #888888;
        --border-color:        #3a3a3a;
        --light-border-color:  #2c2c2c;
        --accent-color:        #3793ff; /* Lighter blue for dark mode */
        /* --accent-text-color remains #ffffff which is fine */
        --button-option-bg:    #333333;
        --button-option-text:  #e0e0e0;
        --button-option-border:#555555;
        --button-disabled-bg:  #424242;
        --button-disabled-text:#757575;
        --current-word-bg:     #2a2a2a;

        /* Correct/Incorrect colors remain the same as defined globally for universal understanding */
        /* If you wanted different shades for dark mode, you'd define them here: */
        /* --correct-bg: #2E7D32; */
        /* --incorrect-bg: #C62828; */

        --share-button-bg: #138496; /* Darker teal for share button in dark mode */
    }

    #quiz-main-wrapper {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }
    /* Default feedback area text color for dark mode (before correct/incorrect class is applied) */
    #feedback-area {
         color: var(--hint-text-color);
    }
}

/* Small screen adjustments */
@media (max-width: 360px) {
    body {
        padding: 15px 10px;
    }
    #quiz-main-wrapper {
        padding: 15px;
    }
    .quiz-action-button,
    #options-area .option-button { /* Target .option-button */
        padding: 10px 15px;
        font-size: clamp(0.85rem, 2.8vw, 0.9rem);
    }
    #current-word {
         font-size: clamp(1.5rem, 6vw, 1.8rem);
    }
    #quiz-main-wrapper h1 {
        font-size: clamp(1.3rem, 4.5vw, 1.6rem);
    }
    .quiz-type-option label {
        font-size: clamp(0.85rem, 2.5vw, 0.95rem);
    }
    #start-screen > p:first-of-type {
        font-size: clamp(0.95rem, 2.8vw, 1rem);
    }
    #quiz-info-message {
        font-size: clamp(0.8rem, 2.3vw, 0.9rem);
    }
     #start-screen > p:last-of-type {
        font-size: clamp(0.9rem, 2.6vw, 1rem);
    }
}

/* Even smaller screens, if necessary */
@media (max-width: 320px) {
    #quiz-main-wrapper h1 {
        font-size: clamp(1.2rem, 4vw, 1.5rem);
    }
    .quiz-action-button,
    #options-area .option-button { /* Target .option-button */
        font-size: clamp(0.8rem, 2.5vw, 0.85rem);
    }
     #current-word {
         font-size: clamp(1.3rem, 5.5vw, 1.6rem);
    }
    .quiz-type-option label {
        font-size: clamp(0.8rem, 2.3vw, 0.9rem);
    }
}