/* 神州 · GTA 风格 HUD */
:root {
  --pink: #ff4fa3;
  --orange: #ff8a3d;
  --sun: #ffd23f;
  --purple: #8a5cff;
  --teal: #2ee6d6;
  --sky: #4fb4ff;
  --ink: #0a0b14;
  --panel: rgba(9, 10, 18, 0.86);
  --panel-2: rgba(255, 255, 255, 0.05);
  --line: rgba(255, 255, 255, 0.12);
  --txt: #f2f0f7;
  --dim: #a3a1b5;
  --grad: linear-gradient(90deg, #ff4fa3 0%, #ff7a59 55%, #ffb23d 100%);
  --font: "Bahnschrift", "DIN Alternate", "Arial Narrow", "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
  --font-cn: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Noto Sans SC", "Source Han Sans SC", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b2733; color: var(--txt); font-family: var(--font-cn); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
#map { position: absolute; inset: 0; }
#vignette { position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(5, 4, 16, 0.55) 100%); }
.maplibregl-ctrl-attrib { display: none !important; }
.maplibregl-canvas:focus { outline: none; }

/* ---------- 标志 ---------- */
#brand { position: absolute; left: 18px; top: calc(14px + var(--safe-t)); z-index: 5; pointer-events: none; }
.logo { display: flex; align-items: center; gap: 10px; filter: drop-shadow(0 3px 10px rgba(0,0,0,.6)); }
.logo-main { font-family: var(--font); font-weight: 900; font-size: 30px; letter-spacing: 1px; line-height: 1;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: 0.5px rgba(255,255,255,.25); font-style: italic; transform: skew(-6deg); }
.logo-sub { display: flex; flex-direction: column; font-family: var(--font); font-weight: 700; font-size: 11px; letter-spacing: 3px; color: #fff; line-height: 1.25; }
.logo-sub b { color: var(--pink); font-weight: 700; }

/* ---------- 顶栏 ---------- */
#topbar { position: absolute; top: calc(14px + var(--safe-t)); right: 16px; z-index: 6; display: flex; gap: 10px; align-items: flex-start; }
.search { position: relative; width: min(380px, 42vw); }
.search input { width: 100%; height: 40px; padding: 0 40px 0 38px; border: 1px solid var(--line); border-radius: 2px;
  background: var(--panel); color: var(--txt); font: 14px var(--font-cn); outline: none; backdrop-filter: blur(8px);
  box-shadow: 0 6px 24px rgba(0,0,0,.35); transition: border-color .15s, box-shadow .15s; }
.search input::placeholder { color: #77758a; }
.search input:focus { border-color: var(--pink); box-shadow: 0 0 0 1px var(--pink), 0 0 22px rgba(255,79,163,.35); }
.search-ic { position: absolute; left: 11px; top: 11px; width: 18px; height: 18px; fill: none; stroke: var(--dim); stroke-width: 2.2; stroke-linecap: round; pointer-events: none; }
.search kbd { position: absolute; right: 10px; top: 10px; font: 11px var(--font); color: var(--dim); border: 1px solid var(--line); padding: 1px 6px; border-radius: 2px; }
.search input:focus ~ kbd { display: none; }
#search-results { position: absolute; left: 0; right: 0; top: 44px; margin: 0; padding: 4px 0; list-style: none; max-height: 60vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(8px); box-shadow: 0 10px 30px rgba(0,0,0,.5); }
#search-results li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; font-size: 14px; }
#search-results li[aria-selected="true"], #search-results li:hover { background: linear-gradient(90deg, rgba(255,79,163,.28), rgba(255,79,163,0)); }
#search-results .rt { margin-left: auto; font-size: 11px; color: var(--dim); white-space: nowrap; }
#search-results .ri { width: 22px; height: 22px; flex: none; }
#search-results mark { background: none; color: var(--pink); font-weight: 700; }

.menu { display: flex; gap: 6px; }
.mbtn { height: 40px; padding: 0 14px; border: 1px solid var(--line); background: var(--panel); backdrop-filter: blur(8px); cursor: pointer;
  font: 600 14px var(--font-cn); letter-spacing: 1px; display: flex; align-items: center; gap: 8px; border-radius: 2px; box-shadow: 0 6px 24px rgba(0,0,0,.35); }
.mbtn .k { font: 700 11px var(--font); color: var(--ink); background: #fff; padding: 1px 5px; border-radius: 2px; }
.mbtn:hover { border-color: rgba(255,255,255,.4); }
.mbtn[aria-expanded="true"] { background: var(--grad); color: #fff; border-color: transparent; }
.mbtn[aria-expanded="true"] .k { background: rgba(0,0,0,.35); color: #fff; }

/* ---------- 面板 ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(10px); box-shadow: 0 18px 50px rgba(0,0,0,.5); border-radius: 2px; }
.panel::before { content: ""; display: block; height: 3px; background: var(--grad); }
.panel-h { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 10px; font: 700 15px var(--font-cn); letter-spacing: 2px; text-transform: uppercase; border-bottom: 1px solid var(--line); }
.panel-b { padding: 12px 16px 16px; overflow: auto; }
.x { width: 28px; height: 28px; border: 0; background: transparent; color: var(--dim); cursor: pointer; font-size: 15px; }
.x:hover { color: #fff; }
.side { position: absolute; right: 16px; top: calc(64px + var(--safe-t)); width: 340px; max-height: calc(100% - 140px); z-index: 7; display: flex; flex-direction: column; }
.side .panel-b { flex: 1; }
.sec-title { font: 700 11px var(--font); letter-spacing: 3px; color: var(--dim); margin: 6px 0 8px; text-transform: uppercase; }
.sec-title:not(:first-child) { margin-top: 18px; }

.seg { display: flex; gap: 0; margin-bottom: 10px; border: 1px solid var(--line); }
.seg button { flex: 1; height: 32px; border: 0; background: transparent; cursor: pointer; font-size: 13px; color: var(--dim); }
.seg button[aria-checked="true"] { background: #fff; color: var(--ink); font-weight: 700; }

.metric-list { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.metric-list button { text-align: left; padding: 7px 9px; border: 1px solid transparent; background: var(--panel-2); cursor: pointer; font-size: 13px; line-height: 1.25; }
.metric-list button small { display: block; color: var(--dim); font-size: 10.5px; margin-top: 1px; }
.metric-list button:hover { border-color: var(--line); }
.metric-list button[aria-checked="true"] { border-color: var(--pink); background: linear-gradient(90deg, rgba(255,79,163,.25), rgba(255,138,61,.08)); }
.metric-list button.none { grid-column: span 2; }
.metric-list .grp { grid-column: span 2; font-size: 11px; color: var(--dim); margin: 6px 0 0; letter-spacing: 2px; }

.toggles { display: flex; flex-direction: column; gap: 2px; }
.tg { display: flex; align-items: center; gap: 10px; padding: 7px 8px; cursor: pointer; user-select: none; }
.tg:hover { background: var(--panel-2); }
.tg img { width: 24px; height: 24px; }
.tg .tl { flex: 1; font-size: 14px; }
.tg .tl small { display: block; color: var(--dim); font-size: 11px; }
.tg-all { border-bottom: 1px solid var(--line); margin-bottom: 4px; padding-bottom: 9px; }
.tg-all .tl { font-weight: 700; }
.tg .sw { width: 34px; height: 18px; border-radius: 9px; background: #3a3946; position: relative; transition: background .15s; flex: none; }
.tg .sw::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: left .15s; }
.tg[aria-checked="true"] .sw { background: var(--pink); }
.tg[aria-checked="true"] .sw::after { left: 18px; }

/* ---------- 详情 ---------- */
.detail { position: absolute; left: 16px; top: calc(76px + var(--safe-t)); width: 360px; max-height: calc(100% - 340px); min-height: 200px; z-index: 7; display: flex; flex-direction: column; animation: slidein .22s ease-out; }
@keyframes slidein { from { transform: translateX(-24px); opacity: 0; } }
.detail .panel-b { flex: 1; }
.d-head { padding: 14px 16px 12px; border-bottom: 1px solid var(--line); position: relative; }
.d-kicker { font: 700 11px var(--font); letter-spacing: 3px; color: var(--pink); text-transform: uppercase; }
.d-title { font: 900 26px var(--font-cn); margin: 2px 0 0; letter-spacing: 1px; }
.d-sub { color: var(--dim); font-size: 12.5px; margin-top: 4px; }
.d-head .x { position: absolute; right: 8px; top: 8px; }
.d-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.d-actions button { height: 28px; padding: 0 10px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; font-size: 12px; }
.d-actions button:hover { border-color: var(--pink); }
.d-actions button.wp { background: var(--purple); border-color: var(--purple); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 0 12px; }
.kv .row { display: contents; }
.kv .k, .kv .v { padding: 7px 0; border-bottom: 1px solid rgba(255,255,255,.06); }
.kv .k { font-size: 13px; color: var(--dim); }
.kv .k i { font-style: normal; font-size: 10.5px; color: #6f6d82; margin-left: 4px; }
.kv .v { text-align: right; font: 600 15px var(--font); white-space: nowrap; }
.kv .v u { text-decoration: none; font-size: 11px; color: var(--dim); font-weight: 400; margin-left: 3px; font-family: var(--font-cn); }
.kv .v .rk { display: inline-block; min-width: 34px; margin-left: 6px; font-size: 11px; color: var(--ink); background: var(--sun); padding: 0 4px; text-align: center; font-weight: 700; }
.kv .grp { grid-column: span 2; font: 700 11px var(--font); letter-spacing: 3px; color: var(--dim); margin: 14px 0 2px; }
.bar { height: 6px; background: rgba(255,255,255,.08); margin: 2px 0 0; grid-column: span 2; display: flex; }
.bar i { display: block; height: 100%; }
.src-line { margin-top: 12px; font-size: 11px; color: #7b798f; line-height: 1.6; }
.src-line a { color: var(--teal); text-decoration: none; cursor: pointer; }
.empty { color: var(--dim); font-size: 13px; padding: 8px 0; }
.chip { display: inline-block; padding: 1px 6px; font-size: 11px; border: 1px solid var(--line); margin: 0 4px 4px 0; color: var(--dim); }
.chip.hot { border-color: var(--pink); color: #fff; background: rgba(255,79,163,.2); }
.nearby { list-style: none; margin: 0; padding: 0; }
.nearby li { display: flex; align-items: center; gap: 8px; padding: 6px 0; cursor: pointer; border-bottom: 1px solid rgba(255,255,255,.05); font-size: 13px; }
.nearby li:hover { color: var(--pink); }
.nearby img { width: 20px; height: 20px; }
.nearby .dist { margin-left: auto; color: var(--dim); font: 12px var(--font); }

/* ---------- 排行榜 ---------- */
#rank-metric { width: 100%; height: 34px; background: #15151f; color: var(--txt); border: 1px solid var(--line); padding: 0 8px; font: 13px var(--font-cn); margin-bottom: 8px; }
.rank-list { list-style: none; margin: 0; padding: 0; counter-reset: r; }
.rank-list li { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 8px; padding: 6px 4px; cursor: pointer; position: relative; font-size: 13.5px; }
.rank-list li:hover { background: var(--panel-2); }
.rank-list .n { font: 700 14px var(--font); color: var(--dim); text-align: right; }
.rank-list li:nth-child(1) .n { color: var(--sun); } .rank-list li:nth-child(2) .n { color: #e6e6f0; } .rank-list li:nth-child(3) .n { color: var(--orange); }
.rank-list .val { font: 600 13.5px var(--font); }
.rank-list .fill { position: absolute; left: 38px; bottom: 1px; height: 2px; background: var(--grad); opacity: .8; }
.rank-list .nm small { color: var(--dim); font-size: 11px; margin-left: 4px; }

/* ---------- 雷达 ---------- */
#radar-wrap { position: absolute; left: 18px; bottom: calc(34px + var(--safe-b)); width: 200px; height: 200px; z-index: 5; pointer-events: none; }
#radar { position: absolute; inset: 0; border-radius: 50%; overflow: hidden; box-shadow: 0 8px 30px rgba(0,0,0,.6); }
#radar .maplibregl-canvas { filter: saturate(1.1); }
.radar-ring { position: absolute; inset: -4px; border-radius: 50%; border: 4px solid rgba(9,10,18,.9);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.15), 0 0 0 1px rgba(255,255,255,.08);
  background: radial-gradient(circle, transparent 66%, rgba(0,0,0,.25) 100%); }
.radar-ring::after { content: ""; position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform: translate(-50%, -60%);
  border-left: 7px solid transparent; border-right: 7px solid transparent; border-bottom: 14px solid #fff; filter: drop-shadow(0 0 3px rgba(0,0,0,.8)); }
.radar-n { position: absolute; left: 50%; top: -8px; transform: translateX(-50%); width: 20px; height: 20px; border-radius: 50%; background: #0a0b14; border: 1px solid rgba(255,255,255,.3);
  font: 700 11px var(--font); display: grid; place-items: center; }
#whereami { position: absolute; left: 230px; bottom: calc(38px + var(--safe-b)); z-index: 5; pointer-events: none; text-shadow: 0 2px 6px rgba(0,0,0,.9), 0 0 2px #000; }
#whereami .w1 { font: 800 22px var(--font-cn); letter-spacing: 1px; }
#whereami .w2 { font: 600 13px var(--font-cn); color: #ddd; letter-spacing: 1px; margin-top: 2px; }
#whereami .w2 b { color: var(--sun); font-family: var(--font); }

/* ---------- 图例 ---------- */
.legend { position: absolute; right: 16px; bottom: calc(34px + var(--safe-b)); width: 320px; z-index: 5; }
.legend .lg-b { padding: 10px 14px 12px; }
.lg-t { font: 700 14px var(--font-cn); display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.lg-t small { font-weight: 400; color: var(--dim); font-size: 11px; }
.lg-hist { display: flex; align-items: flex-end; gap: 1px; height: 38px; margin-top: 8px; }
.lg-hist i { flex: 1; min-height: 1px; }
.lg-ramp { height: 8px; margin-top: 2px; }
.lg-ax { display: flex; justify-content: space-between; font: 11px var(--font); color: var(--dim); margin-top: 3px; }
.lg-note { font-size: 11px; color: #7b798f; margin-top: 6px; line-height: 1.5; }
.lg-null { display: inline-block; width: 10px; height: 10px; background: repeating-linear-gradient(45deg,#555 0 2px,#2a2a33 2px 4px); vertical-align: -1px; margin-right: 4px; }

/* ---------- 缩放 ---------- */
#zoomctl { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); z-index: 5; display: flex; flex-direction: column; gap: 4px; }
#zoomctl button { width: 38px; height: 38px; background: var(--panel); border: 1px solid var(--line); cursor: pointer; font: 700 18px var(--font); backdrop-filter: blur(8px); }
#zoomctl button:hover { border-color: var(--pink); color: var(--pink); }
body.side-open #zoomctl { right: 372px; }

/* ---------- 弹窗 ---------- */
.modal { position: absolute; inset: 0; z-index: 20; background: rgba(4, 3, 12, .6); display: grid; place-items: center; backdrop-filter: blur(3px); }
.modal-card { width: min(900px, 94vw); max-height: 86vh; display: flex; flex-direction: column; }
.modal-card .panel-b { flex: 1; }
.alm-intro { font-size: 13px; color: var(--dim); line-height: 1.7; margin-bottom: 12px; }
.alm-src { border-top: 1px solid var(--line); padding: 12px 0; }
.alm-src h4 { margin: 0; font-size: 15px; }
.alm-src h4 small { font-weight: 400; color: var(--dim); font-size: 12px; margin-left: 6px; }
.alm-src p { margin: 6px 0; font-size: 12.5px; color: #cfcde0; line-height: 1.6; }
.alm-src .meta { font-size: 11.5px; color: var(--dim); }
.alm-src a { color: var(--teal); word-break: break-all; }
.alm-src details { font-size: 11px; color: var(--dim); margin-top: 4px; }
.alm-src details code { font-size: 10.5px; color: #8f8da3; word-break: break-all; }
.alm-src:target { background: rgba(255,79,163,.08); }

/* ---------- 提示 ---------- */
.tooltip { position: absolute; z-index: 15; pointer-events: none; padding: 7px 10px; background: rgba(9,10,18,.92); border-left: 3px solid var(--pink); font-size: 13px; white-space: nowrap; box-shadow: 0 6px 18px rgba(0,0,0,.5); }
.tooltip b { font-size: 14px; }
.tooltip .tv { font: 600 13px var(--font); color: var(--sun); margin-left: 6px; }
.tooltip small { color: var(--dim); display: block; font-size: 11px; }
.toast { position: absolute; left: 50%; top: 70px; transform: translateX(-50%); z-index: 30; background: rgba(9,10,18,.92); padding: 10px 18px; border: 1px solid var(--line); font-size: 13px; }
.toast b { color: var(--sun); }

#disclaimer { position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; padding: 4px 12px calc(4px + var(--safe-b)); font-size: 10.5px; color: rgba(255,255,255,.55); text-align: center;
  background: linear-gradient(0deg, rgba(5,4,14,.7), transparent); text-shadow: 0 1px 2px #000; }
#disclaimer a { color: rgba(255,255,255,.8); }

/* ---------- 载入 ---------- */
#loading { position: absolute; inset: 0; z-index: 50; background: radial-gradient(ellipse at 50% 120%, #ff4fa3 -40%, #3a1250 30%, #0a0b14 75%); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; transition: opacity .6s; }
#loading.done { opacity: 0; pointer-events: none; }
.ld-logo { font: italic 900 64px var(--font); background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; transform: skew(-6deg); letter-spacing: 6px; }
.ld-bar { width: 240px; height: 3px; background: rgba(255,255,255,.15); overflow: hidden; }
.ld-bar i { display: block; height: 100%; width: 30%; background: var(--grad); animation: ld 1.2s ease-in-out infinite; }
@keyframes ld { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }
.ld-txt { font-size: 13px; letter-spacing: 3px; color: var(--dim); }

/* 启动第二阶段：数据未就绪前菜单与搜索暂不可用 */
body.booting #topbar { opacity: .55; pointer-events: none; }

/* ---------- 按键提示 ---------- */
#keyhints { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(24px + var(--safe-b)); z-index: 4; display: flex; gap: 14px; pointer-events: none;
  font-size: 12px; color: rgba(255,255,255,.85); text-shadow: 0 1px 3px #000; white-space: nowrap; }
#keyhints kbd { display: inline-block; min-width: 20px; padding: 1px 6px; margin-right: 5px; background: rgba(255,255,255,.92); color: var(--ink); font: 700 11px var(--font-cn); border-radius: 2px; text-shadow: none; }
@media (max-width: 1280px) { #keyhints { display: none; } }

/* ---------- 平板 ---------- */
@media (max-width: 1024px) {
  .side { width: 310px; }
  body.side-open #zoomctl { right: 342px; }
  .detail { width: 320px; }
}
/* ---------- 手机 ---------- */
@media (max-width: 720px) {
  #brand { left: 12px; top: calc(10px + var(--safe-t)); }
  .logo-main { font-size: 20px; }
  .logo-sub { font-size: 9px; letter-spacing: 2px; }
  #topbar { left: 12px; right: 12px; top: calc(52px + var(--safe-t)); flex-direction: column; gap: 6px; }
  .search { width: 100%; }
  .menu { position: fixed; top: calc(10px + var(--safe-t)); right: 12px; }
  .mbtn { height: 34px; padding: 0 10px; font-size: 13px; }
  .mbtn .k { display: none; }
  .side, .detail { left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 62%; min-height: 0; border-left: 0; border-right: 0; animation: slideup .22s ease-out; }
  @keyframes slideup { from { transform: translateY(30px); opacity: 0; } }
  .side { z-index: 9; }
  .detail { z-index: 8; padding-bottom: var(--safe-b); }
  #radar-wrap { width: 110px; height: 110px; left: 12px; bottom: calc(30px + var(--safe-b)); }
  #whereami { left: 132px; bottom: calc(34px + var(--safe-b)); }
  #whereami .w1 { font-size: 16px; }
  #whereami .w2 { font-size: 11px; }
  .legend { left: 12px; right: 12px; width: auto; bottom: calc(152px + var(--safe-b)); }
  .legend .lg-hist { height: 24px; }
  #zoomctl { top: auto; bottom: calc(150px + var(--safe-b)); transform: none; right: 12px; }
  body.side-open #zoomctl { right: 12px; }
  body.legend-open #zoomctl { bottom: calc(268px + var(--safe-b)); }
  #disclaimer { font-size: 9px; }
  body.panel-open #radar-wrap, body.panel-open #whereami, body.panel-open .legend, body.panel-open #zoomctl { display: none; }
}
