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

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

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background-color: #0b0b1a; /* Dark background for neon */
  font-family: 'Orbitron', sans-serif;
  color: #fff;
  user-select: none;
}

canvas {
  display: block;
  touch-action: none;
}

#ui {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* Let clicks pass through to canvas */
}

/* In-Game UI */
#game-ui {
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#score-board {
  position: absolute;
  left: 20px;
  bottom: 20px;
  font-size: 24px;
  font-weight: bold;
  text-shadow: 0 0 10px #0ff, 0 0 20px #0ff;
  background: rgba(0, 0, 0, 0.5);
  padding: 10px 20px;
  border-radius: 10px;
  border: 1px solid #0ff;
}

#leaderboard {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(0, 0, 0, 0.5);
  padding: 15px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  min-width: 200px;
}

#leaderboard h3 {
  margin-bottom: 10px;
  font-size: 16px;
  text-align: center;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 2px;
}

#leaderboard-list {
  list-style: none;
}

#leaderboard-list li {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
  font-size: 14px;
}

#leaderboard-list li.player {
  color: #0ff;
  font-weight: bold;
  text-shadow: 0 0 5px #0ff;
}

#game-over {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(10, 10, 30, 0.9);
  padding: 40px;
  border-radius: 20px;
  text-align: center;
  border: 2px solid #f0f;
  box-shadow: 0 0 20px #f0f, inset 0 0 20px #f0f;
  pointer-events: auto; /* Buttons need clicks */
}

/* Auth Panels globally centered */
#auth-container {
  display: flex;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  justify-content: center;
  align-items: center;
  pointer-events: auto;
  background-color: rgba(5, 5, 16, 0.85); /* Darken bg when in menus */
  backdrop-filter: blur(8px);
}

.glass-panel {
  background: rgba(10, 10, 25, 0.7);
  border: 1px solid rgba(0, 255, 255, 0.3);
  padding: 40px 50px;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 0 15px rgba(0, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 15px;
  width: 350px;
  text-align: center;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-info {
  font-size: 12px;
  color: #ccc;
  margin-bottom: 10px;
}

.panel-links {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  margin-top: -5px;
}

.panel-links a {
  color: #0ff;
  text-decoration: none;
  transition: text-shadow 0.2s;
}

.panel-links a:hover {
  text-shadow: 0 0 8px #0ff;
}

.lobby-friends {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 15px;
  margin-top: 5px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Typography styles */
.neon-text {
  font-size: 48px;
  margin-bottom: 20px;
  color: #f0f;
  text-shadow: 0 0 10px #f0f, 0 0 30px #f0f;
  letter-spacing: 2px;
}

.neon-text-small {
  font-size: 22px;
  margin-bottom: 15px;
  color: #0ff;
  text-shadow: 0 0 8px #0ff;
  letter-spacing: 4px;
}

/* Inputs */
.neon-input {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 12px 15px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.neon-input:focus {
  border-color: #0ff;
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

/* Buttons */
.neon-btn {
  background: transparent;
  color: #fff;
  padding: 12px 20px;
  font-size: 14px;
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.neon-btn.primary {
  border: 2px solid #0ff;
  box-shadow: 0 0 8px #0ff inset, 0 0 8px #0ff;
  text-shadow: 0 0 5px #0ff;
}

.neon-btn.primary:hover {
  background: #0ff;
  color: #000;
  box-shadow: 0 0 20px #0ff inset, 0 0 30px #0ff;
}

.neon-btn.magic {
  border: 2px solid #f0f;
  box-shadow: 0 0 8px #f0f inset, 0 0 8px #f0f;
  text-shadow: 0 0 5px #f0f;
  background: rgba(255, 0, 255, 0.1);
}

.neon-btn.magic:hover {
  background: #f0f;
  color: #fff;
  box-shadow: 0 0 20px #f0f inset, 0 0 30px #f0f;
}

.neon-btn.outline {
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.neon-btn.outline:hover {
  border-color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.neon-btn.warning {
  border: 1px solid #ff3366;
  color: #ff3366;
}

.neon-btn.warning:hover {
  background: rgba(255, 51, 102, 0.1);
  box-shadow: 0 0 15px #ff3366;
}

.hidden {
  display: none !important;
}

.performance-hidden {
  display: none !important;
}

/* Power-up effect bar (bottom center) */
#powerup-bar {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  pointer-events: none;
}

.pu-chip {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--pu-color, #0ff);
  box-shadow: 0 0 12px var(--pu-color, #0ff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  overflow: hidden;
}

.pu-chip .pu-fill {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background: var(--pu-color, #0ff);
  opacity: 0.25;
  transform-origin: bottom;
  will-change: transform;
}

.pu-chip .pu-glyph {
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 0 4px var(--pu-color, #0ff));
}

.pu-chip .pu-time {
  position: absolute;
  bottom: 1px;
  right: 3px;
  font-size: 9px;
  z-index: 2;
  color: #fff;
  text-shadow: 0 0 3px #000;
}

.pu-chip.expiring {
  animation: puExpire 0.6s ease-in-out infinite alternate;
}

@keyframes puExpire {
  from { opacity: 1; box-shadow: 0 0 12px var(--pu-color, #0ff); }
  to { opacity: 0.55; box-shadow: 0 0 22px var(--pu-color, #0ff); }
}

/* Difficulty selector */
.difficulty-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
}

.difficulty-row .panel-info {
  margin: 0;
  font-size: 12px;
  white-space: nowrap;
}

.difficulty-row select.neon-input {
  flex: 1;
  padding: 8px 10px;
  cursor: pointer;
}

.difficulty-row select.neon-input option {
  background: #0b0b1a;
  color: #fff;
}

/* Color picker row */
.color-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
}

.color-row .panel-info {
  margin: 0;
  font-size: 12px;
}

#color-picker {
  width: 48px;
  height: 32px;
  border: 1px solid #0ff;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.5);
  cursor: pointer;
  padding: 2px;
}

/* Room code display (in-game, top-left) */
#room-display {
  position: absolute;
  top: 20px;
  left: 20px;
  font-size: 16px;
  font-weight: bold;
  letter-spacing: 2px;
  color: #ffd700;
  text-shadow: 0 0 10px #ffd700;
  background: rgba(0, 0, 0, 0.5);
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 215, 0, 0.4);
}

#room-display:empty {
  display: none;
}

/* Minimap (below room display, top-left) */
#minimap {
  position: absolute;
  top: 70px;
  left: 20px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(0, 255, 255, 0.4);
  border-radius: 8px;
  box-shadow: 0 0 12px rgba(0, 255, 255, 0.2);
}

/* Kill feed (top center) */
#kill-feed {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.kill-item {
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  padding: 3px 10px;
  font-size: 11px;
  letter-spacing: 0.5px;
  animation: killIn 0.25s ease-out, killOut 0.5s ease-in forwards;
  animation-delay: 0s, 2.5s;
}

.kill-item .k-name { font-weight: bold; }
.kill-item .k-icon { margin: 0 6px; color: #ff3366; }

@keyframes killIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes killOut {
  to { opacity: 0; transform: translateY(-8px); }
}

/* Death stats */
#death-stats {
  margin: 14px 0 20px;
  text-align: left;
  display: inline-block;
}

#death-stats p {
  margin: 6px 0;
  font-size: 15px;
}

#death-stats span {
  color: #0ff;
  font-weight: bold;
  text-shadow: 0 0 8px #0ff;
}

/* Mute button (bottom-right corner, above joystick area) */
#btn-mute {
  position: absolute;
  top: 20px;
  right: 200px;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(0, 255, 255, 0.4);
  font-size: 20px;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.2s;
}

#btn-mute:hover {
  box-shadow: 0 0 12px #0ff;
}

/* Virtual joystick (mobile) */
#joystick {
  display: none;
  position: absolute;
  bottom: 30px;
  left: 30px;
  width: 132px;
  height: 132px;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  touch-action: none;
  z-index: 10;
}

#joystick-base {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(0, 255, 255, 0.08);
  border: 2px solid rgba(0, 255, 255, 0.4);
  position: relative;
}

#joystick-knob {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(0, 255, 255, 0.5);
  border: 2px solid #0ff;
  box-shadow: 0 0 15px #0ff;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

#btn-sprint {
  display: none;
  position: absolute;
  right: 30px;
  bottom: 30px;
  width: 92px;
  height: 92px;
  border: 2px solid rgba(255, 0, 255, 0.75);
  border-radius: 50%;
  background: rgba(20, 5, 30, 0.78);
  box-shadow: 0 0 18px rgba(255, 0, 255, 0.35), inset 0 0 18px rgba(255, 0, 255, 0.18);
  color: #fff;
  font: 700 10px/1 'Orbitron', sans-serif;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 7px;
  pointer-events: auto;
  touch-action: none;
  z-index: 10;
  transition: transform 120ms cubic-bezier(0.2, 0.8, 0.2, 1),
              background-color 120ms ease,
              box-shadow 120ms ease;
}

#btn-sprint > span:first-child {
  color: #ff4dff;
  font-size: 28px;
  filter: drop-shadow(0 0 6px #f0f);
}

#joystick.active #joystick-base {
  background: rgba(0, 255, 255, 0.14);
  border-color: rgba(0, 255, 255, 0.75);
}

#btn-sprint.active {
  transform: scale(0.93);
  background: rgba(255, 0, 255, 0.28);
  box-shadow: 0 0 28px rgba(255, 0, 255, 0.75), inset 0 0 20px rgba(255, 0, 255, 0.3);
}

/* Capability-driven mobile experience, applied by main.js. */
.mobile-experience #joystick,
.mobile-experience #btn-sprint {
  display: flex;
}

.mobile-experience #leaderboard,
.mobile-experience #minimap,
.mobile-experience #kill-feed,
.mobile-experience #room-display,
.mobile-experience #btn-mute {
  display: none;
}

.mobile-experience #score-board {
  top: max(12px, env(safe-area-inset-top));
  bottom: auto;
  left: max(12px, env(safe-area-inset-left));
  padding: 7px 11px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1;
}

.mobile-experience #powerup-bar {
  top: max(10px, env(safe-area-inset-top));
  bottom: auto;
  gap: 6px;
}

.mobile-experience .pu-chip {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  font-size: 19px;
}

.mobile-experience #joystick {
  left: max(14px, env(safe-area-inset-left));
  bottom: max(16px, env(safe-area-inset-bottom));
}

.mobile-experience #btn-sprint {
  right: max(20px, env(safe-area-inset-right));
  bottom: max(28px, calc(env(safe-area-inset-bottom) + 12px));
}

.mobile-experience #game-over {
  width: min(90vw, 360px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 24px 20px;
  border-radius: 16px;
}

.mobile-experience #game-over .neon-text {
  font-size: clamp(28px, 9vw, 40px);
  margin-bottom: 12px;
}

.mobile-experience .glass-panel {
  width: min(92vw, 350px);
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  padding: 26px 22px;
}

@media (max-height: 500px) and (orientation: landscape) {
  .mobile-experience #joystick {
    width: 112px;
    height: 112px;
    bottom: max(8px, env(safe-area-inset-bottom));
  }

  .mobile-experience #joystick-base {
    width: 104px;
    height: 104px;
  }

  .mobile-experience #btn-sprint {
    width: 78px;
    height: 78px;
    right: max(14px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
  }

  .mobile-experience #game-over {
    padding: 14px 18px;
  }

  .mobile-experience #death-stats {
    margin: 8px 0 10px;
  }
}
