/* ===========================================================
   末日之战 · 黑暗森林  —  HUD / 遮罩 / 控件样式
   =========================================================== */
:root {
  --cyan: #7fe6ff;
  --cyan-dim: rgba(127, 230, 255, 0.42);
  --line: rgba(127, 230, 255, 0.16);
  --red: #ff6a4d;
  --ink: #dfeaf2;
  --panel: rgba(6, 12, 18, 0.55);
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%; width: 100%;
  background: #000; color: var(--ink);
  font-family: var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app { position: fixed; inset: 0; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#gl.dragging { cursor: grabbing; }

.hidden { display: none !important; }

/* ---------------- HUD ---------------- */
#hud {
  position: absolute; inset: 0; pointer-events: none;
  opacity: 0; transition: opacity 1.2s ease 0.2s;
  font-size: 13px;
}
#hud.on { opacity: 1; }
#hud .hud-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 22px 26px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0));
}
.brand-cn { font-size: 21px; letter-spacing: 0.42em; font-weight: 500; text-shadow: 0 0 18px rgba(127, 230, 255, 0.35); }
.brand-en { font-size: 9.5px; letter-spacing: 0.34em; color: var(--cyan-dim); margin-top: 5px; }
.brand-src { font-size: 10.5px; letter-spacing: 0.16em; color: rgba(223, 234, 242, 0.42); margin-top: 3px; }

.tele { text-align: right; font-family: var(--mono); min-width: 190px; }
.tele-row { display: flex; justify-content: space-between; gap: 18px; line-height: 1.72; font-size: 11.5px; }
.tele-row .k { color: rgba(223, 234, 242, 0.45); letter-spacing: 0.1em; }
.tele-row .v { color: var(--cyan); font-variant-numeric: tabular-nums; }
.tele-row.danger .v { color: var(--red); }

.hud-act {
  position: absolute; left: 26px; bottom: 150px;
  font-size: 11px; letter-spacing: 0.28em; color: rgba(223, 234, 242, 0.5);
  display: flex; align-items: center; gap: 10px;
}
.hud-act i { display: block; width: 42px; height: 1px; background: var(--cyan-dim); }

.sub-wrap {
  position: absolute; left: 0; right: 0; bottom: 120px;
  display: flex; justify-content: center; padding: 0 8vw; text-align: center;
}
.subtitle {
  font-family: var(--serif);
  font-size: clamp(15px, 2.05vw, 27px);
  line-height: 1.72; letter-spacing: 0.08em;
  color: rgba(240, 246, 250, 0.95);
  text-shadow: 0 2px 26px rgba(0, 0, 0, 0.95), 0 0 60px rgba(0, 0, 0, 0.8);
  opacity: 0; transition: opacity 0.85s ease;
  max-width: 1100px;
}
.subtitle.on { opacity: 1; }

.hud-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  pointer-events: auto;
  padding: 12px 26px 16px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.28) 62%, rgba(0, 0, 0, 0));
  transition: opacity 0.35s ease, transform 0.35s ease;
}
#hud.barhide .hud-bar { opacity: 0; transform: translateY(14px); pointer-events: none; }

.scrub-row { display: flex; align-items: center; gap: 12px; }
.scrub { flex: 1; position: relative; height: 18px; display: flex; align-items: center; }
.t { font-family: var(--mono); font-size: 11px; color: rgba(223, 234, 242, 0.55); min-width: 46px; font-variant-numeric: tabular-nums; }
.t:last-child { text-align: right; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 3px; background: rgba(223, 234, 242, 0.18);
  outline: none; border-radius: 2px; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--cyan); box-shadow: 0 0 12px rgba(127, 230, 255, 0.85); cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 11px; height: 11px; border: 0; border-radius: 50%;
  background: var(--cyan); box-shadow: 0 0 12px rgba(127, 230, 255, 0.85); cursor: pointer;
}

.btn-row { display: flex; align-items: center; gap: 8px; margin-top: 9px; flex-wrap: wrap; }
.spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; font-size: 12px; font-family: var(--sans); letter-spacing: 0.06em;
  color: rgba(223, 234, 242, 0.86);
  background: rgba(12, 22, 30, 0.62);
  border: 1px solid var(--line); border-radius: 3px;
  cursor: pointer; transition: all 0.18s ease; white-space: nowrap;
  backdrop-filter: blur(6px);
}
.btn:hover { border-color: var(--cyan-dim); color: #fff; background: rgba(20, 38, 50, 0.75); }
.btn:active { transform: translateY(1px); }
.btn.on { border-color: var(--cyan-dim); color: #fff; box-shadow: inset 0 0 18px rgba(127, 230, 255, 0.13); }
.btn.primary { background: rgba(127, 230, 255, 0.14); border-color: rgba(127, 230, 255, 0.45); color: #fff; }
.ic { width: 13px; height: 13px; fill: currentColor; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; backdrop-filter: blur(6px); }
.seg .s {
  padding: 7px 10px; font-size: 11.5px; font-family: var(--mono);
  background: rgba(12, 22, 30, 0.62); color: rgba(223, 234, 242, 0.66);
  border: 0; border-right: 1px solid var(--line); cursor: pointer; transition: all 0.16s ease;
}
.seg .s:last-child { border-right: 0; }
.seg .s:hover { color: #fff; background: rgba(24, 44, 58, 0.8); }
.seg .s.on { background: rgba(127, 230, 255, 0.18); color: #fff; }

.hud-fps {
  position: absolute; right: 26px; bottom: 108px;
  font-family: var(--mono); font-size: 10.5px; color: rgba(223, 234, 242, 0.34);
  letter-spacing: 0.08em;
}

.toast {
  position: absolute; left: 50%; top: 76px; transform: translate(-50%, -8px);
  padding: 8px 18px; font-size: 12.5px; letter-spacing: 0.14em;
  background: rgba(6, 12, 18, 0.82); border: 1px solid var(--line); border-radius: 3px;
  color: var(--cyan); opacity: 0; transition: all 0.4s ease; backdrop-filter: blur(8px);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 遮罩层 ---------------- */
.overlay {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 45%, rgba(8, 14, 22, 0.72), rgba(0, 0, 0, 0.94));
  backdrop-filter: blur(3px);
  transition: opacity 0.9s ease;
}
.overlay.fade { opacity: 0; pointer-events: none; }

.intro-inner { text-align: center; padding: 5vh 8vw; max-width: 900px; animation: fadeUp 1.4s ease both; }
.intro-kicker { font-size: 11.5px; letter-spacing: 0.34em; color: var(--cyan-dim); margin-bottom: 26px; }
.intro-title {
  font-family: var(--serif); font-size: clamp(38px, 7vw, 82px); font-weight: 500;
  letter-spacing: 0.2em; margin: 0 0 6px; color: #f2f8fb;
  text-shadow: 0 0 70px rgba(127, 230, 255, 0.34);
}
.intro-sub { font-size: 12.5px; letter-spacing: 0.42em; color: rgba(223, 234, 242, 0.5); margin-bottom: 40px; }
.intro-epi { font-family: var(--serif); font-size: 15.5px; line-height: 2; color: rgba(223, 234, 242, 0.72); letter-spacing: 0.1em; }
.intro-epi em { font-size: 12px; color: rgba(223, 234, 242, 0.38); font-style: normal; letter-spacing: 0.2em; }
.intro-facts { display: flex; justify-content: center; gap: 52px; margin: 44px 0 40px; flex-wrap: wrap; }
.intro-facts > div { display: flex; flex-direction: column; gap: 7px; }
.intro-facts b { font-family: var(--mono); font-size: 27px; color: var(--cyan); font-weight: 500; text-shadow: 0 0 24px rgba(127, 230, 255, 0.5); }
.intro-facts span { font-size: 11px; letter-spacing: 0.16em; color: rgba(223, 234, 242, 0.45); }
.btn.start {
  padding: 13px 52px; font-size: 14.5px; letter-spacing: 0.4em; text-indent: 0.4em;
  background: rgba(127, 230, 255, 0.1); border-color: rgba(127, 230, 255, 0.42); color: #fff;
}
.btn.start:hover { background: rgba(127, 230, 255, 0.22); box-shadow: 0 0 42px rgba(127, 230, 255, 0.24); }
.intro-tip { margin-top: 30px; font-size: 11px; letter-spacing: 0.12em; color: rgba(223, 234, 242, 0.3); }

.end-inner { text-align: center; padding: 5vh 7vw; max-width: 860px; animation: fadeUp 1.2s ease both; }
.end-title { font-family: var(--serif); font-size: clamp(26px, 4vw, 44px); letter-spacing: 0.28em; margin-bottom: 44px; color: #eef5f9; }
.end-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.end-cell { display: flex; justify-content: space-between; align-items: baseline; padding: 15px 22px; background: rgba(6, 12, 18, 0.86); }
.end-cell.wide { grid-column: 1 / -1; }
.end-cell .k { font-size: 12px; letter-spacing: 0.16em; color: rgba(223, 234, 242, 0.5); }
.end-cell .v { font-family: var(--mono); font-size: 18px; color: var(--cyan); }
.end-cell.bad .v { color: var(--red); }
.end-quote { font-family: var(--serif); margin: 40px 0 36px; font-size: 16px; letter-spacing: 0.14em; color: rgba(223, 234, 242, 0.74); line-height: 2; }

.load-inner { text-align: center; font-size: 12.5px; letter-spacing: 0.28em; color: rgba(223, 234, 242, 0.6); }
.load-ring {
  width: 42px; height: 42px; margin: 0 auto 26px;
  border: 1px solid rgba(127, 230, 255, 0.18); border-top-color: var(--cyan);
  border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.errlog {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 42vh; overflow: auto; z-index: 60;
  margin: 0; padding: 14px 18px; display: none;
  background: rgba(40, 0, 0, 0.9); color: #ffb4a6; font-family: var(--mono); font-size: 11.5px;
  white-space: pre-wrap; border-top: 1px solid rgba(255, 106, 77, 0.4);
}

/* 全屏时收窄 HUD */
body.fs .hud-bar { padding-bottom: 22px; }

@media (max-width: 720px) {
  .tele { display: none; }
  .hud-top { padding: 14px 16px; }
  .hud-bar { padding: 10px 14px 12px; }
  .hud-fps { display: none; }
  .btn span { display: none; }
  .btn { padding: 8px 10px; }
  .seg .s { padding: 8px 7px; font-size: 10.5px; }
  .sub-wrap { bottom: 146px; }
  .hud-act { bottom: 176px; left: 16px; }
}
