/* ==========================================================================
   警笛头 · 黑暗森林 — 样式表
   风格：黑暗、低饱和度、CRT 档案感
   ========================================================================== */

:root {
  --bg: #05070a;
  --panel: rgba(8, 11, 14, 0.72);
  --panel-solid: #0a0e13;
  --line: rgba(150, 170, 180, 0.18);
  --text: #cfd8dc;
  --text-dim: #7d8a92;
  --accent: #b91c1c;
  --accent-soft: #e05252;
  --warn: #d9a441;
  --ok: #4b9e6a;
  --font: "Consolas", "SFMono-Regular", "Menlo", "Courier New", "Microsoft YaHei", monospace;
}

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

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

#app { position: fixed; inset: 0; }

#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }

/* ---------------------------------------------------------------- 覆盖层 */
.overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(30, 12, 12, 0.55) 0%, rgba(2, 3, 5, 0.97) 70%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.014) 0 1px, transparent 1px 3px);
  z-index: 30;
  animation: fadeIn .45s ease both;
}

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

.menu-box {
  width: min(620px, 92vw);
  max-height: 94vh;
  overflow-y: auto;
  padding: 34px 38px 26px;
  background: linear-gradient(180deg, rgba(12,15,19,.94), rgba(6,8,10,.96));
  border: 1px solid var(--line);
  box-shadow: 0 0 0 1px rgba(0,0,0,.6), 0 30px 80px rgba(0,0,0,.8), inset 0 0 60px rgba(120,20,20,.06);
  position: relative;
}
.menu-box::-webkit-scrollbar { width: 6px; }
.menu-box::-webkit-scrollbar-thumb { background: rgba(150,170,180,.2); }

.menu-kicker {
  font-size: 11px; letter-spacing: .32em; color: var(--accent-soft);
  text-transform: uppercase; margin-bottom: 10px; opacity: .85;
}

.menu-title {
  font-size: 46px; letter-spacing: .16em; font-weight: 700;
  color: #e8eef1; line-height: 1.05;
  text-shadow: 0 0 24px rgba(185,28,28,.35), 0 0 2px rgba(255,255,255,.3);
}
.menu-title.small { font-size: 26px; letter-spacing: .12em; margin-bottom: 18px; }

.menu-sub {
  font-size: 12px; letter-spacing: .3em; color: var(--text-dim);
  margin: 8px 0 20px;
}

.menu-brief {
  font-size: 13px; line-height: 1.85; color: #9aa7ae;
  border-left: 2px solid rgba(185,28,28,.5);
  padding-left: 14px; margin-bottom: 22px;
}
.menu-brief b { color: #d7dee2; }

/* ---------------------------------------------------------------- 表单 */
.field { display: block; margin-bottom: 14px; }
.field span {
  display: block; font-size: 11px; letter-spacing: .2em;
  color: var(--text-dim); margin-bottom: 6px;
}
.field input {
  width: 100%; padding: 11px 13px;
  background: rgba(0,0,0,.55);
  border: 1px solid var(--line);
  color: var(--text); font-family: var(--font); font-size: 14px;
  letter-spacing: .12em; outline: none; transition: border-color .2s, box-shadow .2s;
}
.field input:focus { border-color: rgba(185,28,28,.7); box-shadow: 0 0 0 1px rgba(185,28,28,.25); }

.menu-actions { display: flex; gap: 10px; }
.menu-actions .btn { flex: 1; }

.btn {
  display: inline-block; width: 100%;
  padding: 12px 16px; margin-bottom: 10px;
  background: rgba(28,33,38,.9);
  border: 1px solid var(--line);
  color: var(--text); font-family: var(--font); font-size: 13px;
  letter-spacing: .16em; cursor: pointer;
  transition: background .18s, border-color .18s, color .18s, transform .08s;
}
.btn:hover { background: rgba(44,52,58,.95); border-color: rgba(180,200,210,.35); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, rgba(150,26,26,.9), rgba(110,16,16,.9));
  border-color: rgba(220,80,80,.5); color: #f4e9e9; font-weight: 700;
}
.btn.primary:hover { background: linear-gradient(180deg, rgba(180,32,32,.95), rgba(130,20,20,.95)); }
.btn.ghost { background: rgba(0,0,0,.35); color: var(--text-dim); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.divider {
  display: flex; align-items: center; gap: 12px;
  margin: 18px 0 16px; font-size: 11px; letter-spacing: .18em; color: var(--text-dim);
}
.divider::before, .divider::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}

.mini {
  background: transparent; border: 1px solid var(--line); color: var(--text-dim);
  font-family: var(--font); font-size: 10px; padding: 2px 8px;
  cursor: pointer; margin-left: 8px; letter-spacing: .1em;
}
.mini:hover { color: var(--text); border-color: rgba(180,200,210,.4); }

/* ---------------------------------------------------------------- 大厅 */
.room-info {
  margin-top: 18px; padding: 16px;
  border: 1px dashed rgba(185,28,28,.35);
  background: rgba(0,0,0,.35);
}
.room-line { font-size: 13px; letter-spacing: .1em; margin-bottom: 12px; }
.room-line strong { color: var(--accent-soft); letter-spacing: .28em; font-size: 16px; }

.lobby-players {
  list-style: none; margin-bottom: 14px; font-size: 12px; color: var(--text-dim);
  max-height: 120px; overflow-y: auto;
}
.lobby-players li { padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,.04); }
.lobby-players li::before { content: "▸ "; color: var(--accent-soft); }

/* ---------------------------------------------------------------- 加载条 */
.loading-box { margin-top: 20px; }
.loading-box .bar { height: 4px; }
#load-text { font-size: 11px; letter-spacing: .16em; color: var(--text-dim); margin-top: 8px; }

.menu-footer {
  margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line);
  font-size: 10.5px; color: #5d686e; letter-spacing: .06em; line-height: 1.8;
}
.link {
  background: none; border: none; color: var(--text-dim);
  font-family: var(--font); font-size: 10.5px; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; padding: 0;
}
.link:hover { color: var(--accent-soft); }
.dot { margin: 0 6px; }

.credits-list {
  max-height: 46vh; overflow-y: auto; font-size: 11.5px; line-height: 1.9;
  color: #8e9aa1; margin-bottom: 20px; border-left: 2px solid var(--line); padding-left: 14px;
}
.credits-list b { color: #c6ced3; }
.credits-list .cred { margin-bottom: 9px; }

/* ================================================================ HUD */
#hud { position: absolute; inset: 0; z-index: 20; pointer-events: none; }

#vignette {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 32%, rgba(0,0,0,.55) 78%, rgba(0,0,0,.9) 100%);
}
#heartbeat-overlay {
  position: absolute; inset: 0; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(120,0,0,.45) 100%);
  transition: opacity .18s linear;
}
#damage-flash {
  position: absolute; inset: 0; opacity: 0; background: rgba(150,0,0,.75);
  transition: opacity .5s ease-out;
}
#crosshair {
  position: absolute; left: 50%; top: 50%; width: 3px; height: 3px;
  margin: -1.5px 0 0 -1.5px; border-radius: 50%;
  background: rgba(220,230,235,.55); box-shadow: 0 0 6px rgba(0,0,0,.9);
}

.hud-panel {
  position: absolute; padding: 12px 14px;
  background: var(--panel); border: 1px solid var(--line);
  backdrop-filter: blur(3px); font-size: 12px; letter-spacing: .06em;
  min-width: 190px;
}
#objective-panel { top: 16px; left: 16px; }
#vitals-panel { bottom: 16px; left: 16px; width: 216px; }
#team-panel { top: 16px; right: 16px; min-width: 180px; }

.hud-title {
  font-size: 10px; letter-spacing: .28em; color: var(--accent-soft);
  text-transform: uppercase; margin-bottom: 9px; opacity: .9;
}
.hud-row { display: flex; justify-content: space-between; gap: 14px; padding: 2.5px 0; color: #96a2a9; }
.hud-row span { color: #dde4e7; }
.hud-row.dim { color: #6b767d; font-size: 10.5px; margin-top: 6px; }
.hud-hint {
  margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--line);
  font-size: 10.5px; line-height: 1.7; color: #6f7a81;
}

.bar-label {
  display: flex; justify-content: space-between;
  font-size: 10px; letter-spacing: .16em; color: var(--text-dim); margin-bottom: 4px;
}
.bar { height: 6px; background: rgba(0,0,0,.6); border: 1px solid rgba(255,255,255,.07); overflow: hidden; }
.bar + .bar-label { margin-top: 9px; }
.bar-fill { height: 100%; width: 100%; transition: width .12s linear, background .3s; }
.bar-fill.stamina { background: linear-gradient(90deg, #3d7f5e, #63b98a); }
.bar-fill.stamina.low { background: linear-gradient(90deg, #8a5a1e, #d9a441); }
.bar-fill.battery { background: linear-gradient(90deg, #6d6220, #e2cf63); }
.bar-fill.battery.low { background: linear-gradient(90deg, #7a2020, #d84a4a); }
.bar-fill.repair { background: linear-gradient(90deg, #8a2020, #e05252); width: 0%; transition: width .08s linear; }
.bar-fill.load { background: linear-gradient(90deg, #4a2020, #b91c1c); width: 0%; transition: width .2s ease; }

#team-list { list-style: none; }
#team-list li {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 3px 0; font-size: 11.5px; color: #9aa6ad;
}
#team-list li.dead { color: #5a4a4a; text-decoration: line-through; }
#team-list li .status { font-size: 10px; letter-spacing: .08em; }
#team-list li .status.near { color: var(--warn); }
#team-list li .status.ok { color: var(--ok); }
#team-list li.me { color: #e2e9ec; }

/* ------------------------------------------------- 方向指示箭头（模糊） */
#sound-arrow {
  position: absolute; left: 50%; top: 50%;
  width: 260px; height: 260px; margin: -130px 0 0 -130px;
  transition: opacity .5s ease-out;
  filter: blur(1.4px);
}
#sound-arrow .arrow-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 1px solid rgba(200,60,60,.16);
}
#sound-arrow-inner {
  position: absolute; left: 50%; top: 8px; margin-left: -13px;
  font-size: 26px; color: rgba(224,82,82,.85);
  text-shadow: 0 0 14px rgba(224,82,82,.7);
  transform-origin: 50% 122px;
}
#sound-arrow-label {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  font-size: 10px; letter-spacing: .22em; color: rgba(224,82,82,.75);
  text-align: center; width: 200px; line-height: 1.6;
}

/* ---------------------------------------------------------------- 字幕 */
#subtitle {
  position: absolute; left: 50%; bottom: 108px; transform: translateX(-50%);
  max-width: 62vw; padding: 9px 18px;
  background: rgba(0,0,0,.6); border-left: 2px solid rgba(224,82,82,.7);
  font-size: 15px; letter-spacing: .1em; color: #e6dede;
  text-shadow: 0 0 10px rgba(0,0,0,.9); transition: opacity .6s;
  text-align: center;
}
#subtitle.whisper { border-left-color: rgba(120,120,140,.6); color: #b9c0c8; font-style: italic; }

#prompt {
  position: absolute; left: 50%; bottom: 62px; transform: translateX(-50%);
  padding: 8px 16px; background: rgba(0,0,0,.62);
  border: 1px solid var(--line);
  font-size: 13px; letter-spacing: .1em; color: #dfe6e9; white-space: nowrap;
}
#prompt b { color: var(--accent-soft); }

#repair-bar {
  position: absolute; left: 50%; bottom: 62px; transform: translateX(-50%);
  width: 300px; text-align: center;
}
#repair-label {
  font-size: 11px; letter-spacing: .22em; color: var(--accent-soft); margin-top: 7px;
  text-shadow: 0 0 10px rgba(0,0,0,.9);
}

#toast-area {
  position: absolute; left: 50%; top: 84px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 7px; width: 60vw;
  z-index: 46; pointer-events: none;
}
.toast {
  padding: 7px 16px; background: rgba(0,0,0,.82); border: 1px solid var(--line);
  font-size: 12px; letter-spacing: .1em; color: #d6dde1;
  animation: toastIn .3s ease both; max-width: 100%;
}
.toast.warn { border-color: rgba(217,164,65,.5); color: #e8cd8a; }
.toast.bad { border-color: rgba(185,28,28,.6); color: #ef9a9a; }
.toast.good { border-color: rgba(75,158,106,.55); color: #9fd8b5; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px) } to { opacity: 1; transform: none } }

#net-status {
  position: absolute; right: 16px; bottom: 16px;
  font-size: 10.5px; letter-spacing: .12em; color: #5f6a71; text-align: right;
  z-index: 46; pointer-events: none; max-width: 46vw; line-height: 1.7;
}
#net-status .bad { color: #d9776f; }
#net-status .good { color: #6aa583; }

/* ------------------------------------------------------- 菜单内的联机状态 */
.menu-status {
  margin: 4px 0 14px; padding: 11px 13px;
  background: rgba(0,0,0,.45); border: 1px solid var(--line);
  border-left: 2px solid rgba(185,28,28,.55);
}
.menu-status-line {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; letter-spacing: .08em; color: #cfd8dc;
}
.dot-indicator {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--warn); box-shadow: 0 0 8px rgba(217,164,65,.8);
  animation: pulse 1.1s ease-in-out infinite;
}
.menu-status.ok .dot-indicator { background: var(--ok); box-shadow: 0 0 8px rgba(75,158,106,.8); animation: none; }
.menu-status.err { border-left-color: var(--accent); }
.menu-status.err .dot-indicator { background: var(--accent-soft); box-shadow: 0 0 8px rgba(224,82,82,.9); animation: none; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .28 } }

.menu-log {
  list-style: none; margin: 9px 0 0; padding: 8px 0 0;
  border-top: 1px solid var(--line);
  font-size: 10.5px; line-height: 1.75; color: #6f7a81;
  max-height: 108px; overflow-y: auto;
}
.menu-log li { white-space: pre-wrap; word-break: break-all; }
.menu-log li::before { content: "› "; color: #4d565c; }
.menu-log li.err { color: #cf8b85; }
.menu-log li.ok { color: #7fb695; }


#spectator-hint {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  font-size: 11px; letter-spacing: .18em; color: #8a6a6a;
}

/* ---------------------------------------------------------------- 结算 */
.end-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px; margin-bottom: 22px;
}
.end-stats .stat {
  padding: 11px 13px; background: rgba(0,0,0,.4); border: 1px solid var(--line);
}
.end-stats .stat .k { font-size: 10px; letter-spacing: .18em; color: var(--text-dim); }
.end-stats .stat .v { font-size: 17px; color: #e4ebee; margin-top: 5px; }

/* ---------------------------------------------------------------- 移动端 */
@media (max-width: 640px) {
  .menu-title { font-size: 32px; }
  .hud-panel { font-size: 11px; min-width: 150px; }
  #team-panel { min-width: 140px; }
  #subtitle { bottom: 130px; font-size: 13px; }
}
