/* =========================================
   БЁРЧИ | PREMIUM SNAKE FULLSCREEN ENGINE
   ВЕРСИЯ: 13.0 | NEXT-GEN IMMERSIVE DESIGN 2026 🐍✨
   ========================================= */

#snake-game-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* Динамический вьюпорт для мобильных браузеров */
    background: radial-gradient(circle at 50% 30%, #12131a 0%, #050508 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100001;
    color: #fff;
    font-family: 'Inter', sans-serif;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none; /* Запрет скролла и зума системными жестами */
    box-sizing: border-box;
    padding: env(safe-area-inset-top, 20px) env(safe-area-inset-right, 20px) env(safe-area-inset-bottom, 20px) env(safe-area-inset-left, 20px);
}

/* Парящая верхняя панель */
.snake-header {
    position: absolute;
    top: calc(env(safe-area-inset-top, 20px) + 10px);
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    pointer-events: none; /* Пропускаем клики мимо кнопок */
}

.snake-score-box {
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 10px 20px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.snake-score-label {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 800;
    margin-bottom: 2px;
}

.snake-score-value {
    font-size: 32px;
    font-weight: 900;
    color: #00e676;
    text-shadow: 0 0 20px rgba(0, 230, 118, 0.6);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.snake-close-btn {
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    width: 50px;
    height: 50px;
    border-radius: 25px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.snake-close-btn:active {
    transform: scale(0.9) rotate(90deg);
    background: rgba(255, 82, 82, 0.2);
    border-color: rgba(255, 82, 82, 0.4);
    color: #ff5252;
}

/* Центральная зона с полем */
.snake-main-area {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    pointer-events: none;
}

/* Игровое поле: Идеальный квадрат 20x20 */
.snake-board {
    display: grid;
    grid-template-columns: repeat(20, 1fr);
    grid-template-rows: repeat(20, 1fr);
    gap: 1px; /* Тонкая технологичная сетка */
    background: rgba(2, 3, 6, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 4px;
    box-shadow: 0 30px 100px rgba(0,0,0,0.8), inset 0 0 40px rgba(0,0,0,0.9);
    width: 90vw;
    height: 90vw; /* Строгий квадрат */
    max-width: 450px;
    max-height: 450px;
    box-sizing: border-box;
}

/* Клетки */
.snake-cell {
    width: 100%;
    height: 100%;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.02);
    transition: background-color 0.08s ease, box-shadow 0.08s ease, transform 0.08s ease;
    position: relative;
}

/* Неоновое тело Змейки */
.snake-cell.body {
    background: #00e676;
    box-shadow: 0 0 12px rgba(0, 230, 118, 0.8), inset 0 0 4px rgba(255,255,255,0.4);
    transform: scale(0.95); /* Легкий отступ между сегментами */
    border-radius: 4px;
    z-index: 2;
}

/* Свечение Головы Змейки */
.snake-cell.head {
    background: #b2ff59;
    box-shadow: 0 0 20px rgba(178, 255, 89, 1), inset 0 0 6px rgba(255,255,255,0.8);
    transform: scale(1.1);
    border-radius: 6px;
    z-index: 3;
}

/* Пульсирующая еда (Яблоко) */
.snake-cell.food {
    background: #ff1744;
    box-shadow: 0 0 20px rgba(255, 23, 68, 0.9), inset 0 0 6px rgba(255,255,255,0.6);
    border-radius: 50%;
    transform: scale(1.1);
    animation: snakeFoodPulse 1s infinite alternate cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
}

@keyframes snakeFoodPulse {
    0% { transform: scale(0.85); box-shadow: 0 0 10px rgba(255, 23, 68, 0.6); }
    100% { transform: scale(1.15); box-shadow: 0 0 25px rgba(255, 23, 68, 1); }
}

/* Экран смерти */
.snake-game-over {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(5, 5, 8, 0.92);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    z-index: 200;
}

.snake-game-over.active {
    opacity: 1;
    pointer-events: auto;
}

.snake-game-over h2 {
    color: #ff1744;
    font-size: 38px;
    font-weight: 900;
    margin: 0 0 8px 0;
    text-shadow: 0 0 30px rgba(255, 23, 68, 0.7);
    text-transform: uppercase;
    letter-spacing: 3px;
    text-align: center;
}

.snake-game-over p {
    color: rgba(255, 255, 255, 0.6);
    font-size: 18px;
    margin-bottom: 35px;
    font-weight: 500;
}

.snake-restart-btn {
    background: linear-gradient(135deg, #00e676 0%, #b2ff59 100%);
    color: #111;
    border: none;
    padding: 16px 40px;
    border-radius: 24px;
    font-weight: 900;
    font-size: 16px;
    cursor: pointer;
    box-shadow: 0 15px 30px rgba(0, 230, 118, 0.4);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.snake-restart-btn:hover, .snake-restart-btn:active {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 20px 40px rgba(0, 230, 118, 0.6);
}

/* Скрываем старые экранные кнопки для чистого геймплея */
.snake-controls {
    display: none !important;
}

/* Слой трекинга свайпов на весь экран */
.snake-gesture-layer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 50;
    pointer-events: auto;
}