/**
 * Стили для игрового поля
 * Стили для клеток, кораблей и состояний поля
 */

/* Контейнер игрового поля - используем проценты от фиксированного контейнера */
.game-board {
    display: grid;
    gap: 3px; /* Увеличен gap для лучшей видимости */
    background-color: #BBDEFB;
    padding: 6px; /* Увеличен padding */
    border-radius: 12px;
    margin: 0 auto;
    width: 100%;
    max-width: 100%; /* Занимает всю доступную ширину */
    aspect-ratio: 1;
    /* Предотвращаем деформацию при анимациях */
    contain: layout style;
    flex: 1 1 auto; /* Занимает доступное пространство */
    min-width: 0;
    min-height: 0;
    max-height: 100%; /* Не превышает высоту контейнера */
    box-sizing: border-box;
    /* Делаем поле более заметным */
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    border: 3px solid rgba(25, 118, 210, 0.4);
}

/* Клетка игрового поля */
.cell {
    background-color: #E3F2FD;
    border: 2px solid #90CAF9;
    border-radius: 6px; /* Увеличен border-radius */
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px; /* Увеличен размер шрифта для лучшей видимости */
    touch-action: manipulation; /* Предотвращает зум и другие жесты */
    -webkit-touch-callout: none; /* Отключает контекстное меню на iOS */
    /* Предотвращаем деформацию при анимациях */
    will-change: background-color, box-shadow, opacity;
    transform: translateZ(0); /* Аппаратное ускорение без деформации */
    /* Делаем клетки более заметными */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
}

/* Состояние: пустая клетка */
.cell.empty {
    background-color: #E3F2FD;
    border-color: #90CAF9;
}

/* Состояние: клетка с кораблем (видно только на своем поле) */
.cell.ship {
    background-color: #1976D2;
    border-color: #1565C0;
}

/* Состояние: попадание */
.cell.hit {
    background-color: #F44336;
    border-color: #D32F2F;
}

/* Состояние: промах */
.cell.miss {
    background-color: #CFD8DC;
    border-color: #90A4AE;
}

/* Состояние: уничтоженный корабль */
.cell.sunk {
    background-color: #D32F2F;
    border-color: #B71C1C;
    position: relative;
    box-shadow: 0 0 10px rgba(211, 47, 47, 0.6),
                inset 0 0 10px rgba(183, 28, 28, 0.4);
}

/* Контур уничтоженного корабля - показываем границы */
.cell.sunk::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 4px;
    z-index: 1;
    pointer-events: none;
}

/* Эффект свечения для уничтоженного корабля */
.cell.sunk::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: 80%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
    border-radius: 50%;
    animation: sunkGlow 2s ease-in-out infinite;
    z-index: 0;
    pointer-events: none;
}

@keyframes sunkGlow {
    0%, 100% {
        opacity: 0.3;
        transform: translate(-50%, -50%) scale(0.8);
    }
    50% {
        opacity: 0.6;
        transform: translate(-50%, -50%) scale(1.2);
    }
}

/* Индикатор уничтожения (крестик) */
.cell.sunk {
    background-image: 
        linear-gradient(45deg, transparent 40%, rgba(255, 255, 255, 0.8) 40%, rgba(255, 255, 255, 0.8) 60%, transparent 60%),
        linear-gradient(-45deg, transparent 40%, rgba(255, 255, 255, 0.8) 40%, rgba(255, 255, 255, 0.8) 60%, transparent 60%);
    background-size: 60% 60%;
    background-position: center;
    background-repeat: no-repeat;
}

/* Контур уничтоженного корабля */
.cell.sunk-ship-outline {
    border-width: 3px;
    border-style: solid;
    border-color: rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.5),
                inset 0 0 10px rgba(183, 28, 28, 0.4);
}

/* Горизонтальный корабль */
.cell.sunk-ship-horizontal.sunk-ship-start {
    border-left-width: 5px;
    border-top-width: 4px;
    border-bottom-width: 4px;
}

.cell.sunk-ship-horizontal.sunk-ship-end {
    border-right-width: 5px;
    border-top-width: 4px;
    border-bottom-width: 4px;
}

.cell.sunk-ship-horizontal.sunk-ship-middle {
    border-top-width: 4px;
    border-bottom-width: 4px;
    border-left-width: 2px;
    border-right-width: 2px;
}

/* Вертикальный корабль */
.cell.sunk-ship-vertical.sunk-ship-start {
    border-top-width: 5px;
    border-left-width: 4px;
    border-right-width: 4px;
}

.cell.sunk-ship-vertical.sunk-ship-end {
    border-bottom-width: 5px;
    border-left-width: 4px;
    border-right-width: 4px;
}

.cell.sunk-ship-vertical.sunk-ship-middle {
    border-left-width: 4px;
    border-right-width: 4px;
    border-top-width: 2px;
    border-bottom-width: 2px;
}

/* Эффект при наведении (только для активных клеток) */
.cell:not(.hit):not(.miss):not(.sunk) {
    cursor: pointer;
}

.cell:not(.hit):not(.miss):not(.sunk):active {
    transform: scale(0.95);
    opacity: 0.8;
}

/* Клетки противника (не показываем корабли) */
.enemy-board .cell.ship {
    background-color: #E3F2FD;
    border-color: #90CAF9;
}

/* Анимация появления клетки */
.cell {
    animation: cellAppear 0.3s ease;
}

@keyframes cellAppear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Индикатор попадания (крестик) */
.cell.hit::after {
    content: '';
    position: absolute;
    width: 60%;
    height: 60%;
    background: radial-gradient(circle, #fff 0%, transparent 70%);
    border-radius: 50%;
    animation: hitPulse 0.4s ease;
}

/* Индикатор промаха (точка) */
.cell.miss::after {
    content: '';
    position: absolute;
    width: 30%;
    height: 30%;
    background-color: #90A4AE;
    border-radius: 50%;
    animation: missAppear 0.3s ease;
}

/* Анимация пульсации при попадании */
@keyframes hitPulse {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 0.8;
    }
}

/* Анимация появления промаха */
@keyframes missAppear {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Отключение взаимодействия для неактивных клеток */
.cell.disabled {
    cursor: not-allowed;
    opacity: 0.6;
    pointer-events: none;
}

/* Адаптивность отключена - используется Aspect Ratio Lock */
/* Все размеры масштабируются автоматически через --aspect-lock-scale */
/*
@media (max-width: 480px) {
    .game-board {
        max-width: min(260px, calc(100vw - 30px));
        gap: 1px;
        padding: 2px;
    }
    
    .cell {
        font-size: 14px;
    }
}

@media (max-width: 360px) {
    .game-board {
        max-width: min(240px, calc(100vw - 20px));
        gap: 1px;
        padding: 2px;
    }
    
    .cell {
        font-size: 12px;
    }
}

@media (max-height: 700px) {
    .game-board {
        max-width: min(250px, calc(100vw - 30px));
        gap: 1px;
        padding: 2px;
    }
}

@media (max-height: 670px) {
    .game-board {
        max-width: min(220px, calc(100vw - 20px));
        gap: 1px;
        padding: 2px;
    }
    
    .cell {
        font-size: 11px;
    }
}
*/


