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

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border-color: #dee2e6;
    --accent-color: #007bff;
    --accent-hover: #0056b3;
    --success-color: #28a745;
    --error-color: #dc3545;
    --timer-warning: #ffc107;
    --timer-danger: #dc3545;
}

[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --text-primary: #e9ecef;
    --text-secondary: #adb5bd;
    --border-color: #495057;
    --accent-color: #0d6efd;
    --accent-hover: #0a58ca;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background 0.3s, color 0.3s;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
}

.header {
    text-align: center;
    padding: 2rem 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 2rem;
    position: relative;
}

.theme-toggle {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.3s;
}

.theme-toggle:hover {
    background: var(--accent-color);
    color: white;
}

h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.timer {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-color);
    margin: 1rem 0;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    display: inline-block;
}

.timer.warning {
    color: var(--timer-warning);
}

.timer.danger {
    color: var(--timer-danger);
    animation: pulse 1s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

.section-select {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.section-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.section-card:hover {
    border-color: var(--accent-color);
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.section-card h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.section-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    margin: 1rem 0;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent-color);
    transition: width 0.3s;
}

.question-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
}

.question-number {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.question-text {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.option {
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.option:hover {
    border-color: var(--accent-color);
    background: var(--bg-secondary);
}

.option.selected {
    border-color: var(--accent-color);
    background: rgba(0, 123, 255, 0.1);
}

.option-label {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.scale-options {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.scale-option {
    flex: 1;
    min-width: 60px;
    padding: 1rem 0.5rem;
    text-align: center;
    font-size: 0.85rem;
}

.btn {
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 2rem;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.navigation {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 2rem;
}

.results {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 2rem;
    margin-top: 2rem;
}

.result-section {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.result-section:last-child {
    border-bottom: none;
}

.result-section h3 {
    margin-bottom: 1rem;
    color: var(--accent-color);
}

.score-display {
    font-size: 2rem;
    font-weight: bold;
    color: var(--success-color);
    margin: 1rem 0;
}

.feedback-item {
    padding: 0.75rem;
    margin: 0.5rem 0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.feedback-item.correct {
    background: rgba(40, 167, 69, 0.1);
    border-left: 4px solid var(--success-color);
}

.feedback-item.incorrect {
    background: rgba(220, 53, 69, 0.1);
    border-left: 4px solid var(--error-color);
}

.hidden {
    display: none;
}

footer {
    margin-top: 2rem;
    padding: 1rem;
    text-align: center;
}

footer a {
    color: var(--accent-color);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal.hidden {
    display: none;
}

.modal:not(.hidden) {
    display: flex;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 2rem;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.3s;
}

.btn-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.settings-section {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.settings-section h3 {
    margin-bottom: 0.5rem;
}

.quiz-set-btn {
    min-width: 150px;
}

.quiz-set-btn.active {
    background: var(--accent-color);
    color: white;
}

@media (max-width: 640px) {
    h1 {
        font-size: 1.4rem;
    }

    .question-card {
        padding: 1.5rem;
    }

    .question-text {
        font-size: 1.1rem;
    }

    .navigation {
        flex-direction: column;
    }

    .scale-options {
        flex-direction: column;
    }

    .scale-option {
        width: 100%;
    }

    .timer {
        font-size: 1.2rem;
    }

    .difficulty-btn-container {
        flex-direction: column;
    }

    .difficulty-btn-container .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}