/* МАТЕМАТИЧЕСКИЙ ТРЕНАЖЕР - ОСНОВНЫЕ СТИЛИ */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow: hidden;
}

/* ЭКРАННАЯ СИСТЕМА */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    overflow-y: auto;
}

.screen.active {
    opacity: 1;
    visibility: visible;
    z-index: 10;
}

/* ЭКРАН ВЫБОРА УРОВНЯ */
.levels-screen {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.levels-container {
    max-width: 1000px;
    width: 100%;
    background: white;
    border-radius: 25px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: slideUp 0.5s ease;
    max-height: 95vh;
    overflow-y: auto;
}

.levels-header {
    text-align: center;
    margin-bottom: 25px;
}

.levels-header h1 {
    font-size: 2em;
    color: #333;
    margin-bottom: 10px;
}

.levels-header p {
    color: #666;
    margin-bottom: 15px;
}

.level-progress {
    background: #e9ecef;
    border-radius: 20px;
    height: 10px;
    overflow: hidden;
    margin: 15px 0;
}

.level-progress-bar {
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    height: 100%;
    border-radius: 20px;
    transition: width 0.3s;
}

/* Панель настроек */
.settings-panel {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 20px;
    padding: 20px;
    margin: 20px 0;
    border: 2px solid #dee2e6;
}

.settings-panel h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.settings-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
    min-width: 120px;
}

.setting-group label {
    font-size: 0.85em;
    color: #666;
    font-weight: 500;
}

.setting-group select,
.setting-group input {
    padding: 10px 12px;
    border: 2px solid #dee2e6;
    border-radius: 12px;
    font-size: 1em;
    background: white;
    transition: all 0.2s;
}

.setting-group select:focus,
.setting-group input:focus {
    outline: none;
    border-color: #4CAF50;
}

.apply-settings-btn {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 10px 20px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    height: 44px;
}

.apply-settings-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.3);
}

.settings-warning {
    margin-top: 10px;
    font-size: 0.8em;
    color: #f44336;
    display: none;
}

/* Сетка уровней */
.levels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    margin: 25px 0;
}

.level-card {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 15px 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    border: 3px solid transparent;
    position: relative;
}

.level-card:hover:not(.locked) {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    background: white;
    border-color: #4CAF50;
}

.level-card.completed {
    background: #e8f5e9;
    border-color: #4CAF50;
}

.level-card.current {
    background: #e3f2fd;
    border-color: #2196F3;
    animation: pulseBorder 2s infinite;
}

.level-card.locked {
    background: #f5f5f5;
    cursor: not-allowed;
    opacity: 0.6;
}

.level-card.locked:hover {
    transform: none;
}

.level-number {
    font-size: 1.8em;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.level-difficulty {
    font-size: 0.85em;
    font-weight: 600;
    color: #4CAF50;
    margin-bottom: 5px;
}

.level-info {
    font-size: 0.75em;
    color: #888;
    margin: 2px 0;
}

.level-stars {
    margin-top: 8px;
    color: #FFD700;
    font-size: 1.1em;
}

.lock-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.9em;
}

/* ЭКРАН ИГРЫ */
.game-screen {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.game-container {
    width: 100%;
    max-width: 800px;
    background: white;
    border-radius: 30px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeIn 0.4s ease;
    max-height: 95vh;
    height: 95vh;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    flex-shrink: 0;
}

.back-btn {
    background: rgba(255,255,255,0.2);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 10px 15px;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s;
}

.back-btn:hover {
    background: rgba(255,255,255,0.3);
}

.game-level-info {
    display: flex;
    gap: 15px;
    align-items: center;
}

.level-badge {
    background: rgba(255,255,255,0.2);
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 500;
}

.timer-display {
    background: rgba(255,255,255,0.2);
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 600;
}

.header-controls {
    display: flex;
    gap: 10px;
}

.rules-btn, .pause-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 10px;
    width: 45px;
    height: 45px;
    font-size: 1.3em;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rules-btn:hover, .pause-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.05);
}

/* Игровое поле */
.game-board {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Статистика */
.stats-bar {
    display: flex;
    justify-content: space-around;
    gap: 10px;
    flex-wrap: wrap;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 20px;
}

.stat {
    text-align: center;
    flex: 1;
}

.stat-label {
    font-size: 0.75em;
    color: #888;
    display: block;
}

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

/* Прогресс уровня */
.level-progress-bar-container {
    background: #e9ecef;
    border-radius: 10px;
    height: 8px;
    overflow: hidden;
}

.level-progress-fill {
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    height: 100%;
    width: 0%;
    transition: width 0.3s;
    border-radius: 10px;
}

/* Карточка вопроса */
.question-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 30px;
    padding: 25px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.question-number {
    font-size: 0.9em;
    color: #888;
    margin-bottom: 15px;
    display: inline-block;
    background: white;
    padding: 5px 15px;
    border-radius: 20px;
}

.math-expression {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 15px;
    font-size: 2.5em;
    font-weight: bold;
    color: #333;
    margin: 20px 0;
}

.math-expression span {
    font-size: 1em;
}

#answerInput {
    font-size: 1em;
    width: 150px;
    padding: 10px 15px;
    text-align: center;
    border: 3px solid #dee2e6;
    border-radius: 15px;
    background: white;
    font-weight: bold;
}

#answerInput:focus {
    outline: none;
    border-color: #4CAF50;
}

/* Нумпад */
.numpad {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-top: 25px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

.numpad-btn {
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 12px;
    padding: 15px;
    font-size: 1.3em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.1s;
}

.numpad-btn:active {
    transform: scale(0.95);
    background: #e9ecef;
}

.numpad-btn.backspace,
.numpad-btn.clear {
    background: #f8f9fa;
    color: #f44336;
}

/* Сообщения */
.message {
    text-align: center;
    padding: 12px;
    border-radius: 12px;
    font-weight: 500;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s;
}

.message.show {
    opacity: 1;
    transform: translateY(0);
}

.message.success {
    background: #d4edda;
    color: #155724;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
}

.message.warning {
    background: #fff3cd;
    color: #856404;
}

/* Кнопки управления */
.controls {
    display: flex;
    gap: 12px;
    padding: 20px;
    background: #f8f9fa;
    border-top: 2px solid #e9ecef;
    flex-wrap: wrap;
}

.control-btn {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 12px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.check-btn {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
}

.check-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.3);
}

.skip-btn {
    background: #ff9800;
    color: white;
}

.skip-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 152, 0, 0.3);
}

.restart-level-btn {
    background: #6c757d;
    color: white;
}

.restart-level-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(108, 117, 125, 0.3);
}

/* ЭКРАН РЕЗУЛЬТАТОВ */
.result-screen {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
}

.result-container {
    max-width: 500px;
    width: 100%;
    background: white;
    border-radius: 30px;
    padding: 35px;
    text-align: center;
    animation: slideUp 0.4s ease;
}

.result-header h1 {
    font-size: 1.8em;
    color: #333;
    margin-bottom: 15px;
}

.result-stars {
    font-size: 2.5em;
    color: #FFD700;
    margin: 15px 0;
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin: 25px 0;
}

.result-stat {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 15px;
}

.result-icon {
    font-size: 1.5em;
    display: block;
    margin-bottom: 5px;
}

.result-value {
    font-size: 1.8em;
    font-weight: bold;
    color: #333;
    display: block;
}

.result-label {
    font-size: 0.8em;
    color: #888;
}

.result-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

.result-buttons button {
    padding: 15px;
    border: none;
    border-radius: 15px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.next-level-btn {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
}

.levels-btn {
    background: #f8f9fa;
    color: #333;
    border: 2px solid #dee2e6;
}

.restart-btn {
    background: #ff9800;
    color: white;
}

.result-buttons button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

/* ЭКРАН ВРЕМЯ ВЫШЛО */
.timeout-screen {
    background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
}

.timeout-container {
    max-width: 400px;
    width: 100%;
    background: white;
    border-radius: 30px;
    padding: 35px;
    text-align: center;
    animation: slideUp 0.4s ease;
}

.timeout-icon {
    font-size: 4em;
    margin-bottom: 20px;
}

.timeout-container h1 {
    font-size: 1.8em;
    color: #333;
    margin-bottom: 10px;
}

.timeout-container p {
    color: #666;
    margin-bottom: 30px;
}

.timeout-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.timeout-buttons button {
    padding: 14px;
    border: none;
    border-radius: 15px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.timeout-buttons .restart-level-btn {
    background: #ff9800;
    color: white;
}

.timeout-buttons .levels-btn {
    background: #f8f9fa;
    color: #333;
    border: 2px solid #dee2e6;
}

/* МОДАЛЬНОЕ ОКНО */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: white;
    border-radius: 25px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideIn 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 2px solid #e9ecef;
}

.modal-title {
    font-size: 1.3em;
    font-weight: bold;
    color: #333;
}

.close-modal {
    background: none;
    border: none;
    font-size: 2em;
    cursor: pointer;
    color: #999;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rules-content {
    padding: 20px;
    line-height: 1.6;
}

.rules-content h3 {
    color: #4CAF50;
    margin: 15px 0 10px;
}

.rules-content ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

.rules-content li {
    margin: 5px 0;
}

.tips {
    background: #e8f5e9;
    padding: 15px;
    border-radius: 15px;
    margin-top: 15px;
}

.tips h3 {
    margin-top: 0;
    color: #2e7d32;
}

/* ПАУЗА */
.paused-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1100;
    cursor: pointer;
}

.paused-text {
    color: white;
    font-size: 2em;
    text-align: center;
    background: rgba(0,0,0,0.7);
    padding: 40px;
    border-radius: 30px;
    border: 3px solid rgba(255,255,255,0.3);
}

/* АНИМАЦИИ */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes pulseBorder {
    0%, 100% { border-color: #2196F3; }
    50% { border-color: #64B5F6; }
}

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

.shake {
    animation: shake 0.3s ease;
}

/* АДАПТАЦИЯ */
@media (max-width: 768px) {
    .levels-container {
        padding: 20px;
    }
    
    .levels-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }
    
    .level-card {
        padding: 12px 5px;
    }
    
    .level-number {
        font-size: 1.5em;
    }
    
    .settings-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .setting-group {
        min-width: auto;
    }
    
    .apply-settings-btn {
        margin-top: 10px;
    }
    
    .math-expression {
        font-size: 1.8em;
        gap: 10px;
    }
    
    #answerInput {
        width: 120px;
        font-size: 0.8em;
    }
    
    .numpad {
        gap: 8px;
    }
    
    .numpad-btn {
        padding: 12px;
        font-size: 1.1em;
    }
    
    .controls {
        flex-direction: column;
    }
    
    .control-btn {
        padding: 12px;
    }
    
    .result-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .levels-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .game-header {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .game-level-info {
        order: 2;
        width: 100%;
        justify-content: space-between;
    }
    
    .back-btn {
        order: 1;
    }
    
    .header-controls {
        order: 3;
    }
    
    .stats-bar {
        gap: 5px;
    }
    
    .stat-value {
        font-size: 1.2em;
    }
    
    .math-expression {
        font-size: 1.3em;
        flex-direction: column;
        gap: 10px;
    }
    
    .question-card {
        padding: 20px 15px;
    }
    
    .numpad {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
    }
    
    .numpad-btn {
        padding: 10px;
        font-size: 1em;
    }
    
    .result-container {
        padding: 25px;
    }
    
    .result-value {
        font-size: 1.5em;
    }
}
.continue-btn,.home-btn
{
	padding:22px;
	margin:22px;
}
/* Стили для скролла */
.levels-container::-webkit-scrollbar,
.game-board::-webkit-scrollbar,
.modal::-webkit-scrollbar {
    width: 6px;
}

.levels-container::-webkit-scrollbar-track,
.game-board::-webkit-scrollbar-track,
.modal::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.levels-container::-webkit-scrollbar-thumb,
.game-board::-webkit-scrollbar-thumb,
.modal::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}