/* --- СТИЛИ СПЕЦИАЛЬНО ДЛЯ ИГРЫ ТЕТРИС --- */

body {
    overflow: hidden;
}

.tetris-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 1rem;
    animation: fadeInScale 0.8s 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
}

.tetris-header {
    width: 100%;
    max-width: 500px;
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1rem;
}

.back-button {
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    color: var(--accent-color-1);
    padding: 0.5rem;
    transition: color 0.2s;
}
.back-button:hover {
    color: var(--text-color);
}

.game-area {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

#gameCanvas {
    background-color: #000;
    border: 2px solid var(--glass-border);
    border-radius: 10px;
}

.side-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 140px;
}

.info-box {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
}

.info-box p {
    font-size: 0.9rem;
    font-weight: 500;
    color: rgba(226, 232, 240, 0.7);
    margin-bottom: 0.5rem;
}

#score {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-color);
}

#nextCanvas {
    background-color: #000;
    border-radius: 5px;
}

/* ОВЕРЛЕЙ */
.overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center; justify-content: center;
    backdrop-filter: blur(5px);
}
.overlay-content { text-align: center; }
.overlay-content h2 { font-size: 2.5rem; margin-bottom: 1rem; }
.overlay-content p { font-size: 1.2rem; margin-bottom: 1.5rem; }


/* --- НОВЫЙ МОБИЛЬНЫЙ ИНТЕРФЕЙС "ГЕЙМПАД" --- */

/* Стили по умолчанию (для десктопа) */
.touch-controls-tetris {
    display: none; 
}

/* Стили начинают работать на экранах шириной 768px и меньше */
@media (max-width: 768px) {
    .tetris-wrapper {
        justify-content: flex-start; /* Убираем растягивание по высоте */
        padding-bottom: 1rem;
    }

    .game-area {
        flex-direction: column-reverse;
        align-items: center;
        gap: 0.5rem;
    }

    #gameCanvas {
        width: 100%;
        max-width: 270px;
        height: auto;
    }

    .side-panel {
        flex-direction: row;
        width: 100%;
        max-width: 270px;
        gap: 0.5rem;
    }
    
    .info-box {
        width: 50%;
        padding: 0.5rem;
    }

    .info-box p { font-size: 0.8rem; }
    #score { font-size: 1.5rem; }
    #nextCanvas { width: 100%; max-width: 100px; height: auto; aspect-ratio: 1/1; }

    /* Отображаем и стилизуем кнопки управления */
    .touch-controls-tetris {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        max-width: 400px;
        margin-top: 1rem; /* Отступ от игрового поля */
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }
    
    .control-btn {
        background: var(--glass-bg);
        border: 1px solid var(--glass-border);
        color: var(--text-color);
        font-weight: 700;
        transition: all 0.2s;
    }
    .control-btn:active {
        background: rgba(147, 51, 234, 0.2);
        transform: scale(0.95);
    }

    /* Крестовина (D-Pad) */
    .d-pad {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
    }
    .d-pad-row {
        display: flex;
        gap: 4px;
    }
    .d-pad .control-btn {
        width: 60px;
        height: 50px;
        border-radius: 10px;
        font-size: 1.5rem;
    }
    .d-pad-down {
        width: 124px; /* Ширина двух кнопок + отступ */
    }

    /* Кнопки действий */
    .action-buttons {
        display: flex;
        gap: 10px;
        align-items: center;
    }
    .action-btn {
        width: 75px;
        height: 75px;
        border-radius: 50%;
        font-size: 1rem;
    }
    .rotate-btn {
        font-size: 2.2rem;
    }
}