/* 潇洒大乱斗 — HUD 样式
   🔴 移动端三套布局（GDD 06[S10] ⑤ / world-ui-visual §8.4）
   🔴 安全区适配（§8.5）：iOS 刘海屏 + home indicator
   🔴 可点击区域 ≥ 44×44（§8.6）
   🔴 不用 backdrop-filter（§5.3）：移动端性能差
*/
:root {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);

  --glass: rgba(16, 22, 38, 0.72);
  --glass-lite: rgba(16, 22, 38, 0.42);
  --border: rgba(180, 210, 255, 0.16);
  --text: #E8F0FF;
  --text-dim: #9FB4D0;
  --accent: #7FD4F0;
  --gold: #FFD447;
  --danger: #FF6B6B;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  width: 100%; height: 100%;
  overflow: hidden;
  background: #0b1020;
  color: var(--text);
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  user-select: none; -webkit-user-select: none;
}

#game {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
}

/* ============================================================
   进入页
   ============================================================ */

/*
 * 🔴 进入页容器 —— 曾出现"整个面板右移、右侧内容被裁"的严重布局 bug
 *
 * 根因（headless Chrome 360px 实测，左留白 143px / 右留白 3px）：
 *   `#gate` 同时是 `display:flex`（居中子元素）**和** `overflow-y:auto`（滚动容器）。
 *   滚动容器出现纵向滚动条时会占掉内容盒右侧 15px，
 *   flex 居中的参照宽度随之变窄、居中点左移 —— 整体偏右且右侧被裁。
 *
 * 修法（采用 flex + margin:auto 的经典方案，绕开滚动条占位）：
 *   `margin:auto` 在 flex 容器里可以让子元素**双向居中且不溢出**，
 *   与 `justify-content:center` 的区别在于：内容过宽时它会**溢出两侧**
 *   而不是单侧被裁。
 */
#gate {
  position: fixed; inset: 0;
  z-index: 100;
  display: flex;
  overflow-y: auto;
  background: radial-gradient(ellipse at 50% 30%, #1E2A44, #0B1020 70%);
}
#gate.hidden { display: none; }

.gate-inner {
  margin: auto;                /* 🔴 双向自动外边距 = 居中且不裁 */
  width: calc(100% - 32px);    /* 左右各留 16px 视觉安全区 */
  max-width: 420px;
  box-sizing: border-box;
  min-width: 0;
  flex: 0 1 auto;              /* 允许收缩，避免内容撑破容器 */
  text-align: center;
}

/*
 *（.gate-inner 的规则已合并进上面 #gate 段落，用绝对定位居中法）
 * （另有窄屏压缩见 @media (max-width: 400px)）
 */

#gate h1 {
  margin: 0 0 6px;
  font-size: 30px; font-weight: 800;
  letter-spacing: 2px;
  background: linear-gradient(90deg, #FFD98A, #FFB03A, #F2545B);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.gate-sub { margin: 0 0 20px; color: var(--text-dim); font-size: 13px; }

.pick {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;   /* 🔴 窄屏放不下就换行，绝不整体溢出（见下方注释） */
}
/*
 * 🔴 布局修复：按钮曾把文字挤出边框（截图里「影客」掉到按钮外、「铁砚」被压扁）
 *
 * 根因三条，缺一不可：
 *   ① min-width:0 —— flex 子项默认 min-width:auto，会被内容撑破，
 *      导致 flex:1 的等分宽度失效。这是「文字溢出按钮」的直接原因。
 *   ② flex-wrap:wrap —— 极窄屏（如 320px）三列必然放不下，允许换行而非压扁。
 *   ③ .cls b / .cls i 加 overflow-wrap —— 长文案不撑破容器。
 *
 * 不用 aspect-ratio/固定高度：中文文案长度不一，固定高度在窄屏会二次截断。
 */
.cls {
  flex: 1 1 0;
  min-width: 0;          /* ① 关键：允许收缩到内容以下，flex 等分才生效 */
  min-height: 96px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px;
  padding: 12px 8px;
  background: var(--glass-lite);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.cls b {
  font-size: 15px;
  /* ③ 不撑破容器 */
  overflow-wrap: anywhere;
}
.cls i {
  font-size: 10px; font-style: normal; color: var(--text-dim); line-height: 1.3;
  max-width: 100%;       /* ③ 描述文字不超出按钮 */
  overflow-wrap: anywhere;
}
.cls.sel { border-color: var(--accent); background: rgba(127, 212, 240, 0.12); }

/*
 * 🔴 窄屏断点：≤400px 时三列会被挤成极窄的条（"影客"整列被裁掉）。
 *    改为**两列 + 第三个独占一行**，保证每个按钮都有可点的宽度。
 *    用 flex-basis 而非固定像素，避免与 padding/gap 叠加产生溢出。
 */
@media (max-width: 400px) {
  .pick { gap: 8px; }
  .cls { flex: 1 1 calc(50% - 4px); min-height: 84px; padding: 10px 6px; }
  /* 第三个按钮独占整行，避免变成三行把「开始」按钮挤出首屏 */
  .cls:last-child { flex-basis: 100%; }
  /*
   * 🔴 窄屏纵向压缩：进入页内容总高超过 800px 时会出现纵向滚动条，
   *    滚动条占位又会引发横向溢出（见 #gate 的说明）。
   *    这里整体收紧字号与间距，让内容在 640px 高度内放下，从根上避免滚动条。
   */
  #gate { padding-top: calc(10px + var(--sat)); padding-bottom: calc(10px + var(--sab)); }
  #gate h1 { font-size: 24px; margin-bottom: 4px; }
  .gate-sub { font-size: 12px; margin-bottom: 14px; }
  .cls { min-height: 74px; gap: 4px; }
  .cls b { font-size: 14px; }
  .nick { margin-bottom: 10px; }
  .gate-hint { margin-top: 10px; font-size: 10px; line-height: 1.6; }
}

/* 🔴 三职业形状编码（可访问性硬需求：不依赖颜色） */
.shape { width: 16px; height: 16px; display: inline-block; }
.shape-tieyan { background: #E8A33D; border-radius: 2px; }
.shape-yanxing {
  background: #F2545B;
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
  border-radius: 0;
}
.shape-yingke {
  background: #9B6BFF;
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
  border-radius: 0;
}

.nick {
  display: block; text-align: left;
  font-size: 12px; color: var(--text-dim);
  margin-bottom: 12px;
}
.nick input {
  display: block; width: 100%;
  margin-top: 4px; padding: 10px 12px;
  font: inherit; font-size: 15px;
  color: var(--text);
  background: var(--glass-lite);
  border: 1px solid var(--border);
  border-radius: 8px;
  /* 🔴 聊天无输入框，但昵称输入是允许的（进场前，不是战斗中） */
  outline: none;
}
.nick input:focus { border-color: var(--accent); }

.opts {
  display: flex; gap: 14px; justify-content: center;
  font-size: 12px; color: var(--text-dim);
  margin-bottom: 18px;
}
.opts label { display: flex; align-items: center; gap: 4px; cursor: pointer; }

.play {
  width: 100%; min-height: 52px;
  font: inherit; font-size: 17px; font-weight: 700;
  color: #0b1020;
  background: linear-gradient(90deg, #FFD98A, #FFB03A);
  border: none; border-radius: 12px;
  cursor: pointer;
}
.play:active { transform: scale(0.98); }
.play:disabled { opacity: .5; cursor: not-allowed; }

.gate-status { min-height: 18px; margin: 10px 0 0; font-size: 12px; color: var(--danger); }
.gate-hint { margin: 14px 0 0; font-size: 11px; color: var(--text-dim); line-height: 1.7; }

/* ============================================================
   HUD 根
   ============================================================ */

#hud {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 10;
}
#hud button { pointer-events: auto; }

/* ---------- 血条组（左上） ---------- */

.hud-hp {
  position: absolute;
  top: calc(12px + var(--sat)); left: calc(12px + var(--sal));
  width: 220px;
  padding: 7px 9px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.hp-bar {
  position: relative;
  height: 14px;
  background: rgba(0, 0, 0, .45);
  border-radius: 7px;
  overflow: hidden;
}
.hp-fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #3FD8C0, #7FD4F0);
  transition: width .18s ease-out;
}
.hp-text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,.8);
}
.lv-text {
  margin-top: 3px;
  font-size: 11px; color: var(--text-dim);
  text-align: center;
}
/* 🔴 无敌保护期闪烁提示（GDD 06[S5] ②） */
.hud-hp.prot { animation: protBlink .5s infinite alternate; }
@keyframes protBlink {
  from { box-shadow: 0 0 0 0 rgba(127,212,240,0); }
  to   { box-shadow: 0 0 0 3px rgba(127,212,240,.55); }
}

/* ---------- 积分 ---------- */

.hud-score {
  position: absolute;
  top: calc(12px + var(--sat)); left: 50%;
  transform: translateX(-50%);
  padding: 5px 16px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-align: center;
  min-width: 92px;
}
.score-val { font-size: 19px; font-weight: 800; color: var(--gold); line-height: 1.1; }
.score-label { font-size: 9px; color: var(--text-dim); }

/* ---------- 昼夜条 ---------- */

.hud-daynight {
  position: absolute;
  top: calc(74px + var(--sat)); left: 50%;
  transform: translateX(-50%);
  width: 130px; height: 5px;
  background: rgba(0,0,0,.45);
  border-radius: 3px; overflow: hidden;
}
.day-fill { height: 100%; width: 50%; }

/* ---------- 技能栏 ---------- */

.hud-skills {
  position: absolute;
  display: grid;
  gap: 8px;
  pointer-events: none;
}
.skill-slot {
  position: relative;
  width: 52px; height: 52px;
  background: var(--glass-lite);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.skill-slot.ready { border-color: rgba(127,212,240,.5); }
.skill-slot.cooling { opacity: .55; }
.skill-slot.locked { border-style: dashed; opacity: .7; }
.skill-icon { font-size: 22px; line-height: 1; }
.skill-cd {
  position: absolute; bottom: 2px; right: 4px;
  font-size: 10px; font-weight: 700; color: var(--gold);
}
/* 🔴 第 3 槽必须渲染 "Lv10" 文字（美术 §9.9：否则玩家以为是 bug） */
.skill-lock {
  font-size: 11px; font-weight: 700;
  color: var(--text-dim);
}

/* ---------- 排行榜 ---------- */

.hud-leaderboard {
  position: absolute;
  right: calc(16px + var(--sar));
  top: 50%; transform: translateY(-50%);
  width: 178px;
  padding: 7px 8px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 11px;
}
.lb-title { color: var(--text-dim); font-size: 10px; margin-bottom: 4px; }
.lb-rows { max-height: 190px; overflow: hidden; }
.lb-row { display: flex; align-items: center; gap: 5px; height: 20px; }
.lb-rank { width: 16px; text-align: right; color: var(--text-dim); font-size: 10px; }
.lb-shape { width: 8px; height: 8px; flex: none; }
.shape-tieyan { background: #E8A33D; border-radius: 1px; }
.shape-yanxing { background: #F2545B; clip-path: polygon(50% 0%,100% 100%,0% 100%); }
.shape-yingke { background: #9B6BFF; clip-path: polygon(50% 0%,100% 50%,50% 100%,0% 50%); }
.lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-lv { color: var(--text-dim); font-size: 9px; }
.lb-score { color: var(--gold); font-weight: 700; width: 30px; text-align: right; }
/* 🔴 20 名外仍能看到自己（GDD 06[S9] ②） */
.lb-self {
  margin-top: 5px; padding-top: 5px;
  border-top: 1px solid var(--border);
  color: var(--accent); font-weight: 700; font-size: 11px;
}

/* ---------- 聊天 ---------- */

.hud-chat {
  position: absolute;
  left: calc(12px + var(--sal));
  bottom: calc(14px + var(--sab));
  max-width: 320px;
  transition: max-height .2s;
}
.chat-phrases {
  display: flex; flex-wrap: wrap; gap: 5px;
  pointer-events: auto;
}
.phrase {
  /* 🔴 可点击区域 ≥ 44×44 的折中：视觉小，命中区用 padding 撑到 40px 高 */
  min-height: 40px; padding: 8px 11px;
  font: inherit; font-size: 12px;
  color: var(--text);
  background: var(--glass-lite);
  border: 1px solid var(--border);
  border-radius: 18px;
  cursor: pointer;
}
.phrase:active { background: rgba(127,212,240,.22); }
.chat-log {
  margin-top: 5px;
  max-height: 84px; overflow-y: auto;
  font-size: 11px; line-height: 1.5;
  pointer-events: none;
}
.chat-name { color: var(--accent); }
.chat-text { color: var(--text); }
/* 🔴 有敌人 400px 内时聊天区收起为细边（GDD 06[S11] ⑤） */
.hud-chat.collapsed .chat-log,
.hud-chat.collapsed .chat-phrases { display: none; }
.hud-chat.collapsed {
  height: 24px; overflow: hidden;
  border-top: 1px solid var(--border);
  opacity: .5;
}

/* ---------- 攻击按钮 ---------- */

.hud-atk {
  position: absolute;
  width: 68px; height: 68px;
  border-radius: 50%;
  background: rgba(16,22,38,.42);
  border: 2px solid rgba(180,210,255,.30);
  color: var(--text);
  font-size: 26px;
  display: flex; align-items: center; justify-content: center;
  pointer-events: auto;
  cursor: pointer;
}
.hud-atk:active {
  transform: scale(.92);
  border-color: rgba(127,212,240,.6);
}

/* ---------- 击杀播报 ---------- */

.killfeed {
  position: absolute;
  top: 34%; left: 50%;
  transform: translateX(-50%);
  padding: 6px 16px;
  background: rgba(16,22,38,.8);
  border: 1px solid rgba(217,58,43,.5);
  border-radius: 20px;
  font-size: 13px; font-weight: 700;
  color: #FFD98A;
  opacity: 0;
  transition: opacity .25s;
  white-space: nowrap;
}

/* ---------- 提示 / 网络状态 ---------- */

.hud-hint {
  position: absolute;
  left: 50%; bottom: calc(10px + var(--sab));
  transform: translateX(-50%);
  font-size: 11px; color: var(--text-dim);
  white-space: nowrap;
}
.hud-net {
  position: absolute;
  left: calc(12px + var(--sal));
  top: calc(96px + var(--sat));
  font-size: 10px; color: var(--text-dim);
}
.hud-net.bad { color: var(--danger); }

/* ============================================================
   移动端布局（GDD 06[S12] ①：竖屏 + 横屏都要能玩）
   ============================================================ */

@media (max-width: 520px) {
  .hud-hp { width: 168px; }
  .hud-score { padding: 4px 12px; }
  .score-val { font-size: 16px; }
  .hud-leaderboard {
    /* 🔴 竖屏：排行榜改半宽抽屉，避免遮挡 */
    width: 150px;
    right: calc(8px + var(--sar));
    font-size: 10px;
  }
  .lb-rows { max-height: 120px; }
  .hud-chat { max-width: calc(100vw - 24px); bottom: calc(96px + var(--sab)); }
  .phrase { min-height: 40px; font-size: 11px; padding: 8px 9px; }
  .chat-log { max-height: 50px; }
  .hud-atk {
    /* 🔴 必须加 safeBottom：否则被 iOS home indicator 压住 24px */
    right: calc(14px + var(--sar));
    bottom: calc(14px + var(--sab));
    width: 64px; height: 64px;
  }
}

/* 横屏 */
@media (orientation: landscape) and (max-height: 520px) {
  .hud-hp { width: 180px; padding: 5px 8px; }
  .hud-leaderboard {
    top: calc(12px + var(--sat));
    transform: none;
    width: 148px;
    max-height: 150px;
  }
  .lb-rows { max-height: 84px; }
  .hud-chat { bottom: calc(8px + var(--sab)); max-width: 260px; }
  .chat-log { max-height: 34px; }
  .hud-atk {
    right: calc(12px + var(--sar));
    bottom: calc(10px + var(--sab));
  }
  .hud-hint { display: none; }
}

/* 极窄屏（320px）：HUD 元素不许重叠 */
@media (max-width: 340px) {
  .hud-hp { width: 140px; }
  .hud-score { min-width: 70px; padding: 3px 9px; }
  .score-val { font-size: 14px; }
  .hud-leaderboard { width: 128px; font-size: 9px; }
}

/* 桌面 */
@media (min-width: 1024px) {
  .hud-skills {
    bottom: calc(18px + var(--sab));
    left: 50%; transform: translateX(-50%);
    grid-template-columns: repeat(5, 50px);
  }
  .hud-atk { display: none; }   /* 桌面用空格攻击 */
  .hud-chat { max-width: 360px; }
}

/* 移动端技能栏定位 */
@media (max-width: 1023px) and (orientation: portrait) {
  .hud-skills {
    right: calc(124px + var(--sar));
    bottom: calc(240px - var(--sab));
    grid-template-columns: repeat(2, 52px);
  }
}
@media (max-width: 1023px) and (orientation: landscape) {
  .hud-skills {
    right: calc(150px + var(--sar));
    bottom: calc(80px - var(--sab));
    grid-template-columns: repeat(3, 46px);
  }
  .skill-slot { width: 46px; height: 46px; }
}
/* ============================================================
   Boss / 神秘商人 / 商店（本批新增）
   🔴 沿用 §5.3玻璃拟态统一配方：渐变 + 半透明底色，**不用 backdrop-filter**
   🔴 可点击区域 ≥ 44×44（§8.6）
   ============================================================ */

/* ---------- 全服公告条（GDD 03 §2.1 / §4.1） ---------- */
.hud-announce {
  position: absolute;
  top: calc(64px + var(--sat));
  left: 50%;
  transform: translateX(-50%);
  max-width: 82vw;
  padding: 6px 16px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  color: var(--text);
  background: linear-gradient(180deg, rgba(255,255,255,0.07) 0%, rgba(255,255,255,0) 40%),
              rgba(16, 22, 38, 0.82);
  border: 1px solid var(--border);
  border-radius: 10px;
  opacity: 0;
  transition: opacity 0.35s ease-out;
  pointer-events: none;
  z-index: 20;
}
/* Boss 播报 18px + 主色（美术 §5.6「最高光时刻放大」） */
.hud-announce.boss {
  font-size: 18px;
  font-weight: 700;
  color: var(--gold);
  border-color: rgba(255, 212, 71, 0.4);
}

/* ---------- 金币 ---------- */
.hud-gold {
  position: absolute;
  top: calc(46px + var(--sat));
  right: calc(16px + var(--sar));
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--gold);
  background: rgba(16, 22, 38, 0.72);
  border: 1px solid rgba(255, 212, 71, 0.22);
  border-radius: 8px;
  pointer-events: none;
  z-index: 12;
}

/* ---------- 移动端交互按钮 ✋（美术 §8.3） ---------- */
.touch-interact {
  position: absolute;
  width: 48px; height: 48px;
  margin-left: -24px;
  margin-top: -24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text);
  background: rgba(16, 22, 38, 0.44);
  border: 1.5px solid rgba(180, 210, 255, 0.30);
  z-index: 15;
  pointer-events: auto;
  user-select: none;
}
.touch-interact:active {
  border-color: rgba(127, 212, 240, 0.60);
}

/* ---------- 商店面板 ---------- */
.shop-panel {
  position: absolute;
  right: calc(16px + var(--sar));
  bottom: calc(90px + var(--sab));
  width: 320px;
  max-width: 92vw;
  max-height: 68vh;
  display: flex;
  flex-direction: column;
  padding: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.07) 0%, rgba(255,255,255,0) 40%),
              rgba(16, 22, 38, 0.90);
  border: 1px solid var(--border);
  border-radius: 10px;
  z-index: 40;
}
.shop-title { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.shop-gold {
  font-size: 12px; color: var(--gold); margin-bottom: 8px;
  font-weight: 600;
}
.shop-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.shop-tab {
  min-width: 44px; min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
  color: var(--text-dim);
  background: rgba(24, 32, 52, 0.85);
  border: 1px solid rgba(180, 210, 255, 0.18);
  border-radius: 6px;
  cursor: pointer;
}
.shop-tab.sel { color: var(--accent); border-color: var(--accent); }
.shop-list { overflow-y: auto; flex: 1 1 auto; }
.shop-sub {
  font-size: 11px; color: var(--text-dim);
  margin: 4px 0 6px;
}
.shop-card {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.shop-card.soldout { opacity: 0.5; }
.shop-card.owned { opacity: 0.65; }
.shop-icon {
  width: 20px; height: 20px;
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: #0b1020;
  border-radius: 4px;
}
.shop-name { flex: 1 1 auto; font-size: 12px; }
.shop-desc { font-size: 10px; color: var(--text-dim); flex: 1 1 auto; }
.shop-price { font-size: 12px; color: var(--gold); white-space: nowrap; }
.shop-buy, .shop-try {
  min-width: 44px; min-height: 30px;
  padding: 4px 8px;
  font-size: 12px;
  color: var(--text);
  background: rgba(127, 212, 240, 0.18);
  border: 1px solid rgba(127, 212, 240, 0.55);
  border-radius: 6px;
  cursor: pointer;
}
.shop-try {
  min-width: 40px;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(180, 210, 255, 0.28);
}
.shop-hint {
  margin-top: 8px;
  font-size: 10px;
  color: var(--text-dim);
  line-height: 1.5;
}
.shop-close {
  align-self: flex-end;
  min-width: 44px; min-height: 30px;
  margin-top: 8px;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(180, 210, 255, 0.28);
  border-radius: 6px;
  cursor: pointer;
}

/* 移动端：商店全屏抽屉（美术 §8.4：竖屏右侧 280px 太宽） */
@media (max-width: 520px) {
  .shop-panel {
    right: 0; left: 0;
    width: 100%;
    max-width: none;
    bottom: calc(24px + var(--sab));
    max-height: 72vh;
  }
}

/* ============================================================
   🔴 排行榜面板（当前局 / 历史 两个 Tab）
   美术规格：world-ui-visual.md §5.5
   🔴 自己那行（20 名外）固定在底部并高亮 —— GDD 05 §3.1 强制要求
   ⚠️ 不用 backdrop-filter（移动端性能，§5.3）
   ⚠️ 不用 box-shadow —— 用内高光代替
   ============================================================ */

#board {
  position: absolute;
  right: calc(16px + var(--sar));
  top: 50%; transform: translateY(-50%);
  width: 186px;
  padding: 7px 8px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 11px;
  pointer-events: auto;
  z-index: 6;
}

.bd-tabs { display: flex; gap: 4px; margin-bottom: 5px; }
.bd-tab {
  flex: 1;
  min-height: 26px;                 /* 移动端可点区域 */
  padding: 5px 6px;
  font: inherit; font-size: 11px;
  color: var(--text-dim);
  background: var(--glass-lite);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}
.bd-tab.on {
  color: var(--text);
  border-bottom: 2px solid var(--accent);
}

.bd-rows { max-height: 208px; overflow: hidden; }

/* 行高 26px（美术 §5.5） */
.bd-row {
  display: flex; align-items: center; gap: 5px;
  height: 26px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.bd-rank { width: 20px; text-align: right; color: var(--text-dim); font-size: 10px; }
.bd-shape { width: 8px; height: 8px; flex: none; }
.bd-name {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bd-lv { color: var(--text-dim); font-size: 9px; flex: none; }
.bd-score { color: var(--gold); font-weight: 700; text-align: right; flex: none; }
.bd-date { color: var(--text-dim); font-size: 9px; flex: none; width: 26px; text-align: right; }

/* 🔴 前 3 名排名数字染色（美术 §5.5） */
.bd-row.top1 .bd-rank { color: #FFD447; font-weight: 700; }
.bd-row.top2 .bd-rank { color: #C8D4E0; font-weight: 700; }
.bd-row.top3 .bd-rank { color: #D8945A; font-weight: 700; }

/* 历史榜里自己的那一行 */
.bd-row.me { background: rgba(127, 212, 240, 0.14); }

/* 🔴 自己那行：20 名外也**必须**显示（GDD 05 §3.1 强制） */
.bd-self {
  display: flex; align-items: center; gap: 5px;
  margin-top: 5px; padding-top: 5px;
  border-top: 1px solid var(--border);
  background: rgba(127, 212, 240, 0.14);
  border-left: 3px solid rgba(127, 212, 240, 0.8);
  border-radius: 4px;
  padding-left: 4px;
  height: 26px;
  color: var(--accent); font-weight: 700; font-size: 11px;
}
/* 🔴 前 20 名外：更醒目，因为那是"你追不上前面"的诚实提示 */
.bd-self.out {
  background: rgba(255, 212, 71, 0.16);
  border-left-color: rgba(255, 212, 71, 0.9);
  color: var(--gold);
}

.bd-empty {
  color: var(--text-dim); font-size: 10px;
  padding: 12px 4px; text-align: center;
}

/* ---------- 观战工具条 ---------- */

.spec-bar {
  position: absolute;
  left: 50%; transform: translateX(-50%);
  top: calc(10px + var(--sat));
  display: flex; align-items: center; gap: 5px;
  padding: 5px 7px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 10px;
  pointer-events: auto;
  z-index: 7;
}
.spec-badge {
  color: var(--accent);
  font-size: 11px; font-weight: 700;
  padding-right: 5px;
  max-width: 168px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.spec-btn {
  min-height: 32px;                  /* 移动端可点区域 */
  min-width: 44px;
  padding: 6px 10px;
  font: inherit; font-size: 12px;
  color: var(--text);
  background: rgba(127, 212, 240, 0.18);
  border: 1px solid rgba(127, 212, 240, 0.55);
  border-radius: 8px;
  cursor: pointer;
}
.spec-btn:disabled {
  color: var(--text-dim);
  background: var(--glass-lite);
  border-color: var(--border);
  cursor: default;
}
.spec-exit {
  color: #FFD9D9;
  background: rgba(217, 58, 43, 0.22);
  border-color: rgba(217, 58, 43, 0.6);
}

/* ---------- 移动端断点（对齐既有三档布局，world-ui-visual §8.4） ---------- */

@media (max-width: 520px) {
  #board { width: 138px; font-size: 10px; right: calc(8px + var(--sar)); }
  .bd-rows { max-height: 132px; }
  .bd-row { height: 22px; }
  .bd-date { display: none; }
  .spec-btn { min-height: 36px; min-width: 46px; font-size: 13px; }
  .spec-badge { max-width: 108px; font-size: 10px; }
}

@media (max-width: 360px) {
  #board { width: 120px; }
  .bd-rows { max-height: 108px; }
  .spec-bar { gap: 3px; padding: 4px; }
  .spec-badge { display: none; }   /* 极窄屏优先保按钮可点 */
}

/* ============================================================
   新手引导（B4）
   🔴 核心原则：**不遮挡游戏视野**。
      引导层整体 pointer-events:none，只有卡片和按钮可点，
      玩家随时能操作游戏 —— 边玩边学，而不是被弹窗拦住。
   🔴 不用 backdrop-filter（美术 §5.3：移动端性能差）。
   ============================================================ */

.tut {
  position: fixed; inset: 0;
  z-index: 60;                 /* 高于 HUD(50) / 观战条，低于进入页(100) */
  display: none;
  pointer-events: none;
  font-size: 14px;
}
.tut.on { display: block; }

/* 高亮脉冲圈 —— 只描边不填充，视野不受遮挡 */
.tut-ring {
  position: fixed;
  display: none;
  border: 2px solid var(--accent);
  box-shadow:
    0 0 0 2px rgba(127, 212, 240, 0.25),
    inset 0 0 12px rgba(127, 212, 240, 0.18);
  animation: tutPulse 1.5s ease-in-out infinite;
  pointer-events: none;
}
@keyframes tutPulse {
  0%, 100% { border-color: var(--accent); }
  50%      { border-color: rgba(255, 212, 71, 0.9); }
}

/* 🔴 卡片贴底部（移动端拇指区上方），不遮中央战场 */
.tut-card {
  position: fixed;
  left: 50%; bottom: calc(96px + var(--sab));
  transform: translateX(-50%);
  width: min(460px, calc(100% - 24px));
  padding: 14px 16px;
  background: rgba(16, 22, 38, 0.94);
  border: 1px solid rgba(180, 210, 255, 0.28);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
}
.tut.pop .tut-card { animation: tutIn .28s ease-out; }
@keyframes tutIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.tut-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.tut-head b { font-size: 16px; color: var(--accent); }
.tut-head span { font-size: 11px; color: var(--text-dim); margin-left: auto; }
.tut-text { margin: 0 0 6px; font-size: 13px; line-height: 1.6; }
.tut-tip  { margin: 0 0 10px; font-size: 11px; color: var(--text-dim); }
.tut-tip:empty { display: none; }

.tut-btns { display: flex; gap: 8px; }
.tut-skip, .tut-next {
  font: inherit; font-size: 13px;
  min-height: 38px; padding: 0 14px;
  border-radius: 9px; cursor: pointer;
}
.tut-skip {
  color: var(--text-dim);
  background: transparent;
  border: 1px solid rgba(180, 210, 255, 0.2);
}
.tut-next {
  margin-left: auto;
  color: #0b1020; font-weight: 700;
  background: linear-gradient(90deg, var(--accent), #5BC8E8);
  border: none;
}

/* ---------- 进入页「玩法说明」面板 ---------- */
.gate-help {
  position: fixed; inset: 0;
  z-index: 120;                /* 高于 #gate(100) */
  padding: 24px 16px;
  overflow-y: auto;
  background: rgba(8, 12, 24, 0.96);
}
.gate-help h2 {
  margin: 0 0 16px;
  font-size: 18px; text-align: center; color: var(--accent);
}
.gate-help-list {
  max-width: 460px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 8px;
}
.gate-help-row {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 9px 11px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(180, 210, 255, 0.12);
  border-radius: 9px;
}
.gate-help-row b {
  flex: 0 0 52px;
  font-size: 13px; color: var(--gold);
}
.gate-help-row span {
  font-size: 12px; color: var(--text); line-height: 1.55;
}
.gate-help-tip {
  max-width: 460px; margin: 14px auto 0;
  font-size: 12px; line-height: 1.6; color: var(--text-dim);
}
.gate-help-close {
  display: block; margin: 18px auto 0;
  min-height: 42px; padding: 0 28px;
  font: inherit; font-size: 14px; font-weight: 700;
  color: #0b1020;
  background: linear-gradient(90deg, var(--accent), #5BC8E8);
  border: none; border-radius: 10px; cursor: pointer;
}

/* ---------- 进入页「玩法说明」按钮 ---------- */
.gate-help-btn {
  display: block;
  margin: 0 auto 14px;
  min-height: 40px; padding: 0 18px;
  font: inherit; font-size: 13px;
  color: var(--accent);
  background: transparent;
  border: 1px solid rgba(127, 212, 240, 0.42);
  border-radius: 10px; cursor: pointer;
}
.gate-help-btn:active { background: rgba(127, 212, 240, 0.12); }

@media (max-width: 400px) {
  .tut-card { bottom: calc(88px + var(--sab)); padding: 12px 13px; }
  .tut-text { font-size: 12px; }
  .tut-head b { font-size: 15px; }
  .gate-help-row b { flex-basis: 46px; }
}

/* ============================================================
   单机版专属
   ============================================================ */

.gate-save {
  display: flex; gap: 8px; justify-content: center;
  flex-wrap: wrap;
  margin: 0 0 10px;
}
.gate-save .gate-help-btn {
  margin: 0;
  min-height: 36px;
  padding: 0 14px;
  font-size: 12px;
}
.gate-help-btn.danger {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.4);
}
.gate-help-btn.danger:active {
  background: rgba(255, 107, 107, 0.12);
}

/* ============================================================
   更新日志（进入页常驻）
   ============================================================ */

.changelog {
  margin: 14px 0 4px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--border-radius-lg);
  background: rgba(12, 18, 32, 0.6);
  text-align: left;
  max-height: 260px;
  overflow-y: auto;
}

.changelog-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.changelog-caret {
  margin-left: auto;
  font-size: 12px;
  color: #5f6f8c;
  transition: transform 0.18s ease;
}

/* 🔴 默认折叠：只显示标题行，不挤压「开始」按钮 */
.changelog-body {
  display: none;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
  max-height: 240px;
  overflow-y: auto;
}
.changelog.open .changelog-body { display: block; }
.changelog.open .changelog-caret { transform: rotate(180deg); }

.changelog-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary, #e8eefc);
}

.changelog-badge {
  font-size: 11px;
  font-family: ui-monospace, monospace;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(63, 216, 192, 0.16);
  color: #3fd8c0;
}

.changelog-item + .changelog-item {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

.changelog-ver {
  font-size: 12px;
  font-weight: 500;
  color: #9fb4d8;
  margin-bottom: 5px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.changelog-date {
  font-size: 11px;
  font-family: ui-monospace, monospace;
  color: #5f6f8c;
  font-weight: 400;
}

.changelog ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.changelog li {
  font-size: 12px;
  line-height: 1.65;
  padding-left: 14px;
  position: relative;
  color: #8fa3c4;
}

/* 🔴 用前置圆点区分类型，比文字前缀更省空间 */
.changelog li::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 8px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #5f6f8c;
}

.changelog li.chg-add::before  { background: #3fd8c0; }
.changelog li.chg-opt::before  { background: #ffd447; }
.changelog li.chg-fix::before  { background: #7fd4f0; }
.changelog li.chg-del::before  { background: #ff6b6b; }

.changelog li.chg-add { color: #a8e8dc; }
.changelog li.chg-del { color: #d9a0a0; }
