:root {
  color-scheme: dark;
  --bg: #101418;
  --panel: #182028;
  --line: #2f3a45;
  --text: #edf3f7;
  --muted: #9aaab5;
  --water: #123247;
  --water-hover: #1d4b68;
  --ship: #74808a;
  --hit: #d94a3a;
  --miss: #c8d4dc;
  --accent: #19a974;
  --warn: #e4aa30;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
.button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #22303a;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  text-decoration: none;
  font: inherit;
}

button:hover,
.button:hover {
  background: #2b3b47;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.app {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar,
.panelHead,
.boardTitle,
.actions,
.status {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 1;
}

h2 {
  font-size: 1rem;
}

p,
.label,
.boardTitle span,
.log {
  color: var(--muted);
}

.actions {
  gap: 8px;
  flex-wrap: wrap;
}

.status {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.status > div,
.panel,
.boardWrap,
.shareCodePanel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.status > div {
  padding: 12px;
}

.shareCodePanel {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 12px;
  margin-bottom: 14px;
}

.qrCode {
  width: 196px;
  height: 196px;
  display: block;
  background: #ffffff;
  border-radius: 4px;
  justify-self: end;
}

.label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.panel {
  padding: 14px;
  margin-bottom: 14px;
}

.panelHead,
.boardTitle {
  justify-content: space-between;
  gap: 12px;
}

.shipList {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.shipList button {
  min-width: 128px;
}

.shipList button.selected {
  border-color: var(--accent);
  color: #dbfff2;
}

.shipList button.placed {
  background: #173729;
}

.boards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.boardWrap {
  padding: 14px;
  min-width: 0;
}

.boardTitle {
  margin-bottom: 10px;
}

.board {
  display: grid;
  grid-template-columns: repeat(10, minmax(22px, 1fr));
  gap: 4px;
  aspect-ratio: 1;
}

.cell {
  border: 1px solid #27516a;
  border-radius: 4px;
  background: var(--water);
  color: var(--text);
  min-width: 0;
  padding: 0;
  position: relative;
}

.cell::after {
  content: attr(data-label);
  position: absolute;
  top: 3px;
  left: 4px;
  color: rgba(255, 255, 255, 0.45);
  font-size: clamp(0.46rem, 1vw, 0.65rem);
}

.cell.ship {
  background: var(--ship);
  border-color: #9aa4ad;
}

.cell.target:hover {
  background: var(--water-hover);
}

.cell.hit {
  background: var(--hit);
  border-color: #ff9588;
}

.cell.miss {
  background: #e9f1f5;
  border-color: #ffffff;
}

.cell.miss::before {
  content: "";
  width: 28%;
  height: 28%;
  border-radius: 999px;
  background: #37515f;
  position: absolute;
  inset: 36%;
}

.cell.sunk {
  outline: 2px solid var(--warn);
}

.log {
  margin: 12px 0 0;
  padding-left: 20px;
  min-height: 76px;
}

.log li {
  margin: 4px 0;
}

@media (max-width: 820px) {
  .topbar,
  .panelHead {
    align-items: flex-start;
    flex-direction: column;
  }

  .status,
  .boards,
  .shareCodePanel {
    grid-template-columns: 1fr;
  }

  .qrCode {
    justify-self: start;
  }
}
