/* Screen management */
.screen {
    width: 100%;
    min-height: 100vh;
}

body {
    background-color: #303030;
    margin: 0;
    color: white;
    font-family: Verdana, Geneva, Tahoma, sans-serif;
}

/* ============================================
GAME SCREEN LAYOUT
============================================ */

#game-screen {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
    /* overflow: hidden; */
}

.container {
    width: 100%;
    max-width: 1400px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.boards-container {
    display: flex;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    box-sizing: border-box;
    flex: 1;
    /* overflow: hidden; */
}

.player-turn-container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    margin-bottom: 20px;
    flex-shrink: 0;
}

#leave-game-button {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    padding: 10px 20px;
    background-color: #d32f2f;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

#leave-game-button:hover {
    background-color: #b71c1c;
}

/* Main game area - board and controls side by side */
#game {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 40px;
    width: 100%;
    flex-wrap: wrap;
    flex: 1;
    /* overflow: hidden; */
}

/* Board styling */
.board {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(10, 1fr);
    aspect-ratio: 1/1;
    width: min(500px, 45vw);
    background-color: #ddd;
    border: 2px solid #333;
    flex-shrink: 1;
}

.cell {
    background-color: #3997cc;
    border: 1px solid #333;
    display: flex;
    justify-content: center;
    align-items: center;
}

.enemy-cell {
    background-color: #3997cc;
    border: 1px solid #333;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Choose container - sidebar */
.choose-container {
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 20px;
    background-color: #404040;
    border-radius: 10px;
    min-width: 250px;
    max-width: 500px;
    width: 100%;
    align-self: flex-start;
    box-sizing: border-box;
}

.choose-container h3 {
    margin: 0 0 5px 0;
    font-size: 16px;
    color: #3997cc;
}

.choose-container button {
    width: 100%;
    padding: 12px;
    font-size: 14px;
    border-radius: 5px;
    transition: all 0.2s;
}

/* Bomb indicators */
.hit-bomb {
    width: 35%;
    height: 35%;
    border-radius: 50%;
    background-color: red;
}

.miss-bomb {
    width: 35%;
    height: 35%;
    border-radius: 50%;
    background-color: white;
}

.hover-bomb {
    width: 35%;
    height: 35%;
    border-radius: 50%;
    background-color: white;
    opacity: 50%;
}

.last-hit-bomb {
    width: 35%;
    height: 35%;
    border-radius: 50%;
    background-color: #FFD700;
}

/* Button styling */
button {
    box-sizing: border-box;
    padding: 12px 20px;
    background-color: lightblue;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

button:hover {
    background-color: #5ab7ec;
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    background-color: #85a6b3;
    cursor: not-allowed;
    transform: none;
}

.replaceBoat {
    background-color: #d32f2f;
    color: white;
}

.replaceBoat:hover {
    background-color: #b71c1c;
}

.startButtonContainer {
    display: none;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #555;
}

.startButtonContainer h3 {
    margin-top: 0;
}

#startButton {
    background-color: #4caf50;
    color: white;
    padding: 15px;
    font-size: 16px;
}

#startButton:hover {
    background-color: #388e3c;
}

#resetButton {
    background-color: #ff9800;
    color: white;
}

#resetButton:hover {
    background-color: #f57c00;
}

.rotateButtonContainer {
    display: none;
}

/* ============================================
RESPONSIVE DESIGN
============================================ */

/* Very large screens - board and controls side by side */
@media (min-width: 1263px) {
    #game {
        flex-wrap: nowrap;
    }

    .board {
        width: min(600px, 45vw);
    }

    .choose-container {
        max-width: 300px;
    }
}

/* Medium-large screens - 2 boards horizontal but smaller */
@media (min-width: 900px) and (max-width: 1262px) {
    .boards-container {
        gap: 0.5rem;
    }

    .board {
        width: min(45vw, calc((100vh - 140px) * 0.9));
    }

    .choose-container {
        max-width: 300px;
    }
}

/* Medium to small screens - vertical stacking */
@media (max-width: 899px) {
    #game-screen {
        padding: 10px;
    }

    .rotateButtonContainer {
        display: block;
    }

    .boards-container {
        flex-direction: column;
        gap: 0.5rem;
        justify-content: center;
        padding: 0;
    }

    .board {
        /* Calculate available height: 100vh - header (80px) - gaps (20px) - padding (40px) */
        width: min(400px, 90vw, calc((100vh - 140px) / 2));
        flex-shrink: 1;
    }

    .choose-container {
        width: min(500px, 90vw);
        max-width: 500px;
        flex-direction: column-reverse;
    }

    .player-turn-container h2 {
        font-size: 1.2rem;
    }
}

/* Small screens - more compact */
@media (max-width: 599px) {
    #game-screen {
        padding: 5px;
    }

    .player-turn-container {
        margin-bottom: 10px;
    }

    .player-turn-container h2 {
        font-size: 1rem;
    }

    #game {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }

    .boards-container {
        gap: 0.3rem;
    }

    .board {
        /* More aggressive sizing for small screens */
        width: min(95vw, calc((100vh - 120px) / 2));
        max-width: 350px;
    }

    .choose-container {
        width: 95vw;
        min-width: unset;
        max-width: unset;
    }

    .player-turn-container {
        flex-direction: column;
        gap: 10px;
    }

    #leave-game-button {
        display: none;
        position: static;
        transform: none;
        width: 100%;
    }

    .choose-container h3 {
        font-size: 14px;
    }

    button {
        padding: 10px;
        font-size: 13px;
    }
}

/* Very small screens */
@media (max-width: 400px) {
    .boards-container {
        gap: 0.2rem;
    }

    .choose-container {
        padding: 15px;
        gap: 10px;
    }

    .choose-container h3 {
        font-size: 13px;
        margin-bottom: 3px;
    }

    button {
        padding: 8px;
        font-size: 12px;
    }

    .player-turn-container h2 {
        font-size: 0.9rem;
        text-align: center;
    }
}
