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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #000;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: #fff;
  user-select: none;
}

#game { display: block; width: 100vw; height: 100vh; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }

/* 准星：四条短线，间距 --gap 随散布变化 */
#crosshair { --gap: 6px; position: absolute; left: 50%; top: 50%; }
#crosshair i {
  position: absolute; background: #3f6; box-shadow: 0 0 2px #000;
}
#crosshair .ch-top,
#crosshair .ch-bottom { width: 2px; height: 8px; left: -1px; }
#crosshair .ch-left,
#crosshair .ch-right  { width: 8px; height: 2px; top: -1px; }
#crosshair .ch-top    { bottom: var(--gap); }
#crosshair .ch-bottom { top: var(--gap); }
#crosshair .ch-left   { right: var(--gap); }
#crosshair .ch-right  { left: var(--gap); }

/* 命中标记：打中时在准星处闪一个 X */
#hitmarker {
  position: absolute; left: 50%; top: 50%;
  width: 22px; height: 22px; margin: -11px 0 0 -11px;
  opacity: 0;
}
#hitmarker::before, #hitmarker::after {
  content: ""; position: absolute; left: 50%; top: 0;
  width: 2px; height: 100%; margin-left: -1px;
  background: #fff; box-shadow: 0 0 2px #000;
}
#hitmarker::before { transform: rotate(45deg); }
#hitmarker::after  { transform: rotate(-45deg); }
#hitmarker.head::before, #hitmarker.head::after { background: #f33; }
#hitmarker.kill { width: 34px; height: 34px; margin: -17px 0 0 -17px; }
#hitmarker.kill::before, #hitmarker.kill::after { width: 3px; margin-left: -1.5px; }

#reload-tip {
  position: absolute; left: 50%; top: calc(50% + 40px);
  transform: translateX(-50%);
  font-size: 14px; color: #fc3; text-shadow: 0 0 3px #000;
  display: none;
}

#stats {
  position: absolute; left: 16px; top: 16px;
  padding: 10px 14px; border-radius: 6px;
  background: rgba(0, 0, 0, .45);
  font-size: 14px; line-height: 1.7;
}
#stats b { display: inline-block; min-width: 44px; text-align: right; color: #fc3; }

#ammo {
  position: absolute; right: 24px; bottom: 20px;
  font-size: 44px; font-weight: bold; text-shadow: 0 0 4px #000;
}
#ammo.low #ammo-cur { color: #f44; }
#ammo-max { font-size: 22px; margin-left: 6px; opacity: .7; }

#hint {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  font-size: 13px; opacity: .6; text-shadow: 0 0 3px #000;
}

/* ---------- 开始 / 暂停 ---------- */
#overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 14, 20, .72);
}
#overlay.hidden { display: none; }
.panel {
  width: 340px; padding: 28px 32px; border-radius: 10px;
  background: rgba(20, 26, 34, .95); border: 1px solid #334;
  text-align: center;
}
.panel h1 { font-size: 32px; letter-spacing: 4px; }
.panel h1 small { font-size: 14px; opacity: .6; letter-spacing: 0; }
.panel p { margin: 6px 0 18px; opacity: .7; }
.keys-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12px; opacity: .6; margin-bottom: 4px; padding: 0 2px;
}
.keys-head a { color: #9cf; text-decoration: none; }
.keys-head a:hover { text-decoration: underline; }
.keys { width: 100%; border-collapse: collapse; margin-bottom: 18px; font-size: 13px; }
.keys tr { display: flex; align-items: center; }
.keys td { padding: 1px 2px; text-align: left; }
.keys td:first-child { flex: 1; }
.keys td:last-child { width: 46%; text-align: right; }
.keys .key {
  display: inline-block; min-width: 88px; padding: 2px 10px; border-radius: 4px;
  background: #2a3240; border: 1px solid #3c4858; color: #fc3; font-size: 13px;
  cursor: pointer; text-align: center;
}
.keys .key:hover { background: #344056; }
.keys .key.waiting { color: #fff; background: #3a7; border-color: #4b8; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .55; } }
.panel button {
  width: 100%; padding: 12px; border: 0; border-radius: 6px;
  background: #3a7; color: #fff; font-size: 17px; cursor: pointer;
}
.panel button:hover { background: #4b8; }
#btn-resume { margin-bottom: 10px; background: #357; }
#btn-resume:hover { background: #468; }
.mode-btns { display: flex; gap: 8px; }
.mode-btns button { padding: 12px 6px; font-size: 16px; }
#btn-duel { background: #a43; }
#btn-duel:hover { background: #b54; }
#btn-waves { background: #864; }
#btn-waves:hover { background: #975; }
.panel button:disabled { opacity: .45; cursor: default; }
#loading { margin-top: 12px; font-size: 13px; opacity: .7; display: none; }
#wave-info b.me { color: #6f6; }
#wave-info b.enemy { color: #f66; }
#overlay-result {
  margin: -6px 0 18px; padding: 10px; border-radius: 6px;
  background: rgba(170, 50, 40, .25); line-height: 1.8;
}
#overlay-result b { color: #fc3; }

#stats .battle-only { display: none; }
#stats.battle .battle-only { display: block; }

/* ---------- 对战模式 ---------- */
#health {
  position: absolute; left: 24px; bottom: 22px; width: 200px;
  text-shadow: 0 0 4px #000; display: none;
}
#health .label { font-size: 14px; opacity: .75; margin-right: 8px; }
#health-val { font-size: 36px; font-weight: bold; }
#health .bar { height: 6px; margin-top: 4px; background: rgba(0,0,0,.45); border-radius: 3px; overflow: hidden; }
#health-bar { display: block; height: 100%; width: 100%; background: #4c6; transition: width .15s; }
#health.low #health-val { color: #f44; }
#health.low #health-bar { background: #e33; }

/* 受伤时屏幕边缘泛红 */
#damage-flash {
  position: absolute; inset: 0; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(200, 0, 0, .75) 100%);
}

/* 受击方向：围绕准星旋转的红色弧 */
#damage-dir {
  position: absolute; left: 50%; top: 50%; width: 0; height: 0; opacity: 0;
}
#damage-dir i {
  position: absolute; left: -60px; top: -130px; width: 120px; height: 40px;
  border-top: 6px solid rgba(255, 40, 30, .9); border-radius: 50% 50% 0 0;
  filter: drop-shadow(0 0 3px #000);
}

#wave-info {
  position: absolute; left: 50%; top: 16px; transform: translateX(-50%);
  padding: 6px 16px; border-radius: 6px; background: rgba(0, 0, 0, .45);
  font-size: 15px; display: none;
}
#banner {
  position: absolute; left: 0; right: 0; top: 24%;
  text-align: center; font-size: 40px; font-weight: bold; letter-spacing: 4px;
  text-shadow: 0 0 8px #000; opacity: 0;
}
