/**
 * Стили для экрана расстановки кораблей
 * Компактный мобильный дизайн - все на одном экране
 */

/* ============================================
   КОМПАКТНЫЙ МОБИЛЬНЫЙ ДИЗАЙН РАССТАНОВКИ
   ============================================ */

/* Контейнер экрана расстановки - используем фиксированные размеры */
.manual-placement-container {
    width: 100%;
    height: 100%;
    max-height: 100%;
    padding: 0;
    /* Safe areas учитываются через AspectRatioLock offset */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    /* Убеждаемся, что контент не обрезается */
    box-sizing: border-box;
    /* Равномерное распределение пространства */
    justify-content: space-between;
}

/* Верхняя панель с прогрессом и действиями */
.placement-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px; /* Уменьшен padding для экономии места */
    padding-top: calc(8px + var(--aspect-lock-safe-top, 0px)); /* Учитываем safe area top (notch) */
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(250, 252, 255, 0.98) 100%);
    border-bottom: 2px solid rgba(25, 118, 210, 0.1);
    flex-shrink: 0;
    min-height: 44px; /* Уменьшена минимальная высота для большего места полю */
    min-height: calc(44px + var(--aspect-lock-safe-top, 0px)); /* Учитываем safe area top */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    /* Убеждаемся, что панель всегда видна */
    position: relative;
    z-index: 100;
    /* Убеждаемся, что элементы не выходят за границы */
    overflow: hidden;
    gap: 8px; /* Добавлен gap между информационной панелью и кнопками */
}

/* Компактный прогресс */
/* Компактный прогресс */
.progress-compact {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.progress-text {
    font-size: 14px; /* Увеличен размер для лучшей видимости на мобильных */
    font-weight: 700;
    color: #1976D2;
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: 0.5px;
    /* Убеждаемся, что текст виден */
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

.progress-bar-mini {
    width: 100%;
    height: 8px;
    background-color: #E3F2FD;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50 0%, #81C784 100%);
    border-radius: 3px;
    transition: width 0.4s ease;
    width: 0%;
}

/* Кнопки-иконки - улучшенный дизайн */
.btn-icon {
    width: 40px; /* Уменьшен размер для экономии места */
    height: 40px; /* Уменьшен размер для экономии места */
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 100%);
    color: #1976D2;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    padding: 0;
    box-shadow: 0 2px 6px rgba(25, 118, 210, 0.2);
    position: relative;
    font-weight: bold;
}

/* Специальный стиль для кнопки поворота - более заметная */
#rotate-btn {
    background: linear-gradient(135deg, #1976D2 0%, #1565C0 100%);
    color: white;
    box-shadow: 0 3px 8px rgba(25, 118, 210, 0.3);
    width: 48px;
    height: 48px;
    font-size: 22px;
}

#rotate-btn:not(:disabled):hover {
    background: linear-gradient(135deg, #1565C0 0%, #0D47A1 100%);
    transform: translateY(-2px) rotate(90deg);
    box-shadow: 0 5px 12px rgba(25, 118, 210, 0.4);
}

#rotate-btn:not(:disabled):active {
    transform: translateY(0) rotate(90deg) scale(0.95);
}

/* Индикатор ориентации на кнопке поворота */
#rotate-btn::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 2px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 1px;
    transition: all 0.3s ease;
}

#rotate-btn[data-orientation="vertical"]::after {
    width: 2px;
    height: 20px;
}

.btn-icon:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(25, 118, 210, 0.25);
    background: linear-gradient(135deg, #BBDEFB 0%, #90CAF9 100%);
}

.btn-icon:active:not(:disabled) {
    transform: translateY(0) scale(0.95);
    box-shadow: 0 1px 2px rgba(25, 118, 210, 0.2);
}

.btn-icon:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #F5F5F5;
    color: #9E9E9E;
    box-shadow: none;
}

.btn-icon .icon {
    font-size: 9px; /* Уменьшен для экономии места */
    line-height: 1;
    font-weight: bold;
    font-family: Arial, sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    /* Стили для SVG иконок */
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon .icon svg {
    width: 100%;
    height: 100%;
    display: block;
    max-width: 32px;
    max-height: 32px;
}

/* Секция кораблей - отдельно над полем, той же ширины что и поле */
.ships-section-over-board {
    flex-shrink: 0;
    padding: 8px 6px; /* Уменьшен padding для экономии места под поле */
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(250, 252, 255, 0.98) 100%);
    border-bottom: 2px solid rgba(25, 118, 210, 0.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60px; /* Уменьшена высота для большего места полю */
    height: auto;
    box-sizing: border-box;
    margin: 0 auto;
    width: var(--ships-section-width, 100%);
    max-width: var(--ships-section-width, 100%);
    overflow: hidden;
    position: relative;
    /* Убеждаемся, что содержимое не выходит за границы */
    min-width: 0;
}

/* Декоративный элемент для красоты */
.ships-section-over-board::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(25, 118, 210, 0.3) 20%, 
        rgba(25, 118, 210, 0.5) 50%, 
        rgba(25, 118, 210, 0.3) 80%, 
        transparent 100%);
    pointer-events: none;
}

/* Счетчик оставшихся кораблей */
.ships-counter {
    position: absolute;
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: 600;
    color: #1976D2;
    text-align: center;
    padding: 3px 10px;
    background: rgba(25, 118, 210, 0.12);
    border-radius: 14px;
    white-space: nowrap;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(25, 118, 210, 0.25);
    z-index: 10;
    pointer-events: none;
    border: 1px solid rgba(25, 118, 210, 0.2);
}

.ships-counter[data-remaining="0"] {
    background: rgba(76, 175, 80, 0.18);
    color: #4CAF50;
    font-weight: 700;
    border-color: rgba(76, 175, 80, 0.3);
    box-shadow: 0 2px 6px rgba(76, 175, 80, 0.3);
}

.ships-section-over-board .ships-scroll {
    display: flex;
    gap: 6px; /* Уменьшен gap для экономии места */
    align-items: flex-end;
    justify-content: space-between;
    min-width: 0; /* Позволяет сжиматься */
    padding: 0;
    overflow: hidden; /* Убираем прокрутку */
    box-sizing: border-box;
    width: 100%; /* Занимает всю ширину */
    max-width: 100%; /* Не выходит за границы */
    /* Убеждаемся, что содержимое не выходит за границы */
    flex-shrink: 1;
    /* Учитываем padding родителя */
    margin: 0;
}

.ships-section-over-board::-webkit-scrollbar {
    height: 4px;
}

.ships-section-over-board::-webkit-scrollbar-track {
    background: rgba(227, 242, 253, 0.3);
    border-radius: 2px;
}

.ships-section-over-board::-webkit-scrollbar-thumb {
    background: linear-gradient(90deg, #90CAF9 0%, #64B5F6 100%);
    border-radius: 2px;
}

.ships-section-over-board::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(90deg, #64B5F6 0%, #42A5F5 100%);
}

/* Кнопки действий в верхней панели */
.top-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.ships-scroll {
    display: flex;
    gap: 8px; /* Уменьшен gap */
    align-items: flex-end;
    justify-content: space-between; /* Равномерное распределение */
    min-width: 0; /* Позволяет сжиматься */
    padding: 0;
    height: 100%;
    flex-wrap: nowrap;
    width: 100%; /* Занимает всю ширину */
    box-sizing: border-box;
}

/* Улучшенные элементы кораблей - только визуализация корабля, без текста */
.ship-item {
    display: flex;
    flex-direction: row; /* Горизонтальная компоновка */
    align-items: center;
    justify-content: center; /* Центрируем корабль */
    padding: 6px 4px 0px 4px; /* Уменьшен padding для экономии места */
    border: 2.5px solid #BBDEFB;
    border-bottom: none; /* Убираем нижнюю границу, её заменит полоса */
    border-radius: 12px 12px 0 0; /* Скругляем только верхние углы */
    background: linear-gradient(145deg, #FFFFFF 0%, #E3F2FD 50%, #BBDEFB 100%);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 0; /* Позволяет сжиматься */
    /* Убираем width: 100%, используем только flex для распределения */
    flex: 1 1 0; /* Равномерное распределение, может сжиматься */
    max-width: 100%; /* Не выходит за границы родителя */
    height: 50px; /* Увеличена высота для лучшей видимости */
    flex-shrink: 1; /* Может сжиматься при необходимости */
    user-select: none;
    touch-action: manipulation; /* Улучшенная обработка touch */
    position: relative;
    box-shadow: 0 3px 8px rgba(25, 118, 210, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    gap: 0; /* Убираем gap, так как только корабль */
    min-height: 48px; /* Минимальная высота для touch-интерфейсов */
    box-sizing: border-box; /* Учитываем border в размерах */
    /* Убеждаемся, что элемент не выходит за границы */
    overflow: hidden;
}

/* Индикатор ориентации корабля - убран, так как корабли размещаются только через рисование */
.ship-item::before {
    display: none;
}

.ship-item[data-orientation="vertical"]::before {
    display: none;
}

.ship-item.selected::before {
    display: none;
}

.ship-item:hover:not(.placed):not(.all-placed) {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 6px 16px rgba(25, 118, 210, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    border-color: #64B5F6;
    background: linear-gradient(145deg, #FFFFFF 0%, #BBDEFB 50%, #90CAF9 100%);
    animation: hover-pulse 2s ease-in-out infinite; /* Легкая пульсация при hover */
}

@keyframes hover-pulse {
    0%, 100% {
        box-shadow: 0 6px 16px rgba(25, 118, 210, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    }
    50% {
        box-shadow: 0 8px 20px rgba(25, 118, 210, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.95);
    }
}

.ship-item:hover:not(.placed):not(.all-placed) .segmented-bar {
    background: #64B5F6; /* Фон полосы меняется при наведении */
}

.ship-item:active:not(.placed) {
    transform: translateY(0) scale(0.96);
}

.ship-item.selected {
    background: linear-gradient(145deg, #1976D2 0%, #1565C0 50%, #0D47A1 100%);
    border-color: #0D47A1;
    color: white;
    box-shadow: 0 6px 20px rgba(25, 118, 210, 0.5), 0 0 0 3px rgba(25, 118, 210, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transform: translateY(-3px) scale(1.05);
    animation: selected-glow 2s ease-in-out infinite;
    z-index: 10;
}

/* Подсказка при выборе корабля */
.ship-item.selected::after {
    content: 'Нажмите на поле';
    position: absolute;
    bottom: -38px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(25, 118, 210, 0.98) 0%, rgba(21, 101, 192, 0.98) 100%);
    color: white;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(25, 118, 210, 0.4), 0 0 0 2px rgba(255, 255, 255, 0.2);
    pointer-events: none;
    z-index: 1000;
    animation: tooltip-fade-in 0.3s ease;
    letter-spacing: 0.3px;
}

/* Стрелка для подсказки - убрана, так как стрелочки больше не используются */

.ship-item.selected {
    position: relative;
}

@keyframes tooltip-fade-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.ship-item.selected .segmented-bar {
    background: #0D47A1; /* Фон полосы меняется при выборе */
}

@keyframes selected-glow {
    0%, 100% {
        box-shadow: 0 4px 16px rgba(25, 118, 210, 0.4), 0 0 0 3px rgba(25, 118, 210, 0.1);
    }
    50% {
        box-shadow: 0 6px 20px rgba(25, 118, 210, 0.5), 0 0 0 4px rgba(25, 118, 210, 0.15);
    }
}

.ship-item.placed {
    opacity: 0.6; /* Немного увеличена прозрачность для лучшей видимости */
    border-color: #A5D6A7;
    background: linear-gradient(135deg, #C8E6C9 0%, #A5D6A7 100%);
    cursor: default;
    box-shadow: 0 2px 4px rgba(76, 175, 80, 0.15); /* Легкая тень для размещенных */
    transition: opacity 0.3s ease, transform 0.3s ease; /* Плавный переход */
}

.ship-item.placed:hover {
    transform: none;
    box-shadow: none;
}

.ship-item.all-placed {
    display: none; /* Скрываем полностью размещенные группы */
}

.ship-item.placed::after {
    content: '✓';
    position: absolute;
    top: 6px;
    right: 6px;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #4CAF50 0%, #388E3C 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(76, 175, 80, 0.3);
}

.ship-item.dragging {
    opacity: 0.6;
    transform: scale(0.92) rotate(2deg);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

/* Улучшенная визуализация корабля - центрированная, без текста */
.ship-visual {
            display: flex !important;
            flex-direction: row !important;
            gap: 2px;
            margin: 0; /* Убираем отступы */
            padding: 4px 6px;
            border-radius: 6px;
            background: rgba(255, 255, 255, 0.5);
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
            transition: background 0.3s ease, box-shadow 0.3s ease; /* Плавные переходы */
            border: 1px solid rgba(187, 222, 251, 0.3); /* Легкая граница для лучшего разделения */
        }

.ship-item.selected .ship-visual {
    background: rgba(255, 255, 255, 0.3);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

.ship-cell {
    width: 14px; /* Увеличен размер для лучшей видимости */
    height: 14px; /* Увеличен размер для лучшей видимости */
    background: linear-gradient(145deg, #42A5F5 0%, #1976D2 50%, #1565C0 100%);
    border: 1.5px solid #0D47A1;
    border-radius: 3px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2), inset 0 1px 1px rgba(255, 255, 255, 0.4);
    flex-shrink: 0;
}

.ship-item.selected .ship-cell {
    background: linear-gradient(145deg, #FFFFFF 0%, #E3F2FD 50%, #BBDEFB 100%);
    border-color: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3), inset 0 1px 1px rgba(255, 255, 255, 0.6);
}

.ship-item.selected .ship-cell {
    background: linear-gradient(135deg, #FFFFFF 0%, #E3F2FD 100%);
    border-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.ship-item.placed .ship-cell {
    background: linear-gradient(135deg, #66BB6A 0%, #4CAF50 100%);
    border-color: #388E3C;
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

/* Улучшенная информация о корабле - справа в горизонтальной компоновке */
/* Стили для .ship-info и .ship-label удалены - текст больше не используется */

/* Стили для .ship-label удалены - текст больше не используется */

.ship-count {
    font-size: 8px;
    font-weight: 700;
    color: #64B5F6;
    line-height: 1;
    opacity: 0.95;
    letter-spacing: 0.3px;
}

.ship-item.selected .ship-count {
    color: rgba(255, 255, 255, 0.98);
    opacity: 1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Стили для .ship-label удалены - текст больше не используется */

.ship-count {
    font-size: 9px;
    font-weight: 600;
    color: #64B5F6;
    line-height: 1;
    opacity: 0.8;
}

.ship-item.selected .ship-count {
    color: rgba(255, 255, 255, 0.95);
    opacity: 1;
}

/* Сегментированная полоса для отображения количества кораблей - как часть границы элемента */
.segmented-bar {
    position: absolute;
    bottom: 0;
    left: -2.5px; /* Компенсируем границу элемента */
    right: -2.5px; /* Компенсируем границу элемента */
    display: flex;
    flex-direction: row;
    gap: 2px;
    border-radius: 0 0 12px 12px; /* Скругляем нижние углы */
    overflow: hidden;
    height: 4px;
    background: #BBDEFB; /* Фон как граница элемента */
    padding: 0;
    box-sizing: border-box;
}

.segmented-line {
    flex: 1;
    height: 100%;
    /* ИЗМЕНЕНО: изначально светится, показывая доступные корабли */
    background: #4CAF50;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 0 6px rgba(76, 175, 80, 0.5);
    transition: background 0.4s ease, box-shadow 0.4s ease, opacity 0.4s ease; /* Плавная анимация */
    position: relative;
    overflow: hidden;
    /* Анимация свечения для доступных кораблей */
    animation: segment-glow 2s ease-in-out infinite;
}

/* Старая анимация заполнения удалена - теперь сегменты изначально светятся */

/* Анимация свечения для доступных кораблей */
@keyframes segment-glow {
    0%, 100% {
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 0 6px rgba(76, 175, 80, 0.5);
    }
    50% {
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 0 10px rgba(76, 175, 80, 0.7);
    }
}

.segmented-line.empty {
    /* Неактивный сегмент (размещенный корабль) - не светится */
    background: #E0E0E0;
    box-shadow: none;
    opacity: 0.5; /* Уменьшенная прозрачность для неактивных сегментов */
    transition: opacity 0.4s ease, background 0.4s ease, box-shadow 0.4s ease; /* Плавный переход */
    animation: none; /* Убираем анимацию свечения */
}

/* Старая анимация пульсации удалена - теперь используется общая анимация свечения */

/* Фон полосы по умолчанию (уже задан выше в .segmented-bar) */

.ship-item.selected .segmented-line:not(.empty) {
    /* Выбранный корабль - более яркое свечение */
    background: #66BB6A;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 0 12px rgba(102, 187, 106, 0.8);
    animation: segment-glow-selected 1.5s ease-in-out infinite;
}

@keyframes segment-glow-selected {
    0%, 100% {
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 0 12px rgba(102, 187, 106, 0.8);
    }
    50% {
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 0 16px rgba(102, 187, 106, 1);
    }
}

.ship-item.selected .segmented-line.empty {
    background: rgba(255, 255, 255, 0.3);
    box-shadow: none;
    animation: none;
}

/* 4 палубный: 1 корабль = 1 полоса БЕЗ разделителей */
.ship-item[data-ship-total="1"] .segmented-bar {
    gap: 0;
}

.ship-item[data-ship-total="1"] .segmented-line {
    width: 100%;
}

.ship-item[data-ship-total="1"] .segmented-line:nth-child(n+2) {
    display: none;
}

/* 3 палубный: 2 корабля = 2 полосы с 1 разделителем (gap) */
.ship-item[data-ship-total="2"] .segmented-bar {
    gap: 2px;
}

.ship-item[data-ship-total="2"] .segmented-line:nth-child(n+3) {
    display: none;
}

/* 2 палубный: 3 корабля = 3 полосы с 2 разделителями (gap) */
.ship-item[data-ship-total="3"] .segmented-bar {
    gap: 2px;
}

.ship-item[data-ship-total="3"] .segmented-line:nth-child(n+4) {
    display: none;
}

/* 1 палубный: 4 корабля = 4 полосы с 3 разделителями (gap) */
.ship-item[data-ship-total="4"] .segmented-bar {
    gap: 2px;
}

/* Обертка игрового поля (максимальный размер) */
/* Анимация пальца для демонстрации рисования */
.finger-animation {
    position: absolute;
    pointer-events: none;
    z-index: 20;
    opacity: 0;
    transition: opacity 0.3s ease, left 0.3s ease, top 0.3s ease;
    will-change: left, top, opacity;
}

.finger-animation.active {
    opacity: 1;
}

.finger-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.4));
    transform-origin: center bottom;
    animation: fingerTap 0.8s ease-in-out infinite;
    position: relative;
}

.finger-icon::before {
    content: '';
    width: 20px;
    height: 30px;
    background: linear-gradient(135deg, #FF6B6B 0%, #EE5A6F 100%);
    border-radius: 10px 10px 2px 2px;
    position: relative;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.finger-icon::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    background: #FF6B6B;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

@keyframes fingerTap {
    0%, 100% {
        transform: translateY(0) scale(1) rotate(-10deg);
    }
    50% {
        transform: translateY(-8px) scale(1.15) rotate(-5deg);
    }
}

.finger-animation.hidden {
    display: none;
}

.placement-board-wrapper {
    flex: 1 1 auto; /* Занимает все доступное пространство между панелями */
    display: flex;
    align-items: center; /* Центрируем поле вертикально - убираем пустое пространство сверху */
    justify-content: center;
    padding: 8px; /* Уменьшен padding для большего размера поля */
    min-height: 0;
    overflow: hidden; /* Убираем overflow для более чистого вида */
    width: 100%;
    box-sizing: border-box;
    position: relative; /* Для позиционирования подсказки */
    /* Убеждаемся, что поле не выталкивает другие элементы */
    flex-shrink: 1;
    /* Равномерное распределение пространства */
    flex-basis: 0;
}

/* Убраны псевдоэлементы - теперь используем реальные контейнеры */

.placement-board {
    width: 100%;
    max-width: min(98%, calc(100% - 20px)); /* Увеличено максимальное поле - используем почти весь доступный размер */
    aspect-ratio: 1;
    margin: 0 auto 0 auto; /* Убран нижний margin для плотного прилегания к панели */
    /* Делаем поле более заметным */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 2px solid rgba(25, 118, 210, 0.2);
}

/* Компактная нижняя панель - вариант 6 с разделителем */
.placement-bottom-bar {
    display: flex;
    gap: 0; /* Убран gap, разделитель между кнопками */
    padding: 0; /* Убран padding, кнопки на всю ширину */
    padding-bottom: var(--aspect-lock-safe-bottom, 0px); /* Учитываем home indicator */
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(250, 252, 255, 0.98) 100%);
    border-top: 2px solid rgba(25, 118, 210, 0.15);
    flex-shrink: 0;
    min-height: 56px; /* Немного уменьшена высота для большего места полю, но остается удобной */
    min-height: calc(56px + var(--aspect-lock-safe-bottom, 0px)); /* Учитываем safe area bottom */
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
    /* Убеждаемся, что панель всегда видна */
    position: relative;
    z-index: 100;
    /* Убеждаемся, что панель не обрезается */
    margin-bottom: 0;
}

.btn-compact {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px; /* Немного уменьшен padding */
    border: 2px solid #90CAF9;
    border-radius: 0; /* Убраны закругления, так как кнопки соединены */
    background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 100%);
    color: #1976D2;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 56px; /* Соответствует высоте панели */
    box-shadow: none; /* Убрана тень, так как кнопки соединены */
    /* Разделитель между кнопками */
    border-right: 2px solid rgba(25, 118, 210, 0.15);
}

/* Закругления для первой и последней кнопок */
.btn-compact:first-child {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.btn-compact:last-child {
    border-right: none;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.btn-compact:not(.btn-primary-compact):active {
    transform: scale(0.98);
    background: linear-gradient(135deg, #BBDEFB 0%, #90CAF9 100%);
    box-shadow: none;
}

.btn-compact:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    /* Убеждаемся, что disabled кнопки можно выбрать в DevTools */
    pointer-events: auto;
}

.btn-primary-compact {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
    box-shadow: none; /* Убрана тень, так как кнопки соединены */
    /* Разделитель для основной кнопки */
    border-right: 2px solid rgba(102, 126, 234, 0.3);
}

.btn-primary-compact:not(:disabled):hover {
    background: linear-gradient(135deg, #5568d3 0%, #653a8f 100%);
    box-shadow: none;
    transform: translateY(-1px);
}

.btn-primary-compact:active {
    background: linear-gradient(135deg, #5568d3 0%, #653a8f 100%);
    transform: translateY(0) scale(0.98);
    box-shadow: none;
}


.btn-icon-small {
    font-size: 11px; /* Уменьшен для компактности */
    line-height: 1;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.btn-text {
    font-size: 15px; /* Увеличен для лучшей видимости на мобильных */
    line-height: 1.2;
    font-weight: 600;
}

/* Информационная панель со статистикой - в верхней панели */
.placement-info-panel {
    display: flex;
    gap: 8px; /* Уменьшен gap для экономии места */
    align-items: center;
    flex: 1;
    min-width: 0;
    padding: 0;
    /* Убеждаемся, что элементы не выходят за границы */
    overflow: hidden;
}

.placement-info-panel .info-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px; /* Уменьшен gap между числом и текстом */
    flex: 1 1 0; /* Равномерное распределение с возможностью сжатия */
    min-width: 0;
    /* Убеждаемся, что текст не выходит за границы */
    overflow: hidden;
}

.placement-info-panel .info-value {
    font-size: 16px; /* Уменьшен размер для лучшей адаптивности */
    font-weight: 700;
    color: #1976D2;
    line-height: 1;
    transition: color 0.3s ease, transform 0.3s ease;
    white-space: nowrap;
    flex-shrink: 0; /* Число не сжимается */
}

.placement-info-panel .info-value.updated {
    animation: numberPulse 0.5s ease;
}

@keyframes numberPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); color: #4CAF50; }
}

.placement-info-panel .info-label {
    font-size: 9px; /* Уменьшен размер для экономии места */
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.2px; /* Уменьшен letter-spacing */
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 1; /* Текст может немного сжиматься при необходимости */
    /* Обрезаем текст если не помещается */
    overflow: hidden;
    text-overflow: ellipsis;
}


/* Подсказка (минимальная, скрываемая) - теперь скрыта по умолчанию, так как используем информационную панель */
.placement-hint {
    position: fixed;
    bottom: 80px; /* Увеличено расстояние от нижней панели */
    left: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    display: none; /* Скрыта по умолчанию, так как используем информационную панель */
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    z-index: 1000; /* Увеличен z-index для видимости */
    animation: slideUp 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    /* Убеждаемся, что подсказка видна на всех устройствах */
    max-width: calc(100vw - 24px);
    box-sizing: border-box;
}

.placement-hint.hidden {
    display: none;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hint-close {
    width: 20px;
    height: 20px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
    padding: 0;
}

.hint-close:active {
    background: rgba(255, 255, 255, 0.3);
}

/* Подсветка клеток при наведении и drag */
.cell.preview {
    background-color: #81C784 !important;
    border-color: #4CAF50 !important;
    opacity: 0.9;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
    animation: preview-pulse 1.5s ease-in-out infinite;
    transform: scale(1.05);
    z-index: 10;
    transition: all 0.2s ease;
    position: relative;
}

/* Визуальная подсказка о валидных позициях (для мобильных) */
.cell.valid-hint {
    position: relative;
}

.cell.valid-hint::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: rgba(76, 175, 80, 0.4);
    border-radius: 50%;
    animation: hint-pulse 2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes hint-pulse {
    0%, 100% {
        opacity: 0.3;
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        opacity: 0.6;
        transform: translate(-50%, -50%) scale(1.3);
    }
}

@keyframes preview-pulse {
    0%, 100% {
        box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
    }
    50% {
        box-shadow: 0 0 12px rgba(76, 175, 80, 0.9);
    }
}

.cell.drawing {
    background: #4CAF50 !important;
    border-color: #2E7D32 !important;
    opacity: 0.7;
}

.cell.preview-invalid {
    background-color: #E57373 !important;
    border-color: #EF5350 !important;
    opacity: 0.8;
    animation: shake 0.3s ease;
    transform: scale(0.95);
    z-index: 10;
    transition: all 0.2s ease;
    box-shadow: 0 0 8px rgba(244, 67, 54, 0.6);
}

/* Подсветка зон вокруг размещенных кораблей (где нельзя рисовать) */
.cell.restricted-zone {
    background-color: rgba(255, 152, 0, 0.3) !important;
    border-color: rgba(255, 152, 0, 0.6) !important;
    position: relative;
    z-index: 1;
}

.cell.restricted-zone::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    background-color: rgba(255, 152, 0, 0.6);
    border-radius: 50%;
    pointer-events: none;
}

/* Restricted zone становится валидной при перетаскивании (можно разместить корабль) */
.cell.restricted-zone-valid {
    background-color: rgba(76, 175, 80, 0.4) !important;
    border-color: rgba(76, 175, 80, 0.7) !important;
    position: relative;
    z-index: 8;
    box-shadow: 0 0 4px rgba(76, 175, 80, 0.5);
}

.cell.restricted-zone-valid::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background-color: rgba(76, 175, 80, 0.8);
    border-radius: 50%;
    pointer-events: none;
}

/* Restricted zone становится невалидной при перетаскивании (нельзя разместить корабль) */
.cell.restricted-zone-invalid {
    background-color: rgba(244, 67, 54, 0.5) !important;
    border-color: rgba(244, 67, 54, 0.8) !important;
    position: relative;
    z-index: 8;
    box-shadow: 0 0 4px rgba(244, 67, 54, 0.6);
}

.cell.restricted-zone-invalid::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background-color: rgba(244, 67, 54, 1);
    border-radius: 50%;
    pointer-events: none;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

/* Стили для drag & drop */
.cell[draggable="true"] {
    cursor: grab;
}

.cell[draggable="true"]:active {
    cursor: grabbing;
}

.ship-item[draggable="true"] {
    cursor: grab;
}

.ship-item[draggable="true"]:active {
    cursor: grabbing;
}

/* Специальные стили для iPhone и маленьких экранов */
@media (max-width: 414px) {
    .placement-top-bar {
        padding: 8px 10px;
        min-height: 48px;
        gap: 6px;
    }
    
    .placement-info-panel {
        gap: 6px;
    }
    
    .placement-info-panel .info-value {
        font-size: 14px;
    }
    
    .placement-info-panel .info-label {
        font-size: 8px;
        letter-spacing: 0.1px;
    }
    
    .placement-info-panel .info-item {
        gap: 3px;
    }
    
    .btn-icon {
        width: 36px;
        height: 36px;
    }
    
    .btn-icon .icon {
        font-size: 8px;
    }
}

/* Адаптивность для очень маленьких экранов */
@media (max-width: 360px) {
    .progress-text {
        font-size: 12px;
    }
    
    .btn-icon {
        width: 32px;
        height: 32px;
    }
    
    .btn-icon .icon {
        font-size: 16px;
    }
    
    .ship-item {
        min-width: 45px;
        padding: 6px 8px 0px 8px; /* Увеличен padding для лучшей touch-зоны */
        gap: 6px; /* Уменьшен gap для маленьких экранов */
    }
    
    .ship-cell {
        width: 10px;
        height: 10px;
    }
    
    /* Стили для .ship-label удалены - текст больше не используется */
    
    .ship-visual {
        padding: 3px 4px; /* Уменьшен padding для компактности */
    }
    
    /* Адаптация информационной панели для маленьких экранов */
    .placement-info-panel {
        gap: 6px; /* Еще меньше gap */
    }
    
    .placement-info-panel .info-value {
        font-size: 14px; /* Уменьшен размер */
    }
    
    .placement-info-panel .info-label {
        font-size: 8px; /* Уменьшен размер */
        letter-spacing: 0.1px;
    }
    
    .placement-info-panel .info-item {
        gap: 3px; /* Минимальный gap */
    }
    
    /* Уменьшаем padding верхней панели */
    .placement-top-bar {
        padding: 8px 10px;
        min-height: 46px;
        gap: 6px;
    }
    
    .btn-compact {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .btn-text {
        font-size: 12px;
    }
}

/* Улучшения для touch-интерфейсов */
@media (hover: none) and (pointer: coarse) {
    .ship-item {
        min-height: 52px; /* Увеличенная touch-зона для мобильных */
        padding: 10px 12px 0px 12px; /* Больше padding для удобства нажатия */
        height: 54px;
    }
    
    .ship-item:active:not(.placed) {
        transform: scale(0.96); /* Более заметная обратная связь при нажатии */
        background: linear-gradient(145deg, #E3F2FD 0%, #BBDEFB 50%, #90CAF9 100%);
    }
    
    /* Убираем hover-анимацию на touch-устройствах */
    .ship-item:hover:not(.placed):not(.all-placed) {
        animation: none;
    }
    
    /* Улучшенная кнопка поворота для мобильных */
    #rotate-btn {
        width: 52px;
        height: 52px;
        font-size: 24px;
    }
    
    .btn-icon {
        width: 48px;
        height: 48px;
    }
    
    /* Подсказка для мобильных - более заметная */
    .ship-item.selected::after {
        font-size: 12px;
        padding: 8px 14px;
        bottom: -40px;
    }
}

/* Для ландшафтной ориентации */
@media (orientation: landscape) and (max-height: 500px) {
    .placement-top-bar {
        padding: 4px 8px;
        min-height: 40px;
    }
    
    .ships-list-horizontal {
        padding: 4px 8px;
    }
    
    .placement-bottom-bar {
        padding: 4px 8px;
    }
    
    .btn-compact {
        padding: 6px 12px;
        min-height: 36px;
    }
}

/* Специальные стили для iPhone и мобильных устройств */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari */
    .manual-placement-container {
        height: -webkit-fill-available;
        height: var(--real-vh, -webkit-fill-available);
    }
    
    .screen {
        min-height: -webkit-fill-available;
        min-height: var(--real-vh, -webkit-fill-available);
    }
}

/* Дополнительная защита для маленьких экранов */
@media (max-height: 700px) {
    .ships-section-over-board {
        min-height: 60px;
        padding: 8px 6px;
    }
    
    .placement-board-wrapper {
        padding: 8px;
    }
    
    .placement-board {
        max-width: min(95vw, calc(var(--real-vh, 100vh) - 180px));
        max-width: min(95vw, calc(var(--available-height, 100vh) - 180px));
    }
    
    .placement-info-panel {
        gap: 12px;
    }
    
    .placement-info-panel .info-value {
        font-size: 16px;
    }
    
    .placement-info-panel .info-label {
        font-size: 9px;
    }
    
    .placement-hint {
        bottom: 70px;
        font-size: 12px;
        padding: 8px 12px;
    }
}

/* Убеждаемся, что все элементы видны на очень маленьких экранах */
@media (max-height: 600px) {
    .placement-top-bar {
        padding: 8px 12px;
        min-height: 48px;
    }
    
    .ships-section-over-board {
        min-height: 55px;
        padding: 6px 4px;
    }
    
    .placement-bottom-bar {
        padding: 10px 12px;
        min-height: 60px;
    }
    
    .placement-board {
        max-width: min(90vw, calc(var(--real-vh, 100vh) - 180px));
        max-width: min(90vw, calc(var(--available-height, 100vh) - 180px));
    }
    
    .placement-info-panel {
        gap: 4px; /* Минимальный gap для очень маленьких экранов */
    }
    
    .placement-info-panel .info-value {
        font-size: 12px; /* Еще меньше для очень маленьких экранов */
    }
    
    .placement-info-panel .info-label {
        font-size: 7px; /* Минимальный размер */
        letter-spacing: 0;
    }
    
    .placement-info-panel .info-item {
        gap: 2px; /* Минимальный gap */
    }
    
    /* Уменьшаем padding верхней панели */
    .placement-top-bar {
        padding: 6px 8px;
        min-height: 44px;
        gap: 4px;
    }
    
    /* Уменьшаем размер кнопок */
    .btn-icon {
        width: 40px;
        height: 40px;
        font-size: 10px;
    }
    
    .placement-hint {
        bottom: 75px;
        font-size: 11px;
        padding: 6px 10px;
    }
}

/* ============================================
   ВИЗУАЛЬНЫЕ ЭФФЕКТЫ ГОТОВНОСТИ К ИГРЕ
   ============================================ */

/* Фиксация и подсветка поля при готовности */
.placement-board-wrapper.ready {
    position: relative;
}

.placement-board-wrapper.ready::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    pointer-events: none;
    z-index: 1;
    animation: readyOverlay 0.5s ease;
}

.placement-board.ready {
    position: relative;
    border: 3px solid #4CAF50;
    border-radius: 12px;
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.4),
                0 0 40px rgba(76, 175, 80, 0.2),
                inset 0 0 20px rgba(76, 175, 80, 0.1);
    animation: readyGlow 2s ease-in-out infinite;
    z-index: 2;
    /* Легкий зеленый блюр на поле с плавной анимацией */
    animation: readyGlow 2s ease-in-out infinite, blurPulse 3s ease-in-out infinite;
}

.placement-board.ready::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(76, 175, 80, 0.08);
    border-radius: 12px;
    pointer-events: none;
    z-index: 1;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    animation: blurFade 3s ease-in-out infinite;
}

@keyframes readyOverlay {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes readyGlow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(76, 175, 80, 0.4),
                    0 0 40px rgba(76, 175, 80, 0.2),
                    inset 0 0 20px rgba(76, 175, 80, 0.1);
    }
    50% {
        box-shadow: 0 0 30px rgba(76, 175, 80, 0.6),
                    0 0 60px rgba(76, 175, 80, 0.3),
                    inset 0 0 30px rgba(76, 175, 80, 0.15);
    }
}

@keyframes blurPulse {
    0%, 100% {
        filter: blur(0px) brightness(1);
        backdrop-filter: blur(0px);
        -webkit-backdrop-filter: blur(0px);
    }
    50% {
        filter: blur(0.3px) brightness(1.01);
        backdrop-filter: blur(0.5px);
        -webkit-backdrop-filter: blur(0.5px);
    }
}

@keyframes blurFade {
    0%, 100% {
        background: rgba(76, 175, 80, 0.15);
        backdrop-filter: blur(0.3px);
        -webkit-backdrop-filter: blur(0.3px);
    }
    50% {
        background: rgba(76, 175, 80, 0.25);
        backdrop-filter: blur(0.6px);
        -webkit-backdrop-filter: blur(0.6px);
    }
}


/* Активированная кнопка "Начать" */
.btn-primary-compact:not(:disabled) {
    background: linear-gradient(135deg, #4CAF50 0%, #388E3C 100%);
    color: white;
    border-color: #4CAF50;
    animation: buttonPulse 2s ease-in-out infinite;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
    position: relative;
}

.btn-primary-compact:not(:disabled)::before {
    content: '✓';
    margin-right: 6px;
    font-size: 16px;
}

@keyframes buttonPulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 6px 20px rgba(76, 175, 80, 0.6);
        transform: scale(1.02);
    }
}

.btn-primary-compact:not(:disabled):hover {
    background: linear-gradient(135deg, #388E3C 0%, #2E7D32 100%);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.6);
    transform: translateY(-2px) scale(1.02);
}

/* Сообщение о готовности в секции кораблей */
.ships-section-over-board.ready {
    position: relative;
}

.placement-ready-message {
    display: none;
    text-align: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.95) 0%, rgba(56, 142, 60, 0.95) 100%);
    color: white;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
    animation: messageSlideIn 0.5s ease;
    margin: 10px auto;
    max-width: 90%;
}

.ships-section-over-board.ready .placement-ready-message {
    display: block;
}

.ships-section-over-board.ready #ships-list {
    display: none;
}

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

/* Панель прогресса в состоянии готовности */
.placement-info-panel.ready {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.1) 0%, rgba(56, 142, 60, 0.1) 100%);
    border: 2px solid rgba(76, 175, 80, 0.3);
    border-radius: 12px;
    padding: 8px 12px;
}

.placement-info-panel.ready .info-value {
    color: #4CAF50;
    font-weight: 700;
}

.placement-info-panel.ready .info-label {
    color: #388E3C;
}
