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

body {
  background: #0a0a1a;
  font-family: 'Press Start 2P', monospace;
  color: #ffffff;
  overflow: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#canvas {
  display: block;
  image-rendering: pixelated;
  border: 3px solid #2222ff;
  box-shadow: 0 0 30px rgba(34, 34, 255, 0.5);
}

#ui-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 100;
}

#ui-overlay > * {
  pointer-events: auto;
}

.menu-container {
  background: linear-gradient(135deg, #1a0a2e 0%, #0a0a1a 100%);
  border: 3px solid #ff00ff;
  box-shadow: 0 0 50px rgba(255, 0, 255, 0.3), inset 0 0 30px rgba(0, 0, 0, 0.5);
  padding: 40px;
  text-align: center;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
}

.title-container {
  margin-bottom: 30px;
}

.game-title {
  font-size: clamp(24px, 8vw, 48px);
  color: #ffcc00;
  text-shadow: 
    0 0 10px #ff8800,
    0 0 20px #ff6600,
    0 0 40px #ff4400,
    4px 4px 0 #1a0a2e;
  animation: titlePulse 2s infinite;
}

.bomb-icon {
  display: inline-block;
  animation: bombBounce 0.5s infinite alternate;
}

@keyframes titlePulse {
  0%, 100% { text-shadow: 0 0 10px #ff8800, 0 0 20px #ff6600, 4px 4px 0 #1a0a2e; }
  50% { text-shadow: 0 0 20px #ffaa00, 0 0 40px #ff8800, 4px 4px 0 #1a0a2e; }
}

@keyframes bombBounce {
  0% { transform: translateY(0) rotate(-5deg); }
  100% { transform: translateY(-5px) rotate(5deg); }
}

.subtitle {
  font-size: clamp(10px, 3vw, 16px);
  color: #00ffff;
  margin-top: 10px;
  letter-spacing: 4px;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 30px;
}

.menu-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(10px, 2.5vw, 14px);
  padding: 15px 30px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
}

.host-btn {
  background: linear-gradient(180deg, #ffcc00 0%, #ff8800 100%);
  color: #1a0a2e;
  border: 3px solid #ffff00;
  box-shadow: 0 0 15px rgba(255, 200, 0, 0.5);
}

.host-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 25px rgba(255, 200, 0, 0.8);
}

.join-btn {
  background: linear-gradient(180deg, #00ccff 0%, #0088ff 100%);
  color: #1a0a2e;
  border: 3px solid #00ffff;
  box-shadow: 0 0 15px rgba(0, 200, 255, 0.5);
}

.join-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 25px rgba(0, 200, 255, 0.8);
}

.help-btn {
  background: linear-gradient(180deg, #666666 0%, #444444 100%);
  color: #ffffff;
  border: 3px solid #888888;
}

.help-btn:hover {
  transform: scale(1.05);
  background: linear-gradient(180deg, #888888 0%, #666666 100%);
}

.back-btn {
  background: #333333;
  color: #888888;
  border: 2px solid #555555;
  font-size: 10px;
  padding: 10px 20px;
}

.start-btn {
  background: linear-gradient(180deg, #00ff00 0%, #00aa00 100%);
  color: #1a0a2e;
  border: 3px solid #00ff00;
  box-shadow: 0 0 20px rgba(0, 255, 0, 0.5);
}

.start-btn.disabled {
  background: #333333;
  border-color: #555555;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.5;
}

.ghost-parade {
  height: 40px;
  margin: 20px 0;
  display: flex;
  justify-content: center;
  gap: 20px;
  overflow: hidden;
}

.ghost {
  font-size: 24px;
  animation: ghostFloat 3s ease-in-out infinite;
}

@keyframes ghostFloat {
  0%, 100% { transform: translateY(0) rotate(-10deg); }
  50% { transform: translateY(-10px) rotate(10deg); }
}

.footer {
  font-size: 8px;
  color: #666666;
  margin-top: 20px;
}

.footer a {
  color: #ff69b4;
  text-decoration: none;
}

/* Lobby Styles */
.lobby-container {
  background: linear-gradient(135deg, #1a0a2e 0%, #0a0a1a 100%);
  border: 3px solid #00ffff;
  box-shadow: 0 0 30px rgba(0, 255, 255, 0.3);
  padding: 30px;
  text-align: center;
  max-width: 95vw;
  max-height: 95vh;
  overflow-y: auto;
}

.section-title {
  font-size: clamp(14px, 4vw, 20px);
  color: #00ffff;
  margin-bottom: 20px;
  text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

.player-count {
  font-size: 12px;
  color: #aaaaaa;
  margin-bottom: 15px;
}

.player-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 20px;
  min-height: 40px;
}

.player-item {
  padding: 8px 15px;
  border-radius: 4px;
  font-size: 10px;
}

.team-attacker {
  background: rgba(255, 200, 0, 0.2);
  border: 2px solid #ffcc00;
  color: #ffcc00;
}

.team-defender {
  background: rgba(0, 200, 255, 0.2);
  border: 2px solid #00ccff;
  color: #00ccff;
}

.qr-section {
  margin: 20px 0;
  padding: 20px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid #333;
}

.qr-section h3 {
  font-size: 10px;
  color: #aaaaaa;
  margin-bottom: 15px;
}

#offer-qr, #answer-qr {
  max-width: 250px;
  margin: 10px auto;
  display: block;
}

.action-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  padding: 10px 20px;
  margin: 5px;
  background: #2a1a4a;
  color: #ffffff;
  border: 2px solid #ff00ff;
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn:hover {
  background: #3a2a5a;
  box-shadow: 0 0 15px rgba(255, 0, 255, 0.5);
}

.cancel-btn {
  border-color: #ff0000;
}

#scanner-container {
  margin: 15px 0;
}

#scanner-container.hidden {
  display: none;
}

#scanner-video {
  width: 100%;
  max-width: 300px;
  border: 2px solid #00ff00;
}

.manual-input {
  margin-top: 15px;
}

.small-text {
  font-size: 8px;
  color: #666666;
  margin-bottom: 10px;
}

#manual-sdp {
  width: 100%;
  max-width: 280px;
  height: 80px;
  background: #0a0a1a;
  border: 2px solid #333333;
  color: #00ff00;
  font-family: monospace;
  font-size: 10px;
  padding: 8px;
  resize: none;
}

.small-btn {
  font-size: 8px;
  padding: 8px 15px;
}

.code-display {
  width: 100%;
  max-width: 280px;
  height: 100px;
  background: #0a0a1a;
  border: 2px solid #333;
  color: #00ff00;
  font-family: monospace;
  font-size: 8px;
  padding: 8px;
  word-break: break-all;
}

#answer-qr-section.hidden {
  display: none;
}

#connection-status {
  font-size: 10px;
  color: #ffcc00;
  margin-top: 15px;
}

.error {
  color: #ff4444;
  font-size: 10px;
}

.qr-fallback {
  margin: 10px auto;
  max-width: 280px;
}

.qr-fallback-text {
  font-size: 10px;
  color: #ffcc00;
  margin-bottom: 10px;
}

/* Help Screen */
.help-screen {
  text-align: left;
  max-width: 500px;
}

.help-content {
  margin: 20px 0;
}

.help-section {
  margin-bottom: 20px;
  padding: 15px;
  background: rgba(0, 0, 0, 0.3);
  border-left: 3px solid #ff00ff;
}

.help-section h3 {
  font-size: 12px;
  color: #ff00ff;
  margin-bottom: 10px;
}

.help-section p {
  font-size: 10px;
  line-height: 1.8;
  color: #cccccc;
}

/* Victory Screen */
.victory-container {
  background: linear-gradient(135deg, #1a0a2e 0%, #0a0a1a 100%);
  border: 3px solid var(--winner-color, #ffffff);
  box-shadow: 0 0 50px var(--winner-color, #ffffff);
  padding: 40px;
  text-align: center;
}

.victory-title {
  font-size: clamp(20px, 6vw, 36px);
  color: var(--winner-color, #ffffff);
  text-shadow: 0 0 20px var(--winner-color, #ffffff);
  animation: victoryPulse 0.5s infinite alternate;
}

@keyframes victoryPulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.05); }
}

.victory-reason {
  font-size: 14px;
  color: #ffffff;
  margin: 20px 0;
}

.score-display {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin: 20px 0;
  font-size: 12px;
}

/* Mobile Controls */
#controls {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 200;
  pointer-events: none;
}

.mobile-controls {
  display: flex;
  justify-content: space-between;
  padding: 20px;
  pointer-events: auto;
}

.dpad {
  position: relative;
  width: 120px;
  height: 120px;
}

.dpad-btn {
  position: absolute;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.5);
  color: white;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.dpad-btn.up { top: 0; left: 40px; }
.dpad-btn.down { bottom: 0; left: 40px; }
.dpad-btn.left { top: 40px; left: 0; }
.dpad-btn.right { top: 40px; right: 0; }

.dpad-btn:active {
  background: rgba(255, 255, 255, 0.5);
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.action-btn-mobile {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(255, 0, 255, 0.3);
  border: 3px solid #ff00ff;
  color: white;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.action-btn-mobile.shoot {
  background: rgba(255, 100, 0, 0.3);
  border-color: #ff6600;
}

.action-btn-mobile:active {
  transform: scale(0.9);
  background: rgba(255, 0, 255, 0.6);
}

/* Responsive */
@media (max-width: 600px) {
  .menu-container, .lobby-container {
    padding: 20px;
  }
  
  .menu-btn {
    padding: 12px 20px;
  }
  
  .qr-section {
    padding: 10px;
  }
  
  #offer-qr, #answer-qr {
    max-width: 200px;
  }
  
  .instruction {
    font-size: 10px;
    margin-bottom: 10px;
  }
}