/* client/css/style.css */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
 
body {
  background: transparent; /* let star canvas show through */
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  margin: 0;
  /* padding-env: env(safe-area-inset-top) env(safe-area-inset-right) 
              env(safe-area-inset-bottom) env(safe-area-inset-left); */
}

#star-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
}
 
/* Lobby */
#lobby {
  position: relative;
  z-index: 10;
  background: rgba(0, 0, 0, 0.6);
  padding: 40px;
  border-radius: 12px;
  border: 1px solid #333;
  display: flex;
  flex-direction: column;  /* <-- stack vertically */
  align-items: center;
  gap: 16px;
}
 
#lobby h1 { font-size: 3rem; letter-spacing: 0.1em; color: #eee; }
 
#name-input {
  padding: 10px 16px;
  font-size: 1rem;
  border: 2px solid #555;
  border-radius: 6px;
  background: #222;
  color: #eee;
  outline: none;
  text-align: center;
}
 
#name-input:focus { border-color: #7df; }
 
#play-btn {
  padding: 10px 32px;
  font-size: 1rem;
  border: none;
  border-radius: 6px;
  background: #7df;
  color: #111;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.15s;
}
 
#play-btn:hover { background: #5bf; }
 
/* Canvas */
#canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  /* pointer-events: none; */
}
 
/* HUD */
#hud {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  gap: 24px;
  background: rgba(0,0,0,0.5);
  padding: 6px 18px;
  border-radius: 20px;
  font-size: 0.9rem;
  /* pointer-events: none; */
  color: #eee;
  font-family: monospace;
}

#respawn-screen {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  text-align: center;
  color: #fff;
  font-family: monospace;
  /* pointer-events: none; */
  background: rgba(0, 0, 0, 0.6);
  padding: 24px 40px;
  border-radius: 12px;
  border: 1px solid #444;
}

#respawn-screen p {
  font-size: 1rem;
  margin-bottom: 8px;
  color: #aaa;
}

#respawn-countdown {
  font-size: 4rem;
  font-weight: bold;
  color: #7df;
}

#loadout-screen {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  background: rgba(0, 0, 0, 0.7);
  padding: 40px;
  border-radius: 12px;
  border: 1px solid #333;
}

#loadout-screen h2 {
  font-size: 1.8rem;
  letter-spacing: 0.1em;
  color: #eee;
  font-family: monospace;
}

#loadout-container {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

#loadout-canvas {
  cursor: pointer;
  border: 1px solid #333;
  border-radius: 8px;
}

#loadout-info {
  width: 280px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 4px;
}

/* Subtle scrollbar */
#loadout-info::-webkit-scrollbar {
  width: 4px;
}
#loadout-info::-webkit-scrollbar-track {
  background: #111;
}
#loadout-info::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 2px;
}

@media (max-width: 768px) {
  #loadout-container {
    flex-direction: column;
    align-items: center;
  }

  #loadout-canvas {
    width: 300px;
    height: 300px;
  }

  #loadout-info {
    width: 300px;
    max-height: 200px;
  }
}

#picker-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
}

#picker-options::-webkit-scrollbar {
  width: 4px;
}
#picker-options::-webkit-scrollbar-track {
  background: #111;
}
#picker-options::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 2px;
}


.info-section h3 {
  font-family: monospace;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #7df;
  margin-bottom: 8px;
  border-bottom: 1px solid #222;
  padding-bottom: 4px;
}

/* Controls grid */
.info-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  align-items: center;
}

.key {
  background: #222;
  border: 1px solid #444;
  border-bottom: 2px solid #555;
  border-radius: 4px;
  padding: 2px 8px;
  font-family: monospace;
  font-size: 0.75rem;
  color: #eee;
  text-align: center;
  white-space: nowrap;
}

.info-desc {
  font-family: monospace;
  font-size: 0.78rem;
  color: #aaa;
}

/* Status effects */
.info-status {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.status-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: monospace;
  font-size: 0.78rem;
  color: #aaa;
}

.status-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-icon.invuln {
  background: #333;
  border: 2px solid #fff;
  box-shadow: 0 0 8px 2px rgba(255,255,255,0.6);
}

.status-icon.stun {
  background: #333;
  border: 2px solid #44f;
  box-shadow: 0 0 8px 2px rgba(255,255,255,0.6);
}

.status-icon.healthbar {
  background: linear-gradient(to right, #4a0 60%, #aa0 80%, #a00 100%);
  border-radius: 3px;
  height: 8px;
  margin-top: 8px;
  border: 1px solid #555;
}

/* Weapons and addons */
.info-weapons {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.weapon-entry {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px;
  background: #1a1a1a;
  border-radius: 4px;
  border-left: 2px solid #7df;
}

.weapon-name {
  font-family: monospace;
  font-size: 0.8rem;
  color: #fff;
  font-weight: bold;
}

.weapon-desc {
  font-family: monospace;
  font-size: 0.72rem;
  color: #888;
}

/* Tips */
.info-tips {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.info-tips p {
  font-family: monospace;
  font-size: 0.75rem;
  color: #888;
  line-height: 1.4;
}

#addon-picker {
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid #444;
  border-radius: 8px;
  padding: 20px;
  min-width: 200px;
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#picker-title {
  font-family: monospace;
  color: #7df;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.addon-option {
  background: #1a1a1a;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 10px 14px;
  color: #eee;
  cursor: pointer;
  font-family: monospace;
  font-size: 0.85rem;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}

.addon-option:hover {
  background: #2a2a2a;
  border-color: #7df;
}

.addon-option.selected {
  border-color: #7df;
  background: #1a2a3a;
}

.addon-option .addon-name {
  font-weight: bold;
  color: #fff;
  display: block;
  margin-bottom: 3px;
}

.addon-option .addon-desc {
  color: #888;
  font-size: 0.75rem;
}

#picker-clear, #picker-close {
  padding: 8px;
  border: 1px solid #555;
  border-radius: 6px;
  background: #222;
  color: #aaa;
  cursor: pointer;
  font-family: monospace;
  font-size: 0.8rem;
  transition: background 0.15s;
}

#picker-clear:hover { background: #3a1a1a; border-color: #f84; color: #f84; }
#picker-close:hover { background: #2a2a2a; color: #eee; }

#launch-btn {
  padding: 12px 48px;
  font-size: 1.1rem;
  border: none;
  border-radius: 6px;
  background: #7df;
  color: #111;
  cursor: pointer;
  font-weight: bold;
  font-family: monospace;
  transition: background 0.15s;
}

#launch-btn:hover { background: #5bf; }

#room-list-screen,
#create-room-screen,
#waiting-room-screen,
#game-over-screen {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  background: rgba(0, 0, 0, 0.7);
  padding: 40px;
  border-radius: 12px;
  border: 1px solid #333;
  min-width: 400px;
  font-family: monospace;
  color: #eee;
}

h2 {
  font-size: 1.6rem;
  letter-spacing: 0.1em;
  color: #7df;
}

/* Room list */
#room-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
}

.room-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 12px 16px;
  gap: 16px;
}

.room-entry-info { flex: 1; }
.room-entry-name { font-weight: bold; color: #fff; }
.room-entry-details { font-size: 0.75rem; color: #888; margin-top: 3px; }

.room-join-btn {
  padding: 6px 16px;
  background: #7df;
  color: #111;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: monospace;
  font-weight: bold;
  font-size: 0.8rem;
}

.room-join-btn:hover { background: #5bf; }

#room-list-empty {
  color: #555;
  text-align: center;
  padding: 20px;
  font-size: 0.9rem;
}

#room-list-actions {
  display: flex;
  gap: 12px;
}

/* Win condition selector */
#win-condition-options {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.win-condition-btn {
  padding: 8px 16px;
  border: 1px solid #444;
  border-radius: 6px;
  background: #1a1a1a;
  color: #888;
  cursor: pointer;
  font-family: monospace;
  font-size: 0.8rem;
  transition: all 0.15s;
}

.win-condition-btn.active {
  border-color: #7df;
  color: #7df;
  background: #1a2a3a;
}

.condition-settings {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.condition-settings label {
  font-size: 0.8rem;
  color: #888;
}

.condition-settings input {
  padding: 8px 12px;
  background: #222;
  border: 1px solid #444;
  border-radius: 6px;
  color: #eee;
  font-family: monospace;
  font-size: 0.9rem;
}

/* Waiting room */
#waiting-room-settings {
  font-size: 0.85rem;
  color: #888;
  text-align: center;
}

#waiting-player-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.waiting-player {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 10px 14px;
}

.waiting-player-name { color: #fff; font-weight: bold; }
.waiting-player-host { color: #7df; font-size: 0.75rem; }

#waiting-message { color: #888; font-size: 0.85rem; }

#waiting-room-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* Game over */
#game-over-winner {
  font-size: 1.2rem;
  color: #7df;
}

#game-over-scores {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.score-entry {
  display: flex;
  justify-content: space-between;
  padding: 8px 14px;
  background: #1a1a1a;
  border-radius: 6px;
  border: 1px solid #333;
}

.score-entry:first-child {
  border-color: #7df;
  background: #1a2a3a;
}

.score-name { color: #fff; }
.score-value { color: #7df; font-weight: bold; }

/* Shared button styles */
#create-room-btn, #confirm-create-btn, #start-game-btn,
#return-to-lobby-btn {
  padding: 10px 32px;
  font-size: 1rem;
  border: none;
  border-radius: 6px;
  background: #7df;
  color: #111;
  cursor: pointer;
  font-weight: bold;
  font-family: monospace;
  transition: background 0.15s;
}

#create-room-btn:hover, #confirm-create-btn:hover,
#start-game-btn:hover, #return-to-lobby-btn:hover { background: #5bf; }

#back-to-lobby-btn, #cancel-create-btn, #leave-room-btn {
  padding: 10px 24px;
  font-size: 0.9rem;
  border: 1px solid #555;
  border-radius: 6px;
  background: #222;
  color: #aaa;
  cursor: pointer;
  font-family: monospace;
  transition: background 0.15s;
}

#back-to-lobby-btn:hover, #cancel-create-btn:hover,
#leave-room-btn:hover { background: #2a2a2a; color: #eee; }

/* HUD additions */
#hud-time { color: #7df; }
#hud-lives { color: #f84; }

#waiting-launch-screen {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 5;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  /* pointer-events: none; */
}

#waiting-launch-content {
  margin-top: 20px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid #444;
  border-radius: 10px;
  padding: 16px 28px;
  text-align: center;
  font-family: monospace;
  color: #aaa;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#waiting-launch-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.waiting-launch-player {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}

.waiting-launch-player-name { color: #fff; }

.waiting-launch-status-ready   { color: #4f4; font-size: 0.8rem; }
.waiting-launch-status-waiting { color: #888; font-size: 0.8rem; }

#leave-btn-container {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  z-index: 10;
  pointer-events: all;
}

#in-game-leave-btn {
  padding: 6px 14px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid #555;
  border-radius: 6px;
  color: #aaa;
  font-family: monospace;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

#in-game-leave-btn:hover {
  background: rgba(60, 20, 20, 0.8);
  border-color: #f84;
  color: #f84;
}

#scoreboard {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid #444;
  border-radius: 10px;
  padding: 24px 32px;
  min-width: 340px;
  font-family: monospace;
  /* pointer-events: none; */
}

#scoreboard h3 {
  color: #7df;
  font-size: 1rem;
  letter-spacing: 0.1em;
  text-align: center;
  margin-bottom: 16px;
  text-transform: uppercase;
}

#scoreboard-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.scoreboard-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 24px;
  align-items: center;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 0.85rem;
}

.scoreboard-row.me {
  background: rgba(119, 221, 255, 0.1);
  border: 1px solid rgba(119, 221, 255, 0.2);
}

.scoreboard-name { color: #fff; }
.scoreboard-name.me { color: #7df; }

.scoreboard-score {
  color: #7df;
  font-weight: bold;
  text-align: right;
}

.scoreboard-deaths {
  color: #f84;
  text-align: right;
  min-width: 48px;
}

.scoreboard-header {
  color: #555;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid #333;
  padding-bottom: 6px;
  margin-bottom: 2px;
}

.scoreboard-row.eliminated {
  opacity: 0.4;
}

.scoreboard-lives {
  text-align: right;
  font-size: 0.75rem;
}

#audio-controls {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 10;
  display: flex;
  gap: 6px;
}

#music-toggle-btn,
#sfx-toggle-btn {
  width: 36px;
  height: 36px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid #555;
  border-radius: 6px;
  color: #eee;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

#music-toggle-btn:hover,
#sfx-toggle-btn:hover {
  background: rgba(40, 40, 40, 0.8);
  border-color: #7df;
}

#music-toggle-btn.muted,
#sfx-toggle-btn.muted {
  opacity: 0.4;
  border-color: #555;
}

#connection-lost-screen {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 100;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
}

#connection-lost-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid #f84;
  border-radius: 12px;
  padding: 40px;
  font-family: monospace;
  text-align: center;
}

#connection-lost-content h2 {
  color: #f84;
  font-size: 1.6rem;
  letter-spacing: 0.1em;
}

#connection-lost-content p {
  color: #aaa;
  font-size: 0.9rem;
}

#reconnect-btn {
  padding: 10px 32px;
  font-size: 1rem;
  border: none;
  border-radius: 6px;
  background: #7df;
  color: #111;
  cursor: pointer;
  font-weight: bold;
  font-family: monospace;
  transition: background 0.15s;
}

#reconnect-btn:hover { background: #5bf; }

#touch-controls {
  position: fixed;
  bottom: 0; left: 0;
  width: 100vw;
  height: 40vh;
  z-index: 5;
  pointer-events: none;
}

#touch-buttons {
  position: absolute;
  bottom: max(30px, env(safe-area-inset-bottom));
  right: max(30px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  gap: 16px;
  pointer-events: all;
}

#touch-shoot-btn {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 2px solid #7df;
  background: rgba(0, 0, 0, 0.6);
  font-size: 1.8rem;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: none;
}

#touch-shoot-btn:active { background: rgba(119, 221, 255, 0.3); }

@media (max-width: 768px), (max-height: 600px) {
  #loadout-screen {
    padding: 12px;
    gap: 8px;
    overflow-y: auto;
    max-height: 100vh;
    justify-content: flex-start;
    width: 100%;
  }

  #loadout-screen h2 {
    font-size: 1.1rem;
    margin-bottom: 2px;
  }

  /* #loadout-container {
    flex-direction: column;
    align-items: center;
    gap: 12px;
  } */

  #loadout-container {
    flex-direction: row;
    gap: 10px;
    width: 100%;
    justify-content: center;
  }


  #loadout-canvas {
    width: 220px;
    height: 220px;
    flex-shrink: 0;
  }

  #addon-picker,
  #loadout-info {
    width: 160px;
    max-height: 220px;
    overflow-y: auto;
    flex-shrink: 0;
  }

  #launch-btn {
    margin-bottom: max(16px, env(safe-area-inset-bottom)); /* breathing room at bottom */
    width: 100%;
    max-width: 400px;
  }
}

#rotate-prompt {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 50;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
}

#rotate-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  font-family: monospace;
  color: #eee;
  text-align: center;
  padding: 32px;
}

#rotate-icon {
  font-size: 4rem;
  animation: spin 2s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(90deg); }
}

#rotate-dismiss {
  padding: 8px 24px;
  background: #333;
  border: 1px solid #555;
  border-radius: 6px;
  color: #aaa;
  font-family: monospace;
  cursor: pointer;
}
