/* Базовые стили контейнера */
.tetris-container {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    background: #2c3e50;
    border-radius: 12px;
    padding: 12px;
    box-sizing: border-box;
    font-family: 'Arial', sans-serif;
    color: #ecf0f1;
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

/* Полноэкранный оверлей */
.tetris-fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #2c3e50;
    z-index: 100000;
    display: none;
    flex-direction: column;
    padding: 10px;
    box-sizing: border-box;
}

.tetris-fullscreen-overlay.active {
    display: flex;
}

.tetris-fullscreen-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

.tetris-fullscreen-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    margin-bottom: 10px;
    border-bottom: 2px solid #34495e;
}

.tetris-fullscreen-title {
    color: #e74c3c;
    margin: 0;
    font-size: 22px;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.tetris-fullscreen-scores {
    display: flex;
    gap: 12px;
}

.tetris-fullscreen-close {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tetris-fullscreen-close:hover {
    background: #c0392b;
}

.tetris-fullscreen-game-area {
    display: flex;
    flex: 1;
    gap: 12px;
    margin-bottom: 10px;
    min-height: 0;
}

.tetris-fullscreen-main {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

#tetris-fullscreen-canvas {
    background: #1a252f;
    border: 3px solid #34495e;
    border-radius: 6px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
    max-width: 100%;
    max-height: 100%;
}

.tetris-fullscreen-sidebar {
    width: 140px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tetris-fullscreen-next {
    text-align: center;
    background: #34495e;
    padding: 10px;
    border-radius: 6px;
}

.tetris-fullscreen-controls {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tetris-exit-fullscreen-btn {
    background: #e74c3c !important;
    margin-top: 6px;
}

.tetris-exit-fullscreen-btn:hover {
    background: #c0392b !important;
}

/* Область для сенсорного управления */
.tetris-touch-area {
    position: relative;
    display: inline-block;
}

.tetris-touch-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    touch-action: none;
}

/* Подсказки сенсорного управления */
.tetris-touch-help {
    display: none;
    text-align: center;
    margin: 8px 0 4px;
}

.tetris-touch-hint {
    background: #34495e;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    color: #bdc3c7;
}

.tetris-fullscreen-touch-help {
    display: none;
    text-align: center;
    margin-top: 8px;
}

/* Заголовок и информация */
.tetris-game-header {
    text-align: center;
    margin-bottom: 10px;
}

.tetris-title {
    color: #e74c3c;
    margin: 0 0 6px 0;
    font-size: 20px;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.tetris-score-board {
    display: flex;
    justify-content: space-around;
    background: #34495e;
    padding: 6px;
    border-radius: 6px;
    margin-bottom: 10px;
}

.tetris-score-item {
    text-align: center;
}

.tetris-label {
    display: block;
    font-size: 10px;
    color: #bdc3c7;
    margin-bottom: 2px;
}

.tetris-value {
    display: block;
    font-size: 14px;
    font-weight: bold;
    color: #f39c12;
}

/* Игровая область - компактная версия */
.tetris-game-area {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: flex-start;
}

.tetris-side-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 90px;
}

#tetris-game-canvas {
    background: #1a252f;
    border: 2px solid #34495e;
    border-radius: 6px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
    max-width: 100%;
}

.tetris-next-piece {
    text-align: center;
    background: #34495e;
    padding: 6px;
    border-radius: 6px;
}

#tetris-next-canvas {
    background: #1a252f;
    border: 1px solid #7f8c8d;
    border-radius: 4px;
    margin-top: 4px;
}

/* Компактные кнопки управления */
.tetris-controls-compact {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.tetris-controls-row {
    display: flex;
    gap: 5px;
}

.tetris-btn {
    padding: 8px 6px;
    border: none;
    border-radius: 5px;
    font-size: 10px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex: 1;
    min-width: 0;
}

.tetris-start-btn {
    background: #27ae60;
    color: white;
}

.tetris-start-btn:hover {
    background: #219a52;
}

.tetris-pause-btn {
    background: #f39c12;
    color: white;
}

.tetris-pause-btn:hover {
    background: #e67e22;
}

.tetris-reset-btn {
    background: #e74c3c;
    color: white;
}

.tetris-reset-btn:hover {
    background: #c0392b;
}

.tetris-fullscreen-btn {
    background: #3498db;
    color: white;
    font-size: 12px;
    padding: 8px 6px;
}

.tetris-fullscreen-btn:hover {
    background: #2980b9;
}

/* Кнопки поделиться */
.tetris-share-section {
    text-align: center;
    padding-top: 10px;
    border-top: 1px solid #34495e;
}

.tetris-share-title {
    margin: 0 0 6px 0;
    color: #bdc3c7;
    font-size: 11px;
}

.tetris-share-buttons {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.tetris-share-btn {
    width: 35px;
    height: 35px;
    border: none;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.tetris-share-vk { background: #4c75a3; }
.tetris-share-tg { background: #0088cc; }
.tetris-share-wa { background: #25d366; }
.tetris-share-copy { background: #9b59b6; }

.tetris-share-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

/* Уведомления */
.tetris-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100001;
    background: #27ae60;
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    font-weight: bold;
    box-shadow: 0 8px 25px rgba(0,0,0,0.5);
    display: none;
    text-align: center;
    max-width: 250px;
    font-size: 12px;
}

/* Адаптивность */

/* Tablet */
@media (max-width: 768px) {
    .tetris-container {
        max-width: 100%;
        padding: 10px;
    }
    
    .tetris-game-area {
        flex-direction: column;
        align-items: center;
    }
    
    .tetris-side-panel {
        width: 100%;
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        gap: 15px;
    }
    
    .tetris-controls-compact {
        flex-direction: row;
        gap: 8px;
    }
    
    .tetris-controls-row {
        flex-direction: column;
        gap: 4px;
    }
    
    .tetris-btn {
        padding: 6px 4px;
        font-size: 9px;
    }
    
    .tetris-fullscreen-game-area {
        flex-direction: column;
    }
    
    .tetris-fullscreen-sidebar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-around;
        gap: 10px;
    }
    
    .tetris-fullscreen-next,
    .tetris-fullscreen-controls {
        flex: 1;
        min-width: 120px;
    }
    
    .tetris-fullscreen-controls {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 5px;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .tetris-container {
        padding: 8px;
        border-radius: 8px;
    }
    
    .tetris-touch-help {
        display: block;
    }
    
    .tetris-fullscreen-touch-help {
        display: block;
    }
    
    .tetris-game-area {
        flex-direction: column;
        margin-bottom: 8px;
        gap: 8px;
    }
    
    .tetris-side-panel {
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
    }
    
    .tetris-next-piece {
        padding: 4px;
        min-width: 70px;
    }
    
    #tetris-next-canvas {
        width: 50px;
        height: 50px;
    }
    
    .tetris-controls-compact {
        flex-direction: row;
        gap: 6px;
    }
    
    .tetris-controls-row {
        flex-direction: column;
        gap: 3px;
    }
    
    .tetris-btn {
        padding: 5px 3px;
        font-size: 8px;
        min-width: 40px;
    }
    
    .tetris-score-board {
        padding: 4px;
    }
    
    .tetris-value {
        font-size: 12px;
    }
    
    .tetris-title {
        font-size: 18px;
        margin-bottom: 4px;
    }
    
    .tetris-fullscreen-overlay {
        padding: 6px;
    }
    
    .tetris-fullscreen-title {
        font-size: 18px;
    }
    
    .tetris-fullscreen-header {
        flex-direction: column;
        gap: 6px;
        text-align: center;
        padding: 4px 0;
    }
    
    .tetris-fullscreen-scores {
        order: -1;
        width: 100%;
        justify-content: space-around;
    }
    
    .tetris-fullscreen-game-area {
        flex-direction: column;
        margin-bottom: 6px;
        gap: 8px;
    }
    
    .tetris-fullscreen-sidebar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .tetris-fullscreen-next,
    .tetris-fullscreen-controls {
        flex: 1;
        min-width: 100px;
        padding: 6px;
    }
    
    .tetris-fullscreen-controls {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
    }
    
    .tetris-exit-fullscreen-btn {
        margin-top: 0;
        flex-basis: 100%;
    }
    
    .tetris-share-buttons {
        gap: 6px;
    }
    
    .tetris-share-btn {
        width: 30px;
        height: 30px;
        font-size: 10px;
    }
}

/* Small Mobile - очень маленькие экраны */
@media (max-width: 360px) {
    .tetris-container {
        padding: 6px;
    }
    
    .tetris-game-area {
        gap: 6px;
    }
    
    .tetris-side-panel {
        gap: 8px;
    }
    
    .tetris-next-piece {
        min-width: 60px;
    }
    
    #tetris-next-canvas {
        width: 45px;
        height: 45px;
    }
    
    .tetris-controls-compact {
        gap: 4px;
    }
    
    .tetris-btn {
        padding: 4px 2px;
        font-size: 7px;
        min-width: 35px;
    }
    
    .tetris-score-board {
        flex-direction: column;
        gap: 2px;
        padding: 3px;
    }
    
    .tetris-score-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 1px 4px;
    }
    
    .tetris-label, .tetris-value {
        display: inline;
        font-size: 10px;
    }
    
    .tetris-title {
        font-size: 16px;
    }
    
    .tetris-touch-hint {
        font-size: 9px;
        padding: 4px 6px;
    }
    
    .tetris-share-buttons {
        gap: 4px;
    }
    
    .tetris-share-btn {
        width: 28px;
        height: 28px;
        font-size: 9px;
    }
    
    .tetris-fullscreen-sidebar {
        flex-direction: column;
        gap: 6px;
    }
    
    .tetris-fullscreen-next,
    .tetris-fullscreen-controls {
        min-width: 100%;
    }
}

/* Очень-очень маленькие экраны */
@media (max-width: 320px) {
    .tetris-container {
        padding: 4px;
    }
    
    .tetris-btn {
        font-size: 6px;
        padding: 3px 1px;
        min-width: 30px;
    }
    
    .tetris-next-piece {
        min-width: 55px;
    }
    
    #tetris-next-canvas {
        width: 40px;
        height: 40px;
    }
    
    .tetris-title {
        font-size: 14px;
    }
    
    .tetris-label, .tetris-value {
        font-size: 9px;
    }
    
    .tetris-share-btn {
        width: 25px;
        height: 25px;
        font-size: 8px;
    }
}

/* Портретная ориентация на мобильных */
@media (max-width: 480px) and (orientation: portrait) {
    .tetris-fullscreen-game-area {
        flex-direction: column;
    }
    
    #tetris-fullscreen-canvas {
        max-height: 50vh;
    }
}

/* Ландшафтная ориентация на мобильных */
@media (max-height: 480px) and (orientation: landscape) {
    .tetris-fullscreen-overlay {
        padding: 4px;
    }
    
    .tetris-fullscreen-header {
        padding: 2px 0;
        margin-bottom: 4px;
        flex-direction: row;
    }
    
    .tetris-fullscreen-title {
        font-size: 16px;
    }
    
    .tetris-fullscreen-scores {
        order: 0;
        width: auto;
        gap: 8px;
    }
    
    .tetris-fullscreen-game-area {
        flex-direction: row;
        margin-bottom: 4px;
    }
    
    .tetris-fullscreen-sidebar {
        width: 120px;
        gap: 6px;
    }
    
    .tetris-fullscreen-next,
    .tetris-fullscreen-controls {
        padding: 4px;
    }
    
    .tetris-label {
        font-size: 8px;
    }
    
    .tetris-value {
        font-size: 10px;
    }
    
    .tetris-fullscreen-controls {
        flex-direction: column;
        gap: 3px;
    }
    
    .tetris-btn {
        padding: 4px 2px;
        font-size: 8px;
    }
}

/* Состояния игры */
.tetris-game-over {
    opacity: 0.7;
}

.tetris-paused {
    opacity: 0.8;
}

/* Анимация для полноэкранного режима */
@keyframes tetris-fullscreen-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.tetris-fullscreen-overlay.active {
    animation: tetris-fullscreen-in 0.3s ease-out;
}

/* Гарантированное отображение кнопки полноэкранного режима */
.tetris-fullscreen-btn {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Предотвращение скролла при полноэкранном режиме */
body.tetris-fullscreen-active {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Улучшение отображения canvas на мобильных */
#tetris-game-canvas {
    max-width: 100%;
    height: auto;
}

/* Оптимизация для высоких экранов */
@media (min-height: 700px) and (max-width: 480px) {
    .tetris-container {
        max-height: 90vh;
        overflow: hidden;
    }
    
    .tetris-game-area {
        flex: 1;
        min-height: 0;
    }
    
    #tetris-game-canvas {
        max-height: 50vh;
    }
}