/* =========================================================
   墨悟空 · 天命  |  界面：水墨 / 鎏金 / 电影感
   ========================================================= */
:root {
  --ink: #05070a;
  --ink2: #0a0f13;
  --ink3: #121a1f;
  --bone: #eae3d1;
  --bone-dim: #b9b2a2;
  --gold: #c9a45c;
  --gold-hi: #f2dfae;
  --gold-dim: #8a7038;
  --red: #8f2b20;
  --red-hi: #d4553c;
  --teal: #8ad8cc;
  --serif: "Songti SC", "STSong", "SimSun", "Noto Serif SC", Georgia, serif;
  --sans: "Optima", "Avenir Next", "PingFang SC", system-ui, sans-serif;
  --ease: cubic-bezier(.19, 1, .22, 1);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  background: var(--ink); color: var(--bone);
  font-family: var(--serif);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none;
  overscroll-behavior: none;
}
body.mode-auto { cursor: crosshair; }
#app { position: fixed; inset: 0; overflow: hidden; }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

#grain {
  position: absolute; inset: 0; pointer-events: none; z-index: 2; opacity: .05;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/></filter><rect width='160' height='160' filter='url(%23n)' opacity='.6'/></svg>");
  mix-blend-mode: overlay;
}
#vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 3;
  background: radial-gradient(ellipse at 50% 46%, rgba(0,0,0,0) 40%, rgba(0,0,0,.28) 72%, rgba(0,0,0,.68) 100%);
}
#screenFlash { position: absolute; inset: 0; pointer-events: none; z-index: 40; opacity: 0; background: #fff; }
#fxLayer { position: absolute; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; }

.dmg-num {
  position: absolute; top: 0; left: 0; white-space: nowrap;
  font-family: var(--serif); font-weight: 600; letter-spacing: .02em;
  text-shadow: 0 0 10px rgba(0,0,0,.9), 0 2px 3px rgba(0,0,0,.8);
  will-change: transform, opacity;
}
.dmg-num.heavy { text-shadow: 0 0 16px rgba(255,190,110,.75), 0 2px 4px rgba(0,0,0,.9); }
.dmg-num.crit { color: #b8f4ff !important; text-shadow: 0 0 18px rgba(150,230,255,.9), 0 2px 4px rgba(0,0,0,.9); }

#lockOn {
  position: absolute; z-index: 12; width: 30px; height: 30px; margin: -15px 0 0 -15px;
  pointer-events: none; transition: opacity .2s;
}
#lockOn i {
  position: absolute; inset: 0; border: 1px solid rgba(240,225,190,.85);
  transform: rotate(45deg); box-shadow: 0 0 10px rgba(240,225,190,.35);
}
#lockOn b {
  position: absolute; left: 50%; top: 50%; width: 5px; height: 5px; margin: -2.5px;
  background: var(--gold-hi); border-radius: 50%; box-shadow: 0 0 8px var(--gold-hi);
}
#lockOn.hidden { display: none; }

/* 过场：黑边与章节题字 */
#letterbox { position: absolute; inset: 0; z-index: 34; pointer-events: none; }
#letterbox i {
  position: absolute; left: 0; right: 0; height: 0; background: #020304;
  transition: height .9s var(--ease);
}
#letterbox i.top { top: 0; }
#letterbox i.bottom { bottom: 0; }
#letterbox.on i { height: 7.2vh; }

.intro-title {
  position: absolute; left: clamp(30px, 7vw, 110px); top: 47%;
  transform: translateY(-46%); z-index: 36; pointer-events: none;
  opacity: 0; transition: opacity .55s ease, transform .9s var(--ease);
}
.intro-title.on { opacity: 1; transform: translateY(-50%); }
.intro-title .it-no { font-family: var(--sans); font-size: 10px; letter-spacing: .5em; color: var(--gold); }
.intro-title h2 {
  margin: 10px 0 6px; font-size: clamp(36px, 5.4vw, 68px); font-weight: 500;
  letter-spacing: .22em; color: var(--bone);
  text-shadow: 0 6px 30px rgba(0,0,0,.9);
}
.intro-title h2::after {
  content: ''; display: block; width: 76px; height: 1px; margin-top: 16px;
  background: linear-gradient(90deg, var(--gold), transparent);
}
.intro-title p { margin: 0; font-size: 13px; letter-spacing: .32em; color: rgba(226,210,180,.72); }

/* =========================================================
   HUD
   ========================================================= */
#hud { position: absolute; inset: 0; z-index: 10; pointer-events: none; opacity: 1; transition: opacity .4s; }
#hud.hidden { opacity: 0; visibility: hidden; }

.hud-left { position: absolute; left: 28px; top: 24px; width: min(340px, 38vw); }
.who { display: flex; align-items: baseline; gap: 10px; margin-bottom: 7px; }
.chapter-tag {
  font-family: var(--sans); font-size: 10px; letter-spacing: .28em;
  color: var(--gold); padding: 2px 8px; border: 1px solid rgba(201,164,92,.3);
  background: rgba(8,10,12,.4);
}
.who-name { font-size: 17px; letter-spacing: .32em; color: var(--bone); text-shadow: 0 2px 8px #000; }

.vitals { position: relative; }
.bar {
  position: relative; height: 13px; background: rgba(4,6,8,.72);
  border: 1px solid rgba(201,164,92,.34);
  box-shadow: inset 0 0 12px rgba(0,0,0,.9), 0 0 0 1px rgba(0,0,0,.5);
  overflow: hidden;
  clip-path: polygon(0 0, 100% 0, calc(100% - 5px) 100%, 0 100%);
}
.bar s, .bar i {
  position: absolute; left: 0; top: 0; bottom: 0; width: 100%;
  transform-origin: left center; display: block;
}
.bar.hp s { background: linear-gradient(90deg, #6b1a13, #a8382a); opacity: .55; transition: transform .55s .12s var(--ease); }
.bar.hp i { background: linear-gradient(90deg, #8c2a20, #d0503a 55%, #f0836a); box-shadow: 0 0 14px rgba(200,70,45,.5); transition: transform .16s ease-out; }
.bar .grid {
  position: absolute; inset: 0; font-style: normal;
  background-image: repeating-linear-gradient(90deg, rgba(0,0,0,.32) 0 1px, transparent 1px 25%);
  pointer-events: none;
}
.sub-bars { display: flex; gap: 6px; margin-top: 4px; }
.sub-bars .bar { height: 4px; flex: 1; border-color: rgba(201,164,92,.18); clip-path: none; }
.bar.mana i { background: linear-gradient(90deg, #2b5c78, #63b6cc); transition: transform .2s; }
.bar.stam i { background: linear-gradient(90deg, #5a6a3a, #a8b86a); transition: transform .12s; }

.vital-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 5px; padding-right: 4px; }
.hp-num { font-family: var(--sans); font-size: 11px; letter-spacing: .1em; color: var(--bone-dim); }
.hp-num b { font-size: 15px; color: var(--bone); font-weight: 500; }
.hp-num i { font-style: normal; margin: 0 2px; opacity: .5; }
.hp-num s { text-decoration: none; color: rgba(226,214,190,.62); }

.focus { display: flex; gap: 5px; }
.focus i {
  width: 9px; height: 9px; transform: rotate(45deg);
  border: 1px solid rgba(201,164,92,.5); background: rgba(0,0,0,.4);
  transition: all .22s;
}
.focus i.on { background: radial-gradient(circle, var(--gold-hi), var(--gold-dim)); box-shadow: 0 0 10px rgba(240,220,160,.65); }
.focus i.full { border-color: #fff2cc; box-shadow: 0 0 14px rgba(255,240,200,.9); }

.hud-top { position: absolute; right: 30px; top: 26px; text-align: right; }
.combo { display: flex; align-items: baseline; gap: 6px; justify-content: flex-end; }
.combo b { font-size: 46px; line-height: 1; color: var(--gold-hi); font-weight: 600; text-shadow: 0 0 22px rgba(230,190,110,.55); }
.combo span { font-size: 12px; letter-spacing: .3em; color: var(--bone-dim); }
.combo.hidden { display: none; }
.combo.combo b { animation: comboPop .28s var(--ease); }
@keyframes comboPop { 0% { transform: scale(1.45); color: #fff; } 100% { transform: scale(1); } }

.hud-boss {
  position: absolute; left: 50%; bottom: 74px; transform: translateX(-50%);
  width: min(760px, 66vw); pointer-events: none;
  transition: opacity .5s, transform .5s;
}
.hud-boss.hidden { opacity: 0; transform: translateX(-50%) translateY(10px); visibility: hidden; }
.boss-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 6px; padding: 0 2px; }
.boss-name { display: flex; align-items: baseline; gap: 12px; }
.boss-name b { font-size: 20px; letter-spacing: .26em; color: var(--bone); text-shadow: 0 2px 10px #000; font-weight: 500; }
.boss-name span { font-family: var(--sans); font-size: 10px; letter-spacing: .2em; color: var(--gold); opacity: .8; }
.boss-phase { font-size: 11px; letter-spacing: .2em; color: var(--bone-dim); }
.boss-phase.rage { color: #f08a5a; text-shadow: 0 0 12px rgba(220,90,50,.8); }
.bar.boss { height: 10px; border-color: rgba(201,164,92,.45); clip-path: polygon(4px 0, 100% 0, calc(100% - 4px) 100%, 0 100%); }
.bar.boss s { background: linear-gradient(90deg, #5a1a12, #8a2a1c); opacity: .6; transition: transform .6s .12s var(--ease); }
.bar.boss i { background: linear-gradient(90deg, #7c2418, #b8402c 60%, #e07050); box-shadow: 0 0 16px rgba(190,60,40,.55); transition: transform .18s ease-out; }
.boss-line { margin-top: 5px; text-align: right; font-size: 11px; letter-spacing: .16em; color: rgba(220,210,190,.5); }

.hud-bottom { position: absolute; left: 28px; right: 28px; bottom: 22px; display: flex; align-items: flex-end; justify-content: space-between; }
.gourd-box { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.gourd {
  position: relative; width: 46px; height: 60px; display: flex; align-items: center; justify-content: center;
}
.gourd::before, .gourd::after {
  content: ''; position: absolute; left: 50%; transform: translateX(-50%);
  border: 1px solid rgba(201,164,92,.6); background: radial-gradient(circle at 40% 35%, rgba(120,60,30,.95), rgba(40,18,10,.95));
  box-shadow: 0 0 18px rgba(180,120,60,.25), inset 0 0 10px rgba(0,0,0,.7);
}
.gourd::before { width: 22px; height: 16px; top: 6px; border-radius: 50% 50% 40% 40%; }
.gourd::after { width: 36px; height: 34px; top: 20px; border-radius: 46% 46% 50% 50%; }
.gourd b { position: relative; z-index: 2; font-family: var(--sans); font-size: 16px; margin-top: 22px; color: var(--gold-hi); text-shadow: 0 1px 4px #000; }
.gourd-label { font-size: 9px; letter-spacing: .34em; color: rgba(220,210,190,.55); }

.stance-box {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 8px 16px 6px; margin-bottom: 4px; position: relative;
}
.stance-box::before {
  content: ''; position: absolute; inset: 0;
  border: 1px solid rgba(201,164,92,.22);
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 8px 100%, 0 50%);
  background: rgba(6,9,11,.5);
}
.stance-box b { position: relative; font-size: 24px; color: var(--gold-hi); line-height: 1; font-weight: 500; }
.stance-box span { position: relative; font-size: 10px; letter-spacing: .22em; color: var(--bone-dim); }
.stance-box em { position: relative; font-style: normal; font-family: var(--sans); font-size: 8px; letter-spacing: .1em; color: rgba(200,190,170,.4); margin-top: 2px; }

.skills { display: flex; gap: 10px; pointer-events: auto; }
.skill {
  position: relative; width: 56px; height: 56px; border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, rgba(28,32,34,.85), rgba(5,7,9,.9));
  border: 1px solid rgba(201,164,92,.4); color: var(--bone);
  font-family: var(--serif); cursor: pointer;
  box-shadow: inset 0 0 16px rgba(0,0,0,.8), 0 2px 10px rgba(0,0,0,.5);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: transform .18s var(--ease), border-color .2s, box-shadow .2s;
  overflow: hidden;
}
.skill:hover { transform: translateY(-2px); border-color: rgba(240,220,170,.8); box-shadow: 0 0 20px rgba(220,180,110,.28); }
.skill b { font-size: 21px; line-height: 1; color: var(--gold-hi); font-weight: 500; }
.skill small { font-size: 8px; letter-spacing: .08em; color: rgba(210,200,180,.62); margin-top: 3px; }
.skill .key {
  position: absolute; top: 2px; right: 6px; font-family: var(--sans); font-size: 8px; color: rgba(220,200,160,.7);
}
.skill i {
  position: absolute; inset: 0; background: rgba(2,4,6,.82);
  transform-origin: bottom center; transform: scaleY(0); pointer-events: none;
  border-radius: 50%;
}
.skill.ready { border-color: rgba(226,198,132,.62); }
.skill.ready::after {
  content: ''; position: absolute; inset: -3px; border-radius: 50%;
  border: 1px solid rgba(220,190,130,.14);
}

.hint-bar {
  position: absolute; left: 50%; top: 20px; transform: translateX(-50%);
  display: flex; gap: 16px; font-family: var(--sans); font-size: 10px; letter-spacing: .08em;
  color: rgba(210,200,180,.45); pointer-events: none;
}
.hint-bar b { color: rgba(232,216,180,.9); font-weight: 500; border: 1px solid rgba(201,164,92,.3); padding: 1px 5px; margin-right: 3px; }
.icon-btn {
  position: absolute; right: 28px; top: 74px; width: 34px; height: 34px; border-radius: 50%;
  background: rgba(6,9,11,.45); border: 1px solid rgba(201,164,92,.28);
  color: rgba(230,220,200,.7); font-family: var(--sans); font-size: 12px; cursor: pointer;
  pointer-events: auto; transition: all .2s;
}
.icon-btn:hover { border-color: var(--gold); color: var(--gold-hi); }

/* 画面上下压暗，保证 HUD 在明亮场景中也清晰 */
#hud::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 210px;
  background: linear-gradient(180deg, rgba(2,4,6,.62), rgba(2,4,6,0));
  pointer-events: none;
}
#hud::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 260px;
  background: linear-gradient(0deg, rgba(2,4,6,.78), rgba(2,4,6,0));
  pointer-events: none;
}
.hud-left, .hud-top, .hud-boss, .hud-bottom, .hint-bar, .icon-btn { z-index: 2; }
.hud-boss::before {
  content: ''; position: absolute; inset: -20px -80px -26px;
  background: radial-gradient(ellipse at 50% 55%, rgba(2,4,6,.55), rgba(2,4,6,0) 72%);
  pointer-events: none; z-index: -1;
}
.skills { position: relative; }
.skills::before {
  content: ''; position: absolute; inset: -22px -26px -20px -30px;
  background: radial-gradient(ellipse at 68% 50%, rgba(3,6,8,.62), rgba(3,6,8,0) 74%);
  pointer-events: none; z-index: -1;
}

/* =========================================================
   触屏
   ========================================================= */
#touch { position: absolute; inset: 0; z-index: 11; pointer-events: none; }
#touch.hidden { display: none; }
.stick {
  position: absolute; left: 26px; bottom: 100px; width: 130px; height: 130px;
  border-radius: 50%; pointer-events: auto; touch-action: none;
  background: radial-gradient(circle, rgba(20,24,26,.42), rgba(5,7,9,.18));
  border: 1px solid rgba(201,164,92,.18);
}
.stick-ring { position: absolute; inset: 22px; border-radius: 50%; border: 1px solid rgba(201,164,92,.16); }
.stick-knob {
  position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; margin: -24px 0 0 -24px;
  border-radius: 50%; background: radial-gradient(circle at 40% 35%, rgba(220,190,130,.28), rgba(30,26,20,.7));
  border: 1px solid rgba(220,190,130,.42); box-shadow: 0 0 16px rgba(0,0,0,.5);
  transition: transform .05s;
}
.tbtns { position: absolute; right: 22px; bottom: 96px; width: 210px; height: 190px; pointer-events: none; }
.tbtn {
  position: absolute; border-radius: 50%; pointer-events: auto;
  background: radial-gradient(circle at 50% 36%, rgba(30,32,30,.8), rgba(6,8,10,.86));
  border: 1px solid rgba(201,164,92,.36); color: var(--bone);
  display: flex; align-items: center; justify-content: center; touch-action: none;
  box-shadow: inset 0 0 12px rgba(0,0,0,.8);
}
.tbtn small { font-size: 19px; color: var(--gold-hi); font-family: var(--serif); }
.tbtn.active { transform: scale(.93); background: rgba(201,164,92,.2); }
.tbtn .cd {
  position: absolute; inset: 0; border-radius: 50%; background: rgba(2,4,6,.72);
  transform-origin: bottom center; transform: scaleY(0); pointer-events: none;
}
.tbtn[data-act="light"] { right: 0; bottom: 0; width: 86px; height: 86px; }
.tbtn[data-act="light"] small { font-size: 27px; }
.tbtn[data-act="heavy"] { right: 0; bottom: 94px; width: 68px; height: 68px; }
.tbtn[data-act="dodge"] { right: 94px; bottom: 8px; width: 62px; height: 62px; }
.tbtn[data-act="spell1"] { right: 80px; bottom: 84px; width: 48px; height: 48px; }
.tbtn[data-act="spell2"] { right: 132px; bottom: 126px; width: 46px; height: 46px; }
.tbtn[data-act="spell3"] { right: 76px; bottom: 146px; width: 46px; height: 46px; }
.tbtn[data-act="heal"] { right: 14px; bottom: 172px; width: 46px; height: 46px; }
.tbtn[data-act="stance"] { right: 158px; bottom: 68px; width: 42px; height: 42px; }
.tbtn[data-act="lock"] { right: 152px; bottom: 18px; width: 42px; height: 42px; }
.tbtn b { position: absolute; right: -2px; top: -2px; font-family: var(--sans); font-size: 10px; color: var(--gold-hi); }
body.mode-pc #touch { display: none; }

/* 触屏布局：隐藏桌面技能栏与提示，Boss 血条上移避开按键 */
body.mode-touch .hud-bottom { display: none; }
body.mode-touch .hint-bar { display: none; }
body.mode-touch .hud-boss { top: 116px; bottom: auto; width: 92vw; }
body.mode-touch .hud-left { width: min(300px, 62vw); left: 18px; top: 16px; }
body.mode-touch .stick { left: 20px; bottom: 92px; width: 118px; height: 118px; }
body.mode-touch .tbtns { right: 14px; bottom: 78px; width: 200px; height: 220px; }

/* ---------------------------------------------------------
   触屏横屏（手机主力玩法）：视口只有 375~430px 高，
   固定的 top:116px 会把妖王血条顶到画面正中、挡住角色。
   改为贴底居中——左下是摇杆、右下是技能键，中间底部正好是净空区。
   同时按安全区缩进，避开刘海屏 / 挖孔屏。
   --------------------------------------------------------- */
@media (orientation: landscape) and (max-height: 560px) {
  body.mode-touch .hud-boss {
    top: auto;
    bottom: calc(6px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    width: min(44vw, 420px);
    transform: translateX(-50%);
  }
  body.mode-touch .hud-boss.hidden { transform: translateX(-50%) translateY(10px); }
  body.mode-touch .boss-head { margin-bottom: 3px; }
  body.mode-touch .boss-name b { font-size: 14px; }
  body.mode-touch .boss-phase { font-size: 10px; }
  body.mode-touch .bar.boss { height: 9px; }
  body.mode-touch .boss-line { display: none; }
  body.mode-touch #hud .hud-left {
    top: calc(8px + env(safe-area-inset-top, 0px));
    left: calc(14px + env(safe-area-inset-left, 0px));
    width: min(250px, 34vw);
  }
  body.mode-touch .hud-top {
    top: calc(8px + env(safe-area-inset-top, 0px));
    right: calc(14px + env(safe-area-inset-right, 0px));
  }
  body.mode-touch .combo b { font-size: 26px; }
  body.mode-touch .stick { left: calc(20px + env(safe-area-inset-left, 0px)); bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }
  body.mode-touch .tbtns { right: calc(14px + env(safe-area-inset-right, 0px)); bottom: calc(56px + env(safe-area-inset-bottom, 0px)); }
  body.mode-touch .pause-btn { right: calc(14px + env(safe-area-inset-right, 0px)); top: calc(8px + env(safe-area-inset-top, 0px)); }
}

/* =========================================================
   界面屏幕
   ========================================================= */
#ui { position: absolute; inset: 0; z-index: 20; pointer-events: none; }
#ui .screen {
  position: absolute; inset: 0; pointer-events: auto;
  display: flex; flex-direction: column;
  padding: clamp(24px, 5vh, 64px) clamp(24px, 6vw, 96px);
  animation: screenIn .55s var(--ease) both;
}
@keyframes screenIn { from { opacity: 0; } to { opacity: 1; } }

/* 主菜单 */
.screen.menu {
  background:
    linear-gradient(90deg, rgba(3,5,7,.96) 0%, rgba(3,5,7,.82) 32%, rgba(3,5,7,.28) 62%, rgba(3,5,7,.55) 100%),
    radial-gradient(ellipse at 72% 42%, rgba(120,80,30,.18), transparent 60%);
  justify-content: center;
}
.menu-inner { position: relative; max-width: 620px; animation: menuUp 1s var(--ease) both; }
@keyframes menuUp { from { opacity: 0; transform: translateY(26px); } to { opacity: 1; transform: translateY(0); } }

.brand-en {
  font-family: var(--sans); font-size: 10px; letter-spacing: .62em;
  color: rgba(201,164,92,.72); margin-bottom: 10px;
}
.brand {
  position: relative; font-size: clamp(64px, 10vw, 120px); line-height: .92;
  letter-spacing: .06em; font-weight: 500; margin: 0;
  background: linear-gradient(180deg, #f6ecd4 4%, #e2cda0 38%, #b58e4d 78%, #8c6a34 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 10px 30px rgba(0,0,0,.7));
}
.brand .seal {
  position: absolute; right: -62px; top: 6px; width: 54px; height: 54px;
  border: 1.5px solid rgba(180,60,44,.9); border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  color: #e6d7bb; background: rgba(110,28,20,.82);
  font-size: 13px; line-height: 1.05; letter-spacing: .04em; text-align: center;
  transform: rotate(4deg); box-shadow: 0 4px 18px rgba(0,0,0,.5);
}
.brand-sub {
  display: flex; align-items: center; gap: 14px; margin: 16px 0 0;
  font-size: 14px; letter-spacing: .5em; color: rgba(226,210,180,.8);
}
.brand-sub::before, .brand-sub::after { content: ''; height: 1px; width: 48px; background: linear-gradient(90deg, transparent, rgba(201,164,92,.6)); }
.brand-sub::after { background: linear-gradient(90deg, rgba(201,164,92,.6), transparent); }

.menu-nav { margin-top: clamp(28px, 5vh, 52px); display: flex; flex-direction: column; gap: 2px; }
.mbtn {
  position: relative; display: flex; align-items: center; gap: 18px;
  padding: 13px 10px 13px 2px; background: transparent; border: 0;
  color: var(--bone-dim); font-family: var(--serif); font-size: clamp(16px, 1.6vw, 19px);
  letter-spacing: .32em; text-align: left; cursor: pointer;
  transition: color .3s, padding-left .45s var(--ease);
}
.mbtn small {
  font-family: var(--sans); font-size: 9px; letter-spacing: .24em;
  color: rgba(201,164,92,.5); opacity: 0; transform: translateX(-8px);
  transition: all .35s var(--ease);
}
.mbtn .idx { font-family: var(--sans); font-size: 9px; color: rgba(201,164,92,.4); width: 16px; }
.mbtn::before {
  content: ''; position: absolute; left: 0; top: 50%; width: 0; height: 1px;
  background: linear-gradient(90deg, var(--gold), transparent); transition: width .4s var(--ease);
}
.mbtn::after {
  content: ''; position: absolute; left: -10px; top: 50%; width: 4px; height: 4px;
  background: var(--gold); transform: translateY(-50%) rotate(45deg) scale(0); transition: transform .3s;
}
.mbtn:hover, .mbtn.primary:hover { color: var(--gold-hi); padding-left: 22px; }
.mbtn:hover small { opacity: 1; transform: translateX(0); }
.mbtn:hover::before { width: 100%; }
.mbtn:hover::after { transform: translateY(-50%) rotate(45deg) scale(1); }
.mbtn.primary { color: var(--bone); font-size: clamp(18px, 1.8vw, 22px); }
.mbtn.primary::before { width: 34px; background: linear-gradient(90deg, var(--gold), transparent); }
.mbtn.primary:hover::before { width: 100%; }

.menu-side {
  position: absolute; right: clamp(24px, 5vw, 80px); bottom: clamp(24px, 5vh, 48px);
  text-align: right; font-family: var(--sans); font-size: 10px; letter-spacing: .18em;
  color: rgba(210,200,180,.55); line-height: 2;
  padding: 12px 16px; border: 1px solid rgba(201,164,92,.14);
  background: linear-gradient(180deg, rgba(4,7,9,.66), rgba(4,7,9,.5));
  backdrop-filter: blur(3px);
}
.menu-side b { color: rgba(230,212,176,.8); font-weight: 400; }
.menu-ver { position: absolute; right: clamp(24px, 5vw, 80px); top: clamp(24px, 4vh, 40px); font-family: var(--sans); font-size: 9px; letter-spacing: .3em; color: rgba(200,190,170,.34); }
.menu-orn {
  position: absolute; right: 12vw; top: 18vh; width: 34vw; height: 34vw;
  max-width: 520px; max-height: 520px; border: 1px solid rgba(201,164,92,.1); border-radius: 50%;
  pointer-events: none; animation: spin 90s linear infinite;
}
.menu-orn::before {
  content: ''; position: absolute; inset: 8%; border: 1px solid rgba(201,164,92,.07); border-radius: 50%;
}
.menu-orn i { position: absolute; left: 50%; top: -3px; width: 5px; height: 5px; background: rgba(201,164,92,.5); transform: translateX(-50%) rotate(45deg); }
@keyframes spin { to { transform: rotate(360deg); } }

/* 通用面板 */
.panel-head { margin-bottom: clamp(18px, 3.4vh, 34px); animation: menuUp .7s var(--ease) both; }
.panel-head h2 { margin: 0; font-size: clamp(26px, 3.4vw, 38px); font-weight: 500; letter-spacing: .3em; color: var(--bone); }
.panel-head p { margin: 8px 0 0; font-family: var(--sans); font-size: 10px; letter-spacing: .28em; color: rgba(201,164,92,.62); }
.panel-head::after { content: ''; display: block; width: 64px; height: 1px; margin-top: 14px; background: linear-gradient(90deg, var(--gold), transparent); }
.screen.dim { background: linear-gradient(180deg, rgba(3,5,7,.93), rgba(3,5,7,.86) 60%, rgba(3,5,7,.95)); backdrop-filter: blur(6px); }

/* 章节 */
.chapters { display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(10px, 1.4vw, 20px); }
.chapter {
  position: relative; min-height: clamp(300px, 46vh, 430px);
  border: 1px solid rgba(201,164,92,.2); overflow: hidden; cursor: pointer;
  background: linear-gradient(180deg, rgba(14,18,20,.9), rgba(5,7,9,.96));
  transition: transform .45s var(--ease), border-color .3s, box-shadow .45s;
  padding: 22px 20px; display: flex; flex-direction: column;
  animation: cardIn .8s var(--ease) both;
}
.chapter:nth-child(1) { animation-delay: .04s; }
.chapter:nth-child(2) { animation-delay: .1s; }
.chapter:nth-child(3) { animation-delay: .16s; }
.chapter:nth-child(4) { animation-delay: .22s; }
@keyframes cardIn { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: translateY(0); } }
.chapter::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 18%, var(--accent, #c9a45c) 0%, transparent 62%);
  opacity: .1; transition: opacity .5s;
}
.chapter::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent, #c9a45c), transparent);
  opacity: .3; transition: opacity .4s;
}
.chapter:hover { transform: translateY(-8px); border-color: rgba(226,196,138,.55); box-shadow: 0 24px 60px rgba(0,0,0,.6); }
.chapter:hover::before { opacity: .24; }
.chapter:hover::after { opacity: .9; }
.chapter.locked { opacity: .42; cursor: not-allowed; filter: saturate(.35); }
.chapter.locked:hover { transform: none; }
.cno { font-family: var(--sans); font-size: 10px; letter-spacing: .3em; color: var(--accent, #c9a45c); opacity: .85; }
.chapter h3 { margin: 12px 0 4px; font-size: clamp(22px, 2.2vw, 30px); font-weight: 500; letter-spacing: .18em; color: var(--bone); }
.boss-line { font-size: 11px; letter-spacing: .16em; color: var(--accent, #c9a45c); opacity: .8; }
.chapter .desc { margin-top: 18px; font-size: 12px; line-height: 2; letter-spacing: .06em; color: rgba(210,202,186,.62); flex: 1; }
.clear-tag, .lock-tag {
  align-self: flex-start; margin-top: 14px; font-family: var(--sans); font-size: 9px; letter-spacing: .2em;
  padding: 4px 10px; border: 1px solid rgba(201,164,92,.28); color: rgba(226,210,180,.72);
}
.clear-tag { border-color: rgba(180,70,50,.7); color: #e8b6a0; background: rgba(80,22,14,.35); position: absolute; top: 18px; right: 16px; margin: 0; }
.lock-tag::before { content: '· '; }

/* 修行树 */
.tree-wrap { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(10px, 2vw, 28px); flex: 1; align-items: start; }
.tree-branch {
  border: 1px solid rgba(201,164,92,.16); background: linear-gradient(180deg, rgba(14,18,20,.75), rgba(5,7,9,.9));
  padding: 20px 18px 24px; animation: cardIn .8s var(--ease) both;
}
.tree-branch:nth-child(2) { animation-delay: .08s; }
.tree-branch:nth-child(3) { animation-delay: .16s; }
.tree-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.tree-icon {
  width: 40px; height: 40px; display: grid; place-items: center;
  border: 1px solid var(--bc, #c9a45c); color: var(--bc, #c9a45c); font-size: 19px;
  transform: rotate(45deg); background: rgba(0,0,0,.35);
}
.tree-icon span { transform: rotate(-45deg); }
.tree-head h3 { margin: 0; font-size: 18px; letter-spacing: .24em; font-weight: 500; color: var(--bone); }
.tree-head em { display: block; font-style: normal; font-family: var(--sans); font-size: 8px; letter-spacing: .3em; color: rgba(210,200,180,.4); margin-top: 4px; }
.tree-node {
  position: relative; display: flex; gap: 12px; padding: 14px 0 14px 18px;
  border-left: 1px solid rgba(201,164,92,.16); margin-left: 8px;
}
.tree-node::before {
  content: ''; position: absolute; left: -4px; top: 22px; width: 7px; height: 7px;
  border: 1px solid rgba(201,164,92,.4); transform: rotate(45deg); background: var(--ink);
}
.tree-node.on::before { background: var(--bc, #c9a45c); box-shadow: 0 0 10px var(--bc, #c9a45c); }
.node-body { flex: 1; }
.node-body h4 { margin: 0 0 5px; font-size: 14px; font-weight: 500; letter-spacing: .12em; color: var(--bone); }
.node-body p { margin: 0; font-size: 11px; line-height: 1.7; color: rgba(200,192,176,.55); letter-spacing: .04em; }
.node-btn {
  align-self: center; flex: 0 0 auto; font-family: var(--sans); font-size: 10px; letter-spacing: .1em;
  padding: 5px 10px; background: rgba(201,164,92,.1); border: 1px solid rgba(201,164,92,.35);
  color: var(--gold-hi); cursor: pointer; transition: all .2s;
}
.node-btn:hover:not(:disabled) { background: rgba(201,164,92,.24); box-shadow: 0 0 14px rgba(201,164,92,.25); }
.node-btn:disabled { opacity: .35; cursor: not-allowed; }
.node-btn.done { color: rgba(160,200,160,.8); border-color: rgba(120,170,120,.35); background: rgba(40,70,40,.2); }

.res-row {
  display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-bottom: 20px;
  font-family: var(--sans); font-size: 11px; letter-spacing: .2em; color: rgba(210,200,180,.55);
}
.res-row b { font-family: var(--serif); font-size: 26px; color: var(--gold-hi); font-weight: 500; letter-spacing: .05em; }
.res-row::before { content: '灵 蕴'; font-size: 9px; color: var(--gold); }

/* 图鉴 */
.bestiary { display: flex; gap: clamp(16px, 3vw, 40px); flex: 1; min-height: 0; }
.best-list { display: flex; flex-direction: column; gap: 6px; width: 220px; flex: 0 0 auto; }
.best-tab {
  text-align: left; background: transparent; border: 1px solid rgba(201,164,92,.14);
  color: var(--bone-dim); padding: 12px 16px; cursor: pointer; font-family: var(--serif);
  font-size: 14px; letter-spacing: .18em; transition: all .3s; position: relative;
}
.best-tab small { display: block; font-family: var(--sans); font-size: 8px; letter-spacing: .16em; color: rgba(210,200,180,.35); margin-top: 3px; }
.best-tab:hover { border-color: rgba(201,164,92,.4); color: var(--bone); }
.best-tab.on { border-color: rgba(201,164,92,.6); background: linear-gradient(90deg, rgba(201,164,92,.15), transparent); color: var(--gold-hi); }
.best-tab.on::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--gold); }
.best-body {
  flex: 1; border: 1px solid rgba(201,164,92,.16); padding: clamp(20px, 3vw, 40px);
  background: linear-gradient(160deg, rgba(16,20,22,.7), rgba(5,7,9,.9));
  position: relative; overflow: auto;
}
.best-body::before {
  content: ''; position: absolute; right: 30px; top: 10px; width: 1px; height: 120px;
  background: linear-gradient(180deg, rgba(201,164,92,.4), transparent);
}
.best-body h3 { margin: 0; font-size: clamp(30px, 4vw, 48px); font-weight: 500; letter-spacing: .18em; color: var(--bone); }
.b-sub { margin-top: 6px; font-family: var(--sans); font-size: 10px; letter-spacing: .3em; color: var(--gold); }
.best-body p { max-width: 640px; font-size: 13px; line-height: 2.2; letter-spacing: .05em; color: rgba(214,206,190,.7); margin: 22px 0; }
.moves { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 22px; }
.moves span {
  font-size: 11px; letter-spacing: .12em; padding: 5px 12px;
  border: 1px solid rgba(201,164,92,.24); color: rgba(226,210,180,.78);
  background: rgba(201,164,92,.05);
}
.tips { border-left: 2px solid rgba(201,164,92,.45); padding-left: 16px; }
.tips p { margin: 0; color: rgba(200,192,176,.55); font-size: 12px; }

/* 设置 / 帮助 */
.set-list { max-width: 780px; }
.setting-row {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 18px 2px; border-bottom: 1px solid rgba(201,164,92,.1);
}
.s-name { font-size: 15px; letter-spacing: .16em; color: var(--bone); }
.s-desc { font-family: var(--sans); font-size: 10px; letter-spacing: .06em; color: rgba(200,192,176,.45); margin-top: 5px; }
.seg { display: flex; border: 1px solid rgba(201,164,92,.24); flex: 0 0 auto; }
.seg button {
  background: transparent; border: 0; border-left: 1px solid rgba(201,164,92,.16);
  color: rgba(210,202,186,.55); font-family: var(--serif); font-size: 12px; letter-spacing: .1em;
  padding: 7px 14px; cursor: pointer; transition: all .2s;
}
.seg button:first-child { border-left: 0; }
.seg button:hover { color: var(--bone); background: rgba(201,164,92,.08); }
.seg button.on { color: var(--gold-hi); background: rgba(201,164,92,.18); box-shadow: inset 0 0 12px rgba(201,164,92,.1); }

.keys-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 40px; max-width: 760px; }
.krow { display: flex; align-items: center; justify-content: space-between; padding: 11px 2px; border-bottom: 1px solid rgba(201,164,92,.09); }
.krow span { font-size: 13px; letter-spacing: .14em; color: var(--bone-dim); }
.krow b { font-family: var(--sans); font-size: 10px; letter-spacing: .08em; color: var(--gold-hi); font-weight: 400; }
.footnote { margin-top: 24px; font-size: 11px; line-height: 2; letter-spacing: .08em; color: rgba(200,192,176,.42); max-width: 720px; }

/* 按钮组 */
.result-btns { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.rbtn {
  min-width: 170px; padding: 13px 26px; background: rgba(201,164,92,.07);
  border: 1px solid rgba(201,164,92,.32); color: var(--bone);
  font-family: var(--serif); font-size: 14px; letter-spacing: .26em; cursor: pointer;
  transition: all .3s var(--ease); position: relative; overflow: hidden;
}
.rbtn:hover { background: rgba(201,164,92,.18); border-color: rgba(240,220,170,.7); color: var(--gold-hi); box-shadow: 0 0 22px rgba(201,164,92,.18); }
.rbtn.primary { background: linear-gradient(90deg, rgba(150,110,40,.35), rgba(201,164,92,.14)); border-color: rgba(226,196,138,.6); color: var(--gold-hi); }
.rbtn.ghost { background: transparent; border-color: rgba(201,164,92,.18); color: rgba(210,200,180,.6); }

/* 暂停 */
.screen.paused { background: linear-gradient(90deg, rgba(3,5,7,.95) 0%, rgba(3,5,7,.8) 42%, rgba(3,5,7,.5) 100%); backdrop-filter: blur(3px); justify-content: center; }
.pause-inner { max-width: 420px; }
.pause-inner .panel-head h2 { font-size: clamp(30px, 4vw, 44px); }
.pause-menu { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; }

/* 胜负 */
.screen.result { align-items: center; justify-content: center; text-align: center; background: radial-gradient(ellipse at 50% 45%, rgba(20,12,8,.6), rgba(2,3,5,.96) 70%); }
.result-big {
  font-size: clamp(110px, 20vw, 230px); line-height: 1; font-weight: 500; margin: 0;
  letter-spacing: .06em;
  background: linear-gradient(180deg, #f8f0da, #d9bd85 45%, #8f6c34);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 18px 40px rgba(0,0,0,.8));
  animation: sealIn 1.1s var(--ease) both;
}
.result-big.lose { background: linear-gradient(180deg, #d8c8c0, #8a6a60 45%, #4a302a); -webkit-background-clip: text; background-clip: text; }
@keyframes sealIn { 0% { opacity: 0; transform: scale(1.5); filter: blur(14px); } 100% { opacity: 1; transform: scale(1); filter: blur(0); } }
.result-sub { margin-top: 8px; font-size: 13px; letter-spacing: .4em; color: rgba(226,210,180,.7); }
.stats { display: flex; gap: clamp(24px, 5vw, 64px); margin: 38px 0 34px; }
.stat { min-width: 80px; }
.stat b { display: block; font-family: var(--serif); font-size: clamp(22px, 2.6vw, 32px); color: var(--gold-hi); font-weight: 500; }
.stat span { display: block; margin-top: 6px; font-family: var(--sans); font-size: 9px; letter-spacing: .26em; color: rgba(210,200,180,.5); }

/* 加载 */
.loading {
  position: absolute; inset: 0; z-index: 60; background: radial-gradient(ellipse at 50% 45%, #0d1316, #030405 70%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: opacity 1s var(--ease), visibility 1s;
}
.loading.done { opacity: 0; visibility: hidden; pointer-events: none; }
.load-ink { position: relative; width: 132px; height: 132px; margin-bottom: 34px; }
.load-ink i {
  position: absolute; inset: 0; border-radius: 50%;
  border: 1px solid rgba(201,164,92,.2); border-top-color: rgba(240,220,170,.9);
  animation: spin 2.6s linear infinite;
}
.load-ink i:nth-child(2) { inset: 14px; border-color: rgba(201,164,92,.14); border-right-color: rgba(201,164,92,.7); animation-duration: 3.6s; animation-direction: reverse; }
.load-ink i:nth-child(3) { inset: 30px; border-color: rgba(201,164,92,.1); border-bottom-color: rgba(180,90,50,.8); animation-duration: 4.8s; }
.load-ink::after {
  content: '悟'; position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 30px; color: rgba(226,206,166,.85); text-shadow: 0 0 24px rgba(201,164,92,.3);
}
.load-title { font-size: clamp(30px, 4vw, 44px); letter-spacing: .4em; color: var(--bone); text-indent: .4em; }
.load-sub { margin-top: 8px; font-size: 11px; letter-spacing: .8em; color: var(--gold); text-indent: .8em; }
.load-bar { margin-top: 32px; width: min(360px, 60vw); height: 2px; background: rgba(201,164,92,.14); overflow: hidden; }
.load-bar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, rgba(201,164,92,.5), var(--gold-hi)); transition: width .4s var(--ease); box-shadow: 0 0 12px rgba(240,220,170,.5); }
.load-tip { margin-top: 16px; font-family: var(--sans); font-size: 9px; letter-spacing: .24em; color: rgba(200,192,176,.4); }

/* Toast */
.toast {
  position: absolute; left: 50%; top: 16%; transform: translateX(-50%);
  padding: 9px 24px; background: rgba(6,9,11,.82); border: 1px solid rgba(201,164,92,.3);
  color: rgba(236,224,200,.92); font-size: 12px; letter-spacing: .22em; z-index: 45;
  pointer-events: none; animation: toastIn .3s var(--ease);
  backdrop-filter: blur(4px); white-space: nowrap;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(-8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* 滚动条 */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-thumb { background: rgba(201,164,92,.28); }
::-webkit-scrollbar-track { background: transparent; }

/* =========================================================
   响应式
   ========================================================= */
@media (max-width: 1100px) {
  .chapters { grid-template-columns: repeat(2, 1fr); }
  .chapter { min-height: 220px; }
  .chapter .desc { display: none; }
  .menu-orn { display: none; }
}
@media (max-width: 820px) {
  #hud .hud-left { left: 14px; top: 12px; width: 44vw; }
  .who-name { font-size: 13px; }
  .chapter-tag { font-size: 8px; }
  .hud-top { right: 14px; top: 14px; }
  .combo b { font-size: 34px; }
  .hint-bar { display: none; }
  .pause-btn { right: 14px; top: 58px; }
  /* 窄屏 PC 窗口仍把妖王血条压在底部；触屏另有顶部布局规则 */
  .hud-boss { bottom: 74px; width: calc(100vw - 28px); }
  .boss-name b { font-size: 15px; }
  .boss-name span { display: none; }
  .hud-bottom { left: 12px; right: 12px; bottom: 10px; }
  body.mode-touch .stance-box,
  body.mode-touch .gourd-box,
  body.mode-touch .skills { display: none; }
  .skill { width: 48px; height: 48px; }
  .skill small { display: none; }
  .screen { padding: 20px 18px; }
  .brand .seal { right: -44px; width: 42px; height: 42px; font-size: 10px; }
  .brand { font-size: clamp(54px, 15vw, 78px); }
  .menu-nav { margin-top: 24px; }
  .mbtn { padding: 11px 0; font-size: 15px; }
  .chapters { grid-template-columns: 1fr; gap: 8px; }
  .chapter { min-height: 116px; padding: 14px 16px; }
  .chapter .desc { display: none; }
  .chapter h3 { font-size: 21px; margin: 5px 0 2px; }
  .tree-wrap { grid-template-columns: 1fr; gap: 10px; overflow-y: auto; }
  .tree-branch { padding: 14px; }
  .bestiary { flex-direction: column; }
  .best-list { width: 100%; flex-direction: row; overflow-x: auto; }
  .best-tab { flex: 0 0 auto; padding: 8px 12px; font-size: 12px; }
  .best-tab small { display: none; }
  .best-body { padding: 18px; }
  .best-body h3 { font-size: 28px; }
  .keys-grid { grid-template-columns: 1fr; }
  .setting-row { flex-direction: column; align-items: flex-start; gap: 10px; }
  .stats { gap: 20px; flex-wrap: wrap; justify-content: center; }
  .rbtn { min-width: 130px; padding: 11px 18px; font-size: 12px; }
  .menu-side { display: none; }
  .menu-ver { top: 14px; right: 16px; }
  .result-btns { justify-content: center; }
}
@media (max-height: 560px) {
  .brand { font-size: 48px; }
  .menu-nav { margin-top: 10px; gap: 0; }
  .mbtn { padding: 7px 0; font-size: 13px; }
  .panel-head { margin-bottom: 12px; }
  .panel-head h2 { font-size: 22px; }
}
