/* СЧИТАЙ EMOJI - СТИЛИ ДЛЯ ДОШКОЛЬНИКОВ */

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

body {
    font-family: 'Comic Neue', 'Segoe UI', 'Comic Sans MS', cursive, sans-serif;
    background: linear-gradient(135deg, #FF6B6B 0%, #4ECDC4 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, #FF6B6B 0%, #4ECDC4 100%);
}

.levels-container {
    max-width: 1000px;
    width: 100%;
    background: white;
    border-radius: 35px;
    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: 2.2em;
    color: #FF6B6B;
    margin-bottom: 10px;
}

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

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

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

.settings-panel h3 {
    color: #FF9800;
    margin-bottom: 15px;
}

.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.9em;
    color: #E65100;
    font-weight: 600;
}

.setting-group select {
    padding: 12px;
    border: 2px solid #FFCC80;
    border-radius: 15px;
    font-size: 1em;
    background: white;
    font-family: inherit;
    cursor: pointer;
}

.apply-settings-btn {
    background: linear-gradient(135deg, #FF9800, #F57C00);
    color: white;
    border: none;
    border-radius: 15px;
    padding: 12px 20px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

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

.level-card {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 20px;
    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) scale(1.02);
    box-shadow: 0 15px 30px rgba(0,0,0,0.15);
}

.level-card.completed {
    background: linear-gradient(135deg, #C8E6C9, #A5D6A7);
    border-color: #4CAF50;
}

.level-card.current {
    background: linear-gradient(135deg, #B3E5FC, #81D4FA);
    border-color: #2196F3;
    animation: pulseBorder 2s infinite;
}

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

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

.level-difficulty {
    font-size: 0.8em;
    font-weight: 600;
    color: #FF9800;
    margin: 5px 0;
}

.level-info {
    font-size: 0.7em;
    color: #888;
}

.level-stars {
    margin-top: 8px;
    color: #FFD700;
    font-size: 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: 900px;
    background: white;
    border-radius: 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: 95vh;
    height: 95vh;
}

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

.back-btn {
    background: rgba(255,255,255,0.2);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 10px 15px;
    cursor: pointer;
    font-family: inherit;
}

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

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

.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;
}

.game-board {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.stats-bar {
    display: flex;
    justify-content: space-around;
    background: #FFF3E0;
    padding: 15px;
    border-radius: 25px;
}

.stat {
    text-align: center;
}

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

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

.level-progress-bar-container {
    background: #e9ecef;
    border-radius: 10px;
    height: 8px;
    overflow: hidden;
}

.level-progress-fill {
    background: linear-gradient(90deg, #FF9800, #F57C00);
    height: 100%;
    transition: width 0.3s;
}

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

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

.question-number {
    font-size: 0.9em;
    color: #FF9800;
    background: white;
    padding: 5px 15px;
    border-radius: 20px;
}

.operation-badge {
    font-size: 0.9em;
    background: #FF9800;
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
}

/* Emoji блоки */
.emoji-blocks {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    margin: 20px 0;
}

.emoji-block {
    background: white;
    border-radius: 25px;
    padding: 20px;
    text-align: center;
    min-width: 150px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.block-label {
    font-size: 0.8em;
    color: #888;
    margin-bottom: 10px;
}

.emoji-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
    min-height: 100px;
    max-width: 200px;
    margin: 0 auto;
}

.emoji-item {
    font-size: 2rem;
    animation: bounceIn 0.3s ease;
}

.block-count {
    font-size: 1.3em;
    font-weight: bold;
    color: #FF9800;
    margin-top: 10px;
}

.operation-sign, .equal-sign {
    font-size: 2.5em;
    font-weight: bold;
    color: #FF9800;
}

.answer-block {
    background: white;
    border-radius: 25px;
    padding: 20px;
    text-align: center;
    min-width: 150px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.answer-number {
    width: 100px;
    padding: 15px;
    font-size: 1.5em;
    text-align: center;
    border: 3px solid #FFCC80;
    border-radius: 20px;
    font-family: inherit;
    font-weight: bold;
}

.answer-number:focus {
    outline: none;
    border-color: #FF9800;
    box-shadow: 0 0 0 3px rgba(255, 152, 0, 0.2);
}

.answer-number.active-field {
    border-color: #FF9800;
    background: #FFF8E1;
}

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

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

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

.numpad-btn.backspace,
.numpad-btn.clear {
    background: #FFE0B2;
    color: #E65100;
}

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

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

.message.success {
    background: #C8E6C9;
    color: #2E7D32;
}

.message.error {
    background: #FFCDD2;
    color: #C62828;
}

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

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

.control-btn {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 25px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

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

.skip-btn {
    background: linear-gradient(135deg, #FF9800, #F57C00);
    color: white;
}

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

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

.result-container {
    max-width: 500px;
    width: 100%;
    background: white;
    border-radius: 40px;
    padding: 35px;
    text-align: center;
}

.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: #FFF8E1;
    padding: 15px;
    border-radius: 20px;
}

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

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

.result-buttons button {
    padding: 15px;
    border: none;
    border-radius: 25px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

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

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

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

.timeout-container {
    max-width: 400px;
    width: 100%;
    background: white;
    border-radius: 40px;
    padding: 35px;
    text-align: center;
}

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

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

.timeout-buttons button {
    padding: 14px;
    border: none;
    border-radius: 25px;
    font-weight: 600;
    cursor: pointer;
}

/* Модальное окно */
.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: 30px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

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

.close-modal {
    background: none;
    border: none;
    font-size: 2em;
    cursor: pointer;
    color: #FF9800;
}

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

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

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

/* ПАУЗА */
.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;
}

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

@keyframes bounceIn {
    0% { transform: scale(0); opacity: 0; }
    80% { transform: scale(1.1); }
    100% { transform: scale(1); 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-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    
    .level-number {
        font-size: 1.4em;
    }
    
    .settings-row {
        flex-direction: column;
    }
    
    .emoji-blocks {
        flex-direction: column;
    }
    
    .operation-sign, .equal-sign {
        transform: rotate(90deg);
    }
    
    .emoji-item {
        font-size: 1.5rem;
    }
    
    .numpad-btn {
        padding: 12px;
        font-size: 1.1em;
    }
    
    .controls {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .levels-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .game-header {
        flex-wrap: wrap;
    }
    
    .game-level-info {
        order: 2;
        width: 100%;
        justify-content: space-between;
    }
    
    .back-btn {
        order: 1;
    }
    
    .header-controls {
        order: 3;
    }
    
    .stat-value {
        font-size: 1.2em;
    }
    
    .emoji-item {
        font-size: 1.2rem;
    }
    
    .answer-number {
        width: 80px;
        padding: 12px;
        font-size: 1.2em;
    }
}

.continue-btn, .home-btn {
    padding: 22px;
    margin: 22px;
    border: none;
    border-radius: 25px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    font-family: inherit;
}

.continue-btn {
    background: linear-gradient(135deg, #FF9800, #F57C00);
    color: white;
}

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