/* Invaders Lobby */
.invaders-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  padding: 2rem 1rem;
}

.invaders-title {
  font-family: 'Fredoka One', cursive;
  font-size: 2.5rem;
  color: #00ffcc;
  text-shadow: 0 0 20px rgba(0, 255, 204, 0.5);
  margin-bottom: 1rem;
  text-align: center;
}

.invaders-subtitle {
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 2rem;
  text-align: center;
}

.lobby-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 420px;
}

/* Name input */
.lobby-row {
  width: 100%;
}

.name-input {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 2px solid rgba(0, 255, 204, 0.3);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: #00ffcc;
  font-family: 'Nunito', sans-serif;
  font-size: 1.1rem;
  text-align: center;
  box-sizing: border-box;
}

.name-input::placeholder {
  color: rgba(0, 255, 204, 0.3);
}

.name-input:focus {
  outline: none;
  border-color: #00ffcc;
  box-shadow: 0 0 15px rgba(0, 255, 204, 0.2);
}

/* Ship selection */
.ship-select-row {
  width: 100%;
  text-align: center;
}

.ship-label {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  display: block;
}

.ship-options {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.ship-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.ship-option span {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.5);
}

.ship-option:hover {
  border-color: rgba(0, 255, 204, 0.4);
  background: rgba(0, 255, 204, 0.05);
}

.ship-option.selected {
  border-color: #00ffcc;
  background: rgba(0, 255, 204, 0.1);
  box-shadow: 0 0 10px rgba(0, 255, 204, 0.2);
}

.ship-option.selected span {
  color: #00ffcc;
}

.ship-preview {
  display: block;
  width: 60px;
  height: 60px;
}

/* Mode buttons */
.lobby-modes {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: 100%;
}

.lobby-btn {
  width: 100%;
  padding: 0.8rem 1.5rem;
  border: 2px solid rgba(0, 255, 204, 0.4);
  border-radius: 12px;
  background: rgba(0, 255, 204, 0.1);
  color: #00ffcc;
  font-family: 'Nunito', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
}

.lobby-btn:hover {
  background: rgba(0, 255, 204, 0.2);
  border-color: #00ffcc;
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0, 255, 204, 0.3);
}

.lobby-btn.mode-single {
  border-color: rgba(0, 255, 136, 0.4);
  background: rgba(0, 255, 136, 0.08);
  color: #00ff88;
}
.lobby-btn.mode-single:hover {
  background: rgba(0, 255, 136, 0.2);
  border-color: #00ff88;
  box-shadow: 0 4px 20px rgba(0, 255, 136, 0.3);
}

.lobby-btn.mode-multi {
  border-color: rgba(0, 255, 204, 0.4);
}

.lobby-btn.mode-private {
  border-color: rgba(255, 215, 0, 0.3);
  background: rgba(255, 215, 0, 0.06);
  color: #ffd700;
}
.lobby-btn.mode-private:hover {
  background: rgba(255, 215, 0, 0.15);
  border-color: #ffd700;
  box-shadow: 0 4px 20px rgba(255, 215, 0, 0.3);
}

/* Code section */
.lobby-code-section {
  width: 100%;
  display: flex;
  justify-content: center;
}

.lobby-link {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.3rem;
  transition: color 0.2s;
}
.lobby-link:hover {
  color: rgba(255, 255, 255, 0.8);
}

.join-form {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

.code-input {
  flex: 1;
  padding: 0.8rem 1rem;
  border: 2px solid rgba(255, 215, 0, 0.3);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: #ffd700;
  font-family: 'Fredoka One', cursive;
  font-size: 1.4rem;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.3em;
}

.code-input::placeholder {
  color: rgba(255, 215, 0, 0.3);
  font-size: 0.9rem;
  letter-spacing: 0.1em;
}

.code-input:focus {
  outline: none;
  border-color: #ffd700;
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.2);
}

.join-btn {
  padding: 0.8rem 1.5rem;
  border: 2px solid #ffd700;
  border-radius: 12px;
  background: rgba(255, 215, 0, 0.15);
  color: #ffd700;
  font-weight: 700;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.3s;
}

.join-btn:hover {
  background: rgba(255, 215, 0, 0.3);
}

.lobby-error {
  color: #ff6b6b;
  font-size: 0.9rem;
  min-height: 1.2em;
}

/* Help panel */
.lobby-help-btn {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.5);
  padding: 0.4rem 1rem;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.lobby-help-btn:hover {
  border-color: rgba(255, 255, 255, 0.5);
  color: rgba(255, 255, 255, 0.8);
}

.help-panel {
  width: 100%;
  border: 1px solid rgba(0, 255, 204, 0.2);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.3);
  padding: 1rem 1.2rem;
  margin-top: 0.5rem;
}

.help-content h3 {
  color: #00ffcc;
  font-family: 'Fredoka One', cursive;
  font-size: 0.95rem;
  margin: 0.6rem 0 0.3rem;
}

.help-content h3:first-child {
  margin-top: 0;
}

.help-content p {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.85rem;
  margin: 0 0 0.3rem;
}

.help-powerups {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.help-pu {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.pu-icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid;
  flex-shrink: 0;
}

.shield-icon { border-color: #00ff88; background: rgba(0, 255, 136, 0.2); }
.double-icon { border-color: #ffd700; background: rgba(255, 215, 0, 0.2); }
.speed-icon { border-color: #00b4d8; background: rgba(0, 180, 216, 0.2); }
.bomb-icon { border-color: #ff6b6b; background: rgba(255, 107, 107, 0.2); }

/* Waiting Room */
.waiting-room {
  text-align: center;
}

.room-code {
  font-family: 'Fredoka One', cursive;
  font-size: 4rem;
  color: #00ffcc;
  text-shadow: 0 0 30px rgba(0, 255, 204, 0.5);
  letter-spacing: 0.4em;
  margin: 1.5rem 0;
  user-select: all;
}

.waiting-hint {
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 1rem;
}

.waiting-spinner {
  font-size: 2.5rem;
  margin: 1.5rem 0;
  animation: spinnerPulse 1.5s ease infinite;
}

@keyframes spinnerPulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.1); }
}

.player-count {
  font-size: 1.2rem;
  color: #ffd700;
  margin: 1rem 0;
}

.start-btn {
  padding: 1rem 3rem;
  border: 2px solid #00ff88;
  border-radius: 12px;
  background: rgba(0, 255, 136, 0.15);
  color: #00ff88;
  font-family: 'Fredoka One', cursive;
  font-size: 1.3rem;
  cursor: pointer;
  transition: all 0.3s;
  display: none;
}

.start-btn.visible {
  display: inline-block;
  animation: pulse 1.5s ease infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 10px rgba(0, 255, 136, 0.3); }
  50% { box-shadow: 0 0 25px rgba(0, 255, 136, 0.6); }
}

.start-btn:hover {
  background: rgba(0, 255, 136, 0.3);
  transform: scale(1.05);
}

/* Voice chat */
.voice-controls {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.voice-btn {
  padding: 0.6rem 1.2rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s;
}

.voice-btn:hover {
  border-color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.1);
}

.voice-btn.active {
  border-color: #00ff88;
  color: #00ff88;
  background: rgba(0, 255, 136, 0.1);
}

.voice-btn.muted {
  border-color: #ff6b6b;
  color: #ff6b6b;
}

/* Game container */
.game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding-top: 0.5rem;
}

/* HUD - new layout with per-player info */
.game-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 800px;
  max-width: 100%;
  padding: 0.4rem 0.8rem;
  margin-bottom: 0.3rem;
  gap: 0.5rem;
}

.hud-player {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

.hud-p1 {
  justify-content: flex-start;
}

.hud-p2 {
  justify-content: flex-end;
}

.hud-hidden {
  visibility: hidden;
}

.hud-name {
  font-family: 'Fredoka One', cursive;
  font-size: 0.9rem;
}

.hud-hp {
  font-size: 0.85rem;
  letter-spacing: -1px;
}

.hud-kills {
  font-family: 'Nunito', sans-serif;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

.hud-score {
  font-family: 'Fredoka One', cursive;
  color: #ffd700;
  font-size: 1.3rem;
}

.hud-wave {
  font-family: 'Fredoka One', cursive;
  color: #00ffcc;
  font-size: 0.8rem;
}

.game-canvas-container {
  position: relative;
  border: 2px solid rgba(0, 255, 204, 0.3);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.4);
}

#invaders-canvas {
  display: block;
  width: 800px;
  height: 600px;
  max-width: 100vw;
  max-height: 70vh;
}

/* Voice indicator in game */
.game-voice-indicator {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 1.2rem;
  opacity: 0.6;
  cursor: pointer;
}

.game-voice-indicator.active {
  opacity: 1;
  color: #00ff88;
}

/* Pause button */
.game-control-btn {
  position: absolute;
  border: none;
  background: rgba(0, 0, 0, 0.4);
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
  z-index: 5;
}

.game-control-btn:hover {
  background: rgba(0, 0, 0, 0.6);
  color: rgba(255, 255, 255, 0.9);
}

.pause-btn {
  top: 8px;
  left: 8px;
  font-size: 1.3rem;
  padding: 4px 8px;
  line-height: 1;
}

/* Overlay messages */
.game-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  z-index: 10;
}

.game-over-overlay {
  overflow-y: auto;
  padding: 1rem;
}

.game-overlay h2 {
  font-family: 'Fredoka One', cursive;
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.game-overlay .victory { color: #ffd700; text-shadow: 0 0 30px rgba(255, 215, 0, 0.5); }
.game-overlay .defeat { color: #ff6b6b; text-shadow: 0 0 30px rgba(255, 107, 107, 0.5); }
.game-overlay .paused { color: #00ffcc; }

.game-overlay p {
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.new-highscore {
  color: #ffd700 !important;
  font-family: 'Fredoka One', cursive;
  font-size: 1.3rem !important;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
  animation: pulse 1.5s ease infinite;
}

.overlay-buttons {
  display: flex;
  gap: 0.8rem;
  margin-top: 0.8rem;
}

.overlay-btn {
  padding: 0.7rem 2rem;
  border: 2px solid #00ffcc;
  border-radius: 12px;
  background: rgba(0, 255, 204, 0.15);
  color: #00ffcc;
  font-family: 'Fredoka One', cursive;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s;
}

.overlay-btn:hover {
  background: rgba(0, 255, 204, 0.3);
}

.overlay-btn.abort-btn {
  border-color: rgba(255, 107, 107, 0.5);
  background: rgba(255, 107, 107, 0.1);
  color: #ff6b6b;
}

.overlay-btn.abort-btn:hover {
  background: rgba(255, 107, 107, 0.25);
}

/* Lobby live sections: leaderboard + online */
.lobby-live-sections {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  margin-top: 0.5rem;
}

.lobby-live-panel {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
  padding: 12px;
}

.live-section-title {
  font-family: 'Fredoka One', cursive;
  font-size: 0.9rem;
  color: #ffd700;
  margin: 0 0 8px;
  text-align: center;
}

.live-section-title.online-title {
  color: #00ff88;
}

.live-section-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.live-empty {
  text-align: center;
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.8rem;
  padding: 8px 0;
}

/* Leaderboard rows */
.wlb-row {
  display: flex;
  align-items: center;
  padding: 3px 6px;
  border-radius: 4px;
  font-family: 'Nunito', sans-serif;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.7);
  transition: background 0.2s;
}

.wlb-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.wlb-row.hs-gold {
  color: #ffd700;
  background: rgba(255, 215, 0, 0.06);
}

.wlb-row.hs-silver {
  color: #c0c0c0;
}

.wlb-row.hs-bronze {
  color: #cd7f32;
}

.wlb-rank {
  width: 2ch;
  font-weight: 700;
  flex-shrink: 0;
}

.wlb-mode {
  font-size: 0.85rem;
  margin-right: 4px;
  flex-shrink: 0;
}

.wlb-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wlb-score {
  font-weight: 700;
  color: #ffd700;
  margin-left: 6px;
  flex-shrink: 0;
}

.wlb-wave {
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.7rem;
  margin-left: 6px;
  flex-shrink: 0;
}

/* Online rows */
.online-row {
  display: flex;
  align-items: center;
  padding: 4px 6px;
  border-radius: 4px;
  font-family: 'Nunito', sans-serif;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.8);
}

.online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #00ff88;
  box-shadow: 0 0 6px rgba(0, 255, 136, 0.5);
  margin-right: 8px;
  flex-shrink: 0;
}

.online-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.online-ago {
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.7rem;
  margin-left: 6px;
  flex-shrink: 0;
}

/* High scores (game over overlay) */
.overlay-highscores {
  width: 100%;
  max-width: 350px;
}

.overlay-highscores h3 {
  text-align: center;
  color: #ffd700;
  font-family: 'Fredoka One', cursive;
  font-size: 1rem;
  margin: 0.8rem 0 0.4rem;
}

.hs-row {
  display: flex;
  align-items: center;
  padding: 0.2rem 0.4rem;
  font-family: 'Nunito', sans-serif;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.7);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.hs-row.hs-current {
  color: #ffd700;
  background: rgba(255, 215, 0, 0.1);
  border-radius: 4px;
}

.hs-rank {
  color: #ffd700;
  width: 2ch;
  font-weight: 700;
  flex-shrink: 0;
}

.hs-name {
  flex: 1;
  margin-left: 0.4rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hs-score {
  color: #ffd700;
  font-weight: 700;
  margin-left: 0.5rem;
  flex-shrink: 0;
}

.hs-wave {
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.7rem;
  margin-left: 0.5rem;
  flex-shrink: 0;
}

/* Touch controls - hidden by default, shown via JS on touch devices or narrow screens */
.touch-controls {
  display: none;
  width: 100%;
  max-width: 800px;
  padding: 0.5rem;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
}

.touch-controls.visible {
  display: flex;
}

.touch-dpad {
  display: flex;
  gap: 0.5rem;
}

.touch-btn {
  width: 60px;
  height: 60px;
  border: 2px solid rgba(0, 255, 204, 0.4);
  border-radius: 12px;
  background: rgba(0, 255, 204, 0.1);
  color: #00ffcc;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.touch-btn.fire {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border-color: rgba(255, 107, 107, 0.5);
  background: rgba(255, 107, 107, 0.15);
  color: #ff6b6b;
  font-size: 1.2rem;
  font-weight: 700;
}

.touch-btn:active, .touch-btn.pressed {
  background: rgba(0, 255, 204, 0.3);
  transform: scale(0.95);
}

.touch-btn.fire:active, .touch-btn.fire.pressed {
  background: rgba(255, 107, 107, 0.4);
}

.touch-autofire {
  width: 60px;
  height: 60px;
  border-color: rgba(255, 215, 0, 0.4);
  background: rgba(255, 215, 0, 0.08);
  color: #ffd700;
  font-size: 0.8rem;
  font-weight: 700;
}

.touch-autofire.active {
  border-color: #ffd700;
  background: rgba(255, 215, 0, 0.25);
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.4);
}

/* Wave announcement */
.wave-announce {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Fredoka One', cursive;
  font-size: 3rem;
  color: #00ffcc;
  text-shadow: 0 0 40px rgba(0, 255, 204, 0.6);
  pointer-events: none;
  animation: waveAnnounce 2s ease forwards;
  z-index: 5;
}

@keyframes waveAnnounce {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.3); }
}

/* Mobile responsive */
@media (max-width: 850px) {
  .touch-controls {
    display: flex !important;
  }

  #invaders-canvas {
    width: 100vw;
    height: calc(100vw * 0.75);
    max-height: 50vh;
  }

  .game-hud {
    width: 100%;
    padding: 0.3rem 0.5rem;
  }

  .hud-name {
    font-size: 0.75rem;
  }

  .hud-hp {
    font-size: 0.7rem;
  }

  .hud-kills {
    font-size: 0.65rem;
  }

  .hud-score {
    font-size: 1rem;
  }

  .invaders-title {
    font-size: 1.8rem;
  }

  .lobby-live-sections {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .room-code {
    font-size: 2.5rem;
  }

  .ship-option {
    padding: 4px;
  }

  .ship-preview {
    width: 50px;
    height: 50px;
  }
}

@media (max-width: 500px) {
  .touch-btn {
    width: 50px;
    height: 50px;
    font-size: 1.2rem;
  }

  .touch-btn.fire {
    width: 65px;
    height: 65px;
  }

  .ship-options {
    gap: 0.3rem;
  }
}
