@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

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

body {
  background: #0a0a0a;
  overflow: hidden;
  font-family: 'Press Start 2P', monospace;
  color: #e0e0e0;
  height: 100vh;
  width: 100vw;
}

/* ─── Lobby ─── */
#lobby {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: linear-gradient(180deg, #1a1a2e 0%, #0f3d0f 100%);
  position: relative;
  z-index: 100;
}

#lobby::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="4" height="4"><rect width="4" height="4" fill="%23000" opacity="0.3"/><rect width="1" height="1" fill="%23fff" opacity="0.05"/></svg>');
  background-size: 4px 4px;
  pointer-events: none;
  z-index: 1;
}

#lobby > * {
  position: relative;
  z-index: 2;
}

.lobby-title {
  font-size: 28px;
  color: #00ff41;
  text-shadow: 0 0 20px #00ff41, 0 0 40px #00ff41;
  margin-bottom: 8px;
  text-align: center;
  letter-spacing: 2px;
}

.lobby-subtitle {
  font-size: 12px;
  color: #ff4444;
  text-shadow: 0 0 10px #ff4444;
  margin-bottom: 50px;
  letter-spacing: 4px;
}

.lobby-box {
  background: rgba(0, 0, 0, 0.7);
  border: 2px solid #00ff41;
  border-radius: 4px;
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: 0 0 30px rgba(0, 255, 65, 0.15);
  min-width: 400px;
}

/* Mode Selection */
.mode-select {
  display: flex;
  gap: 20px;
  margin-bottom: 30px;
}

.mode-option {
  flex: 1;
  background: rgba(0, 255, 65, 0.1);
  border: 2px solid #00ff41;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-option:hover {
  background: rgba(0, 255, 65, 0.15);
  transform: scale(1.02);
}

.mode-option.selected {
  background: rgba(0, 255, 65, 0.2);
  box-shadow: 0 0 20px rgba(0, 255, 65, 0.3);
}

.mode-title {
  font-size: 18px;
  color: #00ff41;
  margin-bottom: 8px;
  text-shadow: 0 0 10px #00ff41;
}

.mode-desc {
  font-size: 10px;
  color: #888;
  margin-bottom: 12px;
  letter-spacing: 2px;
}

.mode-players {
  font-size: 12px;
  color: #00ff41;
}

.lobby-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin-bottom: 20px;
}

.action-btn {
  background: #00ff41;
  color: #000;
  border: none;
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  padding: 12px 24px;
  cursor: pointer;
  letter-spacing: 2px;
  transition: all 0.2s;
}

.action-btn:hover {
  background: #00cc33;
  box-shadow: 0 0 20px rgba(0, 255, 65, 0.5);
  transform: scale(1.05);
}

.action-divider {
  color: #555;
  font-size: 10px;
}

.rooms-list {
  width: 100%;
}

.rooms-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 10px;
  margin-bottom: 15px;
  font-size: 11px;
  color: #888;
  letter-spacing: 2px;
}

.rooms-count {
  color: #00ff41;
}

.rooms-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 5px;
}

.room-item {
  background: rgba(0, 255, 65, 0.1);
  border: 1px solid #00ff41;
  padding: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s;
  cursor: pointer;
  position: relative;
}

.room-item::after {
  content: attr(data-mode);
  position: absolute;
  top: 5px;
  right: 5px;
  font-size: 8px;
  color: #00ff41;
  background: rgba(0, 0, 0, 0.5);
  padding: 2px 6px;
  border-radius: 2px;
}

.room-item:hover {
  background: rgba(0, 255, 65, 0.2);
  transform: scale(1.02);
}

.room-info {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.room-id {
  font-size: 14px;
  color: #00ff41;
  letter-spacing: 3px;
}

.room-status {
  font-size: 8px;
  color: #888;
  letter-spacing: 1px;
}

.room-players {
  font-size: 12px;
  color: #00ff41;
  letter-spacing: 2px;
}

/* Scrollbar for rooms list */
.rooms-grid::-webkit-scrollbar {
  width: 6px;
}

.rooms-grid::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
}

.rooms-grid::-webkit-scrollbar-thumb {
  background: #00ff41;
  border-radius: 3px;
}

/* Countdown Overlay */
.countdown-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.countdown-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.countdown-title {
  font-size: 24px;
  color: #00ff41;
  text-shadow: 0 0 20px #00ff41;
  letter-spacing: 4px;
}

.countdown-number {
  font-size: 72px;
  color: #fff;
  text-shadow: 0 0 30px #00ff41;
  animation: pulse 1s infinite;
}

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


.lobby-teams {
  display: flex;
  gap: 60px;
  margin-top: 30px;
  font-size: 10px;
}

.team-label-bulls {
  color: #00ff41;
  text-shadow: 0 0 8px #00ff41;
}

.team-label-bears {
  color: #ff4444;
  text-shadow: 0 0 8px #ff4444;
}

/* ─── Game Container ─── */
#game-container {
  display: none;
  position: relative;
  width: 100vw;
  height: 100vh;
  background: #0a0a0a;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

/* ─── CRT + Grain Overlay ─── */
#crt-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

/* Scanlines */
#crt-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.15) 2px,
    rgba(0, 0, 0, 0.15) 4px
  );
  z-index: 51;
}

/* Grain noise */
#crt-overlay::after {
  content: '';
  position: absolute;
  inset: -50%;
  width: 200%;
  height: 200%;
  background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.9" numOctaves="4" stitchTiles="stitch"/></filter><rect width="200" height="200" filter="url(%23n)" opacity="0.12"/></svg>');
  background-size: 200px 200px;
  animation: grain 0.3s steps(4) infinite;
  z-index: 52;
  opacity: 0.6;
}

@keyframes grain {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-5%, -5%); }
  50% { transform: translate(5%, 5%); }
  75% { transform: translate(-2%, 3%); }
  100% { transform: translate(0, 0); }
}

/* Vignette */
#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 53;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.6) 100%);
}

/* ─── Scoreboard ─── */
#scoreboard {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: none;
  align-items: center;
  gap: 24px;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid #333;
  padding: 10px 30px;
  border-radius: 4px;
}

.score-team {
  font-size: 14px;
  letter-spacing: 2px;
}

.score-bulls {
  color: #00ff41;
  text-shadow: 0 0 8px #00ff41;
}

.score-bears {
  color: #ff4444;
  text-shadow: 0 0 8px #ff4444;
}

.score-divider {
  font-size: 18px;
  color: #555;
}

.score-num {
  font-size: 20px;
}

/* ─── HUD ─── */
#hud {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: none;
  align-items: center;
  gap: 16px;
  background: rgba(0, 0, 0, 0.6);
  padding: 8px 24px;
  border-radius: 4px;
  border: 1px solid #333;
}

.hp-bar-bg {
  width: 200px;
  height: 14px;
  background: #333;
  border-radius: 2px;
  overflow: hidden;
}

.hp-bar-fill {
  height: 100%;
  background: #00ff41;
  transition: width 0.2s;
  border-radius: 2px;
}

.hp-text {
  font-size: 10px;
  color: #ccc;
  min-width: 70px;
}

.team-badge {
  font-size: 9px;
  padding: 4px 10px;
  border-radius: 2px;
  letter-spacing: 1px;
}

.badge-bulls {
  background: rgba(0, 255, 65, 0.2);
  color: #00ff41;
  border: 1px solid #00ff41;
}

.badge-bears {
  background: rgba(255, 68, 68, 0.2);
  color: #ff4444;
  border: 1px solid #ff4444;
}

/* ─── Kill Feed ─── */
#kill-feed {
  position: fixed;
  top: 60px;
  right: 16px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kill-msg {
  font-size: 8px;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 2px;
  animation: fadeOut 4s forwards;
  white-space: nowrap;
}

@keyframes fadeOut {
  0% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; }
}

/* ─── Respawn Overlay ─── */
#respawn-overlay {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(139, 0, 0, 0.3);
}

#respawn-overlay span {
  font-size: 20px;
  color: #ff4444;
  text-shadow: 0 0 20px #ff4444;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ─── Round Timer Overlay ─── */
.round-timer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.round-timer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
}

.round-winner {
  font-size: 32px;
  color: #00ff41;
  text-shadow: 0 0 20px #00ff41;
  letter-spacing: 4px;
}

.round-scores {
  font-size: 24px;
  color: #fff;
  letter-spacing: 2px;
  margin: 10px 0;
}

.round-timer {
  font-size: 18px;
  color: #888;
}

.round-timer-number {
  color: #00ff41;
  font-size: 24px;
  text-shadow: 0 0 10px #00ff41;
  animation: pulse 1s infinite;
}

/* ─── Room Info ─── */
#room-info {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 60;
  font-size: 8px;
  color: #555;
  display: none;
}

/* ─── Controls Info ─── */
#controls-info {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 60;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid #00ff41;
  padding: 12px;
  border-radius: 4px;
  display: none;
}

.controls-title {
  color: #00ff41;
  font-size: 12px;
  margin-bottom: 8px;
  text-align: center;
  text-shadow: 0 0 8px #00ff41;
}

.control-item {
  color: #e0e0e0;
  font-size: 8px;
  margin: 4px 0;
  letter-spacing: 1px;
}

/* ─── Chat Interface ─── */
#chat-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 300px;
  height: 300px;
  z-index: 100;
  background: rgba(0, 0, 0, 0.85);
  border: 2px solid #00ff41;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 20px rgba(0, 255, 65, 0.3);
}

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-bottom: 1px solid #333;
}

.chat-message {
  font-size: 8px;
  color: #e0e0e0;
  padding: 4px 8px;
  background: rgba(0, 255, 65, 0.1);
  border-radius: 2px;
  word-wrap: break-word;
}

.chat-message .player-name {
  color: #00ff41;
  margin-right: 5px;
}

.chat-input-container {
  display: flex;
  padding: 12px;
  gap: 8px;
  border-top: none;
}

#chat-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid #333;
  color: #e0e0e0;
  padding: 4px 8px;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  border-radius: 2px;
}

#chat-input:focus {
  outline: none;
  border-color: #00ff41;
}

#chat-send {
  background: #00ff41;
  color: #000;
  border: none;
  padding: 4px 8px;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

#chat-send:hover {
  background: #00cc33;
}

#chat-messages::-webkit-scrollbar {
  width: 4px;
}

#chat-messages::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
}

#chat-messages::-webkit-scrollbar-thumb {
  background: #00ff41;
  border-radius: 2px;
}

/* Hide chat when game is active */
body.in-game #chat-container {
  display: none !important;
}

#game-container[style*="display: block"] ~ #chat-container,
#game-container[style*="display: block"] + #chat-container {
  display: none !important;
}

/* Alternative: Hide chat when lobby is hidden */
#lobby[style*="display: none"] ~ #chat-container {
  display: none !important;
}
