:root {
  --bg: #06202e; --surface: #0d2e40; --surface-2: #123c52; --ink: #eaf6fb; --ink-2: #8fb4c4; --line: #17475f;
  --accent: #5ee1ff; --accent-ink: #04222c; --ok: #7be8a8; --warn: #ffd08a; --bad: #ff6b6b; --info: #5ee1ff;
  --radar-bg: #06202e; --radar-line: rgba(94,225,255,.35); --hit: #ff8a3c; --hull: #8b97a3; --hull-rim: #4c5760;
  --font-display: "Exo 2", "Nunito Sans", sans-serif; --font-ui: "Nunito Sans", system-ui, sans-serif;
}
:root[data-theme="light"] { --bg: #eaf5fa; --surface: #ffffff; --surface-2: #dcecf3; --ink: #06202e; --ink-2: #3d6478; --line: #c3dce6; --accent: #0284c7; --accent-ink: #fff; --radar-bg: #0e3145; --radar-line: rgba(94,225,255,.45); }
:root[data-colorblind="1"] { --hit: #f2b705; }
body { background: radial-gradient(ellipse at 50% 0%, #0d3348 0%, var(--bg) 65%); font-family: var(--font-ui); }
:root[data-theme="light"] body { background: radial-gradient(ellipse at 50% 0%, #ffffff 0%, var(--bg) 65%); }

.logo { display: flex; justify-content: center; margin-bottom: -6px; } .logo canvas { width: 240px; height: 96px; }
.title { font-family: var(--font-display); font-weight: 800; letter-spacing: .04em; text-transform: uppercase; font-size: clamp(2.4rem, 12vw, 4.2rem); text-shadow: 0 0 16px color-mix(in oklab, var(--accent) 55%, transparent); }
.tagline { font-family: var(--font-ui); font-weight: 600; }
.modes { grid-template-columns: 1fr 1fr; }
.opts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.opt-toggle { height: 38px; padding: 0 14px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--ink-2); font-weight: 700; font-size: .82rem; border: 2px solid transparent; }
.opt-toggle[aria-pressed="true"] { color: var(--ink); border-color: var(--accent); background: color-mix(in oklab, var(--accent) 16%, var(--surface-2)); }
.opt-toggle:disabled { opacity: .4; }

/* ---- play screen ---- */
.stage[data-phase] { display: flex; flex-direction: column; min-height: 0; width: 100%; height: 100%; }
.place-view, .battle-view { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; height: 100%; min-height: 0; }
.grid-wrap { display: grid; place-items: center; flex: 1 1 auto; min-height: 0; width: 100%; }
.grid-wrap canvas { max-width: 100%; max-height: 100%; }
.place-view .grid-wrap { flex: 1 1 auto; max-height: 62%; }
.dock { display: flex; gap: 6px; overflow-x: auto; width: 100%; padding: 2px 2px 4px; flex: 0 0 auto; }
.dock-ship { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 60px; min-height: 48px; padding: 6px 8px; border-radius: var(--r-md); background: var(--surface-2); border: 2px solid transparent; }
.dock-ship b { font-size: .72rem; white-space: nowrap; } .dock-ship small { font-size: .68rem; color: var(--ink-2); }
.dock-ship[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 12px color-mix(in oklab, var(--accent) 45%, transparent); }
.dock-ship[data-placed="true"] { opacity: .5; }
.hull-strip { height: 10px; border-radius: 4px; background: linear-gradient(180deg, #b7c1c9, var(--hull) 50%, var(--hull-rim)); display: block; }
.place-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; width: 100%; flex: 0 0 auto; }
.place-actions .btn { min-height: 44px; padding: 0 6px; font-size: .82rem; }

.battle-grids { display: flex; flex-direction: row; gap: 8px; width: 100%; flex: 1 1 auto; min-height: 0; align-items: stretch; }
.grid-enemy { flex: 1 1 auto; order: 1; }
.grid-own { flex: 0 0 38%; order: 2; opacity: .96; }
.battle-grids[data-swapped="true"] .grid-enemy { flex: 0 0 38%; order: 2; }
.battle-grids[data-swapped="true"] .grid-own { flex: 1 1 auto; order: 1; }
.battle-actions { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; flex: 0 0 auto; padding-top: 2px; }
#btn-fire { min-width: 140px; min-height: 48px; letter-spacing: .04em; text-transform: uppercase; }
.salvo-pips { font-weight: 700; font-size: .85rem; color: var(--accent); background: var(--surface-2); padding: 6px 12px; border-radius: var(--r-pill); }

.hulls { display: inline-flex; gap: 3px; }
.hull-dot { width: 9px; height: 9px; border-radius: 2px; background: var(--pc); box-shadow: inset 0 -1px 0 rgb(0 0 0 / .3); }
.hull-dot[data-sunk="true"] { background: var(--line); box-shadow: none; opacity: .6; }

/* portrait: stack grids vertically instead of side-by-side so both stay legible at 360px */
@media (max-width: 480px) and (orientation: portrait) {
  .battle-grids { flex-direction: column; }
  .grid-enemy { flex: 1 1 auto; }
  .grid-own { flex: 0 0 34%; max-height: 34%; }
  .battle-grids[data-swapped="true"] .grid-own { flex: 1 1 auto; max-height: none; }
  .battle-grids[data-swapped="true"] .grid-enemy { flex: 0 0 34%; max-height: 34%; }
}
@media (min-width: 900px) and (min-aspect-ratio: 5/4) {
  .battle-grids { flex-direction: row; }
  .grid-enemy, .grid-own { flex: 1 1 0; order: initial; max-height: none; opacity: 1; }
  .battle-grids[data-swapped="true"] .grid-enemy, .battle-grids[data-swapped="true"] .grid-own { flex: 1 1 0; }
  #btn-swap { display: none; }
}
.result-verdict { color: var(--ink-2); font-weight: 600; }

/* room for "Grandmaster" beside the fleet pips on 360 px phones */
.play .seat { max-width: 60vw; }
