:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --secondary: #10b981;
    --secondary-hover: #059669;
    --accent: #8b5cf6;
    --accent-hover: #7c3aed;
    --bg-color: #f3f4f6;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --card-bg: #ffffff;
    --correct: #10b981;
    --correct-bg: #d1fae5;
    --wrong: #ef4444;
    --wrong-bg: #fee2e2;
    --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', sans-serif; }

body { background-color: var(--bg-color); color: var(--text-main); display: flex; justify-content: center; padding: 2rem 1rem; }
#app { width: 100%; max-width: 800px; }

.screen { display: none; animation: fadeIn 0.4s ease; }
.screen.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.card { background: var(--card-bg); padding: 2rem; border-radius: var(--radius); box-shadow: 0 4px 15px rgba(0,0,0,0.05); margin-bottom: 2rem; }
.form-group { margin-bottom: 1.5rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: 0.5rem; }
.form-group input, .form-group select { width: 100%; padding: 0.85rem; border: 2px solid #e5e7eb; border-radius: 8px; font-size: 1rem; outline: none; transition: border 0.2s; }
.form-group input:focus, .form-group select:focus { border-color: var(--primary); }

.btn { width: 100%; padding: 0.85rem 1.5rem; border: none; border-radius: 8px; font-size: 1rem; font-weight: 600; cursor: pointer; color: white; transition: 0.2s; text-align: center; }
.btn.primary { background: var(--primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.secondary { background: var(--secondary); }
.btn.secondary:hover { background: var(--secondary-hover); }
.btn.accent { background: var(--accent); margin-top: 1rem; }
.btn.accent:hover { background: var(--accent-hover); }
.actions { display: flex; gap: 1rem; }

.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 0.9rem; font-weight: 600; text-decoration: underline; }
.text-danger { color: var(--wrong) !important; text-decoration: none; }

.login-card { max-width: 400px; margin: 4rem auto; text-align: center; }
.login-icon { font-size: 3rem; margin-bottom: 1rem; }
.login-card p { color: var(--text-muted); margin-bottom: 1.5rem; }

.main-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; }
.user-badge { margin-top: 0.5rem; display: inline-block; padding: 0.4rem 0.8rem; background: #e0e7ff; color: var(--primary-hover); border-radius: 20px; font-size: 0.9rem; font-weight: 500; }

.divider { border: 0; border-top: 1px solid #e5e7eb; margin: 2rem 0; }
.full-test-section h3 { margin-bottom: 1rem; }
.timer-checkbox { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; cursor: pointer; }
.timer-checkbox input { width: 18px; height: 18px; cursor: pointer; }

/* Таблица */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
th, td { padding: 0.85rem; text-align: left; border-bottom: 1px solid #e5e7eb; font-size: 0.95rem; }
th { background: #f9fafb; font-weight: 600; color: var(--text-muted); }

/* Викторина */
.quiz-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; flex-wrap: wrap; gap: 10px; }
.timer-display { font-weight: bold; background: #fee2e2; color: #b91c1c; padding: 0.3rem 0.8rem; border-radius: 20px; font-size: 0.95rem; }
.progress-info { font-weight: bold; color: var(--text-muted); font-size: 0.9rem; }
.progress-bar-bg { height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden; margin-bottom: 2rem; }
#progress-bar-fill { height: 100%; background: var(--primary); width: 0%; transition: width 0.3s ease; }

.meta { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1rem; background: #f3f4f6; display: inline-block; padding: 0.3rem 0.6rem; border-radius: 6px; }
#question-text { margin-bottom: 1.5rem; font-size: 1.25rem; line-height: 1.4; }

.options { display: flex; flex-direction: column; gap: 0.75rem; }
.option-btn { padding: 1rem; background: #f9fafb; border: 2px solid #e5e7eb; border-radius: 8px; font-size: 1rem; text-align: left; cursor: pointer; transition: all 0.2s; }
.option-btn:hover:not(:disabled) { border-color: var(--primary); background: #eff6ff; }

.option-btn.correct { background: var(--correct-bg); border-color: var(--correct); color: #065f46; }
.option-btn.wrong { background: var(--wrong-bg); border-color: var(--wrong); color: #991b1b; }

.option-btn.selected { 
    background: #eff6ff; 
    border-color: var(--primary); 
    color: var(--primary-hover);
    font-weight: 500;
}

.explanation { margin-top: 1.5rem; padding: 1.25rem; background: #fffbeb; border-left: 4px solid #f59e0b; border-radius: 8px; }
.explanation h3 { font-size: 1rem; color: #b45309; margin-bottom: 0.5rem; }
.explanation.hidden, .btn.hidden, .hidden { display: none !important; }

.quiz-footer { margin-top: 2rem; display: flex; justify-content: flex-end; }

/* ЭКРАН РЕЗУЛЬТАТОВ */
.result-header { text-align: center; margin-bottom: 2rem; }
.meta-label { color: var(--text-muted); font-weight: 500; margin-top: 0.5rem; }

.result-dashboard { display: flex; justify-content: center; align-items: center; gap: 3rem; margin-bottom: 2rem; padding-bottom: 2rem; border-bottom: 1px solid #e5e7eb; }

/* УЛУЧШЕННЫЙ КРУГ - ЦИФРА НЕ СЛИВАЕТСЯ */
.score-circle { position: relative; width: 140px; height: 140px; border-radius: 50%; background: conic-gradient(var(--primary) 0%, #e5e7eb 0%); display: flex; align-items: center; justify-content: center; }
.score-circle-inner { width: 110px; height: 110px; background: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 2.2rem; font-weight: bold; color: var(--text-main); box-shadow: 0 2px 4px rgba(0,0,0,0.1); }

.score-stats { display: flex; flex-direction: column; gap: 1rem; }
.stat-box { padding: 1rem 1.5rem; border-radius: 8px; text-align: center; min-width: 120px; }
.stat-title { display: block; font-size: 0.9rem; text-transform: uppercase; font-weight: bold; margin-bottom: 0.25rem; opacity: 0.8; }
.stat-value { font-size: 1.8rem; font-weight: bold; }
.correct-box { background: var(--correct-bg); color: #065f46; }
.wrong-box { background: var(--wrong-bg); color: #991b1b; }

/* РАЗБОР ОШИБОК - УЛУЧШЕННЫЙ UI */
.mistakes-section { margin-bottom: 2rem; }
.mistakes-section h3 { margin-bottom: 1rem; color: var(--text-main); }
.mistakes-list { display: flex; flex-direction: column; gap: 1rem; max-height: 400px; overflow-y: auto; padding-right: 0.5rem; }

.mistake-item { background: white; border: 1px solid #e5e7eb; border-left: 5px solid var(--wrong); padding: 1.25rem; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.02); }
.mistake-q { font-weight: 600; font-size: 1.05rem; margin-bottom: 1rem; color: #111827; }
.ans-block { display: flex; align-items: flex-start; gap: 0.5rem; padding: 0.75rem; border-radius: 6px; margin-bottom: 0.5rem; font-size: 0.95rem; }
.ans-wrong-block { background: #fef2f2; color: #991b1b; }
.ans-correct-block { background: #f0fdf4; color: #166534; }
.ans-icon { font-size: 1.1rem; }

@media(max-width: 600px) {
    .actions { flex-direction: column; }
    .result-dashboard { flex-direction: column; gap: 1.5rem; }
}