:root {
    --bg: #0a1929;
    --panel: #102a43;
    --panel-2: #0e2438;
    --line: #1f4066;
    --text: #d9e2ec;
    --muted: #829ab1;
    --accent: #37b3ff;
    --accent-2: #ffb454;
    --danger: #ff6161;
    --ok: #3ddc97;
    --cell: 30px;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Segoe UI", Roboto, system-ui, sans-serif;
    background: radial-gradient(1200px 600px at 70% -10%, #12395f 0%, var(--bg) 55%);
    color: var(--text);
    min-height: 100vh;
}
.hidden { display: none !important; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    border-bottom: 1px solid var(--line);
    background: rgba(10, 25, 41, 0.85);
}
.brand { display: flex; gap: 8px; align-items: center; font-weight: 700; letter-spacing: 0.5px; }
.brand .icon { width: 20px; height: 20px; color: var(--accent); }
.whoami { color: var(--muted); font-size: 14px; }

main { max-width: 1100px; margin: 0 auto; padding: 20px; }
h1 { font-size: 24px; margin: 0 0 10px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; }
.card.narrow { max-width: 440px; margin: 60px auto; }
.card h2 { margin: 0 0 12px; font-size: 18px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.row.center { justify-content: center; margin-top: 16px; }
.columns { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; align-items: start; }
.status { min-height: 22px; font-size: 15px; margin: 6px 0; }
.banner { background: #14395e; border: 1px solid var(--accent); border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; font-size: 14px; }
.field { display: block; margin: 12px 0; }

input, select {
    background: var(--panel-2);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 14px;
}
button {
    background: #1c3f63;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 14px;
    cursor: pointer;
}
button:hover:not(:disabled) { background: #24507c; }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #04121f; font-weight: 600; }
button.primary:hover:not(:disabled) { background: #5cc3ff; }
button.danger { background: #5c2430; border-color: #83333f; }

/* Поля */
.boards { display: flex; gap: 30px; flex-wrap: wrap; justify-content: center; }
.board-wrap h3 { text-align: center; margin: 8px 0; font-weight: 600; }
.board {
    display: grid;
    grid-template-columns: 22px repeat(10, var(--cell));
    grid-template-rows: 22px repeat(10, var(--cell));
    gap: 2px;
    user-select: none;
    width: max-content;
}
.head { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; }
.cell { background: var(--panel-2); border: 1px solid var(--line); border-radius: 3px; position: relative; }
.cell.ship { background: #2f6da0; border-color: #59a0d1; }
.cell.miss::after {
    content: "";
    position: absolute; left: 50%; top: 50%;
    width: 6px; height: 6px; margin: -3px 0 0 -3px;
    border-radius: 50%;
    background: var(--muted);
}
.cell.hit, .cell.sunk { background: #8a4030; border-color: #c25b42; }
.cell.sunk { background: #a33524; border-color: #d05038; }
.cell.hit::after, .cell.sunk::after {
    content: "\2715";
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    color: #ffd9d0; font-weight: 700; font-size: 14px;
}
.cell.revealed { outline: 1px dashed #44607c; outline-offset: -4px; }
.cell.preview-ok { outline: 2px solid var(--ok); }
.cell.preview-bad { outline: 2px solid var(--danger); }
.cell.targetable { cursor: crosshair; }
.cell.targetable:hover { background: #17406b; }

/* Курсор-прицел на вражеском поле: круг + перекрестие + точка в центре.
   Хот-спот 16 16 — центр иконки 32x32. */
#enemy-board .cell.targetable {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cg fill='none' stroke='%23ff6161' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='16' cy='16' r='9'/%3E%3Cline x1='16' y1='1' x2='16' y2='7'/%3E%3Cline x1='16' y1='25' x2='16' y2='31'/%3E%3Cline x1='1' y1='16' x2='7' y2='16'/%3E%3Cline x1='25' y1='16' x2='31' y2='16'/%3E%3C/g%3E%3Ccircle cx='16' cy='16' r='1.5' fill='%23ff6161'/%3E%3C/svg%3E") 16 16, crosshair;
}

/* Турниры */
.t-form { display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px; margin-bottom: 10px; }
.t-item {
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
    padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
    margin-bottom: 8px; background: var(--panel-2);
}
.badge { font-size: 11px; padding: 2px 8px; border-radius: 10px; }
.badge.local { background: #173f2f; color: var(--ok); }
.badge.global { background: #3f2f17; color: var(--accent-2); }
.bracket { display: flex; gap: 14px; overflow-x: auto; padding: 10px 0; }
.round { display: flex; flex-direction: column; justify-content: space-around; gap: 10px; min-width: 150px; }
.round-title { font-size: 12px; color: var(--muted); text-align: center; margin-bottom: 4px; }
.match { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; font-size: 13px; }
.match .slot { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; color: var(--muted); }
.match .slot.winner { color: var(--ok); font-weight: 600; }
.champion { margin: 10px 0; font-size: 16px; color: var(--accent-2); font-weight: 700; }

/* Таблица рейтинга и журнал */
table.lb { width: 100%; border-collapse: collapse; font-size: 14px; }
table.lb th, table.lb td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line); }
table.lb th { color: var(--muted); font-weight: 500; font-size: 12px; }
#log { list-style: none; margin: 0; padding: 0; font-size: 12px; color: var(--muted); max-height: 180px; overflow-y: auto; }
#log li { padding: 2px 0; border-bottom: 1px dashed #16324f; }

.toast {
    position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px;
    background: #14395e; border: 1px solid var(--accent);
    padding: 10px 16px; border-radius: 8px; z-index: 50;
}
.toast.error { border-color: var(--danger); background: #4a1f26; }

@media (max-width: 900px) {
    .columns { grid-template-columns: 1fr; }
    .boards { flex-direction: column; align-items: center; }
    .t-form { grid-template-columns: 1fr 1fr; }
}