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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    backdrop-filter: blur(10px);
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.subtitle {
    font-size: 1.2em;
    opacity: 0.9;
}

/* Навигация по режимам */
.mode-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    flex-wrap: wrap;
    justify-content: center;
}

.mode-btn {
    padding: 12px 24px;
    border: none;
    background: white;
    color: #667eea;
    font-size: 1em;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.mode-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.mode-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

/* Контент режимов */
.mode-content {
    display: none;
}

.mode-content.active {
    display: block;
}

/* Режим "Все вопросы" */
.search-box {
    margin-bottom: 20px;
}

#search-input {
    width: 100%;
    padding: 15px 20px;
    font-size: 1em;
    border: none;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.questions-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.question-item {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: transform 0.2s ease;
}

.question-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.question-number {
    color: #667eea;
    font-weight: bold;
    font-size: 0.9em;
    margin-bottom: 10px;
}

.question-text {
    font-weight: 600;
    font-size: 1.1em;
    color: #333;
    margin-bottom: 15px;
    line-height: 1.6;
}

.answer-text {
    color: #555;
    line-height: 1.8;
    white-space: pre-line;
}

/* Режим "Карточки" - ИСПРАВЛЕНО */
.card-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.card {
    width: 100%;
    max-width: 800px;
    min-height: 500px;
    perspective: 1000px;
    cursor: pointer;
}

.card-inner {
    position: relative;
    width: 100%;
    min-height: 500px;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    min-height: 500px;
    backface-visibility: hidden;
    background: white;
    border-radius: 15px;
    padding: 40px;
    padding-bottom: 80px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    overflow-y: auto;
    max-height: 80vh;
}

.card-back {
    transform: rotateY(180deg);
}

.card-number {
    position: absolute;
    top: 20px;
    left: 20px;
    color: #667eea;
    font-weight: bold;
    font-size: 1.2em;
}

.card-question, .card-answer {
    font-size: 1.2em;
    line-height: 1.8;
    color: #333;
    text-align: left;
    margin-top: 40px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.card-question {
    font-weight: 600;
}

.card-answer {
    white-space: pre-line;
}

.flip-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: #999;
    font-size: 0.9em;
}

.card-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    justify-content: center;
}

.card-btn {
    padding: 12px 24px;
    border: none;
    background: white;
    color: #667eea;
    font-size: 1em;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.card-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.card-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.card-counter {
    color: white;
    font-weight: 600;
    font-size: 1.1em;
}

.shuffle-btn {
    padding: 12px 24px;
    border: none;
    background: white;
    color: #667eea;
    font-size: 1em;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.shuffle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

/* Режим "Квиз" - ИСПРАВЛЕНО */
.quiz-container {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 20px;
}

.quiz-progress {
    flex: 1;
    min-width: 200px;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: #e0e0e0;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s ease;
}

.progress-text {
    color: #666;
    font-size: 0.9em;
}

.quiz-score {
    font-weight: 600;
    color: #667eea;
    font-size: 1.1em;
}

.quiz-question {
    font-size: 1.3em;
    font-weight: 600;
    color: #333;
    margin-bottom: 30px;
    line-height: 1.6;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.quiz-option {
    padding: 20px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
    text-align: left;
    font-size: 1em;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

.quiz-option:hover:not(.correct):not(.incorrect):not(.disabled) {
    border-color: #667eea;
    background: #f5f7ff;
}

.quiz-option.selected {
    border-color: #667eea;
    background: #f5f7ff;
}

.quiz-option.correct {
    border-color: #4caf50;
    background: #e8f5e9;
    cursor: default;
}

.quiz-option.incorrect {
    border-color: #f44336;
    background: #ffebee;
    cursor: default;
}

.quiz-option.disabled {
    cursor: default;
}

.quiz-feedback {
    margin: 20px 0;
    padding: 15px;
    border-radius: 10px;
    font-weight: 600;
}

.quiz-feedback.correct {
    background: #e8f5e9;
    color: #2e7d32;
}

.quiz-feedback.incorrect {
    background: #ffebee;
    color: #c62828;
}

.quiz-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.quiz-btn {
    padding: 12px 24px;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 1em;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.quiz-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.quiz-btn.secondary {
    background: #6c757d;
}

/* Режим "Экзамен" */
.exam-container {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.exam-start {
    text-align: center;
}

.exam-start h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 2em;
}

.exam-start p {
    color: #666;
    margin-bottom: 30px;
    font-size: 1.1em;
}

.exam-settings {
    margin-bottom: 30px;
}

.exam-settings label {
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-weight: 600;
    color: #333;
}

.exam-settings input {
    padding: 10px;
    font-size: 1em;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    max-width: 200px;
    margin: 0 auto;
}

.exam-btn {
    padding: 15px 40px;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 1.1em;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.exam-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.exam-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 15px;
    background: #f5f7ff;
    border-radius: 10px;
}

.exam-timer {
    font-size: 1.2em;
    font-weight: 600;
    color: #667eea;
}

.exam-progress-text {
    color: #666;
    font-weight: 600;
}

.exam-question-item {
    margin-bottom: 30px;
    padding: 20px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
}

.exam-question-number {
    color: #667eea;
    font-weight: bold;
    margin-bottom: 10px;
}

.exam-question-text {
    font-weight: 600;
    font-size: 1.1em;
    margin-bottom: 15px;
    line-height: 1.6;
}

.exam-answer-input {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1em;
    font-family: inherit;
    resize: vertical;
    min-height: 100px;
}

.exam-controls {
    text-align: center;
    margin-top: 30px;
}

.exam-results {
    text-align: center;
}

.exam-results h2 {
    color: #667eea;
    margin-bottom: 30px;
    font-size: 2em;
}

.exam-score-circle {
    width: 200px;
    height: 200px;
    margin: 0 auto 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3em;
    font-weight: bold;
    color: white;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.exam-score-circle.excellent {
    background: linear-gradient(135deg, #4caf50 0%, #81c784 100%);
}

.exam-score-circle.good {
    background: linear-gradient(135deg, #2196f3 0%, #64b5f6 100%);
}

.exam-score-circle.fair {
    background: linear-gradient(135deg, #ff9800 0%, #ffb74d 100%);
}

.exam-score-circle.poor {
    background: linear-gradient(135deg, #f44336 0%, #e57373 100%);
}

.exam-stats {
    margin-bottom: 30px;
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.exam-stat {
    padding: 15px 30px;
    background: #f5f7ff;
    border-radius: 10px;
}

.exam-stat-label {
    color: #666;
    font-size: 0.9em;
    margin-bottom: 5px;
}

.exam-stat-value {
    color: #667eea;
    font-size: 1.5em;
    font-weight: bold;
}

.exam-details {
    margin: 30px 0;
    text-align: left;
}

.exam-detail-item {
    margin-bottom: 20px;
    padding: 15px;
    border-radius: 10px;
}

.exam-detail-item.correct {
    background: #e8f5e9;
    border-left: 4px solid #4caf50;
}

.exam-detail-item.incorrect {
    background: #ffebee;
    border-left: 4px solid #f44336;
}

.exam-detail-item.partial {
    background: #fff3e0;
    border-left: 4px solid #ff9800;
}

.exam-detail-question {
    font-weight: 600;
    margin-bottom: 10px;
}

.exam-detail-answer {
    color: #666;
    font-size: 0.9em;
    margin-bottom: 5px;
}

.exam-detail-score {
    font-size: 0.9em;
    font-weight: 600;
    margin-top: 10px;
}

.exam-detail-score.excellent {
    color: #4caf50;
}

.exam-detail-score.good {
    color: #2196f3;
}

.exam-detail-score.fair {
    color: #ff9800;
}

.exam-detail-score.poor {
    color: #f44336;
}

.show-answer-btn {
    margin-top: 10px;
    padding: 8px 16px;
    border: none;
    background: #667eea;
    color: white;
    font-size: 0.9em;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.show-answer-btn:hover {
    background: #5568d3;
}

.correct-answer-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.correct-answer-popup.show {
    display: flex;
}

.popup-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    position: relative;
}

.popup-close {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.popup-close:hover {
    background: #f0f0f0;
    color: #333;
}

.popup-content h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.5em;
}

.popup-content .correct-answer-text {
    color: #333;
    line-height: 1.8;
    white-space: pre-line;
}

/* Адаптивность */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8em;
    }
    
    .mode-btn {
        flex: 1 1 calc(50% - 5px);
        min-width: 120px;
    }
    
    .card {
        min-height: 400px;
    }
    
    .card-inner {
        min-height: 400px;
    }
    
    .card-front, .card-back {
        min-height: 400px;
        padding: 30px;
        padding-bottom: 70px;
    }
    
    .card-question, .card-answer {
        font-size: 1.1em;
    }
    
    .quiz-question {
        font-size: 1.1em;
    }
    
    .exam-score-circle {
        width: 150px;
        height: 150px;
        font-size: 2em;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    header {
        padding: 15px;
    }
    
    header h1 {
        font-size: 1.5em;
    }
    
    .subtitle {
        font-size: 1em;
    }
    
    .mode-btn {
        padding: 10px 15px;
        font-size: 0.9em;
    }
    
    .card {
        min-height: 350px;
    }
    
    .card-inner {
        min-height: 350px;
    }
    
    .card-front, .card-back {
        min-height: 350px;
        padding: 20px;
        padding-bottom: 60px;
    }
    
    .card-question, .card-answer {
        font-size: 1em;
    }
    
    .popup-content {
        margin: 20px;
        padding: 20px;
    }
}