/* Battleship Game Styles */

.battleship-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding: 1rem;
  width: 100%;
}

/* Phase visibility */
.battleship-lobby,
.battleship-setup,
.battleship-battle,
.battleship-game-over {
  display: none;
  width: 100%;
}

.battleship-lobby.active,
.battleship-setup.active,
.battleship-battle.active,
.battleship-game-over.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

/* Timer */
.battleship-timer {
  font-size: 1.5rem;
  font-weight: bold;
  color: #fff;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.battleship-timer.urgent {
  color: #e74c3c;
  animation: pulse-urgent 0.5s ease-in-out infinite alternate;
}

@keyframes pulse-urgent {
  from { opacity: 1; }
  to { opacity: 0.6; }
}

/* Turn indicator */
.battleship-turn-indicator {
  font-size: 1.2rem;
  padding: 0.75rem 1.5rem;
  border-radius: 4px;
  text-align: center;
}

.battleship-turn-indicator.my-turn {
  background: rgba(46, 204, 113, 0.2);
  color: #2ecc71;
  font-weight: bold;
}

.battleship-turn-indicator.waiting {
  background: rgba(255, 255, 255, 0.1);
  color: #888;
}

/* Board grid */
.battleship-grid {
  display: grid;
  gap: 2px;
  background: rgba(255, 255, 255, 0.1);
  padding: 2px;
  border-radius: 4px;
}

.battleship-grid.size-8 {
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
}

.battleship-grid.large {
  width: 360px;
  height: 360px;
}

.battleship-grid.small {
  width: 180px;
  height: 180px;
}

/* Board cells */
.battleship-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a3a5c 0%, #0d253a 100%);
  font-size: 1.5rem;
  user-select: none;
  transition: all 0.15s ease;
}

.battleship-grid.large .battleship-cell {
  font-size: 1.8rem;
}

.battleship-grid.small .battleship-cell {
  font-size: 1rem;
}

.battleship-cell.clickable {
  cursor: pointer;
}

.battleship-cell.clickable:hover {
  background: linear-gradient(135deg, #2a5a8c 0%, #1d354a 100%);
  transform: scale(1.05);
}

/* Cell states */
.battleship-cell.ship {
  background: linear-gradient(135deg, #4a4a4a 0%, #2a2a2a 100%);
}

.battleship-cell.hit {
  background: linear-gradient(135deg, #c0392b 0%, #96281b 100%);
}

.battleship-cell.miss {
  background: linear-gradient(135deg, #2c3e50 0%, #1a252f 100%);
}

/* Ship placement preview */
.battleship-cell.preview-valid {
  background: linear-gradient(135deg, #27ae60 0%, #1e8449 100%);
  opacity: 0.7;
}

.battleship-cell.preview-invalid {
  background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
  opacity: 0.7;
}

/* Animations */
@keyframes hit-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

.battleship-cell.hit-animation {
  animation: hit-shake 0.3s ease-in-out;
}

@keyframes miss-ripple {
  0% { box-shadow: inset 0 0 0 0 rgba(255, 255, 255, 0.4); }
  100% { box-shadow: inset 0 0 20px 10px rgba(255, 255, 255, 0); }
}

.battleship-cell.miss-animation {
  animation: miss-ripple 0.4s ease-out;
}

/* === LOBBY PHASE === */

.battleship-player-list {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 1rem;
  min-width: 250px;
}

.battleship-player-list h3 {
  margin: 0 0 1rem 0;
  font-size: 1rem;
  color: #888;
}

.battleship-player-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  border-radius: 4px;
  margin-bottom: 0.5rem;
}

.battleship-player-item:last-child {
  margin-bottom: 0;
}

.battleship-player-item.me {
  background: rgba(102, 126, 234, 0.2);
}

.battleship-player-item .ready-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #555;
}

.battleship-player-item .ready-indicator.ready {
  background: #2ecc71;
}

.battleship-player-item .player-name {
  flex: 1;
}

.battleship-player-item .player-badge {
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.1);
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  color: #888;
}

.battleship-waiting-slot {
  color: #555;
  font-style: italic;
  padding: 0.5rem;
}

/* === SETUP PHASE === */

.battleship-setup-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
}

.battleship-ship-queue {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  max-width: 400px;
}

.battleship-ship-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}

.battleship-ship-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.battleship-ship-item.active {
  border-color: #667eea;
  background: rgba(102, 126, 234, 0.2);
}

.battleship-ship-item.placed {
  opacity: 0.5;
  cursor: default;
}

.battleship-ship-item.placed::after {
  content: '✓';
  color: #2ecc71;
  margin-left: 0.5rem;
}

.battleship-ship-cells {
  display: flex;
  gap: 2px;
}

.battleship-ship-cells span {
  width: 12px;
  height: 12px;
  background: #667eea;
  border-radius: 2px;
}

.battleship-ship-item.placed .battleship-ship-cells span {
  background: #555;
}

.battleship-ship-name {
  font-size: 0.85rem;
  color: #aaa;
}

.battleship-setup-controls {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.battleship-setup-controls .btn {
  padding: 0.6rem 1.2rem;
}

.battleship-orientation-indicator {
  font-size: 0.9rem;
  color: #888;
  padding: 0.5rem;
}

.battleship-orientation-indicator kbd {
  background: rgba(255, 255, 255, 0.1);
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  font-family: monospace;
}

/* === BATTLE PHASE === */

.battleship-battle-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  width: 100%;
}

.battleship-your-board-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.battleship-your-board-section h3 {
  margin: 0;
  font-size: 1rem;
  color: #888;
}

.battleship-ships-remaining {
  display: flex;
  gap: 0.5rem;
  font-size: 1.2rem;
}

.battleship-ships-remaining .ship-icon {
  opacity: 1;
}

.battleship-ships-remaining .ship-icon.sunk {
  opacity: 0.3;
  text-decoration: line-through;
}

.battleship-opponents-section {
  width: 100%;
}

.battleship-opponents-section h3 {
  text-align: center;
  margin: 0 0 1rem 0;
  font-size: 1rem;
  color: #888;
}

.battleship-opponents-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
}

.battleship-opponent-board {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  border: 2px solid transparent;
  transition: border-color 0.2s, opacity 0.2s;
  position: relative;
}

.battleship-opponent-board.targetable {
  border-color: rgba(102, 126, 234, 0.5);
}

.battleship-opponent-board.targetable:hover,
.battleship-opponent-board.targetable:focus-within {
  border-color: #667eea;
  outline: none;
}

.battleship-opponent-board.eliminated {
  opacity: 0.6;
}

.battleship-opponent-board.eliminated .battleship-eliminated-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(231, 76, 60, 0.9);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: bold;
  text-transform: uppercase;
  z-index: 1;
}

.battleship-opponent-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.battleship-opponent-name {
  font-weight: 500;
}

.battleship-opponent-ships {
  color: #aaa;
  font-size: 0.8rem;
}

/* === GAME OVER === */

.battleship-game-over-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  text-align: center;
}

.battleship-winner-banner {
  font-size: 2rem;
  font-weight: bold;
  padding: 1rem 2rem;
  border-radius: 8px;
  background: linear-gradient(135deg, #f39c12 0%, #e74c3c 100%);
  color: white;
}

.battleship-winner-banner.you-won {
  background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
}

.battleship-stats-table {
  width: 100%;
  max-width: 500px;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  overflow: hidden;
}

.battleship-stats-table th,
.battleship-stats-table td {
  padding: 0.75rem;
  text-align: center;
}

.battleship-stats-table th {
  background: rgba(255, 255, 255, 0.1);
  font-weight: 500;
  color: #888;
}

.battleship-stats-table tr:not(:last-child) td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.battleship-stats-table tr.winner td {
  background: rgba(46, 204, 113, 0.1);
}

.battleship-stats-table tr.me td {
  font-weight: 500;
}

.battleship-revealed-boards {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
}

.battleship-revealed-board {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.battleship-revealed-board .player-name {
  font-size: 0.9rem;
  color: #888;
}

.battleship-game-over-controls {
  display: flex;
  gap: 1rem;
}

/* === TOAST NOTIFICATIONS === */

.battleship-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 8px;
  font-size: 1.1rem;
  z-index: 1000;
  animation: toast-in 0.3s ease-out;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.battleship-toast.toast-out {
  animation: toast-out 0.3s ease-in forwards;
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
}

/* === RESPONSIVE === */

@media (max-width: 768px) {
  .battleship-grid.large {
    width: 300px;
    height: 300px;
  }

  .battleship-grid.small {
    width: 140px;
    height: 140px;
  }

  .battleship-grid.large .battleship-cell {
    font-size: 1.4rem;
  }

  .battleship-grid.small .battleship-cell {
    font-size: 0.8rem;
  }

  .battleship-ship-queue {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .battleship-grid.large {
    width: 280px;
    height: 280px;
  }

  .battleship-grid.small {
    width: 120px;
    height: 120px;
  }

  .battleship-opponents-grid {
    flex-direction: column;
    align-items: center;
  }
}
