*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #08080f;
  --panel: rgba(14,14,24,0.90);
  --border: rgba(255,255,255,0.07);
  --accent: #0A84FF;
  --green: #30D158;
  --red: #FF453A;
  --t1: rgba(255,255,255,0.92);
  --t2: rgba(255,255,255,0.45);
  --t3: rgba(255,255,255,0.20);
  --blur: blur(5px) saturate(200%);
  --r: 14px;
  --shadow: 0 8px 40px rgba(0,0,0,0.6), 0 2px 8px rgba(0,0,0,0.4);
}
html, body { width:100%; height:100%; overflow:hidden; background:var(--bg);
  font-family:-apple-system,'SF Pro Display','Helvetica Neue',Arial,sans-serif;
  color:var(--t1); -webkit-font-smoothing:antialiased; }
#map { position:fixed; inset:0; z-index:0; }

/* ── Top Bar ── */
.topbar {
  position:fixed; top:0; left:0; right:0; height:46px;
  background:transparent; backdrop-filter:none; -webkit-backdrop-filter:none;
  border-bottom:none; border-radius:0;
  box-shadow:none; z-index:1000;
  display:flex; align-items:center; gap:6px; padding:0 14px;
}
.topbar-logo {
  display:flex; align-items:center; gap:7px;
  font-size:13px; font-weight:700; white-space:nowrap; margin-right:2px;
}
.logo-mark {
  width:24px; height:24px; border-radius:7px; flex-shrink:0;
  overflow:hidden;
}
.logo-mark img { width:100%; height:100%; object-fit:cover; }
.topbar-sep { width:1px; height:22px; background:var(--border); margin:0 2px; flex-shrink:0; }
.map-tabs { display:flex; gap:2px; flex:1; overflow-x:auto; overflow-y:visible; scrollbar-width:none; }
.map-tabs::-webkit-scrollbar { display:none; }
.map-tab {
  padding:5px 11px; border-radius:8px; font-size:11px; font-weight:500;
  color:var(--t2); cursor:pointer; border:none; background:transparent;
  transition:all .15s; white-space:nowrap; font-family:inherit;
}
.map-tab:hover { color:var(--t1); background:rgba(255,255,255,0.07); }
.map-tab.active { color:var(--accent); background:rgba(10,132,255,0.15); }
.topbar-pill {
  display:flex; align-items:center; gap:5px;
  padding:5px 10px; border-radius:20px; cursor:pointer;
  background:rgba(255,255,255,0.05); border:1px solid var(--border);
  font-size:11px; font-weight:500; color:var(--t2);
  transition:all .15s; white-space:nowrap; font-family:inherit;
}
.topbar-pill:hover { background:rgba(255,255,255,0.1); color:var(--t1); }
.topbar-pill.active { color:var(--accent); border-color:rgba(10,132,255,0.3); background:rgba(10,132,255,0.1); }
.conn-dot { width:6px; height:6px; border-radius:50%; background:#636366; transition:background .3s; flex-shrink:0; }
.conn-dot.ok  { background:var(--green); box-shadow:0 0 7px var(--green); }
.conn-dot.err { background:var(--red); }

/* ── Sidebar ── */
.sidebar {
  position:fixed; top:56px; left:10px; bottom:10px; width:224px;
  display:flex; flex-direction:column; gap:0;
  z-index:999; overflow-y:auto; overflow-x:hidden; scrollbar-width:none;
  transition:transform .3s cubic-bezier(.4,0,.2,1);
  background:var(--panel); backdrop-filter:var(--blur); -webkit-backdrop-filter:var(--blur);
  border:1px solid var(--border); border-radius:var(--r) 0 0 var(--r);
  box-shadow:var(--shadow);
}
.sidebar::-webkit-scrollbar { display:none; }
.sidebar.collapsed { transform:translateX(calc(-100% - 10px)); }
.sidebar-toggle {
  position:fixed; top:56px; left:233px;
  width:22px; height:48px;
  background:linear-gradient(to right, var(--panel) 0%, rgba(10,132,255,0.22) 100%);
  backdrop-filter:var(--blur); -webkit-backdrop-filter:var(--blur);
  border:1px solid rgba(10,132,255,0.35); border-left:none;
  border-radius:0 11px 11px 0;
  cursor:pointer; z-index:1000;
  color:var(--accent); font-size:14px; font-family:inherit;
  display:flex; align-items:center; justify-content:center;
  transition:left .3s cubic-bezier(.4,0,.2,1), box-shadow .2s, background .2s;
  box-shadow:4px 0 18px rgba(10,132,255,0.35), 2px 0 6px rgba(0,0,0,0.5);
  outline:none; user-select:none;
}
.sidebar-toggle:hover {
  background:linear-gradient(to right, var(--panel) 0%, rgba(10,132,255,0.38) 100%);
  box-shadow:4px 0 24px rgba(10,132,255,0.55), 2px 0 8px rgba(0,0,0,0.5);
}
.sidebar-toggle.collapsed { left:10px; }

/* ── 浮动当局统计（收缩侧边栏时，收缩按钮下方，两列布局） ── */
.float-stats {
  position:fixed; top:110px; left:10px; z-index:998;
  display:none;
  flex-wrap:wrap; gap:1px 10px;
  width:150px;
  padding:6px 8px;
  background:transparent;
  pointer-events:none;
  user-select:none;
}
.float-stats.show { display:flex; }
.fs-title {
  width:100%;
  font-size:10px; font-weight:700; color:rgba(255,255,255,0.45);
  letter-spacing:1px; margin-bottom:2px;
  text-shadow:0 1px 3px rgba(0,0,0,0.8);
}
.fs-row {
  display:flex; align-items:center; gap:4px;
  width:calc(50% - 5px);
  font-size:11px; line-height:1.7;
}
.fs-dot {
  width:5px; height:5px; border-radius:50%; flex-shrink:0;
}
.fs-val {
  font-weight:700; font-size:12px; min-width:14px;
  color:#fff; text-shadow:0 1px 4px rgba(0,0,0,0.9);
}
.fs-lbl {
  color:rgba(255,255,255,0.5); font-size:10px;
  text-shadow:0 1px 3px rgba(0,0,0,0.8);
}

/* ── 浮动队伍面板（左下角）── */
.team-float {
  position:fixed; bottom:14px; left:14px; z-index:998;
  display:none; flex-direction:column; gap:3px;
  min-width:200px; max-width:240px;
}
.team-float.show { display:flex; }
.team-card {
  background:rgba(0,0,0,0.65); backdrop-filter:blur(8px); -webkit-backdrop-filter:blur(8px);
  border:1px solid rgba(255,255,255,0.08); border-radius:6px;
  padding:6px 8px; cursor:pointer; transition:all .15s;
}
.team-card:hover { background:rgba(0,0,0,0.8); border-color:rgba(255,255,255,0.15); }
.team-card.active { border-color:rgba(10,132,255,0.5); background:rgba(10,132,255,0.12); }
.team-card .tc-top { display:flex; align-items:center; justify-content:space-between; margin-bottom:3px; }
.team-card .tc-name { font-size:12px; font-weight:600; color:#e6edf3; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:120px; }
.team-card .tc-gear { display:flex; gap:4px; align-items:center; font-size:10px; color:#8b949e; }
.team-card .tc-gear span { display:flex; align-items:center; gap:1px; }
.team-card .tc-bar { height:4px; border-radius:2px; background:rgba(255,255,255,0.1); overflow:hidden; }
.team-card .tc-bar-fill { height:100%; border-radius:2px; transition:width .3s; }

/* ── Panel card ── */
.panel {
  background:transparent;
  border:none; border-radius:0;
  box-shadow:none; padding:13px; flex-shrink:0;
  position:relative; overflow:hidden;
}
.panel + .panel {
  border-top:1px solid var(--border);
}
.panel-title {
  font-size:9.5px; font-weight:600; text-transform:uppercase;
  letter-spacing:0.9px; color:var(--t2); margin-bottom:11px;
  display:flex; align-items:center; gap:7px;
}
.panel-title::before {
  content:''; width:3px; height:10px; border-radius:2px;
  background:var(--accent); flex-shrink:0;
  box-shadow:0 0 6px rgba(10,132,255,0.6);
}

/* Stats */
.stats-grid { display:grid; grid-template-columns:1fr 1fr; gap:2px 8px; }
.stat-row {
  display:flex; align-items:center; gap:8px;
  padding:6px 8px; border-radius:8px; transition:background .12s;
}
.stat-row:hover { background:rgba(255,255,255,0.05); }
.stat-dot { width:8px; height:8px; border-radius:50%; flex-shrink:0; }
.stat-val { font-size:18px; font-weight:700; letter-spacing:-0.3px; line-height:1; min-width:20px; }
.stat-lbl { font-size:10px; font-weight:500; color:var(--t2); white-space:nowrap; }

/* Layer rows - 2 column grid */
.layer-grid { display:grid; grid-template-columns:1fr 1fr; gap:3px; }
.layer-row {
  display:flex; align-items:center; justify-content:space-between;
  padding:6px 7px; cursor:pointer; border-radius:8px;
  border:1px solid transparent; transition:background .12s, border-color .12s;
}
.layer-row:hover { background:rgba(255,255,255,0.07); border-color:var(--border); }
.layer-row:active { background:rgba(255,255,255,0.10); }
.layer-lbl { display:flex; align-items:center; gap:6px; font-size:11px; font-weight:500; }
.ldot { width:8px; height:8px; border-radius:50%; flex-shrink:0; }
.ltog {
  width:30px; height:17px; border-radius:9px;
  background:rgba(255,255,255,0.10); position:relative; flex-shrink:0; transition:background .2s;
}
.ltog::after {
  content:''; position:absolute; top:2.5px; left:2.5px;
  width:12px; height:12px; border-radius:50%;
  background:rgba(255,255,255,0.45); transition:all .2s cubic-bezier(.34,1.56,.64,1);
}
.ltog.on { background:var(--accent); }
.ltog.on::after { background:#fff; left:calc(100% - 14.5px); box-shadow:0 1px 4px rgba(0,0,0,0.35); }

/* Inputs */
select, input[type=text] {
  width:100%; background:rgba(255,255,255,0.05);
  border:1px solid var(--border); border-radius:8px;
  color:var(--t1); font-size:12px; padding:7px 10px;
  outline:none; transition:border-color .15s; font-family:inherit;
  -webkit-appearance:none; appearance:none;
}
select:focus, input[type=text]:focus { border-color:rgba(10,132,255,0.5); }
select option { background:var(--panel); color:var(--t1); }
select option:checked { background:rgba(10,132,255,0.3); }
.cfg-row { display:flex; align-items:center; gap:8px; margin-top:7px; }
.cfg-lbl { font-size:11px; color:var(--t2); white-space:nowrap; width:28px; flex-shrink:0; }
.btn-row { display:flex; gap:6px; margin-top:9px; }
.btn {
  flex:1; padding:8px; border-radius:8px; font-size:11px; font-weight:600;
  cursor:pointer; border:1px solid var(--border);
  background:rgba(255,255,255,0.06); color:var(--t1);
  transition:all .15s; font-family:inherit;
}
.btn:hover { background:rgba(255,255,255,0.13); }
.btn-accent { background:var(--accent); border-color:var(--accent); color:#fff; }
.btn-accent:hover { background:#2898FF; border-color:#2898FF; }
.hint { font-size:10px; color:var(--t3); margin-top:6px; line-height:1.4; }

/* Toast */
#toast {
  position:fixed; bottom:20px; left:50%; transform:translateX(-50%) translateY(16px);
  background:rgba(28,28,42,0.96); backdrop-filter:blur(24px);
  border:1px solid var(--border); border-radius:20px;
  padding:9px 20px; font-size:12px; font-weight:500; color:var(--t1);
  opacity:0; transition:all .22s ease; pointer-events:none; z-index:9999;
  box-shadow:var(--shadow);
}
#toast.show { opacity:1; transform:translateX(-50%) translateY(0); }

/* Slider */
.scale-row { display:flex; align-items:center; gap:8px; margin-top:8px; }
.scale-row .cfg-lbl { width:auto; }
.scale-slider {
  flex:1; -webkit-appearance:none; appearance:none; height:4px;
  background:rgba(255,255,255,0.12); border-radius:2px; outline:none;
}
.scale-slider::-webkit-slider-thumb {
  -webkit-appearance:none; width:14px; height:14px; border-radius:50%;
  background:var(--accent); cursor:pointer; border:2px solid rgba(255,255,255,0.3);
}
.scale-val { font-size:11px; color:var(--t2); min-width:28px; text-align:right; }
.scale-val-input {
  width:42px !important; min-width:42px; max-width:42px; padding:2px 4px !important;
  font-size:11px; text-align:center; color:var(--t2);
  background:rgba(255,255,255,0.06); border:1px solid transparent !important;
  border-radius:5px; outline:none; transition:border-color .15s;
}
.scale-val-input:hover { border-color:var(--border) !important; }
.scale-val-input:focus { border-color:rgba(10,132,255,0.5) !important; color:var(--t1); background:rgba(255,255,255,0.10); }

/* Box config dropdown */
.box-cfg-btn {
  font-size:12px; cursor:pointer; color:var(--t2); padding:0 4px;
  border-radius:4px; transition:color .15s, background .15s; line-height:1; user-select:none;
}
.box-cfg-btn:hover { color:var(--t1); background:rgba(255,255,255,0.08); }
.box-cfg-pop {
  display:none; position:absolute; top:100%; left:0; right:0; z-index:100;
  background:rgba(20,20,34,0.97); backdrop-filter:blur(16px);
  border:1px solid var(--border); border-radius:8px;
  padding:6px 8px; margin-top:2px;
}
.box-cfg-pop.open { display:block; }
.box-chk-row {
  display:flex; align-items:center; gap:6px; padding:4px 2px;
  font-size:11px; font-weight:500; cursor:pointer; border-radius:4px;
}
.box-chk-row:hover { background:rgba(255,255,255,0.06); }
.box-chk-row input[type=checkbox] {
  accent-color:var(--accent); width:14px; height:14px; cursor:pointer;
}

/* Leaflet overrides */
.leaflet-container { background:#0a0a16; }
.leaflet-control-zoom { display:none; }

/* Region labels on map */
.map-region-name {
  overflow:visible !important; background:none !important; border:none !important;
  pointer-events:none !important;
}
.map-region-name span {
  display:inline-block; transform:translate(-50%,-50%);
  white-space:nowrap; font-size:12px; font-weight:600;
  color:rgba(255,255,255,0.82); font-family:-apple-system,'SF Pro Display',sans-serif;
  text-shadow:0 1px 4px rgba(0,0,0,0.95),0 0 8px rgba(0,0,0,0.8);
  letter-spacing:0.3px; pointer-events:none;
}

/* ── Landing Page ── */
.landing-overlay {
  position:fixed; inset:0; z-index:9999;
  display:flex; align-items:center; justify-content:center;
  background:radial-gradient(ellipse at 50% 40%, #0f1528 0%, #080810 70%);
  transition:opacity .4s, visibility .4s;
}
.landing-overlay.hidden { opacity:0; visibility:hidden; pointer-events:none; }
.landing-card {
  display:flex; flex-direction:column; align-items:center;
  padding:48px 44px 40px; border-radius:24px;
  background:rgba(16,16,30,0.85);
  backdrop-filter:blur(40px) saturate(180%); -webkit-backdrop-filter:blur(40px) saturate(180%);
  border:1px solid rgba(255,255,255,0.08);
  box-shadow:0 24px 80px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.04) inset;
  min-width:340px; max-width:400px;
  animation:landingIn .6s ease-out;
}
@keyframes landingIn {
  from { opacity:0; transform:translateY(24px) scale(0.96); }
  to   { opacity:1; transform:translateY(0) scale(1); }
}
.landing-icon {
  width:64px; height:64px; border-radius:18px; overflow:hidden;
  box-shadow:0 4px 20px rgba(10,132,255,0.3);
  margin-bottom:20px;
}
.landing-icon img { width:100%; height:100%; object-fit:cover; }
.landing-title {
  font-size:22px; font-weight:700; color:#fff;
  letter-spacing:1px; margin:0 0 6px;
}
.landing-desc {
  font-size:13px; color:rgba(255,255,255,0.45); margin:0 0 28px;
}
.landing-input-wrap {
  display:flex; gap:8px; width:100%;
}
.landing-input {
  flex:1; height:44px; border-radius:12px; border:1px solid rgba(255,255,255,0.12);
  background:rgba(255,255,255,0.06); color:#fff; padding:0 16px;
  font-size:15px; font-family:inherit; outline:none;
  transition:border-color .2s, box-shadow .2s;
}
.landing-input::placeholder { color:rgba(255,255,255,0.25); }
.landing-input:focus {
  border-color:rgba(10,132,255,0.6);
  box-shadow:0 0 0 3px rgba(10,132,255,0.15);
}
.landing-btn {
  height:44px; padding:0 24px; border-radius:12px; border:none;
  background:linear-gradient(135deg, #0A84FF, #0066d6);
  color:#fff; font-size:15px; font-weight:600; cursor:pointer;
  font-family:inherit; transition:transform .15s, box-shadow .15s;
}
.landing-btn:hover { transform:translateY(-1px); box-shadow:0 4px 16px rgba(10,132,255,0.4); }
.landing-btn:active { transform:translateY(0); }
.landing-hint {
  font-size:11px; color:rgba(255,255,255,0.22); margin:16px 0 0;
}

/* 移动端竖屏：隐藏logo，地名靠左，全屏+状态靠右 */
@media (max-width: 600px) and (orientation: portrait) {
  .topbar-logo { display:none; }
  .topbar-sep { display:none; }
  #btnRegion { margin-left:0 !important; }
  #btnFullscreen { margin-left:auto; }
}

/* 全屏模式：确保所有内容铺满屏幕 */
:fullscreen, :-webkit-full-screen {
  background:var(--bg);
  width:100vw !important; height:100vh !important;
  overflow:hidden;
}
::backdrop, ::-webkit-backdrop { background:var(--bg); }
:fullscreen #map, :-webkit-full-screen #map {
  position:fixed !important; inset:0 !important;
  width:100vw !important; height:100vh !important;
}
