/* ============================================================
   棱镜回响 PRISM ECHO — UI 样式 ·「星墨手卷」文艺主题
   玄墨为底 · 宣纸作字 · 朱砂点印 · 月金描线
   题字·正文：思源宋体 · 数笈：Cormorant Garamond（站酷小薇已移除：笔画厚重致「回」「响」内白填死）
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  /* —— 墨与纸 —— */
  --ink-0: #07080c;            /* 玄墨（页面底） */
  --ink-1: #0d1017;            /* 面板墨 */
  --ink-2: #131826;            /* 卡片墨 */
  --paper:    #e6ddc4;         /* 宣纸 */
  --paper-dim: #a89f85;        /* 旧纸 */
  --paper-faint: #6e6957;      /* 淡墨 */
  /* —— 印与金 —— */
  --cinnabar: #c8452e;         /* 朱砂 */
  --cinnabar-hi: #e05a41;      /* 朱砂·亮 */
  --gold: #c9a86a;             /* 月金 */
  --jade: #7fae94;             /* 青玉（点缀） */
  /* —— 线与纹 —— */
  --line: rgba(230, 221, 196, .16);
  --line-soft: rgba(230, 221, 196, .08);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' seed='7'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='linear' slope='0.055'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23p)'/%3E%3C/svg%3E");
  /* —— 字体 —— */
  --font-title: 'Noto Serif SC', 'STSong', 'SimSun', 'Songti SC', serif;
  --font-body:  'Noto Serif SC', 'STSong', 'SimSun', 'Songti SC', serif;
  --font-num:   'Cormorant Garamond', 'Noto Serif SC', 'STSong', serif;
}

html, body { width: 100%; height: 100%; overflow: hidden; background: var(--ink-0); overscroll-behavior: none; }
body {
  font-family: var(--font-body);
  color: var(--paper);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  font-feature-settings: 'liga' 1;
}
/* 移动浏览器 100vh = 工具栏收起时的大视口：导航栏展开时底部布防栏被压在栏下（真机已证实）
   → 100% 链打底（iOS 解析为可见小视口），100dvh 动态视口覆盖（随导航栏伸缩）
   → 不支持 dvh 的老浏览器自动回退 100% */
#app { position: relative; width: 100vw; height: 100vh; height: 100%; height: 100dvh; touch-action: pan-y; }
#scene-holder, #scene-holder canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
/* 触屏手势地面：禁止浏览器默认滚动/缩放，把手势留给游戏 */
#scene-holder canvas { touch-action: none; }
.hidden { display: none !important; }

/* —— 通用墨面板（双线框 · 衬线 · 微纸纹），HUD/卡片/浮层共用 —— */
.ink-panel,
.hud-block,
.tower-card,
#tower-panel,
.feature-card,
.end-stats {
  position: relative;
  background:
    linear-gradient(172deg, rgba(13, 16, 23, .9), rgba(9, 11, 17, .92)),
    var(--grain);
  border: 1px solid var(--line);
  box-shadow:
    inset 0 0 0 1px rgba(7, 8, 12, .9),
    inset 0 0 0 2px var(--line-soft),
    0 10px 34px rgba(0, 0, 0, .5);
  backdrop-filter: blur(8px);
  border-radius: 4px;
}

/* —— 手卷装帧层：纸纹 + 四隅暗角 —— */
#scroll-dress {
  position: absolute; inset: 0; z-index: 5;
  pointer-events: none;
  background:
    var(--grain),
    radial-gradient(125% 95% at 50% 44%, transparent 58%, rgba(3, 4, 7, .52) 100%);
}

/* ---------- 顶部 HUD ---------- */
#hud-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: stretch; gap: 14px;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 18px 14px;
  background: linear-gradient(180deg, rgba(5, 6, 10, .78) 0%, rgba(5, 6, 10, 0) 100%);
  pointer-events: none;
}
.hud-block {
  pointer-events: auto;
  padding: 8px 16px 9px;
  min-width: 112px;
}
.hud-label {
  font-size: 11px; letter-spacing: 4px;
  color: var(--paper-faint);
  margin-bottom: 3px;
  font-family: var(--font-body);
}
.hud-label::before { content: '「'; color: var(--gold); opacity: .5; }
.hud-label::after  { content: '」'; color: var(--gold); opacity: .5; }
.hud-value {
  font-family: var(--font-num);
  font-size: 23px; font-weight: 600;
  color: var(--paper);
  letter-spacing: .04em;
  line-height: 1.15;
}
.hud-value.energy { color: var(--gold); }
.hud-sub { font-size: 13px; color: var(--paper-faint); letter-spacing: 0; }
.hud-spacer { flex: 1; }
#wave-ctl { display: flex; align-items: center; gap: 10px; }
#wave-countdown {
  font-family: var(--font-num);
  color: var(--gold); font-weight: 600; font-size: 19px; min-width: 46px;
}

/* 波次墨点 */
#wave-dots { display: flex; gap: 5px; margin-top: 6px; }
#wave-dots .wd {
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(230, 221, 196, .1);
  border: 1px solid rgba(230, 221, 196, .14);
}
#wave-dots .wd.done { background: var(--paper-dim); border-color: var(--paper-dim); }
#wave-dots .wd.cur {
  background: var(--cinnabar-hi); border-color: var(--cinnabar-hi);
  box-shadow: 0 0 8px rgba(224, 90, 65, .55);
}
#wave-dots .wd.boss { border-color: rgba(224, 90, 65, .55); background: rgba(224, 90, 65, .14); }
#wave-dots .wd.boss.done { background: var(--cinnabar); border-color: var(--cinnabar); }

/* 星核命脉 */
#core-hp-bar {
  width: 172px; height: 9px;
  background: rgba(230, 221, 196, .06);
  border: 1px solid var(--line);
  border-radius: 2px;
  overflow: hidden; margin: 4px 0;
}
#core-hp-fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #b69a5e, #dcc389);
  box-shadow: 0 0 10px rgba(201, 168, 106, .45);
  transition: width 0.25s ease;
}
#core-hp-fill.low {
  background: linear-gradient(90deg, #a83a26, #e05a41);
  box-shadow: 0 0 10px rgba(224, 90, 65, .55);
}
#core-hp-num { font-size: 14px; }

/* ---------- 印章按钮 ---------- */
.btn-primary, .btn-danger, .btn-ghost {
  pointer-events: auto;
  font-family: var(--font-title);
  font-weight: 500;
  border-radius: 4px;
  padding: 9px 24px;
  font-size: 15px; letter-spacing: .28em; text-indent: .28em;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}
.btn-primary {
  color: #f2ecd8;
  background: linear-gradient(165deg, #cf4a31, #a23724);
  border: 1px solid #7e2b1d;
  box-shadow:
    inset 0 1px 0 rgba(255, 235, 200, .22),
    inset 0 0 0 3px rgba(8, 9, 13, .28),
    0 4px 16px rgba(0, 0, 0, .5);
}
.btn-primary:hover:not(:disabled) {
  filter: brightness(1.14);
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 235, 200, .3),
    inset 0 0 0 3px rgba(8, 9, 13, .28),
    0 6px 22px rgba(160, 45, 25, .4);
}
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.38; cursor: not-allowed; filter: grayscale(.3); }

.btn-danger {
  color: var(--paper);
  background: rgba(200, 69, 46, .08);
  border: 1px solid rgba(200, 69, 46, .5);
  box-shadow: inset 0 0 0 1px rgba(7, 8, 12, .6);
}
.btn-danger:hover {
  background: rgba(200, 69, 46, .2);
  color: #f0c9b8;
  box-shadow: inset 0 0 0 1px rgba(7, 8, 12, .6), 0 0 16px rgba(200, 69, 46, .25);
}
.btn-ghost {
  color: var(--paper-dim);
  background: rgba(230, 221, 196, .03);
  border: 1px solid var(--line);
  font-weight: 400;
}
.btn-ghost:hover { color: var(--paper); border-color: rgba(230, 221, 196, .32); }
.btn-big { font-size: 19px; padding: 13px 48px; }

/* ---------- 底部布防栏 ---------- */
#build-bar {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  z-index: 10; text-align: center;
}
.bar-title {
  font-family: var(--font-title);
  font-size: 12px; letter-spacing: 10px; text-indent: 10px;
  color: var(--paper-faint);
  margin-bottom: 8px;
}
#build-cards { display: flex; gap: 12px; }
.tower-card {
  width: 134px;
  padding: 10px 12px 9px;
  cursor: pointer;
  transition: all 0.16s ease;
  position: relative;
  overflow: hidden;
}
.tower-card::before {
  content: ""; position: absolute; left: 0; top: 0; right: 0; height: 3px;
  background: var(--tc, var(--gold));
  opacity: .85;
}
.tower-card::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(80% 60% at 50% 0%, var(--tc, var(--gold)) 0%, transparent 70%);
  opacity: 0; transition: opacity .18s ease; pointer-events: none;
}
.tower-card:hover { transform: translateY(-4px); border-color: rgba(230, 221, 196, .3); }
.tower-card:hover::after { opacity: .1; }
.tower-card.selected {
  border-color: var(--tc, var(--gold));
  box-shadow:
    inset 0 0 0 1px rgba(7, 8, 12, .9),
    inset 0 0 0 2px rgba(230, 221, 196, .06),
    inset 0 0 20px rgba(230, 221, 196, .05),
    0 0 22px rgba(230, 221, 196, .12);
  transform: translateY(-4px);
}
.tower-card.selected::after { opacity: .16; }
.tower-card.poor { opacity: 0.42; filter: saturate(.5); }
.tc-icon {
  font-family: var(--font-body);
  font-size: 25px; line-height: 1.2; margin-bottom: 4px;
  text-shadow: 0 0 14px var(--tc, var(--gold));
}
.tc-name { font-family: var(--font-title); font-size: 16px; letter-spacing: .12em; color: var(--paper); }
.tc-desc {
  font-size: 11px; color: var(--paper-dim);
  margin: 5px 0 7px; line-height: 1.65;
  text-align: left; min-height: 36px;
}
.tc-cost {
  font-family: var(--font-num);
  font-size: 15px; font-weight: 600;
  color: var(--gold); text-align: right; letter-spacing: .03em;
}
.tc-key {
  position: absolute; top: 7px; right: 8px;
  font-family: var(--font-num);
  font-size: 11px; color: var(--paper-faint);
  border: 1px solid var(--line);
  border-radius: 2px; padding: 0 5px; line-height: 16px;
}

/* ---------- 塔详情 ---------- */
#tower-panel {
  position: absolute; right: 20px; bottom: 100px; z-index: 12;
  width: 262px;
  padding: 14px 16px 15px;
}
#tp-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 9px; padding-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
}
#tp-name { font-family: var(--font-title); font-size: 17px; letter-spacing: .1em; color: var(--paper); }
#tp-close {
  background: none; border: none; color: var(--paper-faint);
  font-size: 15px; cursor: pointer; line-height: 1;
}
#tp-close:hover { color: var(--paper); }
#tp-stats { font-size: 12.5px; line-height: 2; color: var(--paper-dim); }
#tp-stats b { color: var(--gold); font-weight: 600; font-family: var(--font-num); font-size: 14px; }
#tp-stats .up { color: var(--jade); }
#tp-actions { display: flex; gap: 8px; margin-top: 12px; }
#tp-actions button { flex: 1; min-height: 44px; padding: 8px 4px; font-size: 13px; letter-spacing: .12em; }

/* ---------- 遗物印匣（左侧） ---------- */
#relic-bar {
  position: absolute; left: 16px; top: 110px; z-index: 9;
  display: flex; flex-direction: column; gap: 8px;
  max-height: calc(100vh - 300px);
  max-height: calc(100dvh - 300px); overflow-y: auto;
  scrollbar-width: none;
}
#relic-bar::-webkit-scrollbar { display: none; }
.relic-icon {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-body); font-size: 21px;
  cursor: default;
  position: relative;
  background: linear-gradient(170deg, rgba(19, 24, 38, .92), rgba(11, 14, 23, .94));
  border: 1px solid var(--rc, rgba(201, 168, 106, .45));
  box-shadow: inset 0 0 0 1px rgba(7, 8, 12, .8), inset 0 0 0 2px rgba(230, 221, 196, .05);
  border-radius: 4px;
}
/* 星屑残页同类合并计数角标（×N） */
.relic-icon .rcount {
  position: absolute;
  right: -5px; bottom: -5px;
  font-style: normal;
  font-family: var(--font-body);
  font-size: 10px; font-weight: 700;
  line-height: 1;
  padding: 2.5px 4px;
  color: #0b0e17;
  background: #c9a86a;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .55);
  pointer-events: none;
}
.relic-icon:hover::after,
.relic-icon.show-tip::after {
  content: attr(data-tip);
  position: absolute; left: 54px; top: 0;
  width: 228px; padding: 10px 14px;
  white-space: pre-line; text-align: left;
  background: linear-gradient(172deg, rgba(13, 16, 23, .97), rgba(9, 11, 17, .97));
  border: 1px solid var(--rc, rgba(201, 168, 106, .45));
  box-shadow: inset 0 0 0 1px rgba(7, 8, 12, .9), 0 10px 30px rgba(0, 0, 0, .55);
  border-radius: 4px;
  font-size: 12.5px; line-height: 1.75; color: var(--paper);
  z-index: 20;
}

/* ---------- 墨签 Toast ---------- */
#toast-wrap {
  position: absolute; top: 86px; left: 50%; transform: translateX(-50%);
  z-index: 30; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  padding: 8px 22px 8px 17px;
  background: rgba(10, 12, 18, .92);
  border: 1px solid var(--line);
  border-left: 3px solid var(--paper-dim);
  border-radius: 3px;
  font-family: var(--font-body);
  font-size: 14px; letter-spacing: .06em;
  color: var(--paper);
  animation: toast-in 0.25s ease, toast-out 0.4s ease 2.1s forwards;
  white-space: nowrap;
}
.toast.bad  { border-left-color: var(--cinnabar-hi); color: #e9b3a2; }
.toast.gold { border-left-color: var(--gold); color: #dcc389; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px); } }

#tip-bottom {
  position: absolute; bottom: 18px; right: 20px; z-index: 8;
  font-size: 11px; color: rgba(168, 159, 133, .55);
  letter-spacing: 1.5px;
}

/* ---------- 触屏视野缩放控件 ---------- */
#zoom-ctl {
  position: absolute; right: 10px; top: 45%; transform: translateY(-50%);
  z-index: 11;
  display: none;
  flex-direction: column; gap: 10px;
}
#zoom-ctl button {
  width: 44px; height: 44px;
  font-family: var(--font-num);
  font-size: 24px; font-weight: 600; line-height: 1;
  color: var(--paper);
  cursor: pointer;
  background: linear-gradient(172deg, rgba(13, 16, 23, .9), rgba(9, 11, 17, .92));
  border: 1px solid var(--line);
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(7, 8, 12, .9), inset 0 0 0 2px var(--line-soft), 0 6px 18px rgba(0, 0, 0, .45);
  transition: all 0.15s ease;
}
#zoom-ctl button:active {
  transform: scale(.92);
  border-color: rgba(201, 168, 106, .5);
  color: var(--gold);
}

/* ---------- 模态层 ---------- */
#modal-layer {
  position: absolute; inset: 0; z-index: 40;
  background:
    var(--grain),
    rgba(4, 6, 10, .74);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* PWA standalone / 刘海屏：上下留出安全区 */
  padding: 16px;
  padding-top: max(16px, env(safe-area-inset-top, 0px));
  padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
}
/* 矮屏可滚动（触屏在 #app pan-y 约束内仍可竖向拖动模态内容） */
.modal-inner {
  text-align: center; max-width: 980px; padding: 20px; animation: modal-in 0.34s ease;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
@keyframes modal-in { from { opacity: 0; transform: scale(.965); } }

/* —— 角饰 —— */
.corner { position: relative; }
.corner::before, .corner::after {
  content: ''; position: absolute; width: 14px; height: 14px;
  pointer-events: none; opacity: .75;
}
.corner::before { top: 6px; left: 6px; border-top: 1px solid var(--gold); border-left: 1px solid var(--gold); }
.corner::after { bottom: 6px; right: 6px; border-bottom: 1px solid var(--gold); border-right: 1px solid var(--gold); }

/* ---------- 主菜单：星墨手卷 · 卷首 ---------- */
.menu-frame {
  display: flex; gap: 58px; align-items: center;
  text-align: left;
  padding: 46px 54px;
}
.menu-left { display: flex; gap: 30px; align-items: flex-start; flex-shrink: 0; }
.game-title { display: flex; }
.game-title .vt {
  writing-mode: vertical-rl;
  font-family: var(--font-title);
  font-weight: 500;
  font-size: 66px; line-height: 1.12;
  letter-spacing: .16em;
  color: var(--paper);
  text-shadow: 0 1px 12px rgba(0, 0, 0, .5);
}
.game-title .vt.accent { color: var(--cinnabar-hi); text-shadow: 0 0 10px rgba(224, 90, 65, .22); }
.menu-side { display: flex; flex-direction: column; align-items: center; gap: 22px; padding-top: 6px; }
.menu-seal {
  display: grid; grid-template-columns: repeat(2, 1fr);
  place-items: center;
  width: 68px; height: 68px;
  background: linear-gradient(160deg, #d0522f, #a03623);
  border-radius: 7px;
  box-shadow:
    inset 0 0 0 2px rgba(242, 236, 216, .34),
    inset 0 0 0 4px rgba(80, 14, 6, .35),
    inset 0 0 14px rgba(46, 8, 3, .55),
    0 6px 18px rgba(0, 0, 0, .55);
  animation: seal-breathe 4.5s ease-in-out infinite;
}
.menu-seal span {
  font-family: var(--font-title);
  font-weight: 500;
  font-size: 20px; line-height: 1.1; color: #f2ecd8;
}
@keyframes seal-breathe { 0%, 100% { opacity: 1; } 50% { opacity: .93; } }
.game-subtitle {
  writing-mode: vertical-rl;
  font-family: var(--font-num);
  font-size: 12px; letter-spacing: .42em;
  color: var(--paper-faint);
}
.menu-right { flex: 1; min-width: 380px; }
.menu-eyebrow {
  font-size: 12px; letter-spacing: 8px;
  color: var(--gold); opacity: .85;
  margin-bottom: 14px;
  font-family: var(--font-body);
}
.menu-intro {
  font-size: 15.5px; line-height: 2.15; color: var(--paper);
  margin-bottom: 24px;
  font-family: var(--font-body);
}
.menu-intro em { color: var(--gold); font-style: normal; }
.menu-intro em.cn { color: var(--cinnabar-hi); }

.feature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 30px; }
.feature-card {
  padding: 16px 16px 14px;
  transition: border-color .2s ease;
}
.feature-card:hover { border-color: rgba(201, 168, 106, .35); }
.feature-card .fc-icon {
  font-family: var(--font-body);
  font-size: 22px; margin-bottom: 8px;
  color: var(--gold); text-shadow: 0 0 14px rgba(201, 168, 106, .4);
}
.feature-card h3 {
  font-family: var(--font-title);
  font-size: 16px; color: var(--paper);
  margin-bottom: 6px; letter-spacing: .22em;
}
.feature-card p { font-size: 12.5px; color: var(--paper-dim); line-height: 1.8; font-family: var(--font-body); }
.menu-tip { margin-top: 20px; font-size: 12px; letter-spacing: 2px; color: var(--paper-faint); }

/* ---------- 回响拾遗 · 三选一 ---------- */
.relic-modal-title {
  font-family: var(--font-title);
  font-weight: 500;
  font-size: 30px; letter-spacing: 18px; text-indent: 18px;
  color: var(--gold);
  margin-bottom: 8px;
  text-shadow: 0 1px 10px rgba(0, 0, 0, .5);
}
.relic-modal-title::before, .relic-modal-title::after {
  content: '❖'; font-size: 13px; color: var(--paper-faint);
  vertical-align: middle; margin: 0 14px; letter-spacing: 0; text-indent: 0;
}
.relic-modal-sub { font-size: 13px; letter-spacing: 3px; color: var(--paper-dim); margin-bottom: 30px; }
.relic-choices { display: flex; gap: 22px; justify-content: center; }

.relic-card {
  position: relative;
  width: 196px; height: 330px;
  display: flex; flex-direction: column; align-items: center;
  padding: 20px 14px 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  background:
    linear-gradient(176deg, rgba(19, 24, 38, .93) 0%, rgba(11, 14, 23, .95) 100%),
    var(--grain);
  border: 1px solid var(--rc, rgba(201, 168, 106, .45));
  box-shadow:
    inset 0 0 0 1px rgba(7, 8, 12, .9),
    inset 0 0 0 2px rgba(230, 221, 196, .05),
    0 12px 34px rgba(0, 0, 0, .5);
  border-radius: 5px;
}
.relic-card::before {
  content: ''; position: absolute; inset: 7px;
  border: 1px solid var(--rc, rgba(201, 168, 106, .3));
  border-radius: 3px; opacity: .5;
  pointer-events: none;
  transition: opacity .2s ease;
}
.relic-card:hover {
  transform: translateY(-9px);
  box-shadow:
    inset 0 0 0 1px rgba(7, 8, 12, .9),
    inset 0 0 0 2px rgba(230, 221, 196, .05),
    0 0 0 1px var(--rc, rgba(201, 168, 106, .5)),
    0 22px 44px rgba(0, 0, 0, .6);
}
.relic-card:hover::before { opacity: .9; }
.relic-card .r-icon {
  font-family: var(--font-body);
  font-size: 30px; line-height: 1;
  color: var(--rc, var(--gold));
  text-shadow: 0 0 18px var(--rc, rgba(201, 168, 106, .5));
  margin-bottom: 14px;
  flex-shrink: 0;
}
.relic-card .r-body {
  flex: 1;
  display: flex; flex-direction: column; align-items: center;
  width: 100%;
}
.relic-card .r-name {
  writing-mode: vertical-rl;
  font-family: var(--font-title);
  font-size: 23px; letter-spacing: .3em;
  color: var(--rc, var(--gold));
  height: 148px;
  display: flex; align-items: center;
  margin-bottom: 12px;
}
.relic-card .r-desc {
  font-size: 12.5px; color: var(--paper-dim);
  line-height: 1.8; min-height: 66px;
  text-align: left;
  border-top: 1px solid var(--line-soft);
  padding-top: 9px;
  width: 100%;
}
.relic-card .r-tag {
  margin-top: auto;
  font-size: 10px; letter-spacing: 5px; text-indent: 5px;
  color: var(--paper-faint);
}

/* ---------- 卷末结算 ---------- */
.end-title {
  font-family: var(--font-title);
  font-weight: 500;
  font-size: 46px; letter-spacing: 22px; text-indent: 22px;
  margin-bottom: 12px;
  text-shadow: 0 1px 14px rgba(0, 0, 0, .55);
}
.end-title.win { color: var(--gold); text-shadow: 0 0 34px rgba(201, 168, 106, .35); }
.end-title.lose { color: var(--cinnabar-hi); text-shadow: 0 0 34px rgba(224, 90, 65, .3); }
.end-sub { font-size: 14px; letter-spacing: 2px; color: var(--paper-dim); margin-bottom: 26px; line-height: 1.9; }
.end-stats {
  display: inline-grid; grid-template-columns: auto auto; gap: 9px 34px;
  text-align: left; font-size: 14px; line-height: 1.95;
  padding: 20px 34px; margin-bottom: 30px;
}
.end-stats span { color: var(--paper-dim); letter-spacing: 2px; }
.end-stats b {
  color: var(--gold); font-family: var(--font-num);
  font-size: 17px; font-weight: 600; text-align: right;
}
.end-actions { display: flex; gap: 14px; justify-content: center; }

/* ---------- 触屏 / 窄屏：星墨掌中卷 ---------- */
/* 视野缩放按钮：触屏或窄屏可见 */
@media (max-width: 900px), (pointer: coarse) {
  #zoom-ctl { display: flex; }
  #tip-bottom { display: none; }
}

@media (max-width: 900px) {
  /* —— 顶部 HUD：两行紧凑 —— */
  #hud-top { flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
  .hud-spacer { display: none; }
  .hud-block { flex: 1 1 42%; min-width: 0; padding: 6px 12px 7px; }
  #wave-block { flex: 0 0 auto; }
  #wave-ctl { flex: 0 0 auto; padding: 6px 8px; gap: 8px; }
  #btn-next-wave { padding: 7px 16px; font-size: 13px; letter-spacing: .18em; text-indent: .18em; }
  #wave-countdown { font-size: 15px; min-width: 36px; }
  .hud-label { font-size: 9px; letter-spacing: 2px; margin-bottom: 2px; }
  .hud-value { font-size: 17px; }
  #wave-dots { display: none; }
  #core-hp-bar { width: 100%; margin: 3px 0; }
  #core-hp-num { font-size: 12px; }

  /* —— 底部布防栏：三列等分紧凑卡（留出 Home Indicator 安全区） —— */
  #build-bar { bottom: calc(8px + env(safe-area-inset-bottom, 0px)); width: calc(100% - 16px); }
  .bar-title { font-size: 10px; letter-spacing: 6px; text-indent: 6px; margin-bottom: 5px; color: var(--paper-dim); }
  #build-cards { gap: 8px; }
  .tower-card { flex: 1 1 0; min-width: 0; width: auto; padding: 7px 8px 6px; }
  .tc-icon { font-size: 17px; margin-bottom: 1px; }
  .tc-name { font-size: 13px; }
  .tc-desc { display: none; }
  .tc-cost { font-size: 13px; text-align: center; }
  .tc-key { display: none; }

  /* —— 塔详情：全宽底板 —— */
  #tower-panel { left: 8px; right: 8px; width: auto; bottom: calc(118px + env(safe-area-inset-bottom, 0px)); padding: 10px 14px 12px; }
  #tp-stats { font-size: 11.5px; line-height: 1.85; }
  #tp-actions button { padding: 9px 4px; }

  /* —— 遗物印匣 —— */
  #relic-bar { left: 8px; top: 128px; gap: 6px; }
  .relic-icon { width: 36px; height: 36px; font-size: 17px; }

  /* —— Toast —— */
  #toast-wrap { top: 124px; }
  .toast { font-size: 12.5px; padding: 7px 16px; }

  #tip-bottom { display: none; }

  /* —— 主菜单：掌中卷首 —— */
  .modal-inner { max-width: 100%; padding: 12px; }
  .menu-frame { flex-direction: column; gap: 22px; padding: 24px 18px; }
  .menu-left { flex-direction: row; gap: 16px; justify-content: center; }
  .game-title .vt { font-size: 42px; }
  .menu-side { flex-direction: row; gap: 16px; padding-top: 0; }
  .menu-seal { width: 52px; height: 52px; border-radius: 5px; }
  .menu-seal span { font-size: 14px; }
  .game-subtitle { writing-mode: horizontal-tb; letter-spacing: .3em; }
  .menu-right { min-width: 0; text-align: center; }
  .menu-eyebrow { font-size: 10px; letter-spacing: 4px; margin-bottom: 10px; }
  .menu-intro { font-size: 13px; line-height: 2; margin-bottom: 16px; }
  .feature-grid { grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 20px; }
  .feature-card { padding: 11px 10px 10px; }
  .feature-card .fc-icon { font-size: 17px; margin-bottom: 4px; }
  .feature-card h3 { font-size: 13px; letter-spacing: .14em; }
  .feature-card p { font-size: 10.5px; line-height: 1.6; }
  .btn-big { font-size: 16px; padding: 11px 34px; }
  .menu-tip { font-size: 10.5px; margin-top: 14px; }

  /* —— 回响拾遗：横排信笺 —— */
  .relic-modal-title { font-size: 22px; letter-spacing: 10px; text-indent: 10px; margin-bottom: 6px; }
  .relic-modal-title::before, .relic-modal-title::after { margin: 0 8px; }
  .relic-modal-sub { font-size: 11px; letter-spacing: 1px; margin-bottom: 18px; padding: 0 10px; }
  .relic-choices { flex-direction: column; gap: 12px; align-items: center; }
  .relic-card { flex-direction: row; align-items: stretch; text-align: left; width: min(88vw, 340px); height: auto; padding: 14px 14px 12px 16px; gap: 12px; }
  .relic-card .r-icon { margin: 0; font-size: 25px; align-self: center; }
  .relic-card .r-body { align-items: flex-start; }
  .relic-card .r-name { writing-mode: horizontal-tb; height: auto; font-size: 18px; letter-spacing: .08em; margin-bottom: 3px; }
  .relic-card .r-desc { border-top: none; padding-top: 0; width: auto; min-height: 0; font-size: 12px; }
  .relic-card .r-tag { margin-top: 0; writing-mode: vertical-rl; letter-spacing: 3px; font-size: 9px; align-self: stretch; border-left: 1px solid var(--line-soft); padding-left: 9px; }

  /* —— 卷末结算 —— */
  .end-title { font-size: 30px; letter-spacing: 12px; text-indent: 12px; }
  .end-sub { font-size: 12px; margin-bottom: 18px; }
  .end-stats { gap: 6px 18px; font-size: 12px; padding: 14px 18px; margin-bottom: 20px; }
  .end-stats b { font-size: 14px; }
  .end-actions { flex-wrap: wrap; }
}

/* 超窄屏（≤ 380px）：进一步收缩 */
@media (max-width: 380px) {
  .hud-block { flex: 1 1 100%; }
  #wave-ctl { flex: 1 1 100%; justify-content: center; }
  .game-title .vt { font-size: 34px; }
  .feature-grid { grid-template-columns: 1fr; }
}

/* 横屏短视口（手机横持 / 平板横放）：纵向寸土寸金，HUD 单行化、布防栏压扁贴底 */
@media (max-height: 500px) and (orientation: landscape) {
  #hud-top { flex-wrap: nowrap; gap: 8px; padding: calc(5px + env(safe-area-inset-top, 0px)) 10px 5px; }
  .hud-block { flex: 0 1 auto; padding: 4px 10px; }
  .hud-label, #wave-dots, .hud-spacer { display: none; }
  .hud-value { font-size: 15px; }
  #core-hp-bar { width: 96px; margin: 2px 0; }
  #core-hp-num { font-size: 11px; }
  #build-bar { bottom: calc(4px + env(safe-area-inset-bottom, 0px)); }
  .bar-title { display: none; }
  #build-cards { gap: 6px; }
  .tower-card { flex: 0 0 116px; width: 116px; padding: 5px 8px 4px; }
  .tc-desc { display: none; }
  .tc-icon { font-size: 15px; margin-bottom: 1px; }
  .tc-name { font-size: 12px; }
  .tc-cost { font-size: 12px; }
  #tower-panel { left: auto; right: 8px; width: 232px; bottom: calc(86px + env(safe-area-inset-bottom, 0px)); }
  #zoom-ctl { top: 40%; }
}

/* ============================================================
   对局控制簇：倍速 / 暂停 / 静音（桌面与触屏通用）
   ============================================================ */
#ctl-cluster {
  position: absolute; right: 14px; top: 76px; z-index: 11;
  display: flex; flex-direction: column; gap: 10px;
}
#ctl-cluster button {
  width: 40px; height: 40px;
  font-family: var(--font-num);
  font-size: 15px; font-weight: 600; line-height: 1;
  color: var(--paper-dim);
  cursor: pointer;
  background: linear-gradient(172deg, rgba(13, 16, 23, .9), rgba(9, 11, 17, .92));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(7, 8, 12, .9), inset 0 0 0 2px var(--line-soft), 0 6px 18px rgba(0, 0, 0, .45);
  transition: all 0.15s ease;
  letter-spacing: 0;
}
#ctl-cluster button:hover { color: var(--paper); border-color: rgba(201, 168, 106, .45); }
#ctl-cluster button:active { transform: scale(.92); border-color: rgba(201, 168, 106, .5); color: var(--gold); }
#btn-mute.muted { opacity: .4; text-decoration: line-through; }
/* 手机横屏短视口：贴紧顶部 */
@media (max-height: 500px) and (orientation: landscape) {
  #ctl-cluster { top: 46px; right: 8px; }
  #ctl-cluster button { width: 34px; height: 34px; font-size: 13px; }
}

/* —— 暂停面板 —— */
.pause-frame {
  width: min(340px, 88vw);
  margin: 0 auto;
  padding: 34px 34px 30px;
  text-align: center;
}
.pause-title {
  font-size: 24px; font-weight: 600;
  letter-spacing: .6em; text-indent: .6em;
  color: var(--paper);
}
.pause-sub {
  margin-top: 10px; margin-bottom: 24px;
  font-size: 12px; color: var(--paper-dim);
  letter-spacing: .25em; text-indent: .25em;
}

/* —— 菜单最高纪录行 / 结算新纪录徽标 —— */
.menu-record {
  margin-top: 14px;
  font-size: 12px; letter-spacing: .14em;
  color: var(--gold);
  opacity: .9;
}
.new-record {
  margin: 10px auto 0;
  display: inline-block;
  font-size: 12px; letter-spacing: .3em; text-indent: .3em;
  color: var(--ink-0);
  background: linear-gradient(172deg, #d9c489, var(--gold));
  padding: 5px 14px;
  border-radius: 3px;
  box-shadow: 0 4px 14px rgba(201, 168, 106, .35);
  animation: modal-in 0.34s ease;
}
