/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Nunito', sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== TOPBAR ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #16213e;
  padding: 0.6rem 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.btn-back {
  color: #8be9fd;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
  transition: opacity 0.2s;
}
.btn-back:hover { opacity: 0.7; }
.game-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: #f8f8f2;
}
.stats {
  display: flex;
  gap: 0.8rem;
  font-size: 0.9rem;
  font-weight: 600;
}

/* ===== GAME WRAPPER ===== */
.game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.8rem 0.5rem 2rem;
  gap: 0.8rem;
}

/* ===== TURN INDICATOR ===== */
.turn-indicator {
  background: #0f3460;
  color: #8be9fd;
  padding: 0.5rem 1.4rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
  transition: background 0.3s, color 0.3s;
}
.turn-indicator.enemy-turn {
  background: #5a1a1a;
  color: #ff6b6b;
}

/* ===== BUTTONS ===== */
.btn {
  padding: 0.6rem 1.6rem;
  border: none;
  border-radius: 10px;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn:active { transform: scale(0.96); }
.btn-orange {
  background: linear-gradient(135deg, #f2994a, #f2784b);
  color: #fff;
  box-shadow: 0 3px 12px rgba(242,153,74,0.4);
}
.btn-orange:hover { box-shadow: 0 4px 18px rgba(242,153,74,0.6); }
.btn-small {
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  background: #2a2a4a;
  color: #8be9fd;
  border: 1px solid #3a3a5a;
}
.btn-small:hover { background: #3a3a5a; }
.btn-blue {
  background: linear-gradient(135deg, #4a90d9, #357abd);
  color: #fff;
  border: none;
}
.btn-blue:hover { box-shadow: 0 3px 12px rgba(74,144,217,0.5); }

/* ===== PLACEMENT PANEL ===== */
.placement-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  width: 100%;
}
.placement-info {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.placement-info p {
  font-size: 1rem;
  font-weight: 700;
  color: #50fa7b;
}
.placement-buttons {
  display: flex;
  gap: 0.6rem;
}
.btn-start {
  margin-top: 0.4rem;
  font-size: 1.1rem;
  padding: 0.7rem 2rem;
}

/* ===== BATTLE PANEL ===== */
.battle-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  width: 100%;
}
.boards {
  display: flex;
  gap: 1.2rem;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
}

/* ===== GRID ===== */
.board-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.board-container.single-board {
  margin: 0 auto;
}
.grid-label {
  font-size: 1rem;
  font-weight: 800;
  color: #bd93f9;
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.grid-headers {
  display: flex;
}
.corner {
  width: 24px;
  height: 24px;
}
.col-headers {
  display: flex;
}
.col-headers span,
.row-headers span {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #6272a4;
}
.col-headers span {
  width: 32px;
  height: 24px;
}
.grid-body {
  display: flex;
}
.row-headers {
  display: flex;
  flex-direction: column;
}
.row-headers span {
  width: 24px;
  height: 32px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(10, 32px);
  grid-template-rows: repeat(10, 32px);
  gap: 1px;
  background: #2a2a4a;
  border: 2px solid #3a3a5a;
  border-radius: 4px;
}
.cell {
  width: 32px;
  height: 32px;
  background: #1a2744;
  border: 1px solid #2a3a5a;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
}
.cell:hover {
  background: #2a3a6a;
  border-color: #4a5a8a;
}
.cell.ship {
  background: #2a5a3a;
  border-color: #3a7a4a;
}
.cell.preview {
  background: #2a4a5a;
  border-color: #4a8a9a;
}
.cell.preview-invalid {
  background: #5a2a2a;
  border-color: #8a3a3a;
}
.cell.hit {
  background: #c0392b;
  border-color: #e74c3c;
  color: #fff;
}
.cell.miss {
  background: #34495e;
  border-color: #4a6a8a;
  color: #7f8c8d;
}
.cell.sunk {
  background: #6b1a1a;
  border-color: #8b2a2a;
  color: #ff6b6b;
}
/* Player grid during battle: no hover effect */
#player-grid .cell {
  cursor: default;
}
#player-grid .cell:hover {
  background: inherit;
  border-color: inherit;
}
/* Restore hover for ship cells */
#player-grid .cell.ship:hover {
  background: #2a5a3a;
  border-color: #3a7a4a;
}
#player-grid .cell.hit:hover {
  background: #c0392b;
  border-color: #e74c3c;
}
#player-grid .cell.miss:hover {
  background: #34495e;
  border-color: #4a6a8a;
}
#player-grid .cell.sunk:hover {
  background: #6b1a1a;
  border-color: #8b2a2a;
}

/* ===== SHIP STATUS ===== */
.ship-status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
  padding: 0.6rem;
  background: #16213e;
  border-radius: 10px;
  max-width: 700px;
  width: 100%;
}
.ship-card {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  background: #1a2744;
  border-radius: 8px;
  border: 1px solid #2a3a5a;
  font-size: 0.8rem;
  font-weight: 600;
}
.ship-card.player-card { color: #50fa7b; }
.ship-card.enemy-card { color: #ff6b6b; }
.ship-card.sunk-card {
  opacity: 0.4;
  text-decoration: line-through;
}
.ship-dots {
  display: flex;
  gap: 2px;
}
.ship-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: currentColor;
}
.ship-card.sunk-card .ship-dot {
  background: #666;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.modal-overlay.hidden { display: none; }
.modal-content {
  background: #16213e;
  border-radius: 16px;
  padding: 2rem;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  max-width: 360px;
  width: 90%;
}
.modal-icon { font-size: 3rem; margin-bottom: 0.5rem; }
.modal-content h2 {
  font-size: 1.4rem;
  margin-bottom: 0.4rem;
  color: #f8f8f2;
}
.modal-content p {
  margin-bottom: 1rem;
  color: #bbb;
  font-size: 0.95rem;
}
.hidden { display: none !important; }

/* ===== RESPONSIVE ===== */
@media (max-width: 700px) {
  .boards {
    flex-direction: column;
    align-items: center;
    gap: 1rem;
  }
  .grid {
    grid-template-columns: repeat(10, 28px);
    grid-template-rows: repeat(10, 28px);
  }
  .cell {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
  }
  .col-headers span { width: 28px; }
  .row-headers span { height: 28px; }
  .game-title { font-size: 1rem; }
  .stats { font-size: 0.8rem; gap: 0.5rem; }
}

@media (max-width: 380px) {
  .grid {
    grid-template-columns: repeat(10, 24px);
    grid-template-rows: repeat(10, 24px);
  }
  .cell {
    width: 24px;
    height: 24px;
    font-size: 0.65rem;
  }
  .col-headers span { width: 24px; height: 20px; }
  .row-headers span { width: 20px; height: 24px; }
  .corner { width: 20px; height: 20px; }
}

/* ===== SEO GAME INFO SECTION ===== */
.game-info {
  max-width: 780px;
  margin: 1rem auto;
  padding: 1rem 1.2rem;
  background: rgba(0,0,0,0.15);
  border-radius: 12px;
  color: rgba(255,255,255,0.85);
  font-size: 0.88rem;
  line-height: 1.6;
}
.game-info h2 { font-size: 1.1rem; font-weight: 800; margin-bottom: 0.5rem; }
.game-info h3 { font-size: 0.95rem; font-weight: 700; margin: 0.8rem 0 0.3rem; }
.game-info ul { padding-left: 1.2rem; }
.game-info li { margin-bottom: 0.2rem; }
