/**
 * PoopCats - Gross Multiplayer 3D Bomberman
 * Disgusting retro styling with CRT effects and gross color scheme
 */

/* CSS Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Courier New', monospace;
  background: #1a1a0a;
  color: #ffdd44;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* App container */
#app {
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: visible;
  z-index: 1;
}

/* CRT Scanline Effect */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    transparent 50%,
    rgba(0, 255, 0, 0.03) 50%
  );
  background-size: 100% 4px;
  pointer-events: none;
  z-index: 1000;
  animation: scanlines 0.1s linear infinite;
}

@keyframes scanlines {
  0% { transform: translateY(0); }
  100% { transform: translateY(4px); }
}

/* Screen Management */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.screen.active {
  opacity: 1;
  visibility: visible;
}

/* Menu Screen */
#menu-screen {
  background: radial-gradient(circle at center, #2a1a0a 0%, #0a0a0a 100%);
  background-image: 
    radial-gradient(circle at 20% 20%, rgba(255, 221, 68, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(139, 69, 19, 0.1) 0%, transparent 50%);
}

.menu-container {
  text-align: center;
  max-width: 600px;
  padding: 2rem;
  background: rgba(0, 0, 0, 0.7);
  border: 2px solid #ffdd44;
  border-radius: 10px;
  box-shadow: 
    0 0 20px rgba(255, 221, 68, 0.3),
    inset 0 0 20px rgba(0, 0, 0, 0.5);
}

.game-title {
  font-size: 4rem;
  font-weight: bold;
  text-shadow: 
    0 0 10px #ffdd44,
    0 0 20px #ffdd44,
    0 0 30px #ffdd44;
  margin-bottom: 0.5rem;
  animation: titlePulse 2s ease-in-out infinite alternate;
}

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

.game-subtitle {
  font-size: 1.2rem;
  color: #ffaa00;
  margin-bottom: 2rem;
  text-shadow: 0 0 5px #ffaa00;
}

.menu-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.menu-btn {
  padding: 1rem 2rem;
  font-size: 1.2rem;
  font-family: inherit;
  font-weight: bold;
  border: 2px solid;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
  position: relative;
  overflow: hidden;
}

.menu-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.menu-btn:hover::before {
  left: 100%;
}

.menu-btn.primary {
  background: #8b4513;
  border-color: #ffdd44;
  color: #ffdd44;
  box-shadow: 0 0 15px rgba(255, 221, 68, 0.3);
}

.menu-btn.primary:hover {
  background: #a0522d;
  box-shadow: 0 0 25px rgba(255, 221, 68, 0.5);
  transform: translateY(-2px);
}

.menu-btn.secondary {
  background: transparent;
  border-color: #ffaa00;
  color: #ffaa00;
  box-shadow: 0 0 10px rgba(255, 170, 0, 0.3);
}

.menu-btn.secondary:hover {
  background: rgba(255, 170, 0, 0.1);
  box-shadow: 0 0 20px rgba(255, 170, 0, 0.5);
  transform: translateY(-2px);
}

/* Join Form */
.join-form {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.join-form.hidden {
  display: none;
}

.join-form input {
  padding: 0.8rem 1rem;
  font-size: 1.1rem;
  font-family: inherit;
  background: rgba(0, 0, 0, 0.7);
  border: 2px solid #ffdd44;
  border-radius: 5px;
  color: #ffdd44;
  text-align: center;
  width: 200px;
}

.join-form input::placeholder {
  color: #ffaa00;
  opacity: 0.7;
}

.join-form input:focus {
  outline: none;
  box-shadow: 0 0 15px rgba(255, 221, 68, 0.5);
  border-color: #ffff00;
}

/* Leaderboard */
.leaderboard {
  margin-top: 2rem;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid #ffaa00;
  border-radius: 5px;
  padding: 1rem;
}

.leaderboard h3 {
  color: #ffaa00;
  margin-bottom: 1rem;
  text-align: center;
}

#leaderboard-list {
  max-height: 200px;
  overflow-y: auto;
}

.leaderboard-entry {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem;
  border-bottom: 1px solid rgba(255, 170, 0, 0.3);
}

.leaderboard-entry:last-child {
  border-bottom: none;
}

.leaderboard-rank {
  font-weight: bold;
  color: #ffdd44;
}

.leaderboard-name {
  color: #ffaa00;
}

.leaderboard-score {
  color: #ffff00;
  font-weight: bold;
}

/* Game Screen */
#game-screen {
  background: #0a0a0a;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#game-canvas {
  width: 100vw;
  height: 100vh;
  display: block;
  cursor: crosshair;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1;
  margin: 0;
  padding: 0;
}

#game-canvas canvas {
  width: 100vw !important;
  height: 100vh !important;
  display: block !important;
}

/* HUD */
#game-hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  padding: 0.5rem;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), transparent);
  pointer-events: none;
}

.hud-left, .hud-right {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: auto;
}

#player-list {
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid #ffdd44;
  border-radius: 4px;
  padding: 0.4rem;
  min-width: 180px;
  max-width: 220px;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 0 8px rgba(255, 221, 68, 0.4);
  font-size: 0.85rem;
}

.room-info {
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid #ffaa00;
  border-radius: 4px;
  padding: 0.3rem 0.6rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: bold;
  color: #ffff00;
  margin-bottom: 0;
  box-shadow: 0 0 8px rgba(255, 170, 0, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block !important;
}

.room-info.hidden {
  display: none !important;
}

.player-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid rgba(255, 221, 68, 0.3);
  gap: 0.4rem;
  transition: background 0.2s ease;
  font-size: 0.85rem;
}

.player-entry:hover {
  background: rgba(255, 221, 68, 0.1);
}

.player-entry.local-player {
  background: rgba(255, 221, 68, 0.15);
  border-left: 3px solid #ffff00;
}

.player-entry:last-child {
  border-bottom: none;
}

.player-name {
  color: #ffaa00;
  font-weight: bold;
}

.player-score {
  color: #ffff00;
  font-weight: bold;
}

.player-status {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #00ff00;
  box-shadow: 0 0 5px #00ff00;
  flex-shrink: 0;
}

.player-status.dead {
  background: #ff0000;
}

#game-timer {
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid #ffdd44;
  border-radius: 4px;
  padding: 0.3rem 0.8rem;
  text-align: center;
  font-size: 0.9rem;
  font-weight: bold;
  color: #ffff00;
  box-shadow: 0 0 8px rgba(255, 221, 68, 0.4);
  text-shadow: 0 0 3px #ffff00;
  width: fit-content;
}

.game-status {
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid #ffaa00;
  border-radius: 4px;
  padding: 0.3rem 0.6rem;
  text-align: center;
  font-size: 0.75rem;
  color: #ffaa00;
  margin-top: 0;
  box-shadow: 0 0 8px rgba(255, 170, 0, 0.4);
  width: fit-content;
}

.game-status.connected {
  border-color: #00ff00;
  color: #00ff00;
}

.game-status.hidden {
  display: none;
}

.hud-btn {
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid #ffdd44;
  border-radius: 5px;
  padding: 0.5rem;
  color: #ffdd44;
  cursor: pointer;
  font-size: 1.2rem;
  transition: all 0.3s ease;
}

.hud-btn:hover {
  background: rgba(255, 221, 68, 0.2);
  box-shadow: 0 0 10px rgba(255, 221, 68, 0.3);
}

/* Mobile Controls */
.mobile-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  display: none;
  justify-content: space-between;
  padding: 1rem;
  pointer-events: none;
}

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

.virtual-dpad {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  gap: 5px;
  width: 120px;
  height: 120px;
  pointer-events: auto;
}

.dpad-btn {
  background: rgba(0, 0, 0, 0.7);
  border: 2px solid #ffdd44;
  border-radius: 10px;
  color: #ffdd44;
  font-size: 1.5rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.1s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.dpad-btn:active {
  background: rgba(255, 221, 68, 0.3);
  transform: scale(0.95);
}

.dpad-btn[data-key="w"] {
  grid-column: 2;
  grid-row: 1;
}

.dpad-btn[data-key="a"] {
  grid-column: 1;
  grid-row: 2;
}

.dpad-btn[data-key="s"] {
  grid-column: 2;
  grid-row: 3;
}

.dpad-btn[data-key="d"] {
  grid-column: 3;
  grid-row: 2;
}

.poop-btn {
  background: #8b4513;
  border: 3px solid #ffdd44;
  border-radius: 50%;
  width: 80px;
  height: 80px;
  color: #ffdd44;
  font-size: 2rem;
  cursor: pointer;
  transition: all 0.1s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  box-shadow: 0 0 15px rgba(255, 221, 68, 0.3);
}

.poop-btn:active {
  background: #a0522d;
  transform: scale(0.9);
  box-shadow: 0 0 25px rgba(255, 221, 68, 0.5);
}

/* Overlays */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.overlay:not(.hidden) {
  opacity: 1;
  visibility: visible;
}

.overlay-content {
  text-align: center;
  background: rgba(0, 0, 0, 0.9);
  border: 3px solid #ffdd44;
  border-radius: 15px;
  padding: 3rem;
  max-width: 500px;
  box-shadow: 
    0 0 30px rgba(255, 221, 68, 0.5),
    inset 0 0 30px rgba(0, 0, 0, 0.5);
}

.overlay h2 {
  font-size: 3rem;
  margin-bottom: 1rem;
  text-shadow: 0 0 15px #ffdd44;
}

.overlay p {
  font-size: 1.3rem;
  margin-bottom: 2rem;
  color: #ffaa00;
}

/* Victory Overlay */
#victory-overlay h2 {
  color: #00ff00;
  text-shadow: 0 0 15px #00ff00;
}

#victory-overlay p {
  color: #ffff00;
}

/* Defeat Overlay */
#defeat-overlay h2 {
  color: #ff0000;
  text-shadow: 0 0 15px #ff0000;
}

#defeat-overlay p {
  color: #ff6666;
}

/* Chat Container - Always Visible */
.chat-container {
  position: fixed !important;
  bottom: 10px !important;
  right: 10px !important;
  width: 280px !important;
  min-width: 250px !important;
  max-height: 350px !important;
  min-height: 150px !important;
  background: rgba(0, 0, 0, 0.85) !important;
  border: 1px solid #ffdd44 !important;
  border-radius: 6px !important;
  box-shadow: 
    0 0 15px rgba(255, 221, 68, 0.4),
    inset 0 0 15px rgba(0, 0, 0, 0.5) !important;
  z-index: 999999 !important;
  display: flex !important;
  flex-direction: column !important;
  transition: all 0.3s ease;
  font-family: 'Courier New', monospace !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  transform: none !important;
  clip: auto !important;
  clip-path: none !important;
}

.chat-container.collapsed {
  max-height: 50px;
  overflow: hidden;
}

.chat-container.collapsed .chat-messages,
.chat-container.collapsed .chat-input-container,
.chat-container.collapsed .chat-char-counter {
  display: none;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.8rem;
  background: rgba(0, 0, 0, 0.6);
  border-bottom: 1px solid #ffdd44;
  cursor: pointer;
}

.chat-header h3 {
  margin: 0;
  color: #ffdd44;
  font-size: 0.9rem;
  text-shadow: 0 0 3px #ffdd44;
}

.chat-toggle-btn {
  background: transparent;
  border: 1px solid #ffdd44;
  border-radius: 3px;
  color: #ffdd44;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  font-size: 1rem;
  transition: all 0.3s ease;
}

.chat-toggle-btn:hover {
  background: rgba(255, 221, 68, 0.2);
  box-shadow: 0 0 5px rgba(255, 221, 68, 0.3);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.4rem;
  max-height: 220px;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #ffdd44;
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: #ffaa00;
}

.chat-message {
  padding: 0.4rem;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 4px;
  border-left: 2px solid #ffdd44;
  font-size: 0.8rem;
  word-wrap: break-word;
  line-height: 1.3;
}

.chat-message-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.2rem;
}

.chat-message-name {
  color: #ffaa00;
  font-weight: bold;
  font-size: 0.85rem;
}

.chat-message-time {
  color: #888;
  font-size: 0.75rem;
}

.chat-message-text {
  color: #ffdd44;
}

.chat-input-container {
  display: flex;
  gap: 0.4rem;
  padding: 0.5rem;
  border-top: 1px solid rgba(255, 221, 68, 0.3);
  background: rgba(0, 0, 0, 0.4);
}

.chat-input-container input {
  flex: 1;
  padding: 0.4rem 0.6rem;
  font-size: 0.8rem;
  font-family: inherit;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid #ffdd44;
  border-radius: 4px;
  color: #ffdd44;
}

.chat-input-container input::placeholder {
  color: #ffaa00;
  opacity: 0.7;
}

.chat-input-container input:focus {
  outline: none;
  box-shadow: 0 0 10px rgba(255, 221, 68, 0.5);
  border-color: #ffff00;
}

.chat-send-btn {
  padding: 0.4rem 0.9rem;
  font-size: 0.75rem;
  font-family: inherit;
  font-weight: bold;
  background: #8b4513;
  border: 1px solid #ffdd44;
  border-radius: 4px;
  color: #ffdd44;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chat-send-btn:hover {
  background: #a0522d;
  box-shadow: 0 0 15px rgba(255, 221, 68, 0.3);
  transform: translateY(-1px);
}

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

.chat-char-counter {
  padding: 0.2rem 0.6rem;
  text-align: right;
  font-size: 0.7rem;
  color: #ffaa00;
  background: rgba(0, 0, 0, 0.4);
  border-top: 1px solid rgba(255, 221, 68, 0.2);
}

#chat-char-count {
  color: #ffdd44;
  font-weight: bold;
}

/* Responsive Design */
@media (max-width: 768px) {
  .game-title {
    font-size: 2.5rem;
  }
  
  .menu-container {
    padding: 1rem;
    margin: 1rem;
  }
  
  .menu-buttons {
    flex-direction: column;
    align-items: center;
  }
  
  .menu-btn {
    width: 200px;
  }
  
  .mobile-controls {
    display: flex;
  }
  
  .hud-left {
    font-size: 0.9rem;
  }
  
  #player-list {
    min-width: 150px;
  }
  
  .chat-container {
    width: 280px;
    bottom: 10px;
    right: 10px;
    max-height: 400px;
  }
  
  .chat-messages {
    max-height: 200px;
    min-height: 80px;
  }
}

@media (max-width: 480px) {
  .game-title {
    font-size: 2rem;
  }
  
  .overlay-content {
    padding: 2rem;
    margin: 1rem;
  }
  
  .overlay h2 {
    font-size: 2rem;
  }
  
  .virtual-dpad {
    width: 100px;
    height: 100px;
  }
  
  .poop-btn {
    width: 70px;
    height: 70px;
    font-size: 1.5rem;
  }
  
  .chat-container {
    width: 250px;
    bottom: 5px;
    right: 5px;
    max-height: 350px;
  }
  
  .chat-messages {
    max-height: 150px;
    min-height: 60px;
    font-size: 0.8rem;
  }
  
  .chat-input-container input {
    font-size: 0.8rem;
    padding: 0.5rem 0.6rem;
  }
  
  .chat-send-btn {
    font-size: 0.8rem;
    padding: 0.5rem 1rem;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  .menu-btn:hover {
    transform: none;
    box-shadow: inherit;
  }
  
  .hud-btn:hover {
    background: rgba(0, 0, 0, 0.7);
    box-shadow: none;
  }
}

/* Loading states */
.loading {
  opacity: 0.5;
  pointer-events: none;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 3px solid #ffdd44;
  border-top: 3px solid transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

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

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

.text-glow {
  text-shadow: 0 0 10px currentColor;
}

.pulse {
  animation: pulse 1s ease-in-out infinite alternate;
}

@keyframes pulse {
  0% { opacity: 0.7; }
  100% { opacity: 1; }
}
