* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #0a0a1a;
  color: #fff;
  min-height: 100vh;
  overflow: hidden;
}

.toast-container {
  position: fixed;
  top: 16px;
  left: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
}

.toast {
  background: rgba(10, 14, 28, 0.92);
  border: 1px solid rgba(120, 150, 255, 0.25);
  color: #e8eeff;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12px;
  letter-spacing: 0.2px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Screen management */
.screen {
  display: none;
  width: 100vw;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  overflow-y: auto;
}

.screen.active {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Container for centered content */
.container {
  background: rgba(20, 20, 40, 0.95);
  padding: 40px;
  border-radius: 16px;
  box-shadow: 0 0 30px rgba(100, 100, 255, 0.3);
  min-width: 300px;
  max-width: 1100px;
  text-align: center;
}

.lobby-container {
  width: min(860px, 95vw);
}

#lobby-screen.active {
  align-items: flex-start;
  padding: 24px 0 40px;
}

.dev-controls {
  position: fixed;
  top: 18px;
  right: 22px;
  display: flex;
  gap: 8px;
  z-index: 20;
}

.dev-toggle {
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: #cfd6ff;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.75rem;
  cursor: pointer;
}

.dev-panel {
  position: fixed;
  top: 54px;
  right: 22px;
  background: rgba(10, 14, 28, 0.95);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  min-width: 200px;
  text-align: left;
  z-index: 20;
}

.dev-panel.hidden {
  display: none;
}

.test-panel {
  position: fixed;
  top: 54px;
  right: 240px;
  background: rgba(10, 14, 28, 0.95);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.8rem;
  min-width: 220px;
  text-align: left;
  z-index: 20;
}

.test-panel.hidden {
  display: none;
}

.dev-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #9ab;
  margin-bottom: 4px;
}

.dev-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #cfd6ff;
}

.dev-range {
  align-items: center;
}

.dev-range input[type='range'] {
  flex: 1;
}

.dev-range-value {
  min-width: 44px;
  text-align: right;
  color: #9ab;
  font-variant-numeric: tabular-nums;
}

.test-subtitle {
  margin-top: 8px;
}

.keybind-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  color: #cfd6ff;
}

.keybind-btn {
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: #cfd6ff;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
}

.keybind-btn.listening {
  background: rgba(255, 180, 100, 0.25);
  color: #ffd9a3;
}


h1 {
  font-size: 2.5rem;
  margin-bottom: 30px;
  color: #7af;
  text-shadow: 0 0 20px rgba(100, 150, 255, 0.5);
}

h2 {
  font-size: 1.5rem;
  margin-bottom: 15px;
  color: #aaf;
}

.muted {
  color: #9aa6cc;
  font-size: 0.9rem;
}

/* Form styles */
.form-group {
  margin-bottom: 20px;
  text-align: left;
}

label {
  display: block;
  margin-bottom: 8px;
  color: #aaa;
  font-size: 0.9rem;
}

input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #334;
  border-radius: 8px;
  background: #1a1a2e;
  color: #fff;
  font-size: 1rem;
  transition: border-color 0.3s;
}

input:focus {
  outline: none;
  border-color: #7af;
}

/* Button styles */
.btn {
  width: 100%;
  padding: 14px 24px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #4466ff, #6688ff);
  color: #fff;
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(100, 100, 255, 0.4);
}

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

.btn.ready {
  background: linear-gradient(135deg, #44ff66, #66ff88);
}

.btn.btn-secondary {
  background: linear-gradient(135deg, #2c3b66, #3b4b7a);
  font-size: 0.95rem;
  padding: 10px 16px;
  width: auto;
}

/* Error message */
.error {
  color: #f66;
  margin-top: 15px;
  font-size: 0.9rem;
}

.lobby-layout {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 40px;
  width: min(1400px, 96vw);
  margin: 0 auto;
}

.lobby-right {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(320px, 92vw);
  margin-top: 40px;
}

.lobby-title {
  margin: 4px 0 6px;
  text-align: left;
}

/* Room info */
#room-info {
  margin: 0 auto 12px;
  font-size: 0.9rem;
  color: #888;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

#lobby-economy {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 360px;
  margin: 0 auto 20px;
  padding: 8px 12px;
  background: rgba(10, 14, 28, 0.5);
  border: 1px solid rgba(120, 150, 255, 0.2);
  border-radius: 12px;
}

#lobby-coins {
  font-size: 0.95rem;
  color: #ffd36e;
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 12px;
  border-radius: 8px;
  flex: 1;
}

.lobby-content {
  display: grid;
  grid-template-columns: minmax(0, 360px) minmax(0, 180px);
  gap: 18px;
  justify-content: center;
  justify-items: center;
  align-items: start;
  text-align: left;
}

.rocket-preview-panel {
  background: rgba(10, 14, 28, 0.6);
  border-radius: 14px;
  padding: 18px;
  border: 1px solid rgba(120, 150, 255, 0.2);
  max-width: 360px;
  margin: 0 auto;
  text-align: center;
}

.lobby-panel {
  background: rgba(10, 14, 28, 0.6);
  border-radius: 14px;
  padding: 18px;
  border: 1px solid rgba(120, 150, 255, 0.2);
}

.players-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.players-panel-float {
  position: fixed;
  top: 150px;
  right: 24px;
  width: 260px;
  max-height: 70vh;
  overflow-y: auto;
  z-index: 10;
}

.customizer-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
}

.rocket-preview-card {
  background: rgba(5, 8, 20, 0.8);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.weapons-panel {
  max-width: 180px;
  width: 100%;
  margin: 0 auto;
}

.weapons-section {
  margin-bottom: 14px;
}

.weapons-section h3 {
  font-size: 0.95rem;
  color: #9bd;
  margin: 4px 0 8px;
}

.weapons-section.defense h3 {
  color: #9fd7c5;
}

.weapons-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.weapons-list li {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(120, 150, 255, 0.18);
  text-align: left;
}

.weapon-name {
  font-weight: 600;
  color: #d7e6ff;
}

.weapon-desc {
  color: #9aa6cc;
  font-size: 0.85rem;
  margin-top: 4px;
}

.mode-select {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
  text-align: left;
}

.mode-select select {
  background: rgba(15, 20, 40, 0.9);
  color: #cfd6ff;
  border: 1px solid rgba(140, 160, 255, 0.2);
  border-radius: 8px;
  padding: 6px 10px;
}

#rocket-preview {
  width: 220px;
  height: 280px;
  border-radius: 10px;
  background: radial-gradient(circle at top, rgba(90, 120, 200, 0.35), rgba(10, 14, 28, 0.95));
}

.rocket-style-name {
  font-weight: 600;
  color: #cfe4ff;
}

.rocket-options {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 16px;
}

.style-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 10px;
}

.style-card {
  border: 1px solid rgba(130, 160, 255, 0.2);
  background: rgba(8, 12, 24, 0.8);
  border-radius: 10px;
  padding: 8px;
  color: #d6e2ff;
  font-size: 0.75rem;
  text-align: center;
  cursor: pointer;
  display: grid;
  gap: 6px;
  justify-items: center;
}

.style-card.selected {
  border-color: rgba(90, 200, 255, 0.9);
  box-shadow: 0 0 18px rgba(90, 200, 255, 0.4);
}

.style-canvas {
  width: 70px;
  height: 90px;
  border-radius: 8px;
  background: rgba(8, 10, 20, 0.9);
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.color-control {
  display: grid;
  gap: 6px;
  font-size: 0.8rem;
  color: #bcd0ff;
}

.color-control input {
  padding: 4px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(120, 150, 255, 0.3);
  background: #0d1324;
}

.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
}

.rocket-modal {
  width: min(820px, 94vw);
  max-height: 86vh;
  overflow: hidden;
}

.rocket-modal-body {
  display: grid;
  grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
  align-items: start;
}

.modal-preview #rocket-preview-modal {
  width: 280px;
  height: 340px;
  border-radius: 10px;
  background: radial-gradient(circle at top, rgba(90, 120, 200, 0.35), rgba(10, 14, 28, 0.95));
}

.modal-preview {
  position: sticky;
  top: 0;
}

.rocket-modal .rocket-options {
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 6px;
}

/* Players list */
#players-list {
  margin-bottom: 0;
}

#player-list {
  list-style: none;
  text-align: left;
}

#player-list li {
  padding: 12px 16px;
  margin-bottom: 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#player-list li .player-name {
  display: flex;
  align-items: center;
  gap: 10px;
}

#player-list li .player-color {
  width: 16px;
  height: 16px;
  border-radius: 50%;
}

#player-list li .ready-status {
  font-size: 0.8rem;
  padding: 4px 8px;
  border-radius: 4px;
}

#player-list li .ready-status.ready {
  background: rgba(68, 255, 68, 0.2);
  color: #4f4;
}

#player-list li .ready-status.not-ready {
  background: rgba(255, 68, 68, 0.2);
  color: #f66;
}

/* Shop modal */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 16, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
}

.modal {
  background: rgba(20, 20, 40, 0.97);
  border-radius: 16px;
  padding: 24px 28px 18px;
  width: min(520px, 90vw);
  box-shadow: 0 0 30px rgba(60, 90, 160, 0.35);
  position: relative;
}

.close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
}

#shop-coins {
  margin-bottom: 16px;
  color: #ffd36e;
  font-size: 0.95rem;
}

#shop-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
  font-size: 0.85rem;
  margin-bottom: 16px;
  color: #c8d4ff;
}

.shop-stat {
  background: rgba(10, 14, 28, 0.6);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.shop-stat-value {
  color: #ffd36e;
}

.shop-stat-delta {
  font-size: 0.8rem;
  min-width: 56px;
  text-align: right;
  opacity: 0.9;
}

.delta-positive {
  color: #6fe38a;
}

.delta-negative {
  color: #ff8b8b;
}

#upgrade-list {
  display: grid;
  gap: 12px;
  max-height: 50vh;
  overflow-y: auto;
  padding-right: 4px;
}

.upgrade-card {
  background: rgba(0, 0, 0, 0.35);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.upgrade-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 1rem;
  color: #aaf;
}

.upgrade-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: #9ab;
}

.upgrade-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.upgrade-cost {
  font-size: 0.9rem;
  color: #ffd36e;
}

.upgrade-buy {
  width: auto;
  padding: 8px 14px;
  font-size: 0.85rem;
}

.upgrade-buy:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  box-shadow: none;
}

/* Countdown */
#countdown-display {
  font-size: 2rem;
  margin-bottom: 20px;
  color: #ff7;
  animation: pulse 1s infinite;
}

#countdown-display.hidden {
  display: none;
}

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

/* Game screen */
#game-screen {
  background: #000;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Game HUD */
#game-hud {
  position: fixed;
  top: 20px;
  left: 20px;
  right: 20px;
  pointer-events: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

#distance-speed-group {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.hud-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #9ab;
  margin-bottom: 6px;
}

#fuel-bar-container {
  width: 200px;
  height: 24px;
  background: rgba(0, 0, 0, 0.7);
  border: 2px solid #444;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
}

#fuel-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #f44, #ff4, #4f4);
  transition: width 0.1s;
}

#fuel-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-weight: bold;
  font-size: 0.8rem;
  text-shadow: 0 0 4px #000;
}

#health-bar-container {
  width: 200px;
  height: 18px;
  background: rgba(40, 15, 10, 0.7);
  border: 2px solid rgba(255, 140, 100, 0.35);
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  margin-top: 8px;
}

#health-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, rgba(255, 120, 80, 0.95), rgba(255, 200, 120, 0.95));
  transition: width 0.1s;
}

#health-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-weight: bold;
  font-size: 0.75rem;
  color: #ffe7d4;
  text-shadow: 0 0 4px #000;
}

#distance-display,
#speed-display {
  background: rgba(0, 0, 0, 0.7);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 1.1rem;
}

#leaderboard {
  background: rgba(0, 0, 0, 0.7);
  padding: 10px 14px;
  border-radius: 10px;
  min-width: 200px;
}

#leaderboard-list {
  list-style: decimal inside;
  font-size: 0.95rem;
}

#leaderboard-list li {
  padding: 4px 0;
}

#leaderboard-list li.dead {
  color: #889;
  text-decoration: line-through;
}

#spectator-banner {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 0.95rem;
  color: #ffd36e;
  pointer-events: none;
}

/* Game over screen */
#gameover-screen .container {
  min-width: 350px;
}

#winner-text {
  color: #ff7;
  font-size: 2rem;
  margin-bottom: 20px;
}

#results {
  list-style: decimal inside;
  text-align: left;
  margin-bottom: 20px;
}

#results li {
  padding: 10px;
  margin-bottom: 5px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
}

#results li:first-child {
  background: rgba(255, 200, 0, 0.2);
}

/* Utility */
.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .lobby-layout {
    flex-direction: column;
    align-items: center;
  }

  .lobby-right {
    width: min(520px, 90vw);
  }

  .lobby-title {
    text-align: center;
  }

  .lobby-content {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 16px;
  }

  .rocket-preview-panel {
    max-width: none;
  }

  .rocket-modal-body {
    grid-template-columns: 1fr;
  }
}
