/* ===================================================================
   style.css — 军事指挥终端风格：暗色金属 + 琥珀色数码字 + 硬边框
   布局：左侧战场自适应铺满，右侧固定宽度侧边栏（红警式）
   =================================================================== */

:root {
  --bg: #0a0d0b;
  --panel: #171b17;
  --panel2: #1f251f;
  --panel3: #2a322a;
  --line: #38423a;
  --line2: #4d5a4c;
  --amber: #e8c14a;
  --amber-dim: #8f7a34;
  --green: #6fd36f;
  --red: #e5533a;
  --blue: #58a8e8;
  --txt: #cfd6cb;
  --txt-dim: #8b968a;
  --side-w: 236px;
}

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--txt);
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 13px;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

#app { position: relative; width: 100%; height: 100%; display: flex; }

/* ============================ 战场 ============================ */
#stage { position: relative; flex: 1; min-width: 0; overflow: hidden; }
#game { display: block; width: 100%; height: 100%; background: #0d100e; }

/* ---------- 左上状态条 ---------- */
#topbar {
  position: absolute; top: 8px; left: 8px;
  display: flex; gap: 4px;
  pointer-events: none;
}
.tb-item {
  background: rgba(12,16,13,0.78);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 3px 8px 4px;
  display: flex; flex-direction: column; align-items: center;
  min-width: 56px;
}
.tb-item em {
  font-style: normal; font-size: 9px; letter-spacing: 1px;
  color: var(--txt-dim); text-transform: uppercase;
}
.tb-item b {
  font-family: "Consolas", monospace; font-size: 14px;
  color: var(--amber); line-height: 1.1;
}
.tb-diff b { color: var(--red); }

/* ---------- 提示条 ---------- */
#toasts {
  position: absolute; left: 10px; bottom: 84px;
  display: flex; flex-direction: column-reverse; gap: 3px;
  pointer-events: none; max-width: 420px;
}
.toast {
  background: rgba(10,14,11,0.86);
  border-left: 3px solid var(--amber);
  padding: 4px 10px; font-size: 12px;
  color: #e6ebe3;
  animation: toastIn 0.18s ease-out;
}
.toast.warn { border-left-color: var(--red); color: #ffd9d0; }
@keyframes toastIn { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: none; } }

/* ---------- 模式提示 ---------- */
#modehint {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  background: rgba(20,26,20,0.9);
  border: 1px solid var(--amber-dim);
  color: var(--amber);
  padding: 4px 14px; font-size: 12px; letter-spacing: 1px;
  pointer-events: none;
}

/* ---------- 底部选中信息 ---------- */
#selbar {
  position: absolute; left: 8px; bottom: 8px;
  display: flex; align-items: stretch; gap: 8px;
  background: rgba(12,16,13,0.85);
  border: 1px solid var(--line);
  padding: 6px;
  max-width: calc(100% - 20px);
}
#sel-icon { width: 56px; height: 46px; background: #0e120f; border: 1px solid var(--line); flex: none; }
#sel-icon canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
#sel-info { min-width: 128px; display: flex; flex-direction: column; justify-content: center; }
#sel-name { font-size: 13px; color: var(--amber); font-weight: 600; }
#sel-detail { font-size: 11px; color: var(--txt-dim); line-height: 1.5; }
#sel-list { display: flex; flex-wrap: wrap; gap: 2px; align-content: center; max-width: 420px; max-height: 46px; overflow: hidden; }
.sel-chip {
  font-size: 10px; padding: 1px 5px;
  background: var(--panel2); border: 1px solid var(--line);
  color: var(--txt); border-radius: 2px;
}
.sel-chip b { color: var(--amber); font-weight: 600; }

/* ============================ 侧边栏 ============================ */
#side {
  width: var(--side-w); flex: none;
  background: linear-gradient(180deg, #1b211b, #12160f);
  border-left: 2px solid var(--line2);
  display: flex; flex-direction: column;
  padding: 6px;
  gap: 6px;
}

/* ---------- 资源 ---------- */
#res { background: #0d110e; border: 1px solid var(--line); padding: 5px 7px; }
.res-credits { display: flex; justify-content: space-between; align-items: baseline; }
.res-label { font-size: 10px; letter-spacing: 1px; color: var(--txt-dim); }
#credits {
  font-family: "Consolas", monospace; font-size: 20px; color: var(--amber);
  text-shadow: 0 0 8px rgba(232,193,74,0.35);
}
.res-power { margin-top: 4px; }
.pw-track {
  position: relative; height: 7px; background: #060806;
  border: 1px solid var(--line); overflow: hidden;
}
.pw-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #3f7f3f, var(--green)); transition: width 0.25s; }
.pw-fill.low { background: linear-gradient(90deg, #8a3020, var(--red)); }
.pw-mark { position: absolute; top: -2px; bottom: -2px; width: 2px; background: #e8e8d0; opacity: 0.8; }
.res-power span { font-size: 10px; color: var(--txt-dim); display: block; margin-top: 2px; }
.res-power span.low { color: var(--red); }

/* ---------- 小地图 ---------- */
#minimap {
  width: 100%; height: 222px;
  background: #070a08; border: 1px solid var(--line2);
  display: block; cursor: crosshair;
  image-rendering: pixelated;
}

/* ---------- 超级武器 ---------- */
#swbar #sw-btn {
  position: relative; width: 100%;
  background: #10160f; border: 1px solid var(--line);
  color: var(--txt); padding: 5px 8px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; cursor: pointer; overflow: hidden;
}
#swbar #sw-btn .sw-name { color: var(--blue); font-weight: 600; z-index: 1; }
#swbar #sw-btn .sw-state { color: var(--txt-dim); z-index: 1; font-family: Consolas, monospace; }
#swbar #sw-btn .sw-fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0%;
  background: rgba(88,168,232,0.22);
}
#swbar #sw-btn.ready { border-color: var(--blue); animation: swPulse 1.1s infinite; }
#swbar #sw-btn.ready .sw-state { color: var(--blue); }
@keyframes swPulse { 0%,100% { box-shadow: 0 0 0 rgba(88,168,232,0); } 50% { box-shadow: 0 0 10px rgba(88,168,232,0.5); } }

/* ---------- 分类页签 ---------- */
#tabs { display: flex; gap: 2px; }
.tab {
  flex: 1; padding: 5px 0; text-align: center;
  background: var(--panel); border: 1px solid var(--line);
  color: var(--txt-dim); font-size: 11px; cursor: pointer;
}
.tab:hover { background: var(--panel2); color: var(--txt); }
.tab.active { background: var(--panel3); color: var(--amber); border-color: var(--amber-dim); }
.tab.locked { opacity: 0.38; cursor: not-allowed; }

/* ---------- 建造列表 ---------- */
#buildlist {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  align-content: start;
  padding-right: 2px;
}
#buildlist::-webkit-scrollbar { width: 6px; }
#buildlist::-webkit-scrollbar-track { background: #0b0e0b; }
#buildlist::-webkit-scrollbar-thumb { background: var(--line2); }

.bcard {
  position: relative; background: #0e120f;
  border: 1px solid var(--line);
  cursor: pointer; overflow: hidden;
  display: flex; flex-direction: column;
  min-height: 74px;
}
.bcard:hover { border-color: var(--line2); background: #131813; }
.bcard.locked { opacity: 0.34; cursor: not-allowed; filter: grayscale(0.7); }
.bcard.active { border-color: var(--amber); }
.bcard.ready { border-color: var(--green); animation: readyPulse 1s infinite; }
@keyframes readyPulse { 0%,100% { background: #0e120f; } 50% { background: #1a2a18; } }

.bcard-icon { width: 100%; height: 44px; background: #0a0d0a; }
.bcard-icon canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.bcard-icon.fb {
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--txt-dim); text-align: center; line-height: 1.2;
}
.bcard-name { font-size: 10.5px; padding: 2px 4px 0; color: var(--txt); line-height: 1.25; }
.bcard-cost {
  font-family: Consolas, monospace; font-size: 10px;
  color: var(--amber-dim); padding: 0 4px 3px;
  display: flex; justify-content: space-between;
}
.bcard-cost .afford { color: var(--amber); }
.bcard-cost .no { color: var(--red); }
.bcard-key {
  position: absolute; top: 1px; right: 2px;
  font-size: 9px; color: var(--txt-dim);
  background: rgba(0,0,0,0.5); padding: 0 3px; border-radius: 2px;
}
.bcard-prog {
  position: absolute; left: 0; bottom: 0; height: 3px;
  background: var(--green); width: 0%;
}
.bcard-mask {
  position: absolute; left: 0; right: 0; top: 0;
  background: rgba(0,0,0,0.62); pointer-events: none;
  height: 0%;
}
.bcard-badge {
  position: absolute; left: 2px; top: 1px;
  font-size: 10px; font-weight: 700; color: #0a0d0a;
  background: var(--amber); padding: 0 4px; border-radius: 2px;
}
.bcard-state {
  position: absolute; left: 0; right: 0; bottom: 3px;
  text-align: center; font-size: 10px; font-weight: 600;
  color: #0a0d0a; background: rgba(232,193,74,0.85);
  padding: 1px 0;
}
.bcard-state.hold { background: rgba(229,83,58,0.85); color: #fff; }
.bcard-state.ready { background: rgba(111,211,111,0.9); }

/* ---------- 工具按钮 ---------- */
#tools { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 3px; }
.tool {
  background: var(--panel); border: 1px solid var(--line);
  color: var(--txt-dim); padding: 5px 0; font-size: 11px; cursor: pointer;
}
.tool:hover { background: var(--panel2); color: var(--txt); }
.tool.on { background: var(--amber-dim); color: #0a0d0a; border-color: var(--amber); font-weight: 600; }

/* ============================ 全屏界面 ============================ */
.screen {
  position: absolute; inset: 0; z-index: 40;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(60,80,50,0.16), transparent 62%),
    linear-gradient(160deg, #0b0f0c 0%, #12160f 55%, #090b08 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 24px;
  overflow-y: auto;
}
.screen.hidden, .hidden { display: none !important; }

.title-art { text-align: center; }
.title-art h1 {
  font-size: 58px; letter-spacing: 12px; font-weight: 800;
  color: #e9e3cf;
  text-shadow: 0 0 22px rgba(232,193,74,0.30), 0 4px 0 #2a2f22;
}
.title-art h2 {
  font-size: 15px; letter-spacing: 7px; color: var(--amber-dim);
  font-weight: 500; margin-top: 2px;
}
.tagline { margin-top: 10px; color: var(--txt-dim); font-size: 13px; }

.scr-title {
  font-size: 24px; letter-spacing: 6px; color: var(--amber);
  font-weight: 700;
}
.scr-sub { color: var(--txt-dim); font-size: 13px; }

.setup { display: flex; flex-direction: column; gap: 8px; min-width: 460px; }
.setup-row { display: flex; align-items: center; gap: 12px; }
.setup-label {
  width: 86px; text-align: right; font-size: 12px;
  color: var(--txt-dim); letter-spacing: 1px; flex: none;
}
.opt-group { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.opt {
  background: var(--panel); border: 1px solid var(--line);
  color: var(--txt-dim); padding: 5px 12px; font-size: 12px; cursor: pointer;
}
.opt:hover { background: var(--panel2); color: var(--txt); }
.opt.on { border-color: var(--amber); color: var(--amber); background: #232a21; }
.opt small { display: block; font-size: 10px; opacity: 0.7; }

.menu { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.btn {
  background: linear-gradient(180deg, #2a322a, #1a201a);
  border: 1px solid var(--line2); color: var(--txt);
  padding: 9px 22px; font-size: 13px; letter-spacing: 2px; cursor: pointer;
}
.btn:hover { background: linear-gradient(180deg, #36402f, #212a1f); color: #fff; }
.btn-major {
  border-color: var(--amber-dim); color: var(--amber);
  box-shadow: inset 0 0 14px rgba(232,193,74,0.10);
}
.btn-major:hover { color: #fff5cf; border-color: var(--amber); }
.hint-line { font-size: 11px; color: #5f6a5e; }

/* ---------- 说明 ---------- */
.help-cols { display: flex; gap: 30px; flex-wrap: wrap; justify-content: center; }
.help-col { min-width: 300px; }
.help-col h4 {
  font-size: 12px; color: var(--amber); letter-spacing: 3px;
  border-bottom: 1px solid var(--line); padding-bottom: 4px; margin-bottom: 6px;
}
.kv { display: flex; gap: 10px; align-items: baseline; padding: 2px 0; font-size: 12px; }
kbd {
  font-family: Consolas, monospace; font-size: 11px;
  background: #0d110e; border: 1px solid var(--line2);
  padding: 1px 6px; color: var(--amber); flex: none; min-width: 92px; text-align: center;
}
.kv span { color: var(--txt-dim); }
.help-note {
  max-width: 700px; font-size: 12px; line-height: 1.8;
  color: var(--txt-dim); border-top: 1px solid var(--line); padding-top: 10px;
}
.help-note b { color: var(--txt); }

/* ---------- 科技树 ---------- */
.tech-body { max-width: 940px; width: 100%; display: flex; flex-direction: column; gap: 14px; }
.tech-tier { border: 1px solid var(--line); background: rgba(13,17,14,0.6); padding: 8px 10px; }
.tech-tier h4 { font-size: 12px; color: var(--amber); letter-spacing: 2px; margin-bottom: 6px; }
.tech-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.tech-item {
  border: 1px solid var(--line); background: #0e120f;
  padding: 4px 8px; font-size: 11px; min-width: 150px;
}
.tech-item b { color: var(--txt); display: block; }
.tech-item i { color: var(--amber-dim); font-style: normal; font-family: Consolas, monospace; }
.tech-item em { color: #6f7a6d; font-style: normal; display: block; font-size: 10px; line-height: 1.4; }

/* ---------- 统计块 ---------- */
.stat-block {
  display: grid; grid-template-columns: repeat(2, minmax(190px, 1fr));
  gap: 4px 22px; font-size: 12px;
  border: 1px solid var(--line); padding: 10px 16px;
  background: rgba(13,17,14,0.6);
}
.stat-row { display: flex; justify-content: space-between; gap: 12px; }
.stat-row span { color: var(--txt-dim); }
.stat-row b { color: var(--amber); font-family: Consolas, monospace; }

.opt-row {
  display: flex; gap: 18px; flex-wrap: wrap; justify-content: center;
  font-size: 12px; color: var(--txt-dim);
}
.opt-row label { display: flex; align-items: center; gap: 6px; }
.opt-row input[type=range] { width: 110px; }

#over-title.win { color: var(--green); }
#over-title.lose { color: var(--red); }

/* ---------- 载入 ---------- */
#loading {
  position: absolute; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: #080b09; color: var(--amber-dim);
  font-size: 14px; letter-spacing: 4px;
}

/* ---------- 窄屏兜底 ---------- */
@media (max-width: 900px) {
  :root { --side-w: 190px; }
  #minimap { height: 170px; }
  .setup { min-width: 0; width: 100%; }
  .title-art h1 { font-size: 40px; letter-spacing: 8px; }
}
