* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

body {
  background: #0C0D14;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding-top: 12px;
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: #e0e0e0;
}

#game-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 860px;
  padding: 0 8px;
}

/* ── Status Bar ──────────────────────────────────────────── */
#status-bar {
  width: 100%;
  background: #13141D;
  border: 1px solid rgba(0, 204, 255, 0.15);
  border-radius: 8px;
  padding: 10px 16px;
  text-align: center;
}

#status-text {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #00ccff;
}

/* ── Placement Controls ──────────────────────────────────── */
#placement-controls {
  width: 100%;
  background: #13141D;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 10px 16px;
}

#placement-controls.hidden {
  display: none;
}

#ship-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

#current-ship-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #00ccff;
}

.ctrl-btn {
  background: #1a2a4a;
  color: #e0e0e0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 6px 14px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
}

.ctrl-btn:hover {
  background: #254070;
  border-color: #00ccff;
}

.ctrl-btn.accent {
  background: rgba(0, 204, 255, 0.12);
  color: #00ccff;
  border-color: rgba(0, 204, 255, 0.3);
}

.ctrl-btn.accent:hover {
  background: rgba(0, 204, 255, 0.25);
}

/* ── Boards Wrapper ──────────────────────────────────────── */
#boards-wrapper {
  display: flex;
  gap: 20px;
  width: 100%;
  justify-content: center;
}

.board-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.board-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 3px;
  color: #888;
  text-transform: uppercase;
}

/* ── Fleet Status ────────────────────────────────────────── */
.fleet-status {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  min-height: 22px;
}

.ship-indicator {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  letter-spacing: 0.5px;
  color: #888;
  transition: opacity 0.3s;
}

.ship-indicator .ship-dots {
  display: flex;
  gap: 2px;
}

.ship-indicator .ship-dot {
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: #3a3a5c;
  transition: background 0.3s;
}

.ship-indicator.sunk {
  opacity: 0.35;
}

.ship-indicator.sunk .ship-dot {
  background: #ff4444;
}

/* ── Board Frame ─────────────────────────────────────────── */
.board-frame {
  display: flex;
  flex-direction: column;
}

.col-labels {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  margin-left: 18px;
  gap: 2px;
}

.col-labels span {
  text-align: center;
  font-size: 10px;
  color: #555;
  font-weight: 600;
}

.board-with-rows {
  display: flex;
}

.row-labels {
  display: flex;
  flex-direction: column;
  gap: 2px;
  justify-content: flex-start;
  width: 18px;
}

.row-labels span {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #555;
  font-weight: 600;
  height: var(--cell-size);
}

/* ── Board Grid ──────────────────────────────────────────── */
.board {
  display: grid;
  grid-template-columns: repeat(10, var(--cell-size));
  grid-template-rows: repeat(10, var(--cell-size));
  gap: 2px;
}

:root {
  --cell-size: 36px;
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  background: #1a2a4a;
  border: 1px solid #0f1a30;
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cell:hover {
  background: #253a5e;
}

/* Player board cells */
.cell.ship {
  background: #3a3a5c;
}

.cell.ship-preview {
  background: rgba(0, 204, 255, 0.2);
  border-color: rgba(0, 204, 255, 0.4);
}

.cell.ship-preview-invalid {
  background: rgba(255, 68, 68, 0.2);
  border-color: rgba(255, 68, 68, 0.4);
}

.cell.hit {
  background: #ff4444;
  animation: hitPulse 0.4s ease-out;
}

.cell.hit::after {
  content: '';
  position: absolute;
  width: 60%;
  height: 60%;
  background: #ff6644;
  border-radius: 50%;
  box-shadow: 0 0 8px #ff4444, 0 0 16px rgba(255, 68, 68, 0.4);
}

.cell.miss {
  background: #0d1b2a;
}

.cell.miss::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  background: #4488aa;
  border-radius: 50%;
  box-shadow: 0 0 4px rgba(68, 136, 170, 0.5);
}

.cell.sunk {
  background: #661111;
  animation: sinkPulse 0.6s ease-out;
}

.cell.sunk::after {
  content: 'X';
  font-size: 16px;
  font-weight: 900;
  color: #ff6644;
  text-shadow: 0 0 6px #ff4444;
}

/* Enemy board - disable hover when not playing */
#enemy-board.disabled .cell {
  cursor: default;
}

#enemy-board.disabled .cell:hover {
  background: #1a2a4a;
}

/* ── Animations ──────────────────────────────────────────── */
@keyframes hitPulse {
  0% { transform: scale(1.3); box-shadow: 0 0 20px rgba(255, 68, 68, 0.8); }
  100% { transform: scale(1); box-shadow: none; }
}

@keyframes sinkPulse {
  0% { transform: scale(1.2); box-shadow: 0 0 24px rgba(255, 68, 68, 0.9); }
  50% { transform: scale(0.9); }
  100% { transform: scale(1); box-shadow: none; }
}

@keyframes splashIn {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.4); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.cell.miss::after {
  animation: splashIn 0.3s ease-out;
}

/* ── Overlay ─────────────────────────────────────────────── */
#overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 13, 20, 0.92);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

#overlay.hidden {
  display: none;
}

#overlay-box {
  background: #13141D;
  border: 1px solid rgba(0, 204, 255, 0.2);
  border-radius: 16px;
  padding: 40px;
  text-align: center;
  max-width: 360px;
  width: 90%;
  box-shadow: 0 0 40px rgba(0, 204, 255, 0.08);
}

#overlay-box h1 {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 8px;
  color: #00ccff;
  text-shadow: 0 0 20px rgba(0, 204, 255, 0.3);
}

.subtitle {
  color: #888;
  font-size: 14px;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.controls-hint {
  color: #666;
  font-size: 12px;
  margin-bottom: 24px;
  line-height: 1.6;
}

.game-btn {
  background: linear-gradient(135deg, #00ccff 0%, #0088cc 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 32px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  box-shadow: 0 4px 20px rgba(0, 204, 255, 0.3);
}

.game-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(0, 204, 255, 0.4);
}

.game-btn:active {
  transform: translateY(0);
}

.hidden {
  display: none !important;
}

#result-title {
  font-size: 28px;
  margin-bottom: 8px;
}

#result-detail {
  color: #888;
  font-size: 13px;
  margin-bottom: 24px;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 600px) {
  :root {
    --cell-size: 28px;
  }

  #boards-wrapper {
    flex-direction: column;
    align-items: center;
    gap: 14px;
  }

  #game-container {
    padding-top: 4px;
  }

  .board-title {
    font-size: 11px;
    letter-spacing: 2px;
  }

  #overlay-box {
    padding: 28px 20px;
  }

  #overlay-box h1 {
    font-size: 26px;
  }

  .ctrl-btn {
    padding: 5px 10px;
    font-size: 11px;
  }
}

@media (max-width: 380px) {
  :root {
    --cell-size: 24px;
  }
}
