:root {
  --bg: #0c1118;
  --panel: #141b24;
  --panel2: #1b2531;
  --line: #2a3645;
  --txt: #d7e0ea;
  --muted: #7c8a9c;
  --accent: #2f6df0;
  --accent2: #36c08a;
  --danger: #e0533d;
  --warn: #d7a452;
  --shadow: 0 8px 30px rgba(0,0,0,.45);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; width: 100%;
  background: var(--bg); color: var(--txt);
  font-family: "Segoe UI", system-ui, -apple-system, "Microsoft YaHei", sans-serif;
  overflow: hidden; touch-action: none;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }

/* ===== 加入页 ===== */
.join-screen {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start;
  background: radial-gradient(1200px 600px at 50% -10%, #16202c 0%, var(--bg) 60%);
  padding: 16px;
  overflow-y: auto;
  touch-action: pan-y;
}
.join-card { margin: 0 auto; }
.join-card {
  width: 100%; max-width: 380px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 16px; padding: 26px 22px;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.brand .logo { font-size: 34px; color: var(--accent); line-height: 1; }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: 3px; }
.brand .sub { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

/* 翻页式首页：软件介绍 / 创建小队 / 加入小队 三页切换 */
.pager { display: flex; gap: 6px; margin-bottom: 18px; }
.pager-btn {
  flex: 1; padding: 10px 6px; border: 1px solid var(--line); background: var(--panel2);
  color: var(--muted); border-radius: 10px; font-size: 13px; cursor: pointer; transition: .15s;
}
.pager-btn.active { border-color: var(--accent); background: rgba(47,109,240,.16); color: #9fc0ff; font-weight: 600; }
.pager-btn:active { transform: translateY(1px); }
.page { display: none; }
.page.active { display: block; animation: pageIn .22s ease; }
@keyframes pageIn { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: none; } }
.intro-cta { display: flex; gap: 10px; margin-top: 16px; }
.ghost-btn {
  flex: 1; padding: 11px; border: 1px solid var(--accent); border-radius: 10px;
  background: rgba(47,109,240,.12); color: #9fc0ff; font-size: 14px; cursor: pointer; transition: .15s;
}
.ghost-btn:hover { background: rgba(47,109,240,.22); color: #fff; }
.ghost-btn:active { transform: translateY(1px); }

/* 首页：创建/加入 单表单 + 软件介绍 块 */
.land-head { margin-bottom: 12px; }
.land-head h2 {
  margin: 0 0 4px; font-size: 17px; letter-spacing: 1px;
  background: linear-gradient(90deg, #fff, #9fc0ff); -webkit-background-clip: text; color: transparent;
}
.land-sub { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.45; }

.intro-list {
  list-style: none; margin: 0 0 14px; padding: 0;
  font-size: 13px; color: var(--txt); line-height: 1.7;
}
.intro-list li { position: relative; padding-left: 18px; }
.intro-list li::before {
  content: '✓'; position: absolute; left: 0; top: 1px;
  color: var(--accent2); font-size: 12px; font-weight: 700;
}
.intro-list kbd, .dl-hint kbd {
  display: inline-block; padding: 1px 5px; border-radius: 5px;
  background: #22303f; border: 1px solid var(--line);
  font-family: inherit; font-size: 11px; color: #9fc0ff;
}

.download-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 12px; margin-top: auto;
  border: 1px solid var(--accent); border-radius: 10px;
  background: rgba(47,109,240,.14); color: #9fc0ff;
  text-decoration: none; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: .15s;
}
.download-btn:hover { background: rgba(47,109,240,.24); color: #fff; }
.download-btn:active { transform: translateY(1px); }
.dl-ico { font-size: 18px; }
.dl-hint {
  margin: 8px 0 14px; font-size: 11px; color: var(--muted); text-align: center;
}

.qq-line {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 0 0 12px; padding: 8px 10px;
  background: rgba(20,27,36,.7); border: 1px solid var(--line); border-radius: 10px;
  font-size: 13px;
}
.qq-lbl { color: var(--muted); }
.qq-num {
  color: #9fc0ff; font-weight: 700; letter-spacing: .5px;
  text-decoration: none;
}
.qq-num:hover { text-decoration: underline; }
.qq-tip { color: var(--muted); font-size: 11px; margin-left: auto; }

.qr-wrap {
  margin-top: 14px; text-align: center;
  padding: 10px; background: #fff; border-radius: 10px;
}
.qr-wrap img { display: block; width: 100%; max-width: 160px; height: auto; margin: 0 auto 6px; border-radius: 6px; }
.qr-wrap p { margin: 0; font-size: 11px; color: #334; }

/* 创建 / 加入 页内提示小字（如「仅创建时可选择」） */
.hint { font-style: normal; font-size: 10px; color: var(--muted); opacity: .8; margin-left: 4px; }
.field { display: block; margin: 12px 0; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; letter-spacing: 1px; }
.field input, .field select {
  width: 100%; padding: 12px 12px; background: var(--panel2); color: var(--txt);
  border: 1px solid var(--line); border-radius: 10px; font-size: 15px; outline: none;
}
.field input:focus, .field select:focus { border-color: var(--accent); }
button.primary {
  width: 100%; margin-top: 16px; padding: 13px; border: 0; border-radius: 10px;
  background: linear-gradient(180deg, #3a7bff, #2f6df0); color: #fff;
  font-size: 16px; font-weight: 600; cursor: pointer; letter-spacing: 1px;
}
button.primary:active { transform: translateY(1px); }
.err { color: var(--danger); font-size: 13px; min-height: 16px; margin-top: 8px; }
.legal { color: var(--muted); font-size: 11px; text-align: center; margin: 14px 0 0; }

/* ===== 主视图 ===== */
#main { position: fixed; inset: 0; display: flex; flex-direction: column; }
.topbar {
  height: 48px; flex: 0 0 48px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); z-index: 5;
}
.tb-left { display: flex; align-items: baseline; gap: 10px; }
.room-code { font-weight: 700; letter-spacing: 2px; font-size: 15px; color: #fff; }
.tb-right { display: flex; align-items: center; gap: 10px; }
.mode-badge {
  font-size: 11px; padding: 3px 8px; border-radius: 20px; background: #2a3645; color: var(--muted);
}
.mode-badge.cmd { background: rgba(47,109,240,.18); color: #7fa6ff; }
.mode-badge.draw { background: rgba(54,192,138,.18); color: #6fd8a8; }
.conn { font-size: 12px; color: var(--accent2); }
.conn.off { color: var(--danger); }
button.ghost {
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  border-radius: 8px; width: 30px; height: 30px; cursor: pointer; font-size: 14px;
}
button.ghost:active { background: var(--panel2); }
/* 房主更换地图 */
.map-switch {
  height: 28px; padding: 0 6px; background: var(--panel2); color: var(--txt);
  border: 1px solid var(--line); border-radius: 8px; font-size: 12px; outline: none; cursor: pointer;
}
.map-switch:focus { border-color: var(--accent); }

.stage { position: relative; flex: 1 1 auto; overflow: hidden; background: #0a0e13; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
#map.drawing { cursor: crosshair; }
#map:active { cursor: grabbing; }
/* 删除模式：十字准星。必须盖掉 :active 的 grabbing ——
   否则按住鼠标时看着像在拖地图，实际会删掉下面的标记，很容易误删。 */
#map.erasing, #map.erasing:active { cursor: crosshair; }

/* 工具栏（指挥端） */
/* 注意：必须定位在顶栏（48px）下方。顶栏是 flex item 因而 z-index 生效，
   任何 top:12px 的浮层都会落在顶栏底下 → 看得见却点不到。 */
.toolbar {
  position: absolute; left: 12px; top: 60px; display: flex; flex-direction: column; gap: 6px;
  background: rgba(20,27,36,.92); border: 1px solid var(--line); border-radius: 12px;
  padding: 6px; backdrop-filter: blur(6px); z-index: 4; max-width: calc(100% - 24px);
}
.tb-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tb-presets { border-top: 1px solid var(--line); padding-top: 6px; }
.pz-cap { font-size: 11px; color: var(--muted); letter-spacing: 1px; padding: 0 2px; }
.presets { display: flex; gap: 5px; flex-wrap: wrap; }
.preset {
  display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 8px;
  border: 1px solid var(--line); background: var(--panel2); color: var(--txt);
  border-radius: 8px; cursor: pointer; font-size: 12px; transition: .12s;
}
.preset .pz-ico { font-size: 15px; line-height: 1; }
.preset.active { border-color: var(--accent); background: rgba(47,109,240,.2); color: #9fc0ff; }
.preset:hover { background: #22303f; border-color: #3d4d61; color: #fff; }
.preset.active:hover { border-color: #4b83ff; background: rgba(47,109,240,.3); color: #bdd3ff; }
.preset:active { transform: translateY(1px); }
.quick-label {
  height: 30px; padding: 0 10px; background: var(--panel2); color: var(--txt);
  border: 1px solid var(--line); border-radius: 8px; font-size: 12px; outline: none; min-width: 130px;
}
.quick-label:focus { border-color: var(--accent); }
.tool {
  width: 38px; height: 38px; border: 1px solid var(--line); background: var(--panel2);
  color: var(--txt); border-radius: 9px; font-size: 17px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
}
.tool.active { border-color: var(--accent); background: rgba(47,109,240,.2); color: #9fc0ff; }
.tool:hover { background: #22303f; border-color: #3d4d61; color: #fff; }
.tool.active:hover { border-color: #4b83ff; background: rgba(47,109,240,.3); color: #bdd3ff; }
.tool:active { transform: translateY(1px); }
.tool.tower-toggle { width: auto; padding: 0 10px; font-size: 12px; font-weight: 600; letter-spacing: .3px; }
.tool.tower-toggle:not(.active) { opacity: .55; background: transparent; }
.sep { width: 1px; height: 28px; background: var(--line); margin: 0 2px; }

/* ---- 工具台 收起/展开（EXE 窗口化后地图是主角，工具台必须能隐藏） ---- */
.tb-toggle { flex: 0 0 auto; width: 44px; gap: 3px; }
.tb-toggle .tb-ico { font-size: 15px; line-height: 1; }
.tb-toggle .tb-mini { display: none; font-size: 12px; letter-spacing: .5px; white-space: nowrap; }
.tb-chev { display: inline-block; font-size: 11px; line-height: 1; transition: transform .18s ease; }
.toolbar.collapsed .tb-chev { transform: rotate(180deg); }
/* 收起态：只保留 #tbToggle —— 隐藏行1 的其它控件 + 整行2 */
.toolbar.collapsed { padding: 5px; }
.toolbar.collapsed .tb-row > *:not(.tb-toggle) { display: none; }
.toolbar.collapsed .tb-row:not(:first-child) { display: none; }
.toolbar.collapsed .tb-toggle { width: auto; padding: 0 12px; gap: 7px; }
.toolbar.collapsed .tb-mini { display: inline; }

/* ---- 键盘可达性：焦点必须可见（WCAG 2.2 · 焦点外观） ---- */
button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid #8fb6ff; outline-offset: 2px;
}
.quick-label:focus-visible, .field input:focus-visible, .field select:focus-visible { outline-offset: 1px; }
.colors { display: flex; gap: 5px; }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; transition: transform .12s, border-color .12s; }
.swatch:hover { transform: scale(1.14); }
.swatch.active { border-color: #fff; }

.zoom-ctl { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 4; }
.zoom-ctl button {
  width: 40px; height: 40px; border: 1px solid var(--line); background: rgba(20,27,36,.92);
  color: var(--txt); border-radius: 10px; font-size: 20px; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.zoom-ctl button:hover { background: var(--panel2); border-color: #3d4d61; }
.zoom-ctl button:active { background: var(--panel2); transform: translateY(1px); }
.coord-readout {
  position: absolute; left: 12px; bottom: 12px; font-size: 11px; color: var(--muted);
  background: rgba(20,27,36,.8); padding: 4px 8px; border-radius: 8px; z-index: 4;
  font-variant-numeric: tabular-nums;
}
/* 还没移动过指针时不显示空占位（否则地图上多一块无意义的「—」小方块） */
.coord-readout:empty { display: none; }

/* 成员名册 */
/* 成员名册：同样必须落在顶栏下方；z-index 抬高到交互面板最高层 */
.roster {
  position: absolute; right: 12px; top: 60px; width: 248px; max-width: 60vw;
  background: rgba(20,27,36,.92); border: 1px solid var(--line); border-radius: 12px;
  backdrop-filter: blur(6px); z-index: 6; overflow: hidden;
}
.roster-head {
  display: flex; justify-content: space-between; align-items: center;
  min-height: 44px; padding: 8px 10px 8px 12px; font-size: 13px; cursor: pointer;
  border-bottom: 1px solid var(--line); user-select: none;
}
.roster-head b { color: #fff; }
/* 折叠指示：给足触摸命中区（原先 ▾ 只有 7×20px，手机点不中） */
.chev {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; margin: -5px -4px -5px 0; flex: 0 0 auto;
  border-radius: 7px; color: var(--muted); font-size: 13px; line-height: 1;
  transition: transform .16s ease, background .16s;
}
.roster-head:hover .chev { background: var(--panel2); color: var(--txt); }
.roster.collapsed .chev { transform: rotate(-90deg); }
#members { list-style: none; margin: 0; padding: 6px; max-height: 42vh; overflow-y: auto; }
#members li { display: flex; align-items: center; gap: 8px; padding: 6px 6px; border-radius: 8px; }
#members li:hover { background: var(--panel2); }
.m-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.m-name { flex: 1 1 auto; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-func { font-size: 10px; padding: 1px 6px; border-radius: 10px; background: #2a3645; color: var(--muted); }
.m-role { font-size: 10px; color: var(--warn); }
.m-cmd { color: var(--accent2); }
.m-perm {
  flex: 0 0 auto; width: 22px; height: 22px; padding: 0; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel2); color: var(--txt);
  font-size: 11px; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
}
.m-perm:hover { border-color: var(--accent); }
.m-perm.on { background: rgba(54,192,138,.18); border-color: var(--accent2); }
.m-kick {
  flex: 0 0 auto; width: 22px; height: 22px; padding: 0; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel2); color: var(--muted);
  font-size: 10px; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
}
.m-kick:hover { border-color: var(--danger); color: var(--danger); background: rgba(224,83,61,.14); }
.m-crown {
  flex: 0 0 auto; width: 22px; height: 22px; padding: 0; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel2); color: var(--txt);
  font-size: 11px; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
}
.m-crown:hover { border-color: var(--warn); background: rgba(215,164,82,.16); }
.m-tag { font-size: 10px; padding: 1px 6px; border-radius: 10px; background: rgba(54,192,138,.16); color: #6fd8a8; flex: 0 0 auto; }
.m-tag.ro { background: rgba(124,138,156,.18); color: #9aa6b3; }
.roster.collapsed #members { display: none; }

/* 只读入口提示 */
.ro-mode {
  display: flex; align-items: center; gap: 6px; margin: 0 0 14px;
  padding: 9px 12px; border-radius: 10px; font-size: 12px;
  background: rgba(54,192,138,.1); border: 1px solid rgba(54,192,138,.32); color: #7fe0b4;
}
.field input.locked { background: #10161d; color: var(--muted); cursor: not-allowed; letter-spacing: 2px; }

/* 被移出房间 */
.kick-screen {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  background: rgba(8,12,18,.9); backdrop-filter: blur(4px);
}
.kick-card {
  background: var(--panel); border: 1px solid var(--danger); border-radius: 14px;
  padding: 26px 30px; text-align: center; box-shadow: var(--shadow); max-width: 320px;
}
.kick-card .kick-ico { font-size: 34px; line-height: 1; margin-bottom: 10px; }
.kick-card p { margin: 0; font-size: 14px; color: var(--txt); }

/* 轻提示 */
.toast {
  position: fixed; left: 50%; top: 60px; transform: translateX(-50%);
  background: rgba(20,27,36,.97); border: 1px solid var(--accent2); color: var(--txt);
  padding: 9px 16px; border-radius: 10px; font-size: 13px; z-index: 30;
  box-shadow: var(--shadow); pointer-events: none;
}

/* ===== 移动端 ===== */
@media (max-width: 640px) {
  .join-card { padding: 18px 14px; }
  .land-head h2 { font-size: 16px; }
  .intro-list { font-size: 12px; }
  .qq-tip { width: 100%; margin-left: 0; margin-top: 2px; }
  .qr-wrap { max-width: 220px; margin: 0 auto; }
  /* 名册贴底展开，z-index 高于工具栏，保证头部（含 ▾）永远可点 */
  .roster { top: auto; bottom: 12px; right: 12px; left: 12px; width: auto; max-width: none; z-index: 6; }
  .roster-head { min-height: 48px; }
  .chev { width: 40px; height: 40px; font-size: 15px; margin: -8px -6px -8px 0; }
  .roster #members { max-height: 30vh; }
  .coord-readout { top: auto; bottom: 64px; left: 12px; right: auto; }
  .zoom-ctl { bottom: auto; top: 60px; }
  /* 工具台：左上角固定（顶栏下方），不再浮到屏幕中央；名册在底部全宽，互不遮挡 */
  .toolbar { top: 60px; left: 12px; right: auto; bottom: auto; max-width: calc(100vw - 24px); }
  /* 顶栏：房主换图控件与地图名不能挤爆 */
  .map-switch { max-width: 32vw; }
  .map-name { max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tb-left { gap: 6px; }
  .tb-right { gap: 6px; }
  /* 收起后的胶囊给足手指命中区 */
  .toolbar.collapsed .tb-toggle { min-height: 44px; padding: 0 14px; }
}

/* 尊重系统「减少动态效果」偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ===== 浮层 / 小地图（Windows EXE 专用） =====
   由 URL 参数 ?hud=1 / ?mini=1 或 C# 侧调用 window.SquadOpsSetChrome(false) 触发。
   注意：class 打在 <html> 上（不是 body），因为背景色在 html 与 body 上都有，
   只改 body 的话 html 那一层的底色还在，透明就不彻底。 */

/* 浮层：剥掉所有面板，背景透明 —— 叠在游戏画面上时只看到地图和标记 */
html.hud, html.hud body { background: transparent; }
html.hud .topbar,
html.hud .toolbar,
html.hud .roster,
html.hud .coord-readout,
html.hud .zoom-ctl { display: none !important; }
/* 登录卡片还得看得见（要输房间码），但背后的渐变底要透明 */
html.hud .join-screen { background: transparent; }

/* 小地图：整图缩略 + 只读，同样不要任何交互外壳。
   背景保留实色 —— 小地图是独立小窗，透明反而看不清。 */
html.mini { background: var(--bg); }
html.mini .topbar,
html.mini .toolbar,
html.mini .roster,
html.mini .coord-readout,
html.mini .zoom-ctl { display: none !important; }
html.mini #map { cursor: default; }
/* 还没进房间时别让加入页糊住小窗 */
html.mini .join-screen { background: var(--bg); }
html.mini .join-card { max-width: 100%; border: 0; box-shadow: none; background: transparent; padding: 8px; }
html.mini .brand { display: none; }
