:root {
  color-scheme: dark;
  --bg: #08141f;
  --panel: #0f2230;
  --panel-2: #132b3a;
  --line: #274558;
  --text: #eff8ff;
  --muted: #8db1c7;
  --accent: #33c4a0;
  --danger: #ff5c7a;
  --water: #0b6a91;
  --ship: #d8dde6;
  --hit: #ff4f40;
  --miss: #b9e7ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top, #123248 0, var(--bg) 42%);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent);
  color: #031711;
  cursor: pointer;
  font-weight: 750;
  min-height: 42px;
  padding: 0 14px;
}

button:disabled {
  cursor: not-allowed;
  filter: grayscale(1);
  opacity: 0.55;
}

.app {
  margin: 0 auto;
  max-width: 980px;
  min-height: 100vh;
  padding: 18px;
}

.topbar,
.status,
.actions,
.invite,
.placement,
.board-panel {
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  padding: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
  letter-spacing: 0;
}

.label,
#subtitle,
.board-head span {
  color: var(--muted);
  display: block;
  font-size: 12px;
}

.icon-button {
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--text);
  font-size: 20px;
  width: 44px;
}

.status {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 90px;
  margin-top: 12px;
  padding: 14px;
}

.status strong {
  display: block;
  font-size: 18px;
  min-height: 25px;
}

#timer {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.actions {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 12px;
  padding: 10px;
}

.invite {
  margin-top: 12px;
  padding: 12px;
}

.placement {
  margin-top: 12px;
  padding: 12px;
}

.placement-head,
.placement-actions {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.placement-head button,
.placement-actions button {
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--text);
}

.ship-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.ship-choice {
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--text);
  min-height: 36px;
}

.ship-choice.active {
  background: var(--accent);
  color: #031711;
}

.ship-choice.done {
  opacity: 0.45;
}

.hidden {
  display: none;
}

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

.board-panel {
  padding: 12px;
}

.board-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.board {
  aspect-ratio: 1;
  display: grid;
  gap: 3px;
  grid-template-columns: repeat(10, 1fr);
  width: 100%;
}

.cell {
  align-items: center;
  aspect-ratio: 1;
  background: linear-gradient(145deg, #0a5879, var(--water));
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  display: flex;
  justify-content: center;
  min-width: 0;
  position: relative;
  transition: transform 160ms ease, filter 160ms ease, background 160ms ease;
}

.target .cell.available:hover {
  filter: brightness(1.35);
  transform: translateY(-2px);
}

.cell.ship {
  background: linear-gradient(145deg, #f4f7fb, var(--ship));
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.16);
}

.cell.ghost {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
}

.cell.hit,
.cell.sunk {
  animation: blast 420ms ease both;
  background: var(--hit);
}

.cell.miss {
  animation: splash 480ms ease both;
  background: #155a73;
}

.cell.hit::after,
.cell.sunk::after {
  content: "×";
  color: #fff;
  font-size: clamp(14px, 4vw, 30px);
  font-weight: 900;
}

.cell.miss::after {
  content: "•";
  color: var(--miss);
  font-size: clamp(16px, 4vw, 32px);
}

.toast {
  animation: rise 220ms ease both;
  background: #eef9ff;
  border-radius: 8px;
  bottom: 18px;
  color: #07151d;
  left: 50%;
  max-width: calc(100vw - 36px);
  padding: 12px 14px;
  position: fixed;
  transform: translateX(-50%);
  width: max-content;
}

@keyframes blast {
  0% {
    transform: scale(0.7);
  }
  60% {
    filter: brightness(1.5);
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes splash {
  0% {
    transform: scale(0.8);
  }
  50% {
    filter: brightness(1.6);
    transform: scale(1.06);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@media (max-width: 760px) {
  .app {
    padding: 12px;
  }

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