/* CSS Variables for easy theming */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --success-gradient: linear-gradient(135deg, #4CAF50, #45a049);
    --error-gradient: linear-gradient(135deg, #f44336, #d32f2f);
    --secondary-gradient: linear-gradient(135deg, #6c757d, #5a6268);
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    
    --primary-color: #667eea;
    --success-color: #4CAF50;
    --error-color: #f44336;
    --text-primary: #333;
    --text-secondary: #666;
    --bg-white: rgba(255, 255, 255, 0.95);
    --border-color: #e0e0e0;
    --shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 5px 20px rgba(102, 126, 234, 0.3);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-image: url('background.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-color: #667eea;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 0;
    pointer-events: none;
}

.container {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 40px;
    max-width: 800px;
    width: 100%;
    backdrop-filter: blur(10px);
    position: relative;
    overflow-x: hidden;
    overflow-y: visible;
    z-index: 1;
}

.header {
    text-align: center;
    margin-bottom: 40px;
    position: relative;
    z-index: 30;
}

.main-title {
    font-size: 1.3rem;
    color: #fff;
    margin-bottom: 20px;
    margin-top: 0;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    line-height: 1.3;
    padding: 12px 80px 12px 15px;
    background: var(--primary-gradient);
    border-radius: var(--radius-md);
    backdrop-filter: blur(5px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    position: relative;
}

.lang-switcher {
    position: absolute;
    top: 12px;
    right: 15px;
    z-index: 100;
}

.lang-select {
    appearance: none;
    background: #ffffff;
    border: 2px solid var(--primary-color);
    border-radius: 16px;
    padding: 8px 36px 8px 14px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="8" viewBox="0 0 12 8"><path fill="%23667eea" d="M6 8L0 0h12z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: var(--transition);
}

.lang-select:hover {
    background-color: #f8f9fa;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.lang-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.quiz-title-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    margin-top: 10px;
    gap: 15px;
}

.quiz-title {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin: 0;
    font-weight: 600;
    flex: 1;
    text-align: center;
}

.quiz-subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Loading & Error States */
.loading, .error {
    text-align: center;
    padding: 40px;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error {
    background: #f8d7da;
    color: #721c24;
    padding: 20px;
    border-radius: 10px;
    border: 1px solid #f5c6cb;
}

/* Start Screen */
.start-screen {
    display: none;
    padding: 10px 0 20px;
    text-align: center;
    animation: fadeIn 0.3s ease;
}

.start-screen.active {
    display: block;
}

.start-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.06);
    display: inline-block;
    min-width: 260px;
    max-width: 92vw;
}

.start-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.section-container,
.feedback-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}

.section-select,
.feedback-select {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: #fff;
    font-size: 0.95rem;
    min-width: 200px;
}

.randomize-container {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 15px 0;
}

.randomize-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-primary);
    user-select: none;
}

.randomize-checkbox {
    display: none;
}

.checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    margin-right: 10px;
    position: relative;
    background: #fff;
    transition: var(--transition);
}

.randomize-checkbox:checked + .checkmark {
    background: var(--primary-gradient);
    border-color: var(--primary-color);
}

.randomize-checkbox:checked + .checkmark::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Random Questions Input */
.random-questions-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
    flex-direction: column;
}

.random-questions-label {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 500;
}

.random-questions-input {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: #fff;
    font-size: 0.95rem;
    width: 100%;
    max-width: 200px;
    text-align: center;
}

.random-questions-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.random-questions-input:invalid {
    border-color: var(--error-color);
}

.random-questions-error {
    color: var(--error-color);
    font-size: 0.85rem;
    margin-top: 5px;
    text-align: center;
}

/* Progress Bar */
.progress-container {
    margin-bottom: 30px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--success-gradient);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    text-align: center;
    margin-top: 10px;
    color: var(--text-secondary);
    font-weight: 500;
}

.section-summary {
    text-align: right;
    color: #555;
    font-size: 0.95rem;
    margin-bottom: 8px;
}

/* Questions */
.question-container {
    display: none;
}

.question-container.active {
    display: block;
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(15px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

/* Smooth transitions for all interactive elements */
.option,
.btn,
.start-card {
    transition: var(--transition);
}

/* Prevent layout shift on mobile */
.start-card,
.section-select,
.feedback-select {
    will-change: transform;
}

.question-number {
    color: var(--primary-color);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.question-text {
    font-size: 1.4rem;
    color: var(--text-primary);
    margin-bottom: 30px;
    line-height: 1.6;
}

.options-container {
    margin-bottom: 40px;
}

.option {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: var(--radius-md);
    padding: 15px 20px;
    margin-bottom: 15px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    min-height: 44px;
    display: flex;
    align-items: center;
    touch-action: manipulation;
}

.option:hover {
    background: #e9ecef;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.option.selected {
    background: var(--primary-gradient);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.option.correct {
    background: var(--success-gradient);
    color: white;
    border-color: var(--success-color);
}

.option.incorrect {
    background: var(--error-gradient);
    color: white;
    border-color: var(--error-color);
}

.option-label {
    font-weight: 600;
    margin-right: 10px;
}

.explanation-area {
    margin-top: 15px;
    padding: 12px;
    background: #f8f9fa;
    border-left: 4px solid var(--error-color);
    border-radius: 6px;
    font-size: 0.9rem;
    line-height: 1.4;
    color: #495057;
    display: none;
}

.explanation-area.show {
    display: block;
}

.explanation-title {
    font-weight: 600;
    color: var(--error-color);
    margin-bottom: 8px;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Navigation */
.navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    position: relative;
    padding: 12px;
    margin-top: 20px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-md);
    min-height: 60px;
}

.btn {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex: 1;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: var(--secondary-gradient);
}

.btn-success {
    background: var(--success-gradient);
}

/* Results */
.results-container {
    display: none;
    text-align: center;
}

.results-container.active {
    display: block;
    animation: fadeIn 0.4s ease-out;
}

.score-display {
    background: var(--primary-gradient);
    color: white;
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 30px;
}

.score-percentage {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.score-details {
    font-size: 1.2rem;
    opacity: 0.9;
}

.wrong-answers {
    text-align: left;
    margin: 30px 0;
}

.wrong-answer-item {
    background: #fff;
    border-left: 4px solid var(--error-color);
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 0 10px 10px 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.wrong-question {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.wrong-user-answer {
    color: var(--error-color);
    margin-bottom: 5px;
}

.correct-answer {
    color: var(--success-color);
    font-weight: 600;
    margin-bottom: 10px;
}

.explanation {
    color: var(--text-secondary);
    font-style: italic;
    background: #f8f9fa;
    padding: 10px;
    border-radius: 5px;
    margin-top: 10px;
}

.results-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

/* Mobile Optimizations */
.option {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    will-change: transform;
}

.option:active,
.option.touching {
    transform: scale(0.97);
    transition: transform 0.1s ease;
}

.btn {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    will-change: transform;
}

.btn:active:not(:disabled) {
    transform: scale(0.97);
    transition: transform 0.1s ease;
}

/* Smooth scrolling for mobile */
@media (max-width: 768px) {
    html {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
    
    body {
        padding: 10px;
        overflow-x: hidden;
    }
    
    .container {
        padding: 15px;
        border-radius: 15px;
        max-height: 100vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    

    .start-screen.active ~ .container,
    .start-screen.active .container {
        max-height: none;
        overflow: visible;
    }

    .section-container,
    .feedback-container,
    .random-questions-container {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .section-select,
    .feedback-select,
    .random-questions-input {
        width: 100%;
        min-width: unset;
        padding: 10px 12px;
        font-size: 0.95rem;
        max-width: 100%;
    }

    .main-title {
        font-size: 0.9rem;
        padding: 8px 50px 8px 10px;
        margin-bottom: 12px;
    }

    .quiz-title-container {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 8px;
        margin-top: 8px;
    }
    
    .quiz-title {
        font-size: 1.3rem;
        margin: 0;
    }
    
    .credits {
        align-self: flex-end;
    }

    .quiz-subtitle {
        font-size: 1rem;
    }

    .question-text {
        font-size: 1.1rem;
        margin-bottom: 20px;
        line-height: 1.5;
    }

    .option {
        padding: 14px 16px;
        font-size: 0.95rem;
        min-height: 50px;
        margin-bottom: 12px;
    }

    .option:active,
    .option.touching {
        transform: scale(0.96);
        transition: transform 0.1s ease;
    }

    .navigation {
        flex-direction: column;
        gap: 12px;
    }

    .btn {
        width: 100%;
        padding: 14px 20px;
        min-height: 48px;
        font-size: 0.95rem;
    }

    .btn:active:not(:disabled) {
        transform: scale(0.96);
        transition: transform 0.1s ease;
    }

    .progress-text {
        font-size: 0.9rem;
    }

    .score-percentage {
        font-size: 2.5rem;
    }

    .score-details {
        font-size: 1.1rem;
    }

    .results-actions {
        flex-direction: column;
        gap: 12px;
    }

    .wrong-answer-item {
        padding: 15px;
        margin-bottom: 15px;
    }

    .explanation-area {
        font-size: 0.85rem;
        padding: 10px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 5px;
    }
    
    .container {
        padding: 12px;
        border-radius: 12px;
    }

    .main-title {
        font-size: 0.75rem;
        padding: 6px 45px 6px 8px;
        margin-bottom: 10px;
    }
    
    .lang-switcher {
        top: 6px;
        right: 8px;
    }
    
    .lang-select {
        padding: 6px 28px 6px 10px;
        font-size: 0.8rem;
    }

    .quiz-title-container {
        flex-direction: column;
        gap: 8px;
        margin-top: 8px;
    }
    
    .quiz-title {
        font-size: 1.1rem;
        margin: 0;
    }
    
    .credits {
        align-self: flex-end;
    }

    .quiz-subtitle {
        font-size: 0.95rem;
    }

    .question-text {
        font-size: 1rem;
        line-height: 1.4;
    }

    .option {
        padding: 12px 14px;
        font-size: 0.9rem;
        min-height: 48px;
    }

    .option-label {
        font-size: 0.85rem;
    }

    .btn {
        padding: 12px 16px;
        font-size: 0.9rem;
        min-height: 44px;
    }

    .score-percentage {
        font-size: 2.2rem;
    }

    .score-details {
        font-size: 1rem;
    }

    .start-card {
        padding: 20px;
    }
}

/* Credits */
.credits {
    flex-shrink: 0;
    pointer-events: auto;
}

.credits-link {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    transition: var(--transition);
    opacity: 0.7;
}

.credits-link:hover {
    opacity: 1;
    color: var(--primary-color);
}

.credits-text {
    font-weight: 500;
}

.credits-logo {
    height: 24px;
    width: auto;
    opacity: 0.8;
    transition: var(--transition);
}

.credits-link:hover .credits-logo {
    opacity: 1;
    transform: scale(1.05);
}

@media (max-width: 768px) {
    .credits-link {
        font-size: 0.75rem;
        gap: 6px;
    }
    
    .credits-logo {
        height: 20px;
    }
}

@media (max-width: 480px) {
    .credits-link {
        font-size: 0.7rem;
        gap: 5px;
    }
    
    .credits-logo {
        height: 18px;
    }
}

