body {
    font-family: sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 10px; /* Reduced margin for smaller screens */
    background-color: #f0f0f0;
    min-height: 100vh; /* Ensure body takes full viewport height */
}

h1 {
    color: #333;
    font-size: 2em; /* Default font size */
    margin-bottom: 15px;
}

.game-container {
    display: flex;
    flex-wrap: wrap; /* Allow boards to wrap on smaller screens */
    gap: 20px; /* Reduced gap for smaller screens */
    margin-top: 15px;
    justify-content: center; /* Center items when wrapped */
    width: 100%; /* Take full width */
    max-width: 900px; /* Max width for larger screens */
}

canvas {
    border: 2px solid #333;
    background: linear-gradient(-45deg, #a7d9ed, #62b9d1, #a7d9ed, #62b9d1); /* More complex gradient */
    background-size: 400% 400%; /* Make background larger than canvas for animation */
    animation: waterFlow 15s ease infinite; /* Apply animation */
    display: block;
    width: calc(50% - 10px); /* Roughly half width, accounting for gap */
    max-width: 400px; /* Max width for individual canvas */
    height: auto; /* Maintain aspect ratio */
}

@keyframes waterFlow {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.player-board-container, .computer-board-container {
    text-align: center;
    flex: 1 1 45%; /* Allow containers to grow and shrink, with a base of 45% for two columns */
    min-width: 250px; /* Minimum width before stacking */
}

/* Media query for smaller screens */
@media (max-width: 768px) {
    h1 {
        font-size: 1.5em;
    }

    .game-container {
        flex-direction: column; /* Stack boards vertically */
        gap: 20px;
    }

    canvas {
        width: 90vw; /* Take up most of the viewport width */
        max-width: 350px; /* Even smaller max-width */
    }

    .player-board-container, .computer-board-container {
        flex: 1 1 100%; /* Take full width */
    }
}

button {
    margin-top: 20px;
    padding: 10px 20px;
    font-size: 1.2em;
    cursor: pointer;
}

/* Canvas is used for win/lose messaging now; no DOM overlay styles required. */

/* helper to hide computer during placement */
.hidden { display: none !important; }

/* Controls styling */
.controls { margin-top: 12px; display: flex; gap: 8px; align-items: center; }
.controls button { padding: 8px 12px; border: none; background: #222; color: #fff; border-radius: 6px; cursor: pointer; }
.controls button#randomizeButton { background: #2c9f4a; }
.controls button#restartButton { background: #c94b4b; }
.controls button:disabled { opacity: 0.5; cursor: not-allowed; }