* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #0a0e17;
  color: #e8ecf4;
  overflow: hidden;
  cursor: default;
}

.hidden {
  display: none !important;
}

/* 菜单 */
#menu {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0a0e17 0%, #1a2332 50%, #0d1520 100%);
  z-index: 100;
}

.menu-panel {
  background: rgba(20, 28, 42, 0.95);
  border: 1px solid rgba(100, 160, 255, 0.2);
  border-radius: 12px;
  padding: 40px 48px;
  width: 460px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.menu-panel h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(90deg, #6eb5ff, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: #8899b0;
  font-size: 14px;
  margin-bottom: 28px;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: #a0aec0;
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 10px 14px;
  background: #0d1520;
  border: 1px solid #2a3a52;
  border-radius: 6px;
  color: #e8ecf4;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: #6eb5ff;
}

.form-group small {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: #667788;
}

.appearance-group {
  margin-bottom: 22px;
}

.appearance-preview {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
  padding: 16px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  border: 1px solid #2a3a52;
}

.preview-avatar {
  position: relative;
  width: 72px;
  height: 96px;
}

.preview-body {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 52px;
  height: 58px;
  border-radius: 26px 26px 10px 10px;
  background: #6eb5ff;
  transition: background 0.2s;
}

.preview-head {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #ffdbac;
}

.preview-face {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 22px;
  line-height: 1;
  pointer-events: none;
  user-select: none;
}

.appearance-row {
  margin-top: 12px;
}

.sub-label {
  display: block;
  font-size: 12px;
  color: #8899b0;
  margin-bottom: 8px;
}

.color-picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

#playerColor {
  width: 44px;
  height: 36px;
  padding: 2px;
  border: 1px solid #2a3a52;
  border-radius: 6px;
  background: #0d1520;
  cursor: pointer;
  flex-shrink: 0;
}

.color-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}

.color-swatch:hover {
  transform: scale(1.1);
}

.color-swatch.active {
  border-color: #e8ecf4;
  box-shadow: 0 0 0 2px rgba(110, 181, 255, 0.5);
}

.face-presets {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.face-btn {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: #0d1520;
  border: 1px solid #2a3a52;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
  padding: 0;
}

.face-btn:hover {
  border-color: #6eb5ff;
  transform: translateY(-1px);
}

.face-btn.active {
  border-color: #6eb5ff;
  background: rgba(110, 181, 255, 0.15);
  box-shadow: 0 0 0 1px rgba(110, 181, 255, 0.3);
}

.setting-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  color: #c8d4e4;
  user-select: none;
}

.setting-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #6eb5ff;
  cursor: pointer;
}

.setting-range {
  margin-top: 12px;
}

.setting-range-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 14px;
  color: #c8d4e4;
}

.setting-range-value {
  color: #6eb5ff;
  font-variant-numeric: tabular-nums;
}

.setting-range input[type="range"] {
  width: 100%;
  height: 6px;
  accent-color: #6eb5ff;
  cursor: pointer;
}

#pauseOverlay .setting-range {
  margin-top: 0;
}

#pauseOverlay .setting-range-header {
  color: #c8d4e4;
}

.weapon-presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.weapon-btn {
  padding: 12px 10px;
  background: #0d1520;
  border: 1px solid #2a3a52;
  border-radius: 8px;
  color: #c8d4e4;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}

.weapon-btn:hover {
  border-color: #6eb5ff;
}

.weapon-btn.active {
  border-color: #6eb5ff;
  background: rgba(110, 181, 255, 0.12);
}

.weapon-btn-title {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #e8ecf4;
  margin-bottom: 4px;
}

.weapon-btn-desc {
  display: block;
  font-size: 11px;
  color: #8899b0;
  line-height: 1.4;
}

.death-weapon-pick {
  margin-top: 20px;
}

.death-weapon-pick .weapon-presets {
  max-width: 360px;
  margin: 10px auto 0;
}

.scope-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  --scope-radius: 44vmin;
  background: radial-gradient(
    circle at center,
    transparent var(--scope-radius),
    #000 var(--scope-radius)
  );
  box-shadow: inset 0 0 0 2px #000;
}

.scope-overlay::before,
.scope-overlay::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  background: #000;
}

.scope-overlay::before {
  width: 2px;
  height: calc(var(--scope-radius) * 2);
  margin: calc(var(--scope-radius) * -1) 0 0 -1px;
}

.scope-overlay::after {
  width: calc(var(--scope-radius) * 2);
  height: 2px;
  margin: -1px 0 0 calc(var(--scope-radius) * -1);
}

.crosshair.sniper-crosshair {
  width: 20px;
  height: 20px;
  background: transparent;
  border: none;
  box-shadow: none;
}

.crosshair.sniper-crosshair::before,
.crosshair.sniper-crosshair::after {
  content: '';
  position: absolute;
  background: rgba(255, 255, 255, 0.85);
}

.crosshair.sniper-crosshair::before {
  left: 50%;
  top: 2px;
  width: 1px;
  height: 16px;
  margin-left: -0.5px;
}

.crosshair.sniper-crosshair::after {
  top: 50%;
  left: 2px;
  width: 16px;
  height: 1px;
  margin-top: -0.5px;
}

.kill-weapon-tag {
  color: #93c5fd;
  font-weight: 600;
  margin-right: 6px;
}

#joinBtn {
  width: 100%;
  padding: 14px;
  margin-top: 8px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

#joinBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.server-info {
  margin-top: 20px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 6px;
  font-size: 12px;
  color: #8899b0;
  line-height: 1.6;
}

/* HUD */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.damage-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 12;
  opacity: 0;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(200, 20, 20, 0.55) 75%, rgba(140, 0, 0, 0.85) 100%);
  transition: opacity 0.08s ease-out;
}

.damage-vignette.active {
  opacity: 1;
}

.damage-vignette.hidden {
  display: none;
}

.crosshair-wrap {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 52px;
  height: 52px;
}

.reload-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.reload-ring.hidden {
  display: none;
}

.reload-ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.2);
  stroke-width: 3;
}

.reload-ring-progress {
  fill: none;
  stroke: #fbbf24;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 125.66;
  stroke-dashoffset: 125.66;
}

.crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
}

.crosshair::before,
.crosshair::after {
  content: '';
  position: absolute;
  background: rgba(255, 255, 255, 0.85);
}

.crosshair::before {
  width: 2px;
  height: 20px;
  left: 9px;
  top: 0;
}

.crosshair::after {
  width: 20px;
  height: 2px;
  left: 0;
  top: 9px;
}

.hud-top {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

#healthBar {
  position: relative;
  width: 200px;
  height: 24px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  overflow: hidden;
}

#healthFill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #22c55e, #16a34a);
  transition: width 0.2s;
}

#healthText {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

#scoreboard {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 10px 14px;
  min-width: 180px;
  font-size: 13px;
}

#scoreboard .score-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  gap: 16px;
}

#scoreboard .score-row.me {
  color: #6eb5ff;
  font-weight: 600;
}

#killFeed {
  position: absolute;
  top: 60px;
  right: 16px;
  text-align: right;
}

.kill-msg {
  background: rgba(0, 0, 0, 0.5);
  padding: 6px 12px;
  border-radius: 4px;
  margin-bottom: 4px;
  font-size: 12px;
  animation: fadeOut 4s forwards;
}

.kill-msg-headshot {
  background: rgba(60, 20, 20, 0.65);
  border-right: 3px solid #f87171;
}

.headshot-tag {
  color: #fbbf24;
  font-weight: 700;
  margin-right: 6px;
}

@keyframes fadeOut {
  0%, 70% { opacity: 1; }
  100% { opacity: 0; }
}

.hud-bottom {
  position: absolute;
  bottom: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}

#ammoInfo {
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

#ammoInfo.reloading {
  color: #fbbf24;
}

#ammoInfo.empty {
  color: #f87171;
}

#deathOverlay {
  position: absolute;
  inset: 0;
  background: rgba(120, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  cursor: default;
  z-index: 30;
}

#deathOverlay p {
  font-size: 32px;
  font-weight: 700;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

.respawn-hint {
  font-size: 16px !important;
  margin-top: 12px;
  color: #ccc;
}

#pauseOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  cursor: pointer;
}

.pause-panel {
  cursor: default;
  background: rgba(20, 28, 42, 0.96);
  border: 1px solid rgba(100, 160, 255, 0.2);
  border-radius: 12px;
  padding: 28px 32px 24px;
  width: min(400px, 92vw);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.pause-title {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  background: linear-gradient(90deg, #6eb5ff, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.pause-hint {
  font-size: 13px;
  color: #8899b0;
  text-align: center;
  line-height: 1.5;
}

.pause-settings {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 4px;
  border-top: 1px solid rgba(100, 160, 255, 0.12);
}

.pause-resume-btn {
  width: 100%;
  padding: 12px;
  margin-top: 4px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.pause-resume-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

canvas {
  display: block;
}
