:root {
  color-scheme: dark;
  --bg: #111;
  --fg: #ddd;
  --dim: #888;
  --value: #6c6;
  --ship: #69f;
  --selected: #4dd;
  --hit: #e55;
  --warn: #ec4;
}

body {
  margin: 0;
  padding: 1rem;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-monospace, monospace;
}

.lobby .label {
  color: var(--dim);
}

.lobby .value {
  color: var(--value);
  user-select: all;
  overflow-wrap: anywhere;
}

button {
  font: inherit;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--dim);
  border-radius: 4px;
  padding: 0.25rem 0.75rem;
  cursor: pointer;
}

button:hover,
button:focus-visible {
  border-color: var(--fg);
}

.ended {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

h2 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  font-weight: bold;
}

.gap {
  margin-top: 1rem;
}

.grids {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 4rem;
}

.grid {
  border-collapse: collapse;
  user-select: none;
}

/* Dragging a ship must not scroll the page instead. */
.grid.place .cell {
  touch-action: none;
}

.grid th {
  font-weight: normal;
  color: var(--dim);
  padding: 0 0.5rem 0 0;
  text-align: right;
}

.grid thead th {
  text-align: center;
  padding: 0;
}

.cell {
  width: 1.5em;
  height: 1.5em;
  text-align: center;
  outline-offset: -2px;
}

.cell.water,
.cell.miss {
  color: var(--dim);
}

.cell.ship {
  color: var(--ship);
}

.cell.ship.selected {
  color: var(--selected);
  font-weight: bold;
}

.cell.hit {
  color: var(--hit);
  font-weight: bold;
}

.cell.clickable {
  cursor: pointer;
}

.cell.cursor {
  outline: 2px solid var(--fg);
}

.grid.waiting .cell.cursor {
  outline-color: var(--dim);
}

/* Not my turn: a click does nothing. */
.grid.waiting .cell.clickable {
  cursor: default;
}

.cell.flash {
  background: var(--hit);
  color: var(--bg);
}

.sidebar .ships {
  list-style: none;
  margin: 0;
  padding: 0;
  white-space: pre;
}

.locked,
.banner.won,
.status.turn {
  color: var(--value);
  font-weight: bold;
}

.banner {
  margin: 0 0 0.5rem;
}

.banner.lost {
  color: var(--hit);
  font-weight: bold;
}

footer hr {
  border: 0;
  border-top: 1px solid var(--dim);
  margin: 1rem 0 0.25rem;
}

footer p,
footer ul {
  margin: 0;
}

.status {
  min-height: 1.2em;
  white-space: pre;
}

.status.warn {
  color: var(--warn);
  font-weight: bold;
}

.log {
  list-style: none;
  padding: 0;
  min-height: 3.6em;
}

.keys {
  color: var(--dim);
}

@media (max-width: 639px) {
  body {
    padding: 0.5rem;
  }

  .grids {
    flex-direction: column;
    gap: 1rem;
  }

  .status {
    white-space: pre-wrap;
  }
}
