:root {
  --bg: #1A1A1A;
  --surface: #242424;
  --line: #3A3A3A;
  --text: #E0E0E0;
  --muted: #888888;
  --orange: #E85D00;
  --orange-muted: #D4722A;
  --green: #4ADE80;
  --stop: #CC3333;
  --cell: clamp(24px, 7.6vw, 38px);
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 Inter, system-ui, sans-serif;
}

.o { color: var(--orange); }
.muted { color: var(--muted); }

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 24px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
}

.wordmark { color: var(--text); text-decoration: none; font-weight: 700; }
#code { color: var(--green); font-weight: 700; letter-spacing: 0.15em; margin-right: 12px; }

main { max-width: 960px; margin: 0 auto; padding: 32px 24px 64px; }

h1 { font-size: 48px; font-weight: 700; line-height: 1.1; margin: 24px 0 16px; }
h2, label {
  display: block;
  font: 700 13px var(--mono);
  letter-spacing: 0.05em;
  margin: 32px 0 12px;
}
h2 .muted { font-weight: 400; }
.lede { font-size: 18px; color: var(--muted); max-width: 34em; }

button, input {
  font: 400 14px var(--mono);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 10px 16px;
}
button { cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--orange); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.primary { background: var(--orange); border-color: var(--orange); color: #111; font-weight: 700; }
button.primary:hover:not(:disabled) { background: var(--orange-muted); }
button.ghost { background: none; padding: 4px 10px; font-size: 12px; }
input:focus-visible, button:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
#name { width: min(100%, 320px); }
#join-code { width: 7em; text-transform: uppercase; letter-spacing: 0.2em; }
kbd { font: inherit; color: var(--muted); }

.lobby-actions { display: flex; flex-wrap: wrap; gap: 0 64px; }
.error { color: var(--stop); font-family: var(--mono); font-size: 14px; min-height: 1.5em; margin: 8px 0 0; }

#status { font: 700 18px var(--mono); margin: 0; }
.cursor { color: var(--orange); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.boards { display: flex; flex-wrap: wrap; gap: 0 48px; }

.board {
  display: grid;
  grid-template-columns: repeat(11, var(--cell));
  grid-auto-rows: var(--cell);
  font: 400 12px var(--mono);
  width: max-content;
}
.board .label { display: grid; place-items: center; color: var(--muted); }
.cell {
  padding: 0;
  border: 1px solid var(--bg);
  background: var(--surface);
  display: grid;
  place-items: center;
  font: 700 calc(var(--cell) * 0.5) / 1 var(--mono);
  color: var(--muted);
}
.cell:disabled { opacity: 1; cursor: default; }
.cell.ship { background: #5C5C5C; }
.cell.preview { background: var(--orange-muted); }
.cell.preview.bad { background: var(--stop); }
.cell.miss::after { content: '·'; }
.cell.hit { color: var(--orange); }
.cell.hit::after { content: '×'; }
.cell.sunk { background: var(--stop); color: #111; }
.cell.last { outline: 2px solid var(--orange); outline-offset: -2px; }
.board.live .cell:not(.miss):not(.hit) { cursor: crosshair; }
.board.live .cell:not(.miss):not(.hit):hover { border-color: var(--orange); background: #333; }

#ships { list-style: none; padding: 0; margin: 16px 0; font: 400 14px var(--mono); }
#ships li { display: flex; gap: 12px; align-items: center; padding: 2px 0; color: var(--muted); }
#ships li.next { color: var(--text); }
#ships li.next::before { content: '$'; color: var(--orange); }
#ships li.placed { color: var(--green); }
#ships li.placed::before { content: '✓'; }
#ships li::before { content: ' '; width: 1ch; white-space: pre; }
#ships .pips { letter-spacing: 2px; }
.dock-actions { display: flex; flex-wrap: wrap; gap: 8px; }
#rematch { margin-top: 16px; }

#log { list-style: none; padding: 0; margin: 0; font: 400 14px var(--mono); color: var(--muted); }
#log li:first-child { color: var(--text); }
#log .sunk { color: var(--stop); }
#log .hit { color: var(--orange); }
