/* Game board styles */

/* ── Fleet tooltip (opponent hover) ──────────────────────────────────────── */
.fleet-tooltip {
    position: fixed;
    z-index: 9999;
    background: #2e2e2e;
    border: 1px solid #444;
    border-radius: 0;
    padding: 10px 16px;
    pointer-events: none;
    white-space: nowrap;
    font-size: 18px;
    color: rgb(180, 180, 180);
    box-shadow: none;
}
.fleet-tooltip__title {
    font-size: 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.6;
    margin-bottom: 8px;
}
.fleet-tooltip__ship {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    line-height: 1.8;
}
.fleet-tooltip__ship--sunk {
    opacity: 0.35;
    text-decoration: line-through;
}
.fleet-tooltip__meta {
    /* name + size prefix */
}
.fleet-tooltip__size {
    color: #888;
    letter-spacing: 2px;
}

.fleet-info-icon {
    font-size: 14px;
    opacity: 0.5;
    vertical-align: middle;
    cursor: help;
    user-select: none;
    transition: opacity 0.15s;
}
.board-label:hover .fleet-info-icon {
    opacity: 1;
}

.faction-tag {
    font-weight: bold;
}
.faction-tag--blue {
    color: #5aabff;
}
.faction-tag--red {
    color: #ff5a5a;
}

.game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.game-boards {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    justify-content: center;
    padding: 15px;
    flex-shrink: 0;
}

.board-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* Board header: fixed-height zone above each board so both boards align vertically
   regardless of whether the faction selector or opponent name is visible. */
.board-header {
    min-height: 64px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}

.board-label {
    font-size: 26px;
    font-weight: bold;
    letter-spacing: 1px;
    color: rgb(221, 221, 221);
}

/* Board container - fixed aspect ratio */
.board {
    flex-shrink: 0;
}

/* Board table */
.board__table {
    /* border-collapse: separate (not collapse) keeps each border owned by exactly
       one cell, avoiding Firefox's subpixel rounding inconsistencies when the
       table is inside a CSS transform: scale(). border-spacing: 0 keeps cells flush. */
    border-collapse: separate;
    border-spacing: 0;
    user-select: none;
    table-layout: fixed;
}

.board__table th {
    width: 30px;
    height: 30px;
    font-size: 11px;
    font-weight: bold;
    color: rgba(0, 255, 80, 0.85);
    text-align: center;
    vertical-align: middle;
}

.board__cell {
    width: 30px;
    height: 30px;
    /* Only right + bottom so adjacent cells never share/double a border edge. */
    border-right: 1px solid rgba(0, 255, 80, 0.7);
    border-bottom: 1px solid rgba(0, 255, 80, 0.7);
    background: transparent;
    cursor: default;
    transition: background 0.15s ease;
    text-align: center;
    vertical-align: middle;
}

/* Left edge: first td in every data row */
.board__table tr td:first-of-type {
    border-left: 1px solid rgba(0, 255, 80, 0.7);
}

/* Top edge: all cells in the first data row (tr index 2, after the header tr) */
.board__table tr:nth-child(2) .board__cell {
    border-top: 1px solid rgba(0, 255, 80, 0.7);
}

.board__cell:hover {
    background: rgba(0, 255, 80, 0.15);
}

/* Ship cell - default / blue faction */
.board__cell--ship {
    background: rgba(100, 180, 255, 0.55);
    border-color: rgba(100, 180, 255, 0.4);
    /* box-shadow is set inline by BoardRenderer to outline the whole ship */
}

/* Ship cell - red faction */
.board--faction-red .board__cell--ship {
    background: rgba(255, 100, 100, 0.55);
    border-color: rgba(255, 100, 100, 0.4);
    /* box-shadow is set inline by BoardRenderer */
}

/* Hit */
.board__cell--hit {
    background: rgba(255, 80, 80, 0.7);
    border-color: rgba(255, 80, 80, 0.5);
}

.board__cell--hit::after {
    content: '✕';
    font-size: 18px;
    color: white;
}

/* Miss */
.board__cell--miss {
    background: rgba(180, 180, 180, 0.25);
}

.board__cell--miss::after {
    content: '•';
    font-size: 20px;
    color: rgba(255, 255, 255, 0.5);
}

/* Sunk */
.board__cell--sunk {
    background: rgba(220, 30, 30, 0.9);
    border-color: rgba(255, 80, 80, 0.8);
    /* box-shadow is set inline by BoardRenderer for per-edge outline */
}

.board__cell--sunk::after {
    content: '✕';
    font-size: 18px;
    color: white;
}

/* Enemy sunk ships — orange pulse to stand out from friendly sunk (red) */
@keyframes enemy-sunk-pulse {
    0%, 100% { background: rgba(210, 80, 0, 0.92); }
    50%       { background: rgba(255, 140, 0, 0.65); }
}
.board--enemy .board__cell--sunk {
    background: rgba(210, 80, 0, 0.92);
    border-color: rgba(255, 140, 0, 0.9);
    animation: enemy-sunk-pulse 2s ease-in-out infinite;
}

/* Island */
.board__cell--island {
    background: rgba(80, 60, 30, 0.7);
    border-color: rgba(80, 60, 30, 0.5);
    cursor: not-allowed;
}

/* Exclusion zone - cells where ships cannot be placed (adjacent to existing ships) */
.board__cell--exclusion {
    background: rgba(200, 200, 200, 0.08);
    border-color: rgba(200, 200, 200, 0.28);
}

/* Failed rotation flash */
@keyframes rotate-fail-flash {
    0%   { background: rgba(255, 215, 0, 0.7); box-shadow: inset 0 0 0 2px rgba(255, 180, 0, 0.9); }
    100% { background: rgba(255, 215, 0, 0); box-shadow: none; }
}
.board__cell--rotate-fail {
    animation: rotate-fail-flash 0.5s ease-out;
}

/* Drag ghost - valid position */
.board__cell--ghost-valid {
    background: rgba(80, 220, 100, 0.45) !important;
    border-color: rgba(80, 220, 100, 0.5) !important;
}

/* Drag ghost - invalid position */
.board__cell--ghost-invalid {
    background: rgba(255, 60, 60, 0.45) !important;
    border-color: rgba(255, 60, 60, 0.5) !important;
}

/* Firing pattern hover preview on enemy board */
.board__cell--hover-target {
    background: rgba(255, 80, 80, 0.35) !important;
    border-color: rgba(255, 80, 80, 0.6) !important;
    transition: background 0.05s;
}

/* Enemy board */
.board--enemy .board__cell {
    cursor: crosshair;
}

.board--enemy .board__cell--ship {
    /* Hide enemy ships - show as empty water */
    background: rgba(0, 100, 180, 0.25);
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: none;
}

/* Suppress hover highlight on own board during active battle */
.board--no-hover .board__cell:hover {
    background: rgba(0, 100, 180, 0.25);
    cursor: default;
}
/* Keep ship background unchanged on hover (no glowing water) */
.board--no-hover .board__cell--ship:hover {
    background: rgba(100, 180, 255, 0.55);
}
.board--no-hover.board--faction-red .board__cell--ship:hover {
    background: rgba(255, 100, 100, 0.55);
}

/* Revealed enemy ships at game end (outline set inline by BoardRenderer.revealShips) */
.board__cell--revealed {
    background: rgba(255, 160, 60, 0.45);
}

/* Disabled / greyed out board */
.board--disabled {
    opacity: 0.6;
    pointer-events: none;
}

/* Randomize & controls */
.board-controls {
    display: flex;
    gap: 5px;
    justify-content: left;
    flex-wrap: wrap;
}

.board-controls .btn-primary,
.board-controls .btn-secondary {
    padding: 8px 18px;
    font-size: 14px;
    margin: 0;
}

/* Responsive */
/* @media (max-width: 900px) {
    .game-boards {
        flex-direction: column;
        align-items: center;
    }
} */

/* Game status & controls bar */
/* .game-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 0 15px;
    flex-shrink: 0;
} */

.game-status {
    text-align: center;
    padding: 10px 20px;
    font-size: 14px;
    color: #e0e0e0;
    background: transparent;
    border-radius: 8px;
    min-height: 24px;
    width: 100%;
    max-width: 500px;
}

/* .game-footer-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
} */

/* Faction selector */
.faction-selector {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.faction-option {
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 4px;
    transition: border-color 0.15s, filter 0.15s;
    filter: grayscale(100%) brightness(0.5);
    user-select: none;
    padding: 0;
    line-height: 0;
}

.faction-option img {
    display: block;
    width: auto;
    height: auto;
    pointer-events: none;
}

.faction-option.selected {
    filter: none;
}

.faction-option--blue.selected {
    border-color: #8cc4ff;
}

.faction-option--red.selected {
    border-color: #ff8c8c;
}

.game-footer-controls .btn-primary,
.game-footer-controls .btn-secondary {
    padding: 8px 18px;
    font-size: 14px;
    margin: 0;
}
