:root {
    --bg-color: #1e293b;
    --board-bg: #334155;
    --cell-border: #475569;
    --cell-size: 35px; /* Change this to resize the whole game */
    --accent-blue: #38bdf8;
    --accent-red: #ef4444;
    --accent-yellow: #facc15;
    --text-color: #f1f5f9;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Courier New', Courier, monospace; /* Monospace for tactical feel */
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

/* --- Layout Containers --- */
#main {
    display: flex;
    flex-wrap: wrap;
    gap: 50px;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    background: #0f172a;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    border: 1px solid #334155;
}

.hide {
    display: none !important;
}

/* --- The Grids --- */
#container, #enemyContainer, .initContainer {
    display: grid;
    /* Uses the variable to set grid size perfectly */
    grid-template-columns: repeat(10, var(--cell-size));
    grid-template-rows: repeat(10, var(--cell-size));
    border: 2px solid var(--accent-blue);
    background-color: var(--board-bg);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.2);
}

/* Individual Cells */
.cell, #mockCell {
    width: var(--cell-size);
    height: var(--cell-size);
    border: 1px solid var(--cell-border);
    transition: background-color 0.2s;
}

/* Enemy Board Hover Effect */
#enemyContainer .cell:not(.bombed):not(.missed):hover {
    background-color: rgba(255, 255, 255, 0.1);
    cursor: crosshair;
}

/* --- Setup Phase Layout --- */
#initBoard {
    /* Removed absolute positioning */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

/* Ship Dock (Drag and Drop Area) */
#dragandrop {
    /* Removed absolute positioning */
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    border: 1px dashed var(--accent-blue);
}

/* --- Draggable Ships --- */
/* We calculate width based on cell size to ensure they fit perfectly */
#battleship {
    background-color: var(--accent-blue);
    width: calc(var(--cell-size) * 4); 
    height: var(--cell-size);
    margin-bottom: 10px;
    border: 1px solid white;
    cursor: grab;
    border-radius: 4px;
}
#submarine {
    background-color: var(--accent-blue);
    width: calc(var(--cell-size) * 3);
    height: var(--cell-size);
    margin-bottom: 10px;
    border: 1px solid white;
    cursor: grab;
    border-radius: 4px;
}
#patrol {
    background-color: var(--accent-blue);
    width: calc(var(--cell-size) * 2);
    height: var(--cell-size);
    margin-bottom: 10px;
    border: 1px solid white;
    cursor: grab;
    border-radius: 4px;
}
#simple {
    background-color: var(--accent-blue);
    width: var(--cell-size);
    height: var(--cell-size);
    margin-bottom: 10px;
    border: 1px solid white;
    cursor: grab;
    border-radius: 4px;
}

/* --- Game States --- */

/* Placed Ship */
.ship {
    background-color: #64748b; /* Steel gray for ships */
    border: 1px solid #94a3b8;
    position: relative;
}
/* Add a little "rivet" look to ships */
.ship::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40%;
    height: 40%;
    background: rgba(0,0,0,0.2);
    border-radius: 50%;
}

/* Miss */
.missed {
    background-color: transparent;
    position: relative;
}
.missed::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    background-color: var(--text-color); /* White dot */
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: splash 0.3s ease-out;
}

/* Hit / Bombed */
.bombed {
    background-color: var(--accent-red);
    position: relative;
    box-shadow: inset 0 0 10px black;
    animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}
/* X mark on hit */
.bombed::before, .bombed::after {
    content: '';
    position: absolute;
    background-color: white;
    top: 50%;
    left: 50%;
    width: 70%;
    height: 3px;
    border-radius: 2px;
}
.bombed::before { transform: translate(-50%, -50%) rotate(45deg); }
.bombed::after { transform: translate(-50%, -50%) rotate(-45deg); }

/* --- UI Elements --- */

#left {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

button {
    background: transparent;
    color: var(--accent-blue);
    border: 2px solid var(--accent-blue);
    padding: 10px 20px;
    font-size: 1rem;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 10px;
    box-shadow: 0 0 5px var(--accent-blue);
}

button:hover {
    background: var(--accent-blue);
    color: #0f172a;
    box-shadow: 0 0 15px var(--accent-blue);
}

#message {
    width: 100%;
    text-align: center;
    color: var(--accent-yellow);
    font-weight: bold;
    margin-bottom: 20px;
    padding: 10px;
    border: 1px solid var(--accent-yellow);
    background: rgba(250, 204, 21, 0.1);
}

/* --- Animations --- */

@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}

@keyframes splash {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    50% { opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
}
