/* =========================================
   БЁРЧИ | PREMIUM TETRIS FULLSCREEN ENGINE
   ВЕРСИЯ: 13.0 | NEXT-GEN IMMERSIVE DESIGN 2026 🎛️⚡
   ========================================= */

#tetris-game-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* Поддержка динамического мобильного вьюпорта 2026 */
    background: radial-gradient(circle at 50% 30%, #12131a 0%, #050508 100%);
    display: block;
    z-index: 100001;
    color: #fff;
    font-family: 'Inter', sans-serif;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none; /* Блокируем системный скролл и лупу браузера */
    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);
    box-sizing: border-box;
}

/* Топовая панель управления (Интерфейс парит над игрой) */
.tetris-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; /* Пропускаем тапы сквозь шапку, кроме кнопок */
}

.tetris-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);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

.tetris-score-value {
    font-size: 32px;
    font-weight: 900;
    color: #00e5ff;
    text-shadow: 0 0 20px rgba(0, 229, 255, 0.6);
    line-height: 1;
    font-variant-numeric: tabular-nums; /* Фиксированная ширина цифр чтобы не прыгал интерфейс */
}

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

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

/* Центральная игровая зона (Занимает всё доступное пространство) */
.tetris-main-area {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* Стакан Тетриса: Идеальные пропорции 1:2, растягивается по вертикали мобилки */
.tetris-board {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(20, 1fr);
    gap: 2px;
    background: rgba(2, 3, 6, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.05);
    border-radius: 24px;
    padding: 6px;
    box-shadow: 0 30px 100px rgba(0,0,0,0.8), inset 0 0 40px rgba(0,0,0,0.9);
    width: 88vw;
    height: 76vh;
    height: 76dvh;
    max-width: 420px; /* Ограничение для планшетов и ПК */
    max-height: 840px;
    box-sizing: border-box;
    position: relative;
}

/* Игровые пиксели / Ячейки стакана */
.tetris-cell {
    width: 100%;
    height: 100%;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.01);
    box-sizing: border-box;
    transition: background-color 0.1s ease, box-shadow 0.1s ease;
    position: relative;
}

/* Премиальная 3D-Неоновая стилизация блоков в стиле Бёрчи 2026 */
.tetris-cell[class*="type-"]::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px; right: 2px; bottom: 2px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    pointer-events: none;
}

.tetris-cell.type-I { background: #00e5ff; box-shadow: 0 0 14px rgba(0, 229, 255, 0.6), inset 0 -4px 0 rgba(0,0,0,0.2); }
.tetris-cell.type-J { background: #2979ff; box-shadow: 0 0 14px rgba(41, 121, 255, 0.6), inset 0 -4px 0 rgba(0,0,0,0.2); }
.tetris-cell.type-L { background: #ff9100; box-shadow: 0 0 14px rgba(255, 145, 0, 0.6), inset 0 -4px 0 rgba(0,0,0,0.2); }
.tetris-cell.type-O { background: #ffea00; box-shadow: 0 0 14px rgba(255, 234, 0, 0.6), inset 0 -4px 0 rgba(0,0,0,0.2); }
.tetris-cell.type-S { background: #00e676; box-shadow: 0 0 14px rgba(0, 230, 118, 0.6), inset 0 -4px 0 rgba(0,0,0,0.2); }
.tetris-cell.type-Z { background: #ff1744; box-shadow: 0 0 14px rgba(255, 23, 68, 0.6), inset 0 -4px 0 rgba(0,0,0,0.2); }
.tetris-cell.type-T { background: #d500f9; box-shadow: 0 0 14px rgba(213, 0, 249, 0.6), inset 0 -4px 0 rgba(0,0,0,0.2); }

/* Высокотехнологичный прозрачный Призрак (Тень падения) */
.tetris-cell.type-ghost { 
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed rgba(255, 255, 255, 0.25);
    box-shadow: inset 0 0 8px rgba(255,255,255,0.05);
}

/* Экран жесткого поражения (Смерть) */
.tetris-game-over {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(5, 5, 8, 0.92);
    border-radius: 24px;
    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;
}

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

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

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

.tetris-restart-btn {
    background: linear-gradient(135deg, #00e5ff 0%, #2979ff 100%);
    color: #fff;
    border: none;
    padding: 16px 40px;
    border-radius: 24px;
    font-weight: 800;
    font-size: 16px;
    cursor: pointer;
    box-shadow: 0 15px 30px rgba(0, 229, 255, 0.3);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.tetris-restart-btn:hover, .tetris-restart-btn:active {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 20px 40px rgba(0, 229, 255, 0.5);
}

/* Старый блок кнопок ПОЛНОСТЬЮ Скрыт во имя чистоты 2026 года */
.tetris-controls {
    display: none !important;
}

/* Невидимая сетка-пад для тактильного фидбека жестов на мобилках */
.tetris-gesture-layer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 50;
    pointer-events: auto;
}