* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #0a2a3a;
    color: #ecf0f1;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

#app {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

h1 {
    font-size: 28px;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: #3498db;
}

#message {
    font-size: 14px;
    color: #bdc3c7;
    min-height: 20px;
    text-align: center;
}

/* ---- Grid area — two panels side by side ---- */

#grid-area {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.grid-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition: opacity 0.3s;
}

.grid-panel-title {
    font-size: 15px;
    font-weight: bold;
    color: #85c1e9;
}

.panel-inactive {
    opacity: 0.25;
    pointer-events: none;
}

/* ---- Left panel (grayscale) ---- */

.grid-panel-mine .grid {
    background: #3a3a3a;
    border-color: #666;
}

.grid-panel-mine .grid-label {
    color: #aaa;
}

.grid-panel-mine .cell {
    background: #252525;
}

.grid-panel-mine .cell:hover {
    background: #333;
}

.grid-panel-mine .cell-ship {
    background: #555;
}

.grid-panel-mine .cell-hit {
    background: #e74c3c;
    color: #fff;
}

.grid-panel-mine .cell-sunk {
    background: #922b21;
    color: #fff;
}

.grid-panel-mine .cell-miss {
    background: #3a3a3a;
    color: #888;
}

/* ---- Grid ---- */

.grid {
    display: grid;
    grid-template-columns: 36px repeat(10, 42px);
    grid-template-rows: 36px repeat(10, 42px);
    gap: 1px;
    background: #1a5276;
    border: 2px solid #2980b9;
    border-radius: 4px;
    user-select: none;
}

.grid-label {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    color: #85c1e9;
}

.cell {
    background: #1a3c50;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.15s;
    border-radius: 2px;
}

.cell:hover {
    background: #1f4f6e;
}

/* Placement states */
.cell-ship {
    background: #566573;
}

.cell-ship-selected {
    background: #7f8c8d;
    animation: pulse 0.8s infinite alternate;
}

@keyframes pulse {
    from { opacity: 0.7; }
    to { opacity: 1; }
}

.cell-hover-valid {
    background: rgba(46, 204, 113, 0.5) !important;
}

.cell-hover-invalid {
    background: rgba(231, 76, 60, 0.5) !important;
}

/* Game states */
.cell-hit {
    background: #e74c3c;
    color: #fff;
}

.cell-sunk {
    background: #922b21;
    color: #fff;
}

.cell-miss, .cell-water {
    background: #2471a3;
    color: #aed6f1;
}

/* ---- Dock ---- */

#dock {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.dock-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px;
    background: #1a3c50;
    border: 2px solid #2980b9;
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.dock-item:hover {
    border-color: #3498db;
    background: #1f4f6e;
}

.dock-selected {
    border-color: #2ecc71 !important;
    background: #1a4a3a !important;
}

.dock-placed {
    opacity: 0.4;
    border-color: #566573;
}

.dock-label {
    font-size: 11px;
    color: #bdc3c7;
    white-space: nowrap;
}

.dock-preview {
    display: grid;
    gap: 1px;
}

.preview-cell {
    width: 16px;
    height: 16px;
    background: #1a3c50;
    border-radius: 1px;
}

.preview-ship {
    background: #85929e;
}

/* ---- Controls ---- */

#controls {
    display: flex;
    gap: 10px;
    min-height: 40px;
    align-items: center;
}

button {
    padding: 10px 28px;
    font-size: 16px;
    font-weight: bold;
    border: 2px solid #2980b9;
    border-radius: 6px;
    background: #1a5276;
    color: #ecf0f1;
    cursor: pointer;
    transition: background 0.2s;
    letter-spacing: 1px;
}

button:hover {
    background: #2980b9;
}

button:disabled {
    opacity: 0.4;
    cursor: default;
}

.nav-btn {
    display: none;
}

/* ---- Result overlay ---- */

#result {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    font-weight: bold;
    padding: 20px 40px;
    border-radius: 12px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 100;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

#result.visible {
    opacity: 1;
}

.result-water {
    background: rgba(41, 128, 185, 0.9);
    color: #fff;
}

.result-hit {
    background: rgba(231, 76, 60, 0.9);
    color: #fff;
}

.result-sunk {
    background: rgba(146, 43, 33, 0.9);
    color: #fff;
}

/* ---- Mobile ---- */

@media (max-width: 960px) {
    body {
        padding: 8px;
    }

    h1 {
        font-size: 22px;
    }

    /* Show only the active panel */
    #grid-area[data-view="left"] .grid-panel:nth-child(2) {
        display: none;
    }

    #grid-area[data-view="right"] .grid-panel:nth-child(1) {
        display: none;
    }

    /* Show nav button, hide sunk button on left view */
    .nav-btn {
        display: inline-block;
    }

    #grid-area[data-view="left"] ~ #controls .sunk-btn {
        display: none;
    }

    /* Grid fills screen width */
    .grid {
        grid-template-columns: 28px repeat(10, calc((100vw - 65px) / 10));
        grid-template-rows: 28px repeat(10, calc((100vw - 65px) / 10));
    }

    .grid-label {
        font-size: 12px;
    }

    .cell {
        font-size: 16px;
    }

    #result {
        font-size: 36px;
        padding: 14px 28px;
    }
}
