/* =========================================================
 * 星际狙击 · 外星入侵防御
 * 深空战术 HUD 视觉
 * ========================================================= */

:root {
  --bg: #070b14;
  --bg-panel: #0c1424;
  --line: #1b2a44;
  --text: #c8d6e8;
  --text-dim: #7489a8;
  --cyan: #39e6b0;      /* 主题强调：外星能量 / 主 HUD */
  --orange: #ffb454;    /* 命中 / 弹药 */
  --red: #ff4d5e;       /* 危险 / 失守 */
  --blue: #5b8cff;      /* 友军 / 联机队友 */
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: "JetBrains Mono", "Consolas", "Courier New", ui-monospace, monospace;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ===== 画布 ===== */
#game {
  display: block;
  width: 100%;
  height: 100%;
  cursor: none;               /* 用游戏内的战术瞄准镜替代系统鼠标 */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ===== HUD ===== */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.hud-topleft {
  position: absolute;
  top: 16px;
  left: 18px;
  display: flex;
  gap: 10px;
}

.hud-cell {
  min-width: 84px;
  padding: 8px 12px 9px;
  background: rgba(10, 18, 34, 0.72);
  border: 1px solid var(--line);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  backdrop-filter: blur(2px);
}

.hud-label {
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.hud-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.hud-topright {
  position: absolute;
  top: 16px;
  right: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

.hud-mode {
  font-size: 13px;
  letter-spacing: 0.14em;
  color: var(--cyan);
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(10, 18, 34, 0.72);
}

.hud-btn {
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: rgba(10, 18, 34, 0.72);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 7px 14px;
  cursor: pointer;
  letter-spacing: 0.08em;
  transition: border-color 0.15s, color 0.15s;
}

.hud-btn:hover { border-color: var(--cyan); color: var(--cyan); }
.hud-btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.hud-alert {
  position: absolute;
  top: 96px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 17px;
  letter-spacing: 0.3em;
  color: var(--red);
  opacity: 0;
  transition: opacity 0.25s;
  text-shadow: 0 0 14px rgba(255, 77, 94, 0.6);
  white-space: nowrap;
}

.hud-alert.on { opacity: 1; }

/* ===== 联机排行榜 ===== */
#scoreboard {
  position: fixed;
  top: 86px;
  right: 18px;
  width: 210px;
  z-index: 10;
  pointer-events: none;
}

.sb-title {
  font-size: 11px;
  letter-spacing: 0.24em;
  color: var(--text-dim);
  margin-bottom: 6px;
}

#sb-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#sb-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 6px 10px;
  background: rgba(10, 18, 34, 0.72);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
}

#sb-list .rank { color: var(--text-dim); width: 18px; text-align: right; }
#sb-list .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#sb-list .sc   { color: var(--cyan); font-weight: 700; }
#sb-list li.me { border-color: var(--blue); }
#sb-list li.me .name { color: var(--blue); }

/* ===== 覆盖面板（菜单 / 结束 / 暂停）===== */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(7, 11, 20, 0.82) 0%, rgba(7, 11, 20, 0.94) 100%);
  cursor: auto;
}

.panel {
  width: min(440px, 92vw);
  padding: 34px 38px 30px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  text-align: center;
}

.game-title {
  font-size: 42px;
  letter-spacing: 0.08em;
  font-weight: 900;
  color: var(--text);
}

.game-title span { color: var(--cyan); }

.game-sub {
  margin: 6px 0 26px;
  font-size: 12px;
  letter-spacing: 0.34em;
  color: var(--text-dim);
}

.go-title {
  font-size: 30px;
  letter-spacing: 0.14em;
  font-weight: 900;
  margin-bottom: 22px;
  color: var(--red);
}

.field {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  margin-bottom: 18px;
}

.field label {
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--text-dim);
}

.field input {
  width: 100%;
  padding: 11px 14px;
  font-family: inherit;
  font-size: 16px;
  color: var(--text);
  background: rgba(4, 8, 16, 0.6);
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  transition: border-color 0.15s;
}

.field input:focus { border-color: var(--cyan); }
.field input::placeholder { color: rgba(116, 137, 168, 0.55); }

.btn-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 4px 0 6px;
}

.btn {
  font-family: inherit;
  font-size: 16px;
  letter-spacing: 0.18em;
  padding: 13px 16px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.08s, filter 0.15s, border-color 0.15s;
}

.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.btn-primary {
  background: var(--cyan);
  color: #06231a;
  font-weight: 700;
}

.btn-primary:hover { filter: brightness(1.08); }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}

.btn-ghost:hover { border-color: var(--cyan); color: var(--cyan); }

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.net-status {
  min-height: 20px;
  margin-top: 4px;
  font-size: 13px;
  color: var(--orange);
  letter-spacing: 0.06em;
}

.net-status.ok  { color: var(--cyan); }
.net-status.err { color: var(--red); }

.tip {
  margin-top: 18px;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  line-height: 1.7;
}

/* ===== 结束统计 ===== */
.go-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.go-cell {
  padding: 12px;
  background: rgba(4, 8, 16, 0.55);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.go-rank {
  margin-bottom: 16px;
  padding: 12px 14px;
  background: rgba(4, 8, 16, 0.55);
  border: 1px solid var(--line);
  border-radius: 6px;
  text-align: left;
}

.go-rank h3 {
  font-size: 12px;
  letter-spacing: 0.22em;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.go-rank ol {
  list-style: none;
  counter-reset: rk;
}

.go-rank li {
  counter-increment: rk;
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  border-bottom: 1px dashed rgba(27, 42, 68, 0.7);
}

.go-rank li:last-child { border-bottom: none; }

.go-rank li::before {
  content: counter(rk) ".";
  width: 28px;
  color: var(--text-dim);
}

.go-rank li.me { color: var(--cyan); font-weight: 700; }

/* 移动端适配 */
@media (max-width: 640px) {
  .hud-topleft { top: 10px; left: 10px; gap: 6px; }
  .hud-cell { min-width: 62px; padding: 6px 8px; }
  .hud-value { font-size: 16px; }
  .hud-topright { top: 10px; right: 10px; }
  #scoreboard { top: 72px; right: 10px; width: 170px; }
  .panel { padding: 26px 22px 24px; }
  .game-title { font-size: 34px; }
}
