:root {
    --bg: #f4efe3;
    --panel: #fffdf8;
    --ink: #101010;
    --accent: #b6482f;
    --accent-2: #2568a0;
    --ok: #1f7a3f;
    --warn: #b66f15;
    --error: #9f1f1f;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, #efe2c0 0, transparent 30%),
        radial-gradient(circle at bottom right, #ded3bf 0, transparent 35%),
        var(--bg);
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

.landing-page,
.setup-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.landing-shell,
.setup-shell {
    width: min(680px, 100%);
    background: var(--panel);
    border: 3px solid var(--ink);
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.1);
    padding: 28px;
}

h1,
h2 {
    margin: 0 0 12px;
    letter-spacing: 0.02em;
}

p {
    margin-top: 0;
}

.setup-form {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

label {
    font-weight: 700;
}

input {
    width: 100%;
    padding: 10px 12px;
    font-size: 16px;
    border: 2px solid #5a5a5a;
    border-radius: 8px;
    background: #fff;
}

.setup-message {
    min-height: 20px;
    font-weight: 700;
}

.setup-message.ok {
    color: var(--ok);
}

.setup-message.warn {
    color: var(--warn);
}

.setup-message.error {
    color: var(--error);
}

.primary-btn,
.secondary-btn {
    display: inline-block;
    border: 2px solid var(--ink);
    border-radius: 10px;
    padding: 10px 14px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
}

.primary-btn {
    background: var(--accent);
    color: #fff;
}

.primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.secondary-btn {
    background: var(--accent-2);
    color: #fff;
}

.leaderboard-panel {
    margin: 18px 0;
    padding: 12px;
    border: 2px solid #2a2a2a;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.7);
}

.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.leaderboard-header h2 {
    margin: 0;
}

.leaderboard-status {
    margin: 10px 0;
    font-weight: 700;
}

.leaderboard-table-wrap {
    overflow-x: auto;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.leaderboard-table th,
.leaderboard-table td {
    border: 1px solid #3e3e3e;
    padding: 8px;
    text-align: left;
    font-size: 14px;
}

.leaderboard-table th {
    background: #ebdfc9;
}

.back-link {
    display: inline-block;
    margin-top: 14px;
    font-weight: 700;
    color: var(--ink);
}

.game-page {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    background:
        radial-gradient(circle at 15% 20%, rgba(112, 165, 202, 0.28), transparent 38%),
        radial-gradient(circle at 86% 8%, rgba(58, 111, 157, 0.25), transparent 32%),
        linear-gradient(180deg, #b9d4ea 0%, #8fb4d2 45%, #6f9ec4 100%);
}

.game-header,
.game-footer {
    padding: 14px 18px;
    background: rgba(241, 248, 255, 0.86);
    border-bottom: 2px solid #173247;
    backdrop-filter: blur(3px);
}

.game-header {
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.game-header p {
    margin: 0;
    font-weight: 700;
}

.game-footer {
    border-top: 2px solid #173247;
    border-bottom: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.control-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.split-screen-wrap {
    display: grid;
    grid-template-columns: 1fr 18px 1fr;
    min-height: 0;
}

.split-divider {
    background: #000;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.player-pane {
    padding: 16px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    background:
        linear-gradient(180deg, rgba(241, 248, 255, 0.7), rgba(218, 236, 250, 0.82)),
        repeating-linear-gradient(
            0deg,
            rgba(0, 62, 106, 0.05) 0,
            rgba(0, 62, 106, 0.05) 1px,
            transparent 1px,
            transparent 18px
        );
}

.player-pane.active-pane {
    box-shadow: inset 0 0 0 3px rgba(15, 73, 119, 0.55);
}

.player-meta {
    font-weight: 700;
}

.turn-indicator {
    min-height: 28px;
    margin: 0 0 8px;
    padding: 4px 12px;
    border-radius: 999px;
    font-weight: 800;
    letter-spacing: 0.03em;
    color: transparent;
}

.turn-indicator.is-active {
    color: #fff;
    background: linear-gradient(180deg, #1f8a4d 0%, #166a3a 100%);
    box-shadow: 0 4px 10px rgba(16, 83, 45, 0.35);
}

.grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(10, 1fr);
    gap: 5px;
    margin-top: 10px;
    width: min(100%, 640px);
    aspect-ratio: 1 / 1;
    padding: 8px;
    border-radius: 10px;
    border: 2px solid #184a6a;
    background: rgba(13, 53, 82, 0.2);
    box-shadow: 0 10px 24px rgba(7, 27, 43, 0.24);
}

.cell {
    border: 1px solid #20577a;
    border-radius: 4px;
    background:
        radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.32), transparent 48%),
        linear-gradient(180deg, #8dc0df 0%, #76afd2 46%, #5f9bc4 100%);
    cursor: pointer;
}

.cell.ship {
    border-color: #26313a;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0) 34%),
        repeating-linear-gradient(
            90deg,
            #48545f 0,
            #48545f 8px,
            #3b4651 8px,
            #3b4651 14px
        );
    box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.3);
}

.cell.hit {
    border-color: #7a1616;
    background:
        radial-gradient(circle at 50% 50%, #ffca57 0%, #ff7448 34%, #b62323 76%);
}

.cell.miss {
    border-color: #4b6d84;
    background:
        radial-gradient(circle at 50% 50%, #ffffff 0%, #d5e5f0 35%, #9fb7c9 88%);
}

.cell.disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.cell.preview-valid {
    background: #5cab75;
}

.cell.preview-invalid {
    background: #d57a7a;
}

.ship-dock {
    margin-top: 12px;
    padding: 10px;
    border: 2px dashed #23455f;
    border-radius: 10px;
    background: rgba(231, 243, 253, 0.86);
    min-height: 86px;
}

.ship-dock-title {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 700;
}

.ship-dock-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.dock-ship {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 5px;
    border: 2px solid #253645;
    border-radius: 8px;
    background: linear-gradient(180deg, #ddebf6 0%, #b3cedf 100%);
    cursor: grab;
    user-select: none;
    box-shadow: 0 3px 8px rgba(8, 34, 56, 0.2);
}

.dock-ship.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.dock-ship-cell {
    width: 16px;
    height: 14px;
    border: 1px solid #2d3135;
    background:
        linear-gradient(180deg, #5b6670 0%, #414c56 100%);
}

.dock-ship-cell.is-bow {
    border-radius: 8px 2px 2px 8px;
}

.dock-ship-cell.is-stern {
    border-radius: 2px 8px 8px 2px;
}

.dock-ship-cell.is-single {
    border-radius: 8px;
}

.dock-empty {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    color: #2b6f4d;
}

#resultStatus {
    font-weight: 700;
}

@media (max-width: 1100px) {
    .split-screen-wrap {
        grid-template-columns: 1fr;
        grid-template-rows: auto 12px auto;
    }

    .split-divider {
        height: 12px;
        width: 100%;
    }

    .grid {
        width: min(100%, 520px);
    }
}
