:root {
  --bg: #0f1320;
  --bg2: #0b0e18;
  --panel: #171c2e;
  --panel2: #1f2740;
  --panel3: #26304d;
  --text: #e6e9f2;
  --muted: #9aa3b8;
  --border: #2a3252;
  --red: #ff5a5a;
  --red-d: #7a2230;
  --blue: #4aa3ff;
  --blue-d: #1d3c5c;
  --gold: #ffb02e;
  --green: #3ddc97;
  --shadow: 0 8px 30px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 70% -10%, #1a2138 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* 顶栏 */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 0; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: rgba(15,19,32,.85); backdrop-filter: blur(8px);
  z-index: 20;
}
.brand { font-weight: 800; font-size: 20px; letter-spacing: .5px; }
.brand .flag { color: var(--gold); }
.topbar .spacer { flex: 1; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 14px; font-size: 14px; cursor: pointer; transition: .15s;
}
.btn:hover { background: var(--panel3); text-decoration: none; }
.btn.primary { background: linear-gradient(135deg, #ffb02e, #ff7a45); color: #1a1205; border: none; font-weight: 700; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }

/* Hero */
.hero { padding: 46px 0 26px; }
.hero h1 { font-size: 38px; margin: 0 0 10px; letter-spacing: 1px; }
.hero h1 .accent { color: var(--gold); }
.hero p { color: var(--muted); font-size: 16px; max-width: 760px; }

.section-title { font-size: 22px; margin: 34px 0 16px; display: flex; align-items: center; gap: 10px; }
.section-title::before { content: ""; width: 6px; height: 22px; background: var(--gold); border-radius: 3px; }

/* 战役墙 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card {
  background: linear-gradient(180deg, var(--panel), var(--bg2));
  border: 1px solid var(--border); border-radius: 14px; padding: 16px;
  cursor: pointer; transition: .18s; position: relative; overflow: hidden;
}
.card:hover { transform: translateY(-3px); border-color: var(--gold); box-shadow: var(--shadow); }
.card .bname { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.card .bera { color: var(--muted); font-size: 12.5px; }
.card .tags { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 11.5px; padding: 2px 8px; border-radius: 20px; border: 1px solid var(--border); color: var(--muted); }
.tag.dom { color: var(--red); border-color: var(--red-d); }
.tag.intl { color: var(--blue); border-color: var(--blue-d); }
.faces { margin-top: 12px; display: flex; gap: -6px; }
.face {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; border: 2px solid var(--bg); margin-left: -6px;
  background: var(--panel3); color: var(--text);
}
.vs { margin: 8px 0; font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }
.vs b { color: var(--text); font-weight: 600; }

/* AI 阵容 */
.ai-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.ai-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 14px; }
.ai-card h3 { margin: 0 0 2px; font-size: 16px; }
.ai-card .style { color: var(--gold); font-size: 12.5px; font-weight: 700; }
.ai-card .tag2 { color: var(--muted); font-size: 12px; margin: 6px 0 10px; }
.bars { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.bar { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.bar .lab { width: 28px; }
.bar .track { flex: 1; height: 6px; background: var(--panel2); border-radius: 4px; overflow: hidden; }
.bar .fill { height: 100%; background: linear-gradient(90deg, var(--blue), var(--gold)); }

/* 战力榜 */
.lb { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 16px; }
.lb .row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--border); }
.lb .row:last-child { border-bottom: none; }
.lb .nm { width: 110px; font-weight: 600; }
.lb .track { flex: 1; height: 12px; background: var(--panel2); border-radius: 6px; overflow: hidden; }
.lb .fill { height: 100%; background: linear-gradient(90deg, var(--gold), #ff7a45); }
.lb .num { width: 70px; text-align: right; color: var(--muted); font-size: 13px; }

/* Footer */
footer { margin: 50px 0 30px; padding-top: 18px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }

/* ---------- 沙盘页 ---------- */
.sandbox { display: grid; grid-template-columns: 320px 1fr; gap: 18px; align-items: start; }
.config { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 16px; position: sticky; top: 80px; }
.config h3 { margin: 0 0 10px; font-size: 15px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
select, input[type="range"] { width: 100%; }
select {
  background: var(--panel2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px; font-size: 14px;
}
.ai-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ai-pick .opt {
  display: flex; align-items: center; gap: 6px; font-size: 12.5px;
  padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; background: var(--panel2);
}
.ai-pick .opt.on { border-color: var(--gold); background: var(--panel3); }
.ai-pick .opt .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.ai-pick.red .opt.on .dot { background: var(--red); }
.ai-pick.blue .opt.on .dot { background: var(--blue); }
.side-label { font-weight: 700; margin: 4px 0; }
.side-label.red { color: var(--red); }
.side-label.blue { color: var(--blue); }
.config .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }

.stage { display: flex; flex-direction: column; gap: 16px; }

/* 战场 */
.battlefield {
  background: linear-gradient(180deg, #0d1226, #10182f);
  border: 1px solid var(--border); border-radius: 14px; padding: 16px; position: relative; overflow: hidden;
}
.bf-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.bf-head .bt { font-size: 18px; font-weight: 700; }
.bf-head .phase { font-size: 13px; color: var(--muted); }
.bf-svg { width: 100%; height: 220px; display: block; background:
  repeating-linear-gradient(0deg, transparent, transparent 21px, rgba(255,255,255,.03) 22px),
  repeating-linear-gradient(90deg, transparent, transparent 21px, rgba(255,255,255,.03) 22px);
  border-radius: 10px; border: 1px solid var(--border); }
.forces { display: flex; gap: 16px; margin-top: 14px; }
.force { flex: 1; }
.force .fh { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.force.red .fh .nm { color: var(--red); font-weight: 700; }
.force.blue .fh .nm { color: var(--blue); font-weight: 700; }
.meter { height: 14px; background: var(--panel2); border-radius: 8px; overflow: hidden; margin-bottom: 8px; }
.meter .fill { height: 100%; transition: width .4s ease; }
.force.red .meter .fill { background: linear-gradient(90deg, #ff7a45, var(--red)); }
.force.blue .meter .fill { background: linear-gradient(90deg, #2f7fd6, var(--blue)); }
.sub { display: flex; gap: 12px; font-size: 11.5px; color: var(--muted); }
.sub .sm { flex: 1; }
.sub .strack { height: 5px; background: var(--panel2); border-radius: 3px; overflow: hidden; margin-top: 3px; }
.sub .strack .sf { height: 100%; }
.sub .morale .sf { background: var(--green); }
.sub .supply .sf { background: var(--gold); }

/* 事件流 */
.log {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 14px;
  height: 280px; overflow-y: auto; font-size: 13.5px;
}
.log .ev { padding: 7px 10px; margin-bottom: 7px; border-radius: 8px; border-left: 3px solid var(--border); background: var(--panel2); }
.log .ev.red { border-left-color: var(--red); }
.log .ev.blue { border-left-color: var(--blue); }
.log .ev.sys { border-left-color: var(--gold); color: var(--muted); }
.log .ev .who { font-weight: 700; }
.log .ev.red .who { color: var(--red); }
.log .ev.blue .who { color: var(--blue); }
.log .ev .st { color: var(--muted); font-size: 11.5px; margin-left: 6px; }
.log .turnsep { text-align: center; color: var(--muted); font-size: 11.5px; margin: 10px 0 4px; letter-spacing: 2px; }

/* 结果 */
.result { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 16px; }
.result .win { font-size: 22px; font-weight: 800; }
.result .win.red { color: var(--red); }
.result .win.blue { color: var(--blue); }
.result .win.draw { color: var(--gold); }
.result .hist { color: var(--muted); font-size: 13.5px; margin-top: 8px; border-top: 1px dashed var(--border); padding-top: 10px; }
.result .cmp { margin-top: 8px; font-size: 13.5px; }
.result .cmp .ok { color: var(--green); }
.result .cmp .no { color: var(--red); }
.kpi { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; }
.kpi .k { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; font-size: 12.5px; }
.kpi .k b { display: block; font-size: 16px; color: var(--text); }

/* 控制条 */
.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.controls .speed { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.controls input[type=range] { width: 120px; }
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--panel3); border: 1px solid var(--gold); color: var(--text);
  padding: 10px 18px; border-radius: 10px; opacity: 0; transition: .25s; z-index: 50; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 展示模式 */
body.present .topbar, body.present .config, body.present .controls .nonpres { display: none; }
body.present .sandbox { grid-template-columns: 1fr; }
body.present .battlefield { padding: 28px; }
body.present .bf-svg { height: 320px; }
body.present .log { height: 360px; }

/* ---------- 真实地图（Leaflet） ---------- */
.bf-map {
  width: 100%; height: 440px; border-radius: 10px; border: 1px solid var(--border);
  overflow: hidden; background: #0a1020;
}
.bf-map .leaflet-container { background: #0a1020; }
.map-legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin: 8px 0 4px; flex-wrap: wrap; }
.map-legend .red { color: var(--red); }
.map-legend .blue { color: var(--blue); }
.map-legend .line { color: var(--gold); }

/* ---------- 粘贴板 ---------- */
.paste-layout { display: grid; grid-template-columns: 320px 1fr; gap: 18px; align-items: start; }
.pconfig { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 16px; position: sticky; top: 80px; }
.pconfig h3 { margin: 0 0 10px; font-size: 15px; }
.pstage { display: flex; flex-direction: column; gap: 16px; }

.prompt-box { background: linear-gradient(180deg, var(--panel), var(--bg2)); border: 1px solid var(--border); border-radius: 14px; padding: 14px; }
.pb-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-weight: 700; }
.prompt-text { white-space: pre-wrap; font-size: 13px; line-height: 1.55; background: var(--bg2); color: var(--text);
  padding: 12px; border-radius: 10px; border: 1px solid var(--border); max-height: 280px; overflow: auto; margin: 0; }

.paste-area { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 14px; }
.pa-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-weight: 700; }
.pa-actions { display: flex; gap: 8px; }
#pasteInput {
  width: 100%; min-height: 200px; background: var(--bg2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 12px;
  font-size: 14px; line-height: 1.6; resize: vertical; font-family: inherit;
}
#pasteInput:focus { outline: none; border-color: var(--gold); }

.reports { display: flex; flex-direction: column; gap: 12px; }
.report { background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.report.red { border-left-color: var(--red); }
.report.blue { border-left-color: var(--blue); }
.report .rh { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.report .side-tag.red { color: var(--red); font-weight: 700; }
.report .side-tag.blue { color: var(--blue); font-weight: 700; }
.report .rt { color: var(--muted); font-size: 12px; margin-left: auto; }
.report .del { margin-left: 6px; background: transparent; border: 1px solid var(--border); color: var(--muted);
  border-radius: 6px; padding: 2px 9px; cursor: pointer; font-size: 12px; }
.report .del:hover { border-color: var(--red); color: var(--red); }
.report .rtext { white-space: pre-wrap; font-size: 13px; line-height: 1.6; color: var(--text); margin: 0;
  max-height: 260px; overflow: auto; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }

@media (max-width: 860px) {
  .sandbox { grid-template-columns: 1fr; }
  .config { position: static; }
  .paste-layout { grid-template-columns: 1fr; }
  .pconfig { position: static; }
  .hero h1 { font-size: 30px; }
}
