@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg-dark: #07070e;
  --bg-gradient: linear-gradient(135deg, #07070e 0%, #0d0c1d 100%);
  --neon-pink: #ff007f;
  --neon-cyan: #00f3ff;
  --neon-purple: #9d4edd;
  --neon-amber: #ffaa00;
  --glass-bg: rgba(15, 15, 28, 0.65);
  --glass-border: rgba(255, 255, 255, 0.08);
  --text-primary: #f8f9fa;
  --text-secondary: #a0a5c0;
  --text-muted: #5e6488;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  font-family: 'Outfit', sans-serif;
}

input, textarea {
  user-select: auto;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-dark);
  color: var(--text-primary);
}

#canvas-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* UI Container overlaying the canvas */
#ui-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none; /* Let clicks pass through to Three.js when needed */
}

#ui-container * {
  pointer-events: auto; /* Re-enable clicks for UI elements */
}

/* Fullscreen Overlay Panels */
.overlay-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  z-index: 100;
  transition: opacity 0.4s ease, transform 0.4s ease;
  padding: 20px;
}

.overlay-screen.hidden {
  opacity: 0;
  pointer-events: none !important;
  transform: scale(1.05);
}

/* Glass Card styling */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 32px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4),
              inset 0 1px 0 rgba(255, 255, 255, 0.1);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.glass-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -50%;
  width: 200%;
  height: 100%;
  background: linear-gradient(
    to right,
    transparent,
    rgba(255, 255, 255, 0.05),
    transparent
  );
  transform: rotate(45deg);
  pointer-events: none;
  animation: shine 6s infinite linear;
}

@keyframes shine {
  0% { transform: translate(-30%, -30%) rotate(45deg); }
  100% { transform: translate(30%, 30%) rotate(45deg); }
}

/* Typography */
h1.game-title {
  font-size: 42px;
  font-weight: 800;
  letter-spacing: 2px;
  background: linear-gradient(to right, var(--neon-cyan), var(--neon-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
  text-transform: uppercase;
  text-shadow: 0 0 30px rgba(0, 243, 255, 0.2);
}

h2.section-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text-primary);
  letter-spacing: 1px;
}

p.subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 30px;
  font-weight: 300;
}

/* Inputs and Forms */
.input-group {
  margin-bottom: 20px;
  text-align: left;
}

.input-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  display: block;
}

input.neon-input {
  width: 100%;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 500;
  transition: all 0.3s ease;
  outline: none;
}

input.neon-input:focus {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 15px rgba(0, 243, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
}

/* Character Customizer */
.color-picker {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
}

.color-option {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all 0.2s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.color-option.selected {
  border-color: var(--text-primary);
  transform: scale(1.15);
}

/* Buttons */
.btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  padding: 14px 28px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  outline: none;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--neon-cyan) 0%, var(--neon-purple) 100%);
  border: none;
  box-shadow: 0 8px 24px rgba(0, 243, 255, 0.25);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(0, 243, 255, 0.4);
}

.btn-pink {
  background: linear-gradient(135deg, var(--neon-pink) 0%, var(--neon-purple) 100%);
  border: none;
  box-shadow: 0 8px 24px rgba(255, 0, 127, 0.25);
}

.btn-pink:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(255, 0, 127, 0.4);
}

.btn-danger {
  border-color: rgba(231, 76, 60, 0.4);
  color: #ff6b6b;
}

.btn-danger:hover {
  background: rgba(231, 76, 60, 0.15);
}

.btn-block {
  display: flex;
  width: 100%;
}

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 2px;
  margin: 20px 0;
  text-transform: uppercase;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--glass-border);
}

.divider:not(:empty)::before {
  margin-right: 15px;
}

.divider:not(:empty)::after {
  margin-left: 15px;
}

/* Sound Switcher */
.sound-switcher {
  position: absolute;
  top: 24px;
  right: 24px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  z-index: 200;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.sound-switcher:hover {
  border-color: var(--neon-cyan);
  background: rgba(255, 255, 255, 0.1);
}

/* Lobby Waiting Room styles */
.player-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 16px;
  margin: 20px 0 30px 0;
  max-height: 200px;
  overflow-y: auto;
  padding: 8px;
}

.lobby-player-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 12px 6px;
  position: relative;
}

.lobby-player-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  margin-bottom: 8px;
  border: 2px solid rgba(255,255,255,0.2);
}

.lobby-player-name {
  font-size: 12px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  max-width: 70px;
}

.lobby-host-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--neon-amber);
  color: #000;
  font-size: 8px;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 4px;
}

/* HUD Overlay Panels (In-Game UI) */
#hud-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
  transition: opacity 0.3s ease;
}

#hud-overlay.hidden {
  opacity: 0;
  pointer-events: none !important;
}

.hud-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
}

/* Leaderboard */
.leaderboard-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  padding: 16px 20px;
  width: 240px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.leaderboard-header {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--neon-cyan);
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 6px;
}

.leaderboard-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
}

.leaderboard-row:last-child {
  margin-bottom: 0;
}

.leaderboard-name {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

.leaderboard-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.leaderboard-score {
  font-weight: 700;
  color: var(--neon-amber);
}

/* Game Info Display (Center Top) */
.game-info-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  padding: 10px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.game-info-timer {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: 1px;
}

.game-info-state {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--neon-pink);
  margin-top: 2px;
}

/* Chat overlay and Quick messages */
.chat-side-panel {
  display: flex;
  flex-direction: column;
  width: 280px;
  max-height: 200px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  padding: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  align-self: flex-start; /* stick to bottom-left */
  pointer-events: auto; /* re-enable for chat interactions */
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 8px;
  padding-right: 6px;
}

.chat-message {
  font-size: 12px;
  line-height: 1.4;
  margin-bottom: 6px;
  word-break: break-word;
}

.chat-sender {
  font-weight: 700;
}

.chat-input-row {
  display: flex;
  gap: 8px;
}

.chat-input {
  flex: 1;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}

.chat-input:focus {
  border-color: var(--neon-cyan);
}

/* Quick Emotes Panel */
.emotes-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.emote-btn {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.emote-btn:hover {
  transform: scale(1.15);
  border-color: var(--neon-pink);
}

/* Virtual Joystick for Mobile */
#joystick-zone {
  position: absolute;
  bottom: 40px;
  left: 40px;
  width: 120px;
  height: 120px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  display: none; /* Activated via JS if touch device detected */
  z-index: 100;
  justify-content: center;
  align-items: center;
  touch-action: none;
}

#joystick-knob {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--neon-cyan) 0%, var(--neon-purple) 100%);
  border-radius: 50%;
  box-shadow: 0 4px 10px rgba(0,243,255,0.3);
  position: absolute;
  transform: translate(0, 0);
  transition: transform 0.05s ease;
  pointer-events: none;
}

#mobile-jump-btn {
  position: absolute;
  bottom: 40px;
  right: 40px;
  width: 80px;
  height: 80px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  display: none; /* Activated via JS if touch device */
  z-index: 100;
  justify-content: center;
  align-items: center;
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 700;
  touch-action: none;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

#mobile-jump-btn:active {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--neon-pink);
  box-shadow: 0 0 15px rgba(255, 0, 127, 0.3);
}

/* Floating HTML Player Names projecting 3D positions to 2D */
.html-player-label {
  position: absolute;
  transform: translate(-50%, -100%);
  z-index: 40;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.html-player-bubble {
  background: var(--glass-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 4px 10px rgba(0,0,0,0.25);
  transition: all 0.2s ease;
}

.html-player-bubble::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px 6px 0;
  border-style: solid;
  border-color: var(--glass-bg) transparent;
  display: block;
  width: 0;
}

.html-player-emote {
  background: rgba(255, 255, 255, 0.95);
  color: #000;
  padding: 4px 8px;
  border-radius: 10px;
  font-size: 16px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  animation: bounce 0.4s infinite alternate;
}

@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-4px); }
}

/* Scrollbar customization */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Toast Messages */
.toast-msg {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(15, 15, 28, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid var(--neon-pink);
  border-radius: 12px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: 0 10px 30px rgba(255, 0, 127, 0.15);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 1000;
}

.toast-msg.show {
  transform: translateX(-50%) translateY(0);
}
