/* СТИЛИ ДЛЯ ИГРЫ ЛАБИРИНТ */

/* Экран выбора уровня */
.levels-screen {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

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

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

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

.levels-header p {
    font-size: 1.1em;
    color: #666;
    margin: 5px 0;
}

/* Сетка уровней */
.levels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 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;
    box-sizing: border-box;
    min-height: 110px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.level-card:hover {
    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: pulse 2s infinite;
}

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

.level-card.locked:hover {
    transform: none;
    box-shadow: none;
    border-color: transparent;
}

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

.level-difficulty {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 3px;
}

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

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

.lock-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    color: #999;
}

/* Экран лабиринта */
.maze-screen {
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.maze-container {
    width: 100%;
    height: 100%;
    max-width: 1000px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 15px 50px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
}

/* Шапка лабиринта */
.maze-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #2196F3, #1976D2);
    color: white;
    flex-shrink: 0;
    box-sizing: border-box;
    min-height: 70px;
}

.maze-level-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.maze-level-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9em;
}

.maze-timer {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.9em;
}

/* Игровое поле лабиринта */
.maze-game-board {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px;
    box-sizing: border-box;
    width: 100%;
    overflow: hidden;
    min-height: 0;
}

.maze-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    min-height: 0;
    max-height: 100%;
}

.maze-grid {
    display: grid;
    gap: 1px;
    background: #333;
    border: 2px solid #333;
    border-radius: 4px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    width: auto !important;
    height: auto !important;
    overflow: hidden;
    margin: auto;
}

.cell {
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: background-color 0.2s;
    font-size: 0;
    line-height: 1;
}

.cell.wall {
    background: #333;
}

.cell.path {
    background: white;
}

.cell.start {
    background: #4CAF50 !important;
    animation: pulse 2s infinite;
}

.cell.end {
    background: #FF9800 !important;
    animation: pulse 2s infinite;
}

.cell.player {
    background: #2196F3 !important;
    z-index: 2;
    position: relative;
}

.cell.visited {
        background: linear-gradient(135deg, #FF5722, #FFC107) !important;
}

.cell.hint {
    background: #FFF9C4 !important;
    animation: pulse 1s infinite;
}

.cell .emoji {
    font-size: 70%;
    line-height: 1;
    z-index: 3;
    position: relative;
}

/* Информационная панель */
.maze-info {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 15px 20px;
    background: #f8f9fa;
    border-top: 2px solid #e9ecef;
    flex-shrink: 0;
    box-sizing: border-box;
    min-height: 150px;
}

.stats-panel {
    display: flex;
    justify-content: space-around;
    gap: 15px;
}

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

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

.stat-label {
    font-size: 0.85em;
    color: #666;
    display: block;
}

/* Управление */
.controls-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 100%;
}

.touch-controls {
    display: none;
    grid-template-columns: repeat(3, 60px);
    grid-template-rows: repeat(3, 60px);
    gap: 8px;
    margin: 15px 0;
    justify-content: center;
}

.touch-btn {
    background: linear-gradient(135deg, #2196F3, #1976D2);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.6em;
    cursor: pointer;
    display: flex;
	padding-bottom:7px;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 4px 8px rgba(33, 150, 243, 0.3);
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    width: 60px;
    height: 40px;
}

.touch-btn:active {
    transform: scale(0.9);
    box-shadow: 0 2px 4px rgba(33, 150, 243, 0.5);
}

.touch-btn.up { 
    grid-column: 2; 
    grid-row: 1; 
    background: linear-gradient(135deg, #4CAF50, #388E3C);
}

.touch-btn.down { 
    grid-column: 2; 
    grid-row: 3; 
    background: linear-gradient(135deg, #4CAF50, #388E3C);
}

.touch-btn.left { 
    grid-column: 1; 
    grid-row: 2; 
    background: linear-gradient(135deg, #FF9800, #F57C00);
}

.touch-btn.right { 
    grid-column: 3; 
    grid-row: 2; 
    background: linear-gradient(135deg, #FF9800, #F57C00);
}

/* Кнопки действий */
.action-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

.action-btn {
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: 1;
    min-width: 120px;
    box-sizing: border-box;
}

.hint-btn {
    background: #FFC107;
    color: #333;
}

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

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

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

/* Модальное окно правил */
.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: 15px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: slideIn 0.3s ease;
}

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

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

.close-modal {
    background: none;
    border: none;
    font-size: 2em;
    cursor: pointer;
    color: #666;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* Оверлей паузы */
.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: 999;
}

.paused-text {
    color: white;
    font-size: 2em;
    text-align: center;
    animation: pulse 2s infinite;
}

/* Экран победы и время вышло */
.victory-overlay,
.time-expired-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1100;
    padding: 20px;
    box-sizing: border-box;
}

.victory-content,
.time-expired-content {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    padding: 25px;
    border-radius: 15px;
    text-align: center;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 15px 40px rgba(0,0,0,0.4);
    border: 2px solid rgba(255,255,255,0.2);
    box-sizing: border-box;
}

.time-expired-content {
    background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
}

.victory-icon,
.time-expired-icon {
    font-size: 4em;
    margin-bottom: 15px;
}

.victory-title,
.time-expired-title {
    font-size: 1.8em;
    margin-bottom: 15px;
}

.victory-message,
.time-expired-message {
    font-size: 1.1em;
    margin-bottom: 20px;
    line-height: 1.5;
}

.victory-stats {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 10px;
    margin: 15px 0;
}

.victory-stats-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 1em;
}

.victory-stars {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 20px 0;
    font-size: 2em;
}

.victory-star {
    color: #FFD700;
}

.victory-buttons,
.time-expired-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.next-level-btn,
.levels-btn,
.continue-btn,
.back-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    background: white;
    color: #333;
    text-align: center;
}

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

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

.back-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.next-level-btn:hover,
.continue-btn:hover,
.back-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

/* Адаптивные стили для лабиринта */
@media (max-width: 768px) {
    .levels-container {
        padding: 20px;
    }
    
    .levels-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }
    
    .level-card {
        padding: 12px 6px;
        min-height: 95px;
    }
    
    .level-number {
        font-size: 1.6em;
    }
    
    .maze-header {
        padding: 12px 15px;
        flex-direction: column;
        gap: 12px;
    }
    
    .maze-level-info {
        width: 100%;
        justify-content: space-between;
    }
    
    .touch-controls {
        display: grid;
        grid-template-columns: repeat(3, 55px);
        grid-template-rows: repeat(3, 55px);
        gap: 6px;
    }
    
    .touch-btn {
        font-size: 1.4em;
        border-radius: 10px;
    }
    
    .action-btn {
        font-size: 0.85em;
        padding: 8px 12px;
        min-width: 100px;
    }
    
    .stat-value {
        font-size: 1.2em;
    }
    
    .victory-content,
    .time-expired-content {
        padding: 20px;
        margin: 15px;
    }
    
    .maze-info {
        min-height: 130px;
        padding: 12px 15px;
    }
}

@media (max-width: 480px) {
    .levels-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .maze-game-board {
        padding: 10px;
    }
    
    .touch-controls {
        grid-template-columns: repeat(3, 50px);
        grid-template-rows: repeat(3, 50px);
    }
    
    .touch-btn {
        font-size: 1.3em;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .action-btn {
        min-width: 100%;
    }
    
    .victory-content,
    .time-expired-content {
        padding: 15px;
        margin: 10px;
    }
    
    .victory-stars {
        font-size: 1.6em;
        gap: 10px;
    }
    
    .maze-info {
        min-height: 120px;
        padding: 10px 12px;
    }
}

/* Динамические размеры для разных уровней */
.level-1 .cell { min-width: 40px; min-height: 40px; }
.level-2 .cell { min-width: 35px; min-height: 35px; }
.level-3 .cell { min-width: 30px; min-height: 30px; }
.level-4 .cell { min-width: 28px; min-height: 28px; }
.level-5 .cell { min-width: 25px; min-height: 25px; }
.level-6 .cell { min-width: 22px; min-height: 22px; }
.level-7 .cell { min-width: 20px; min-height: 20px; }
.level-8 .cell { min-width: 18px; min-height: 18px; }
.level-9 .cell { min-width: 16px; min-height: 16px; }
.level-10 .cell { min-width: 14px; min-height: 14px; }

@media (max-width: 768px) {
    .level-1 .cell { min-width: 35px; min-height: 35px; }
    .level-2 .cell { min-width: 30px; min-height: 30px; }
    .level-3 .cell { min-width: 25px; min-height: 25px; }
    .level-4 .cell { min-width: 22px; min-height: 22px; }
    .level-5 .cell { min-width: 20px; min-height: 20px; }
    .level-6 .cell { min-width: 18px; min-height: 18px; }
    .level-7 .cell { min-width: 16px; min-height: 16px; }
    .level-8 .cell { min-width: 14px; min-height: 14px; }
    .level-9 .cell { min-width: 12px; min-height: 12px; }
    .level-10 .cell { min-width: 10px; min-height: 10px; }
}

/* Анимации */
@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Скрытие экранов */
.screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.screen.active {
    display: flex;
    justify-content: center;
    align-items: center;
}
