:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --bg-card: #1a1a1a;
    --bg-accent: #2a2a2a;
    --border-primary: #333333;
    --border-accent: #404040;
    
    --text-primary: #ffffff;
    --text-secondary: #f1cd04;
    --text-accent: #ffffff;
    
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --accent: #10b981;
    --accent-light: #34d399;
    --warning: #f59e0b;
    --warning-light: #fbbf24;
    --error: #ef4444;
    --error-light: #f87171;
    
    --success: #10b981;
    --legend: #8b5cf6;
    --veteran: #f59e0b;
    --support: #6b7280;
    
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-hover: 0 12px 48px rgba(0, 0, 0, 0.6);
    --glow: 0 0 20px rgba(99, 102, 241, 0.3);
    --glow-success: 0 0 20px rgba(16, 185, 129, 0.3);
    --glow-error: 0 0 20px rgba(239, 68, 68, 0.3);
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    line-height: 1.6;
    font-size: 16px;
    font-weight: 500;
}

.game-container {
    display: flex;
    height: 100vh;
    background: var(--bg-primary);
}

/* ===== STUDENTS PANEL ===== */
.students-panel {
    width: 80px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-primary);
    padding: 20px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    overflow-y: auto;
    transition: width 0.3s ease;
}

.student-btn {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    font-weight: 600;
}

.student-btn:hover {
    transform: scale(1.1);
    width: 120px;
    justify-content: flex-start;
    padding-left: 15px;
}

.student-btn:hover .student-name {
    display: block;
    margin-left: 8px;
    font-size: 0.8rem;
    font-weight: 600;
}

.student-name {
    display: none;
}

.student-btn.active {
    box-shadow: var(--glow);
    transform: scale(1.15);
}

.student-btn.correct {
    animation: pulseSuccess 0.6s ease;
}

.student-btn.incorrect {
    animation: pulseError 0.6s ease;
}

/* ===== GAME AREA ===== */
.game-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 20px;
    overflow: hidden;
}

/* Progress Bar */
.game-progress {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 15px 20px;
    border: 1px solid var(--border-primary);
    box-shadow: var(--shadow);
}

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

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 4px;
    transition: width 0.5s ease;
    width: 0%;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 700;
}

.mistakes-counter {
    color: var(--error-light);
    font-weight: 700;
}

/* ===== QUESTION AREA ===== */
.question-area {
    flex: 1;
    background: var(--bg-card);
    border-radius: 20px;
    border: 1px solid var(--border-primary);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.question-header {
    background: var(--bg-secondary);
    padding: 20px 25px;
    display: flex;
    align-items: center;
    gap: 20px;
    border-bottom: 1px solid var(--border-primary);
}

.question-icon {
    font-size: 3rem;
    animation: iconBounce 2s ease-in-out infinite;
    font-weight: 700;
}

.question-title-content {
    flex: 1;
}

.question-title {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
    text-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}

.question-subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.question-content {
    flex: 1;
    padding: 25px;
    overflow-y: auto;
    font-size: 1.1rem;
    line-height: 1.7;
    font-weight: 500;
}

/* Main Question Text */
.question-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.6;
    margin-bottom: 25px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border-left: 5px solid var(--primary);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* ===== ANSWERS AREA ===== */
.answers-area {
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border-primary);
    box-shadow: var(--shadow);
    padding: 20px;
}

.answers-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.answer-btn {
    background: linear-gradient(135deg, var(--bg-accent), var(--bg-secondary));
    border: 3px solid var(--border-accent);
    border-radius: 12px;
    padding: 25px 20px;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    position: relative;
    overflow: hidden;
    line-height: 1.5;
}

.answer-btn:hover {
    transform: translateY(-3px);
    border-color: var(--primary);
    box-shadow: var(--shadow-hover);
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: white;
}

.answer-btn:disabled {
    cursor: not-allowed;
    opacity: 0.7;
    transform: none;
}

.answer-btn.correct {
    background: linear-gradient(135deg, var(--success), #059669);
    border-color: var(--success);
    color: white;
    box-shadow: var(--glow-success);
    animation: celebrate 0.6s ease;
    font-weight: 700;
}

.answer-btn.incorrect {
    background: linear-gradient(135deg, var(--error), #dc2626);
    border-color: var(--error);
    color: white;
    box-shadow: var(--glow-error);
    animation: shake 0.5s ease;
    font-weight: 700;
}

/* ===== CONTROLS ===== */
.controls-area {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.control-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    padding: 15px 25px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow);
}

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

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ===== MODALS ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.modal.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    border: 2px solid var(--border-primary);
    box-shadow: var(--shadow-hover);
    animation: slideUp 0.4s ease;
}

.modal-content h2 {
    text-align: center;
    margin-bottom: 25px;
    font-size: 2.2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ===== SETUP FORM ===== */
.setup-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 10px;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 1.1rem;
}

.students-input-container {
    display: flex;
    gap: 10px;
}

#studentNameInput {
    flex: 1;
    background: var(--bg-secondary);
    border: 2px solid var(--border-primary);
    border-radius: 10px;
    padding: 15px;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
}

#studentNameInput:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3);
}

.add-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 15px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    font-size: 1rem;
}

.add-btn:hover {
    background: var(--accent-light);
    transform: translateY(-2px);
    box-shadow: var(--glow-success);
}

.students-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    max-height: 200px;
    overflow-y: auto;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 2px solid var(--border-primary);
}

.student-tag {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 10px 15px;
    border-radius: 20px;
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.remove-student {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.remove-student:hover {
    background: rgba(255, 255, 255, 0.3);
}

.start-btn {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: white;
    border: none;
    padding: 18px 35px;
    border-radius: 12px;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    box-shadow: var(--shadow);
}

.start-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: var(--glow-success);
}

.start-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ===== LEADERBOARD ===== */
.leaderboard {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 18px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 2px solid var(--border-primary);
    transition: all 0.3s ease;
    font-weight: 600;
}

.leaderboard-item:hover {
    transform: translateX(5px);
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.rank {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--primary-light);
    min-width: 35px;
}

.student-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.student-icon {
    font-size: 1.3rem;
}

.student-name {
    font-weight: 700;
    font-size: 1.1rem;
}

.score {
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--accent-light);
    min-width: 100px;
    text-align: right;
}

.grade {
    padding: 8px 12px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.grade.отлично {
    background: var(--legend);
    color: white;
}

.grade.хорошо {
    background: var(--veteran);
    color: white;
}

.grade.удовлетворительно {
    background: var(--support);
    color: white;
}

.status-icon {
    font-size: 1.1rem;
}

/* Rank Styles */
.rank-1 {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    border: 3px solid #fbbf24;
    transform: scale(1.05);
}

.rank-2 {
    background: linear-gradient(135deg, #c0c0c0, #e5e7eb);
    border: 3px solid #9ca3af;
}

.rank-3 {
    background: linear-gradient(135deg, #cd7f32, #f59e0b);
    border: 3px solid #d97706;
}

.close-btn {
    width: 100%;
    background: var(--bg-accent);
    color: var(--text-primary);
    border: 2px solid var(--border-primary);
    padding: 15px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    margin-top: 20px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 1rem;
}

.close-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    transform: translateY(-2px);
}

/* ===== RESULTS ===== */
.results-content {
    text-align: center;
    padding: 20px 0;
}

.final-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin: 30px 0;
}

.stat {
    text-align: center;
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 12px;
    border: 2px solid var(--border-primary);
}

.stat strong {
    display: block;
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary-light);
    margin-bottom: 8px;
}

.stat span {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.success-message, .error-message {
    text-align: center;
    margin-bottom: 30px;
}

.success-message h3 {
    color: var(--accent);
    font-weight: 700;
    font-size: 1.5rem;
    margin-bottom: 15px;
}

.error-message h3 {
    color: var(--error);
    font-weight: 700;
    font-size: 1.5rem;
    margin-bottom: 15px;
}

.final-leaderboard {
    margin-top: 30px;
    border-top: 3px solid var(--border-primary);
    padding-top: 25px;
}

.final-leaderboard h4 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.restart-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    padding: 18px 35px;
    border-radius: 12px;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 25px;
    box-shadow: var(--shadow);
}

.restart-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--glow);
}

/* ===== DIFFICULTY BADGES ===== */
.difficulty-badge {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.difficulty-easy {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: white;
    border: 2px solid var(--accent-light);
}

.difficulty-medium {
    background: linear-gradient(135deg, var(--warning), var(--warning-light));
    color: white;
    border: 2px solid var(--warning-light);
}

.difficulty-hard {
    background: linear-gradient(135deg, var(--error), var(--error-light));
    color: white;
    border: 2px solid var(--error-light);
}

/* ===== FEEDBACK MESSAGES ===== */
.feedback-message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    animation: slideDown 0.3s ease;
}

.feedback-content {
    padding: 18px 25px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1.1rem;
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    gap: 12px;
    border: 2px solid transparent;
}

.feedback-success {
    background: var(--success);
    color: white;
    border-color: var(--accent-light);
}

.feedback-error {
    background: var(--error);
    color: white;
    border-color: var(--error-light);
}

.feedback-warning {
    background: var(--warning);
    color: white;
    border-color: var(--warning-light);
}

.feedback-info {
    background: var(--primary);
    color: white;
    border-color: var(--primary-light);
}

/* Student Scores */
.student-score {
    font-weight: 800;
    font-size: 0.95em;
    background: rgba(255,255,255,0.25);
    padding: 4px 8px;
    border-radius: 12px;
    margin-left: auto;
}

/* Progress Check Styles */
.code-block {
    background: #1f2937;
    color: #e5e7eb;
    padding: 20px;
    border-radius: 10px;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    line-height: 1.5;
    margin: 20px 0;
    overflow-x: auto;
    font-weight: 500;
    border: 2px solid #374151;
}

.definition {
    background: #1e293b;
    border-left: 5px solid var(--primary);
    padding: 20px;
    margin: 20px 0;
    border-radius: 0 12px 12px 0;
    font-weight: 500;
    border: 1px solid #334155;
}

.interactive-question {
    background: #1e40af;
    border: 3px dashed #3b82f6;
    padding: 20px;
    border-radius: 12px;
    margin: 20px 0;
    font-weight: 600;
    color: white;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes slideDown {
    from {
        transform: translateX(-50%) translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

@keyframes iconBounce {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-8px) scale(1.15); }
}

@keyframes pulseSuccess {
    0%, 100% { box-shadow: var(--glow-success); }
    50% { box-shadow: 0 0 40px rgba(16, 185, 129, 0.8); }
}

@keyframes pulseError {
    0%, 100% { box-shadow: var(--glow-error); }
    50% { box-shadow: 0 0 40px rgba(239, 68, 68, 0.8); }
}

@keyframes celebrate {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.12); }
    100% { transform: scale(1); }
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1024px) {
    .answers-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .students-panel {
        width: 70px;
    }
    
    .student-btn {
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
    }
    
    .question-text {
        font-size: 1.3rem;
    }
}

@media (max-width: 768px) {
    .game-container {
        flex-direction: column;
    }
    
    .students-panel {
        width: 100%;
        height: 80px;
        flex-direction: row;
        padding: 15px;
        overflow-x: auto;
    }
    
    .student-btn {
        flex-shrink: 0;
        min-width: 50px;
        height: 50px;
    }
    
    .answers-grid {
        grid-template-columns: 1fr;
    }
    
    .controls-area {
        flex-wrap: wrap;
    }
    
    .final-stats {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .question-text {
        font-size: 1.2rem;
        padding: 15px;
    }
    
    .answer-btn {
        font-size: 1rem;
        padding: 20px 15px;
    }
    
    .question-title {
        font-size: 1.6rem;
    }
    
    .question-subtitle {
        font-size: 1rem;
    }
    
    .question-icon {
        font-size: 2.5rem;
    }
    
    .modal-content {
        padding: 20px;
    }
    
    .modal-content h2 {
        font-size: 1.8rem;
    }
}

/* Ограничение высоты контейнера с теорией */
.theory-content {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px;
    font-weight: 500;
}

/* Стили для скроллбара */
.theory-content::-webkit-scrollbar {
    width: 10px;
}

.theory-content::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 5px;
}

.theory-content::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 5px;
}

.theory-content::-webkit-scrollbar-thumb:hover {
    background: var(--primary-light);
}

/* Убедимся, что основной контейнер вопросов не растягивается слишком сильно */
.question-content {
    min-height: 200px;
    max-height: 500px;
    overflow: hidden;
}

/* Для progress check уровней делаем больше высоту */
.question-area.progress-check .question-content {
    max-height: 600px;
}