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

:root {
    /* ... (your color variables remain the same) ... */
    --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-bg: #4CAF50;
    --correct-text: #ffffff;
    --correct-border: #388E3C;
    --incorrect-bg: #F44336;
    --incorrect-text: #ffffff;
    --incorrect-border: #D32F2F;
    /* Optional: Share button color variable
    --share-button-bg: #28a745;
    */
}

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;
    /* MODIFIED: Changed justify-content to flex-start if content might overflow vertically
       This ensures the top of the content is always visible.
       If content is shorter than viewport, padding will handle spacing. */
    justify-content: flex-start;
    min-height: 100vh; /* Ensures body takes at least full viewport height */
    padding: 20px 15px; /* Added top/bottom padding to body */
    -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; /* Reduced top/bottom padding slightly if body has padding */
    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;    /* ADDED: Pushes wrapper down if content is short */
    margin-bottom: auto; /* ADDED: Helps center vertically with flex-start on body */
    /* Ensure it doesn't get a fixed height that's too small */
    /* min-height: fit-content; /* or some other appropriate value if needed */
}


/* 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; /* Adjusted margin */
}
#quiz-main-wrapper h2 {
    font-size: clamp(1.25rem, 4vw, 1.5rem);
    margin-bottom: 10px; /* Adjusted margin */
}
#quiz-main-wrapper p {
    margin-bottom: 10px; /* Adjusted margin */
    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; /* ADDED: Max width for very wide screens but still centered by wrapper */
    margin-left: auto;   /* ADDED: To center if max-width is applied */
    margin-right: auto;  /* ADDED: To center if max-width is applied */
    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;
}

/* Optional: Specific style for the share button */
.quiz-share-button {
    background-color: #28a745; /* Example: Green color for sharing */
    /* Or use your CSS variable:
    background-color: var(--share-button-bg);
    */
}


/* Quiz Area Specifics */
#quiz-screen {
    text-align: left;
}
#question-area p {
    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 {
    font-size: clamp(1.75rem, 7vw, 2.25rem);
    font-weight: 700;
    margin: 10px 0 20px 0; /* Adjusted margin */
    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; /* Adjusted margin */
}
#options-area button {
    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; /* Slightly adjusted padding */
    text-align: left;
    font-weight: 500;
    width: 100%;
    margin-bottom: 8px; /* Adjusted margin */
    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 button:hover:not(:disabled) {
    border-color: var(--accent-color);
    opacity: 1;
}
#options-area button.correct {
    background-color: var(--correct-bg) !important;
    color: var(--correct-text) !important;
    border-color: var(--correct-border) !important;
    font-weight: 600;
}
#options-area button.incorrect {
    background-color: var(--incorrect-bg) !important;
    color: var(--incorrect-text) !important;
    border-color: var(--incorrect-border) !important;
    font-weight: 600;
}
#options-area button:disabled:not(.correct):not(.incorrect) {
    background-color: var(--button-option-bg);
    color: var(--hint-text-color);
    border-color: var(--button-option-border);
    opacity: 0.6;
    cursor: not-allowed;
}

#feedback-area {
    margin: 15px 0; /* Adjusted margin */
    font-weight: bold;
    font-size: clamp(1rem, 3vw, 1.1rem);
    min-height: 1.5em;
    text-align: center;
    transition: color 0.3s;
}

/* Start and Result Screens */
#start-screen, #result-screen {
    padding-top: 10px;
    /* ADDED: Ensure start screen can scroll if content is too tall */
    /* overflow-y: auto; /* This might be too aggressive, better to ensure wrapper can grow */
}

/* Paragraph specific to the start screen introductory text */
#start-screen > p:first-of-type { /* Targets "Выберите категорию слов для квиза:" */
    font-size: clamp(1rem, 3vw, 1.1rem); /* Slightly larger */
    margin-bottom: 15px;
    color: var(--text-color); /* Make it more prominent */
    font-weight: 500;
}


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

/* Paragraph specific to the "Готовы проверить..." text */
#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; /* Adjusted margin */
    transition: color 0.3s;
}

/* Quiz Type Selection */
#quiz-type-selection {
    margin-bottom: 15px; /* Adjusted margin */
    text-align: left;
    /* ADDED: Ensure this section doesn't cause horizontal overflow or become too wide */
    max-width: 100%;
}

.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);
    width: 1.15em;
    height: 1.15em;
    cursor: pointer;
    flex-shrink: 0; /* Prevent radio from shrinking */
}

.quiz-type-option label {
    font-size: clamp(0.9rem, 2.7vw, 1rem); /* Slightly adjusted responsive font size */
    color: var(--text-color);
    cursor: pointer;
    /* Allow label to wrap if needed */
    word-break: break-word;
    hyphens: auto; /* Optional: improve word breaking */
}


/* 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;
        --accent-text-color:   #ffffff;
        --button-option-bg:    #333333;
        --button-option-text:  #e0e0e0;
        --button-option-border:#555555;
        --button-disabled-bg:  #424242;
        --button-disabled-text:#757575;
        --current-word-bg:     #2a2a2a;
        /* Optional: Share button dark mode color
        --share-button-bg: #218838;
        */
    }

    #quiz-main-wrapper {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }
    #feedback-area {
         color: var(--text-color);
    }
}

/* Small screen adjustments */
@media (max-width: 360px) {
    body {
        padding: 15px 10px; /* Adjust body padding for very small screens */
    }
    #quiz-main-wrapper {
        padding: 15px;
    }
    .quiz-action-button,
    #options-area button {
        padding: 10px 15px; /* Keep this */
        font-size: clamp(0.85rem, 2.8vw, 0.9rem); /* Adjusted font size */
    }
    #current-word {
         font-size: clamp(1.5rem, 6vw, 1.8rem); /* Adjusted font size */
    }
    #quiz-main-wrapper h1 {
        font-size: clamp(1.3rem, 4.5vw, 1.6rem); /* Adjusted font size */
    }
    .quiz-type-option label {
        font-size: clamp(0.85rem, 2.5vw, 0.95rem); /* Adjusted font size */
    }
    /* Paragraphs on start screen for very small devices */
    #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 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);
    }
}
