:root {
  --bg: #0a1014;
  --panel: #121c23;
  --panel-2: #182833;
  --line: #2a4453;
  --text: #e6f1f7;
  --dim: #8aa2b1;
  --cyan: #6fe3ff;
  --gold: #ffcf5c;
  --danger: #ff5c7a;
  --green: #86d94f;
  --purple: #a86bff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

@supports (height: 100dvh) {
  html, body { height: 100dvh; }
}

#game-canvas {
  position: fixed;
  top: 0;
  left: 0;
  display: block;
  width: 100vw;
  height: 100vh;
  background: #0a1410;
  touch-action: none;
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: rgba(4, 8, 11, 0.72);
  backdrop-filter: blur(3px);
  z-index: 10;
}

.overlay.hidden { display: none; }

.screen {
  width: min(1080px, 94vw);
  max-height: 92vh;
  overflow: auto;
  padding: 28px 34px 30px;
  background: linear-gradient(180deg, rgba(24, 40, 51, 0.96), rgba(12, 20, 26, 0.98));
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(111, 227, 255, 0.08);
}

h1 {
  font-size: 34px;
  letter-spacing: 4px;
  background: linear-gradient(90deg, var(--cyan), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

h2 { font-size: 22px; letter-spacing: 2px; margin-bottom: 14px; }

.sub { color: var(--dim); font-size: 13px; margin: 8px 0 20px; letter-spacing: 1px; }

/* ===== 主菜单：全屏片头（星空 + 六人奔跑）+ 逐字 3D 弧形标题 ===== */
.overlay.menu-mode {
  background: radial-gradient(ellipse 85% 70% at 50% 38%,
    rgba(9, 18, 30, 0.94), rgba(2, 5, 9, 0.99));
  backdrop-filter: blur(7px);
}

.screen.screen-full {
  width: 100%;
  height: 100%;
  max-height: none;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: hidden;
}

.menu {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 55% at 50% 108%, rgba(58, 118, 255, 0.16), transparent 64%),
    radial-gradient(ellipse 55% 45% at 16% 20%, rgba(140, 80, 255, 0.10), transparent 62%),
    radial-gradient(ellipse 50% 45% at 84% 26%, rgba(255, 70, 120, 0.08), transparent 62%);
}

.menu-sky {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.menu-stage {
  position: relative;
  z-index: 1;
  width: min(1120px, 92vw);
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3vh 0 4vh;
}

.menu .game-title {
  position: relative;
  isolation: isolate;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  perspective: 1000px;
  margin: 0;
  background: none;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  color: #fff;
  font-weight: 800;
  line-height: 1.12;
}

/* 标题背后的 RGB 氛围光 */
.menu .game-title::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 56%;
  width: 114%;
  height: 250%;
  transform: translate(-50%, -50%);
  background:
    radial-gradient(ellipse at 24% 50%, rgba(255, 48, 120, 0.24), transparent 58%),
    radial-gradient(ellipse at 76% 50%, rgba(40, 216, 255, 0.26), transparent 58%),
    radial-gradient(ellipse at 50% 50%, rgba(126, 118, 255, 0.20), transparent 64%);
  filter: blur(12px);
  z-index: -1;
  pointer-events: none;
  animation: auraPulse 6s ease-in-out infinite, auraHue 14s linear infinite;
}

@keyframes auraPulse {
  0%, 100% { opacity: 0.6; transform: translate(-50%, -50%) scale(0.95); }
  50%      { opacity: 1;   transform: translate(-50%, -50%) scale(1.07); }
}

@keyframes auraHue {
  0%   { filter: blur(12px) hue-rotate(0deg); }
  100% { filter: blur(12px) hue-rotate(360deg); }
}

/* 逐字：两侧后退、中间前凸，形成弧形景深 */
.menu .tchar {
  --k: 0;   /* 距中心的相对距离 0~1 */
  --s: 0;   /* 左右方向 -1 / 0 / 1 */
  display: inline-block;
  margin: 0 0.035em;
  font-size: clamp(32px, 5.6vw, 68px);
  color: rgb(
    calc(247 - 108 * var(--k)),
    calc(252 - 48 * var(--k)),
    calc(255 - 10 * var(--k))
  );
  text-shadow:
    -0.06em 0 0.18em rgba(255, 40, 118, 0.72),
     0.06em 0 0.18em rgba(38, 210, 255, 0.72),
    -0.17em 0 0.6em rgba(255, 60, 140, 0.26),
     0.17em 0 0.6em rgba(40, 200, 255, 0.26),
     0 0 0.38em rgba(140, 210, 255, 0.5),
     0 0.09em 0.16em rgba(2, 9, 14, 0.55);
  transform:
    translate3d(0, calc(var(--k) * 7px), calc(var(--k) * -60px))
    scale(calc(1 - 0.05 * var(--k)))
    rotateY(calc(var(--s) * var(--k) * -16deg));
  transform-origin: 50% 65%;
  filter: blur(calc(var(--k) * 0.35px));
}

/* 下方奔跑的六名角色 */
.menu-runners {
  display: block;
  width: 100%;
  height: clamp(150px, 26vh, 260px);
  margin-top: -18px;
  transition: opacity 0.9s ease;
}

.menu.is-settled .menu-runners { opacity: 0.8; }

/* 标题落定后完全静止：光晕不再呼吸/变色，只有角色继续奔跑 */
.menu.is-settled .game-title::before { animation: none; }

/* 菜单按钮区：片头播完后淡入 */
.menu-ui {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: opacity 0.6s ease 0.05s,
              transform 0.6s cubic-bezier(0.22, 0.61, 0.36, 1) 0.05s;
}

.menu.is-intro .menu-ui {
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
}

/* 片头：标题自下升起 */
.menu.is-intro .game-title {
  animation: titleRise 1.7s cubic-bezier(0.16, 0.84, 0.3, 1) 0.15s both;
}

@keyframes titleRise {
  from { opacity: 0; transform: translateY(120px) scale(0.94); filter: blur(10px); }
  to   { opacity: 1; transform: none; filter: none; }
}

@media (prefers-reduced-motion: reduce) {
  .menu .game-title::before { animation: none; }
  .menu.is-intro .game-title { animation: none; }
  .menu-ui, .menu-runners { transition: none; }
}

.menu .flow-hint {
  margin: 14px 0 22px;
  padding: 7px 15px;
  border-color: rgba(111, 227, 255, 0.2);
  background: rgba(111, 227, 255, 0.035);
}

.menu .actions { justify-content: center; gap: 14px; flex-wrap: wrap; }

.menu .actions button { padding: 12px 28px; }

.menu .actions button.primary {
  box-shadow: 0 6px 22px rgba(70, 200, 232, 0.22);
}

.menu .sub { font-size: 12px; margin: 20px 0 0; opacity: 0.82; }

.menu .record {
  width: min(620px, 100%);
  margin-top: 22px;
  padding-top: 18px;
  justify-content: center;
  gap: 38px;
  border-top: none;
  background: linear-gradient(90deg, transparent, rgba(42, 68, 83, 0.9) 22%,
              rgba(42, 68, 83, 0.9) 78%, transparent) top / 100% 1px no-repeat;
}

/* 选角色 */
.hero-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.hero-card {
  position: relative;
  padding: 10px 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(24, 40, 51, 0.92), rgba(12, 20, 26, 0.96));
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.hero-card:hover {
  transform: translateY(-3px);
  border-color: rgba(111, 227, 255, 0.55);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
}

.hero-card.selected {
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px rgba(111, 227, 255, 0.35), 0 8px 24px rgba(111, 227, 255, 0.12);
}

.hero-card.locked { opacity: 0.45; cursor: not-allowed; }
.hero-card.locked:hover { transform: none; border-color: var(--line); box-shadow: none; }

.hero-canvas {
  display: block;
  width: 100%;
  height: 136px;
}

.hero-name { font-size: 18px; font-weight: 700; letter-spacing: 2px; margin-top: 4px; }
.hero-sub { font-size: 11px; color: var(--dim); margin-top: 2px; }
.hero-foot { font-size: 11px; color: #9fb7c4; margin-top: 6px; }

/* 悬停详情面板（固定定位，跟随卡片） */
.char-tip {
  position: fixed;
  left: 0; top: 0;
  width: 300px;
  padding: 14px 16px;
  background: rgba(10, 18, 23, 0.98);
  border: 1px solid rgba(111, 227, 255, 0.42);
  border-radius: 10px;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.6);
  z-index: 40;
  pointer-events: none;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
}

.tip-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.tip-head b { font-size: 16px; letter-spacing: 2px; }
.tip-head span { font-size: 11px; color: var(--dim); }

.tip-sec {
  margin-top: 10px;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--cyan);
  border-left: 2px solid var(--cyan);
  padding-left: 6px;
}

.tip-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px 8px;
  margin-top: 4px;
  color: var(--dim);
}

.tip-grid b { color: var(--text); }

.tip-desc { margin-top: 4px; color: #b9ccd8; font-size: 12px; }

/* 流程提示 */
.flow-hint {
  display: inline-block;
  font-size: 12px;
  color: var(--dim);
  letter-spacing: 1px;
  padding: 6px 12px;
  margin-bottom: 18px;
  border: 1px dashed var(--line);
  border-radius: 20px;
}

.lock-tag {
  position: absolute;
  top: 10px; right: 10px;
  font-size: 10px;
  color: var(--gold);
  border: 1px solid rgba(255, 207, 92, 0.4);
  border-radius: 4px;
  padding: 1px 5px;
}

.actions { display: flex; gap: 12px; align-items: center; margin-top: 6px; }

button {
  font-family: inherit;
  font-size: 15px;
  letter-spacing: 2px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 26px;
  cursor: pointer;
  transition: all 0.15s;
}

button:hover { border-color: var(--cyan); color: var(--cyan); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

button.primary {
  background: linear-gradient(180deg, #2a7f9e, #1a5871);
  border-color: #46c8e8;
  color: #eafcff;
  font-weight: 700;
}

button.primary:hover { background: linear-gradient(180deg, #35a0c2, #206f8d); color: #fff; }

.record {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 28px;
  font-size: 12px;
  color: var(--dim);
}

.record b { color: var(--gold); font-size: 15px; }

/* 升级面板 */
.levelup { text-align: center; }
.levelup h2 { font-size: 26px; color: var(--gold); }
.levelup .hint { font-size: 12px; color: var(--dim); margin-bottom: 20px; }

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 20px; }

.card {
  padding: 18px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  min-height: 150px;
  display: flex;
  flex-direction: column;
}

.card:hover { border-color: var(--cyan); transform: translateY(-3px); background: var(--panel-2); }

.card .tag {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  margin-bottom: 10px;
  align-self: flex-start;
  letter-spacing: 1px;
}

.tag.common { background: rgba(200, 220, 230, 0.12); color: #c8dce6; }
.tag.rare { background: rgba(111, 200, 255, 0.14); color: #7fc8ff; }
.tag.epic { background: rgba(168, 107, 255, 0.18); color: var(--purple); }
.tag.weapon { background: rgba(255, 207, 92, 0.15); color: var(--gold); }

.card .cname { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.card .cdesc { font-size: 12px; color: var(--dim); line-height: 1.6; flex: 1; }
.card .ckey { font-size: 11px; color: var(--dim); margin-top: 10px; opacity: 0.7; }

.skip-btn { background: transparent; border-style: dashed; font-size: 13px; padding: 8px 20px; }

/* 暂停 / 结算 */
.pause-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 22px; }
.pause-col h3 { font-size: 14px; color: var(--cyan); margin-bottom: 10px; letter-spacing: 1px; }
.pause-col ul { list-style: none; font-size: 13px; color: var(--dim); line-height: 1.9; }
.pause-col ul b { color: var(--text); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 20px 0 24px;
}

.stat-box {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  text-align: center;
}

.stat-box .k { font-size: 11px; color: var(--dim); margin-bottom: 6px; }
.stat-box .v { font-size: 22px; font-weight: 700; color: var(--gold); }
.stat-box.win .v { color: var(--green); }

.toast {
  position: fixed;
  left: 50%;
  top: 16%;
  transform: translateX(-50%);
  padding: 10px 22px;
  background: rgba(12, 20, 26, 0.92);
  border: 1px solid var(--gold);
  border-radius: 8px;
  color: var(--gold);
  font-size: 14px;
  letter-spacing: 1px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 20;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }

/* 选副本 */
.scene-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.scene-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
}

.scene-card:hover { transform: translateY(-2px); background: var(--panel-2); }

/* 难度门禁：未解锁档位置灰并保留悬浮提示 */
.diff-btn.locked {
  opacity: 0.45;
  cursor: not-allowed;
  border-style: dashed;
}

.scene-card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(255, 207, 92, 0.3), 0 6px 20px rgba(255, 207, 92, 0.1);
}

.scene-thumb {
  position: relative;
  height: 64px;
  border-radius: 8px;
  margin-bottom: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: linear-gradient(135deg, #24323b, #121a20);
  overflow: hidden;
}

.scene-thumb[data-scene="jungle"] {
  background:
    radial-gradient(circle at 78% 22%, rgba(120, 200, 120, 0.28), transparent 55%),
    linear-gradient(135deg, #1f3d2a, #0e1a13);
}

.scene-thumb[data-scene="space"] {
  background:
    radial-gradient(circle at 25% 75%, rgba(110, 160, 255, 0.3), transparent 55%),
    linear-gradient(135deg, #16203f, #0a0f1e);
}

.scene-thumb[data-scene="tomb"] {
  background:
    radial-gradient(circle at 70% 30%, rgba(220, 170, 90, 0.26), transparent 55%),
    linear-gradient(135deg, #3b2e17, #14100a);
}

.scene-tag {
  position: absolute;
  top: 8px; left: 8px;
  font-size: 10px;
  letter-spacing: 2px;
  padding: 1px 8px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid currentColor;
}

.scene-name { font-size: 19px; font-weight: 700; letter-spacing: 3px; }

.scene-boss { font-size: 11px; color: var(--gold); margin-top: 2px; letter-spacing: 1px; }

.scene-desc { font-size: 12px; color: #a9bcc8; line-height: 1.6; margin-top: 8px; min-height: 54px; }

.scene-mods {
  font-size: 11px;
  color: var(--dim);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

/* 强化商店 */
.shop-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.shop-item .shop-info { flex: 1; }
.shop-item .cname { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.shop-item .cdesc { font-size: 12px; color: var(--dim); }
.shop-lvl { font-size: 12px; color: var(--gold); font-weight: 600; margin-left: 8px; }
.shop-buy { min-width: 110px; }

/* 天赋树角色切换 */
.talent-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  padding: 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
}
.talent-tabs .ttab {
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 8px;
  background: rgba(255,255,255,0.025);
  color: #c9d6df;
  cursor: pointer;
  transition: all 0.15s ease;
}
.talent-tabs .ttab:hover {
  border-color: var(--ctab);
  color: #fff;
  background: rgba(255,255,255,0.05);
  transform: translateY(-1px);
}
.talent-tabs .ttab.active {
  border-color: var(--ctab);
  color: var(--ctab);
  background: color-mix(in srgb, var(--ctab) 14%, rgba(255,255,255,0.03));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--ctab) 30%, transparent) inset, 0 2px 10px color-mix(in srgb, var(--ctab) 25%, transparent);
  cursor: default;
}

/* 天赋树 */
.tgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

.tbranch {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  padding: 12px;
}

.tbranch h3 {
  font-size: 14px;
  color: var(--cyan);
  letter-spacing: 2px;
  margin-bottom: 10px;
  text-align: center;
}

.trow { display: flex; gap: 8px; margin-bottom: 8px; }
.trow-pair .tnode { flex: 1; }
.trow:not(.trow-pair) .tnode { flex: 1; }

.tnode {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  cursor: pointer;
  transition: all 0.15s;
  min-height: 74px;
  display: flex;
  flex-direction: column;
}

.tnode .tname { font-size: 12px; font-weight: 700; margin-bottom: 3px; }
.tnode .tdesc { font-size: 10px; color: var(--dim); line-height: 1.45; flex: 1; }
.tnode .tcost { font-size: 10px; color: var(--gold); margin-top: 5px; }

.tnode.lit { border-color: var(--green); background: rgba(134, 217, 79, 0.08); }
.tnode.lit .tname { color: var(--green); }

.tnode.avail:hover { border-color: var(--cyan); transform: translateY(-2px); }

.tnode.locked { opacity: 0.45; cursor: not-allowed; }
.tnode.locked:hover { transform: none; }

.ult-tag {
  font-size: 9px;
  color: var(--gold);
  border: 1px solid rgba(255, 207, 92, 0.4);
  border-radius: 3px;
  padding: 0 3px;
  margin-left: 3px;
}

@supports (height: 100dvh) {
  .screen { max-height: 92dvh; }
}

/* ===== 触屏虚拟摇杆 / 暂停按钮（仅触屏设备创建，对局中显示）===== */
.touch-stick {
  position: fixed;
  left: calc(16px + env(safe-area-inset-left));
  bottom: calc(58px + env(safe-area-inset-bottom));
  width: 132px;
  height: 132px;
  border-radius: 50%;
  border: 1px solid rgba(111, 227, 255, 0.26);
  background: radial-gradient(circle, rgba(111, 227, 255, 0.10), rgba(10, 20, 26, 0.34));
  display: none;
  z-index: 5;
  touch-action: none;
}

body.in-game .touch-stick { display: block; }

.touch-stick.active {
  background: radial-gradient(circle, rgba(111, 227, 255, 0.18), rgba(10, 20, 26, 0.4));
}

.touch-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 35% 30%, rgba(205, 240, 255, 0.6), rgba(70, 160, 200, 0.35));
  border: 1px solid rgba(111, 227, 255, 0.6);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.42);
  pointer-events: none;
}

.touch-pause {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(58px + env(safe-area-inset-bottom));
  width: 56px;
  height: 56px;
  padding: 0;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 50%;
  border: 1px solid rgba(111, 227, 255, 0.35);
  background: rgba(10, 20, 26, 0.62);
  color: #dbeef7;
  z-index: 5;
  touch-action: manipulation;
}

body.in-game .touch-pause { display: flex; }

.touch-pause span {
  display: block;
  width: 4px;
  height: 18px;
  border-radius: 2px;
  background: currentColor;
}

/* ===== 移动端布局适配 ===== */
@media (max-width: 900px) {
  .screen { width: 96vw; padding: 18px 16px 20px; border-radius: 10px; }
  .hero-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .hero-canvas { height: 108px; }
  .hero-name { font-size: 16px; }
  .cards { grid-template-columns: 1fr; gap: 10px; }
  .card { min-height: 0; padding: 12px 14px; }
  .card .cname { font-size: 15px; margin-bottom: 4px; }
  .tgrid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .pause-grid { grid-template-columns: 1fr; gap: 14px; }
  button { padding: 10px 18px; font-size: 14px; }
  .menu .actions { flex-wrap: wrap; }
  .record { flex-wrap: wrap; justify-content: center; gap: 12px 22px; }
  .overlay { backdrop-filter: blur(2px); }
  .menu .game-title::before { filter: blur(9px); }
  .toast { font-size: 13px; padding: 8px 16px; }
}

@media (max-height: 540px) {
  .screen { padding: 12px 16px 14px; }
  .cards { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .card { padding: 10px 12px; }
  .card .cdesc { font-size: 11px; line-height: 1.5; }
  .hero-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .hero-canvas { height: 84px; }
  .scene-thumb { height: 46px; }
  .scene-desc { min-height: 0; }
  .menu-runners { height: clamp(80px, 20vh, 130px); margin-top: -10px; }
  .menu .tchar { font-size: clamp(22px, 6.6vh, 44px); }
  .menu-stage { padding: 1vh 0 2vh; }
  .menu .flow-hint { margin: 8px 0 12px; padding: 4px 12px; }
  .menu .record { margin-top: 12px; padding-top: 10px; gap: 20px; }
  .menu .sub { margin-top: 6px !important; }
  .pause-grid { grid-template-columns: 1fr 1fr; }
  .stats-grid { margin: 12px 0 16px; }
  h2 { font-size: 19px; margin-bottom: 10px; }
}

@media (pointer: coarse) {
  button { min-height: 42px; }
  .char-tip { display: none !important; }
  .cards .ckey { display: none; }
}

/* ===== 成就系统（《11-成就系统设计》第六章）===== */
#btn-ach { position: relative; }
#btn-ach .ach-dot {
  position: absolute; top: -4px; right: -4px; width: 10px; height: 10px;
  background: #ff5c7a; border-radius: 50%;
  box-shadow: 0 0 6px #ff5c7a;
}

.ach-page { max-width: 1060px; margin: 0 auto; padding-bottom: 30px; }
.ach-page .panel-head {
  display: flex; align-items: center; gap: 14px; margin-bottom: 8px;
}
.ach-page .panel-head h2 { flex: 1; margin: 0; }
.ach-page .gold { color: #ffcf5c; font-weight: 700; }
.ach-status { margin: 4px 0 12px; color: #c9d6e2; font-size: 14px; }
.ach-status .ach-title {
  background: none; border: 1px solid #ffcf5c; color: #ffcf5c;
  border-radius: 10px; padding: 1px 10px; cursor: pointer; font-size: 13px;
}
.ach-status .ach-title:hover { background: rgba(255, 207, 92, 0.12); }

.ach-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.ach-tab {
  background: #1a2530; color: #8aa2b1; border: 1px solid #2c3e50;
  border-radius: 14px; padding: 4px 14px; cursor: pointer; font-size: 13px;
}
.ach-tab:hover { color: #e8eef4; }
.ach-tab.active { background: #2c4a66; color: #9fe8ff; border-color: #4a7ba6; }

.ach-near {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  background: #16202b; border: 1px solid #2c3e50; border-radius: 8px;
  padding: 8px 12px; margin-bottom: 10px; font-size: 13px;
}
.ach-near-k { color: #8aa2b1; }
.ach-near-item b { color: #9fe8ff; }

.ach-tasks { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.ach-task {
  background: #141b24; border: 1px solid #243242; border-radius: 8px;
  padding: 6px 12px; font-size: 12px; color: #a8bcc9;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.ach-task.done { opacity: 0.85; }
.ach-task .ok { color: #86d94f; }
.ach-task .bar { flex: 1; min-width: 80px; max-width: 160px; }

.ach-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
}
.ach-card {
  background: #1a2530; border: 1px solid #2c3e50; border-radius: 10px;
  padding: 10px 12px; display: flex; flex-direction: column; gap: 5px;
}
.ach-card.done { border-color: #4a7ba6; background: #16222e; }
.ach-card.locked { opacity: 0.78; }
.ach-card.hidden { border-style: dashed; }
.ach-name { font-weight: 700; font-size: 14px; color: #e8eef4; }
.ach-card.done .ach-name { color: #ffcf5c; }
.ach-desc { font-size: 12px; color: #c9d6e2; line-height: 1.45; }
.ach-hint { font-size: 11px; color: #7d95a8; }
.ach-date { font-size: 11px; color: #7d95a8; }
.ach-prog { font-size: 11px; color: #9fe8ff; }
.ach-card .bar {
  height: 6px; background: #0e151d; border-radius: 3px; overflow: hidden;
}
.ach-card .bar i, .ach-task .bar i {
  display: block; height: 100%; background: linear-gradient(90deg, #4a9de8, #9fe8ff);
}
.ach-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: #8aa2b1; margin-top: auto;
}
.ach-tier { font-weight: 700; padding: 1px 8px; border-radius: 8px; }
.tier-bronze { color: #d8a35c; border: 1px solid #d8a35c; }
.tier-silver { color: #c9d6e2; border: 1px solid #c9d6e2; }
.tier-gold { color: #ffcf5c; border: 1px solid #ffcf5c; }
.tier-legend { color: #ff9ad5; border: 1px solid #ff9ad5; text-shadow: 0 0 6px rgba(255, 154, 213, 0.5); }

.ach-result {
  margin: 14px auto 4px; max-width: 420px; text-align: left;
  background: #16202b; border: 1px solid #2c3e50; border-radius: 8px; padding: 8px 12px;
}
.ach-result-k { font-size: 12px; color: #8aa2b1; margin-bottom: 4px; }
.ach-result-item { font-size: 13px; color: #c9d6e2; padding: 2px 0; }
.ach-result-item.done { color: #ffcf5c; }

/* 副本选择页右上角的成就入口（《11》§6.1） */
.ach-side {
  float: right; position: relative;
  background: #1a2530; color: #c9d6e2; border: 1px solid #2c3e50;
  border-radius: 14px; padding: 3px 14px; cursor: pointer; font-size: 13px;
}
.ach-side:hover { color: #9fe8ff; border-color: #4a7ba6; }
.ach-side .ach-dot {
  position: absolute; top: -4px; right: -4px; width: 9px; height: 9px;
  background: #ff5c7a; border-radius: 50%; box-shadow: 0 0 6px #ff5c7a;
}
