:root {
  --amber: #ffbf5e; --amber2: #ff8a2a; --ink: #f3ead8; --dim: #b9b0a0; --panel: rgba(18, 17, 22, .78); --line: rgba(255, 210, 140, .28);
  --sat: env(safe-area-inset-top, 0px); --sar: env(safe-area-inset-right, 0px); --sab: env(safe-area-inset-bottom, 0px); --sal: env(safe-area-inset-left, 0px);
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", serif;
  --sans: -apple-system, "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #14161b; overflow: hidden; overscroll-behavior: none; }
body { font-family: var(--sans); color: var(--ink); -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: none; }
#app { position: fixed; inset: 0; overflow: hidden; }
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
kbd { display: inline-block; min-width: 1.5em; padding: 0 .35em; margin: 0 .2em; border: 1px solid rgba(255,255,255,.35); border-bottom-width: 2px; border-radius: 4px; font: 600 .82em var(--sans); color: #fff; background: rgba(255,255,255,.08); text-align: center; }

/* ---------- 屏幕效果 ---------- */
#vignette { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, transparent 45%, rgba(160, 10, 0, .75) 100%); }
#hurt { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, rgba(255, 40, 20, 0) 35%, rgba(255, 40, 20, .7) 100%); }
#app::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse 85% 80% at 50% 50%, transparent 58%, rgba(5, 6, 10, .5) 100%); }
#fade { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; }

/* ---------- 伤害数字 ---------- */
#numbers { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.dmg { position: absolute; left: 0; top: 0; font: 800 20px/1 var(--sans); color: #fff6e6; text-shadow: 0 2px 0 #4a2200, 0 0 6px rgba(0,0,0,.8); white-space: nowrap; will-change: transform, opacity; }
.dmg.big { font-size: 25px; color: #ffd27a; }
.dmg.crit { font-size: 30px; color: #ffe85a; text-shadow: 0 2px 0 #8a2a00, 0 0 12px rgba(255, 140, 0, .8); }
.dmg.crit::after { content: "!"; }
.dmg.hurt { color: #ff6b5a; font-size: 22px; text-shadow: 0 2px 0 #3a0000, 0 0 6px #000; }
.dmg.heal { color: #8dffad; text-shadow: 0 2px 0 #003a10, 0 0 6px #000; }
.dmg.info { font-size: 15px; color: #e8e2ff; text-shadow: 0 1px 0 #000, 0 0 6px #000; font-weight: 700; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; }
.hud-tl { position: absolute; left: calc(14px + var(--sal)); top: calc(12px + var(--sat)); display: flex; gap: 10px; align-items: flex-start; }
.lvl-badge { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; align-content: center; background: radial-gradient(circle at 35% 30%, #4a3a26, #1d1812); border: 2px solid var(--amber); box-shadow: 0 0 14px rgba(255, 170, 60, .35), inset 0 0 8px rgba(0,0,0,.6); line-height: 1; }
.lvl-badge small { font-size: 9px; color: var(--amber); letter-spacing: .05em; }
.lvl-badge b { font-size: 19px; font-weight: 800; }
.bars { display: flex; flex-direction: column; gap: 5px; padding-top: 3px; }
.bar { position: relative; width: 230px; height: 16px; border-radius: 3px; background: rgba(10, 10, 14, .72); border: 1px solid rgba(255,255,255,.14); overflow: hidden; box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.bar i { position: absolute; inset: 0; transform-origin: 0 50%; }
.bar.hp .fill { background: linear-gradient(#ff6a52, #c62a1e 60%, #9b1d14); }
.bar .lag { background: #fff2dc; opacity: .75; }
.bar span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; font-weight: 700; text-shadow: 0 1px 2px #000; letter-spacing: .02em; }
.bar.st { height: 7px; width: 190px; }
.bar.st .fill { background: linear-gradient(#ffe7a0, #e0a83a); }
.bar.st.low .fill { background: linear-gradient(#ff9d7a, #c4522a); }
.xprow { display: flex; align-items: center; gap: 8px; }
.xp { position: relative; width: 140px; height: 4px; border-radius: 2px; background: rgba(10,10,14,.7); overflow: hidden; }
.xp i { position: absolute; inset: 0; transform-origin: 0 50%; background: linear-gradient(90deg, #ff8a2a, #ffd27a); }
.shard { font-size: 13px; font-weight: 700; text-shadow: 0 1px 2px #000; }
.shard em { font-style: normal; color: var(--amber2); margin-right: 3px; text-shadow: 0 0 8px rgba(255, 138, 42, .9); }

.hud-tc { position: absolute; left: 50%; top: calc(10px + var(--sat)); transform: translateX(-50%); text-align: center; width: min(46vw, 460px); }
#pips { display: flex; justify-content: center; gap: 10px; margin-bottom: 5px; }
#pips i { width: 13px; height: 13px; transform: rotate(45deg); border: 2px solid rgba(220, 220, 240, .55); background: rgba(40, 40, 55, .7); transition: .4s; }
#pips i.lit { border-color: #fff1c8; background: var(--amber); box-shadow: 0 0 12px var(--amber2); }
#obj { font: 700 17px/1.25 var(--serif); letter-spacing: .06em; text-shadow: 0 2px 4px #000, 0 0 12px rgba(0,0,0,.6); }
#objSub { font-size: 12.5px; color: var(--dim); margin-top: 3px; text-shadow: 0 1px 3px #000; min-height: 1em; }

.hud-tr { position: absolute; right: calc(12px + var(--sar)); top: calc(10px + var(--sat)); display: flex; gap: 8px; align-items: flex-start; }
.mini-wrap { width: 118px; height: 138px; border-radius: 10px; overflow: hidden; background: rgba(12, 13, 18, .62); border: 1px solid var(--line); box-shadow: 0 4px 14px rgba(0,0,0,.45); }
#mini { width: 100%; height: 100%; display: block; }
.sys { display: flex; flex-direction: column; gap: 8px; }
.sysbtn { pointer-events: auto; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: rgba(14, 14, 20, .68); border: 1px solid var(--line); color: #f1e6d0; }
.sysbtn svg { width: 22px; height: 22px; }
#bMute .x { display: none; } #bMute.off .x { display: inline; } #bMute.off .wave { display: none; }

#bossBar { position: absolute; left: 50%; bottom: calc(26px + var(--sab)); transform: translateX(-50%); width: min(58vw, 620px); text-align: center; opacity: 0; transition: opacity .5s; }
#bossBar.show { opacity: 1; }
#bossName { font: 700 16px var(--serif); letter-spacing: .2em; color: #ffd9c8; text-shadow: 0 2px 4px #000, 0 0 10px rgba(255, 60, 30, .5); margin-bottom: 5px; }
#bossBar .bar { width: 100%; height: 13px; border-color: rgba(255, 160, 120, .4); }
#bossBar .fill { background: linear-gradient(#e2492e, #8f1a10); }

#toast { position: absolute; left: 50%; bottom: calc(58px + var(--sab)); transform: translate(-50%, 8px); padding: 9px 18px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); font-size: 14px; text-align: center; opacity: 0; transition: .35s; max-width: min(88vw, 520px); box-shadow: 0 8px 24px rgba(0,0,0,.4); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#hud.bossfight #toast { bottom: calc(70px + var(--sab)); }
#toast b { display: block; color: var(--amber); font: 700 15px var(--serif); letter-spacing: .08em; margin-bottom: 2px; }
#toast span { color: #e6dccb; font-size: 13px; }

#banner { position: absolute; left: 0; right: 0; top: 17%; text-align: center; opacity: 0; transform: scale(.96); transition: opacity .6s, transform .6s; pointer-events: none; }
#banner.show { opacity: 1; transform: none; }
#banner .b-t { display: inline-block; padding: 8px 46px; font: 800 34px/1.2 var(--serif); letter-spacing: .25em; color: #fff3dc; text-shadow: 0 3px 10px #000, 0 0 24px rgba(255, 170, 60, .55); background: linear-gradient(90deg, transparent, rgba(10,10,14,.55) 20%, rgba(10,10,14,.55) 80%, transparent); }
#banner .b-s { margin-top: 8px; font-size: 15px; color: #e5d9c4; text-shadow: 0 2px 4px #000; letter-spacing: .06em; }
#banner.gold .b-t { color: #ffe2a2; }
#banner.boss .b-t { color: #ffd0c0; text-shadow: 0 3px 10px #000, 0 0 26px rgba(255, 50, 20, .7); }
#banner.intro .b-t { font-size: 44px; }
#banner.low { top: 66%; }

#prompt { position: absolute; left: 50%; bottom: calc(18% + var(--sab)); transform: translateX(-50%); padding: 8px 16px; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); font-size: 15px; opacity: 0; transition: .25s; }
#prompt.show { opacity: 1; }
#keys { position: absolute; left: 50%; bottom: calc(10px + var(--sab)); transform: translateX(-50%); display: flex; gap: 14px; font-size: 12px; color: rgba(240, 230, 210, .7); white-space: nowrap; text-shadow: 0 1px 2px #000; }
body.touch #keys, body.touch #prompt { display: none; }

/* ---------- 触屏 ---------- */
#touch { display: none; }
body.touch #touch { display: block; }
#joyZone { position: absolute; left: 0; bottom: 0; width: 46%; height: 62%; pointer-events: auto; touch-action: none; }
#joy { position: absolute; left: calc(110px + var(--sal)); top: calc(100% - 110px - var(--sab)); width: 124px; height: 124px; margin: -62px 0 0 -62px; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.06) 40%, rgba(255,255,255,.14) 70%, rgba(255,255,255,.04) 72%); border: 2px solid rgba(255, 220, 170, .28); opacity: .55; transition: opacity .2s; }
#joy.on { opacity: 1; transition: none; }
#knob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #fff4dc, #d8a85a 70%); box-shadow: 0 0 16px rgba(255, 170, 60, .55), 0 3px 8px rgba(0,0,0,.5); }
#joyHint { position: absolute; left: calc(110px + var(--sal)); bottom: calc(14px + var(--sab)); transform: translateX(-50%); font-size: 11px; color: rgba(255,255,255,.45); }
#btns { position: absolute; right: calc(18px + var(--sar)); bottom: calc(16px + var(--sab)); width: 230px; height: 210px; pointer-events: none; }
.tbtn { position: absolute; pointer-events: auto; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; color: #fff3de; background: radial-gradient(circle at 40% 30%, rgba(80, 64, 46, .9), rgba(24, 20, 18, .85)); border: 2px solid rgba(255, 200, 130, .45); box-shadow: 0 4px 14px rgba(0,0,0,.5), inset 0 0 10px rgba(0,0,0,.4); transition: transform .06s, filter .06s; touch-action: none; }
.tbtn svg { width: 44%; height: 44%; }
.tbtn span { font-size: 11px; font-weight: 700; letter-spacing: .1em; opacity: .9; }
.tbtn.down { transform: scale(.9); filter: brightness(1.35); }
.tbtn.atk { right: 0; bottom: 0; width: 98px; height: 98px; border-color: rgba(255, 200, 120, .75); background: radial-gradient(circle at 40% 30%, rgba(150, 92, 40, .95), rgba(60, 30, 14, .9)); }
.tbtn.dodge { right: 108px; bottom: 2px; width: 68px; height: 68px; }
.tbtn.skill { right: 70px; bottom: 98px; width: 72px; height: 72px; overflow: hidden; }
.tbtn.skill.ready { border-color: #ffd27a; box-shadow: 0 0 18px rgba(255, 180, 70, .6), 0 4px 14px rgba(0,0,0,.5); }
.tbtn.skill #skillCd { position: absolute; inset: 0; border-radius: 50%; }
.tbtn.skill #skillCdTxt { position: absolute; inset: 0; display: grid; place-items: center; font-size: 22px; font-weight: 800; text-shadow: 0 2px 3px #000; }
.tbtn.act { right: 2px; bottom: 112px; width: 62px; height: 62px; opacity: 0; transform: scale(.6); pointer-events: none; transition: .2s; border-color: #ffd27a; background: radial-gradient(circle at 40% 30%, rgba(190, 130, 40, .95), rgba(80, 40, 10, .9)); }
.tbtn.act.show { opacity: 1; transform: none; pointer-events: auto; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 26px rgba(255, 190, 80, .9), 0 4px 14px rgba(0,0,0,.5); } }

/* ---------- 菜单 ---------- */
#title { position: absolute; inset: 0; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 45%, rgba(10,10,14,.15), rgba(10,10,14,.72) 75%), linear-gradient(180deg, rgba(10,10,16,.35), rgba(10,10,16,0) 30%, rgba(10,10,16,.55)); padding: calc(16px + var(--sat)) calc(16px + var(--sar)) calc(16px + var(--sab)) calc(16px + var(--sal)); }
.t-inner { text-align: center; max-width: 640px; }
.t-kicker { font: 600 12px var(--sans); letter-spacing: .5em; color: var(--amber); opacity: .85; margin-left: .5em; }
#title h1 { margin: 6px 0 10px; font: 900 clamp(46px, 9vw, 92px)/1.05 var(--serif); letter-spacing: .18em; margin-right: -.18em; color: #fff0d6; text-shadow: 0 0 30px rgba(255, 150, 40, .55), 0 4px 0 #3a1c06, 0 8px 24px rgba(0,0,0,.8); }
.t-story { font: 500 clamp(14px, 2.2vw, 17px)/1.75 var(--serif); color: #eadfca; text-shadow: 0 2px 6px #000; margin: 0 0 22px; letter-spacing: .05em; }
.t-btns { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.mbtn { pointer-events: auto; min-width: 210px; padding: 12px 26px; border-radius: 999px; font: 700 16px var(--sans); letter-spacing: .3em; text-indent: .3em; color: #fbecd2; background: rgba(22, 20, 24, .72); border: 1px solid rgba(255, 210, 150, .4); box-shadow: 0 6px 18px rgba(0,0,0,.35); transition: transform .1s, background .2s; }
.mbtn:hover { background: rgba(50, 40, 34, .85); }
.mbtn:active { transform: scale(.97); }
.mbtn.primary { color: #2a1606; background: linear-gradient(#ffd690, #e79a3a); border-color: #ffe3b0; box-shadow: 0 0 24px rgba(255, 160, 50, .45), 0 6px 18px rgba(0,0,0,.4); }
.mbtn.ghost { background: transparent; border-color: rgba(255,255,255,.2); font-weight: 500; font-size: 14px; padding: 9px 22px; }
.mbtn small { display: block; font-size: 11px; letter-spacing: .1em; text-indent: 0; opacity: .75; font-weight: 500; margin-top: 2px; }
.t-hint { margin-top: 18px; font-size: 12px; color: rgba(240, 230, 210, .6); }
.t-hint .mob { display: none; } body.touch .t-hint .desk { display: none; } body.touch .t-hint .mob { display: inline; }

.overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(8, 8, 12, .6); opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .35s, visibility .35s; }
.overlay.show { opacity: 1; visibility: visible; pointer-events: auto; backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.panel { display: flex; flex-direction: column; gap: 10px; align-items: center; padding: 26px 34px; border-radius: 18px; background: rgba(20, 18, 22, .86); border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0,0,0,.6); max-height: calc(100% - 24px); overflow: auto; }
.panel h2 { margin: 0 0 8px; font: 800 26px var(--serif); letter-spacing: .3em; margin-right: -.3em; color: #ffe8c2; }
.panel.wide { max-width: min(92vw, 560px); }
.v-txt { margin: 0 0 6px; text-align: center; font: 15px/1.7 var(--serif); color: #e5d9c4; }
#vStats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; margin: 6px 0 10px; }
#vStats div { padding: 9px 6px; border-radius: 10px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); text-align: center; }
#vStats span { display: block; font-size: 11.5px; color: var(--dim); }
#vStats b { font-size: 20px; color: var(--amber); }
.v-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
#victory { background: radial-gradient(ellipse at center, rgba(40, 30, 10, .35), rgba(8,8,12,.7)); }
#dead { background: radial-gradient(ellipse at center, rgba(30, 10, 5, .5), rgba(0,0,0,.85)); flex-direction: column; display: flex; justify-content: center; align-items: center; }
.dead-t { font: 900 44px var(--serif); letter-spacing: .4em; margin-right: -.4em; color: #ffb89a; text-shadow: 0 0 24px rgba(255, 60, 20, .6); }
.dead-s { margin-top: 10px; color: #d9c9b6; font-size: 15px; letter-spacing: .1em; }

#loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; background: #121318; transition: opacity .6s; z-index: 10; }
#loading.done { opacity: 0; pointer-events: none; }
.l-t { font: 800 34px var(--serif); letter-spacing: .3em; margin-right: -.3em; color: #ffe3b4; text-shadow: 0 0 20px rgba(255, 150, 40, .5); }
.l-bar { width: 220px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.1); overflow: hidden; }
.l-bar i { display: block; height: 100%; background: linear-gradient(90deg, #ff8a2a, #ffd27a); transform-origin: 0 50%; transform: scaleX(0); transition: transform .2s; }
#loadTxt { font-size: 13px; color: var(--dim); }
#rotate { display: none; }

/* ---------- 小屏横屏（手机） ---------- */
@media (max-height: 500px) {
  .lvl-badge { width: 38px; height: 38px; } .lvl-badge b { font-size: 16px; }
  .bar { width: 170px; height: 13px; } .bar span { font-size: 10px; } .bar.st { width: 140px; height: 6px; } .xp { width: 100px; }
  .mini-wrap { width: 84px; height: 98px; }
  .sysbtn { width: 34px; height: 34px; } .sysbtn svg { width: 19px; height: 19px; }
  #obj { font-size: 14.5px; } #objSub { font-size: 11px; }
  #pips i { width: 10px; height: 10px; }
  .hud-tc { width: min(40vw, 360px); }
  #toast { bottom: calc(40px + var(--sab)); font-size: 12.5px; padding: 7px 14px; max-width: 40vw; }
  #hud.bossfight #toast { bottom: calc(64px + var(--sab)); }
  .dmg { font-size: 15px; } .dmg.big { font-size: 18px; } .dmg.crit { font-size: 21px; } .dmg.hurt { font-size: 16px; } .dmg.info { font-size: 12px; }
  #banner, #banner.low { top: 21%; }
  #toast span { font-size: 12px; } #toast b { font-size: 13.5px; }
  #banner .b-t { font-size: 22px; padding: 4px 28px; } #banner.intro .b-t { font-size: 28px; } #banner .b-s { font-size: 12px; margin-top: 4px; }
  #bossBar { bottom: calc(10px + var(--sab)); width: min(40vw, 420px); } #bossName { font-size: 13px; margin-bottom: 3px; } #bossBar .bar { height: 10px; }
  #btns { transform: scale(.86); transform-origin: 100% 100%; }
  #title h1 { font-size: 52px; margin: 2px 0 6px; } .t-story { margin-bottom: 12px; font-size: 13.5px; line-height: 1.6; }
  .t-btns { flex-direction: row; flex-wrap: wrap; justify-content: center; } .mbtn { min-width: 150px; padding: 10px 20px; font-size: 15px; }
  .t-hint { margin-top: 10px; }
  .panel { padding: 16px 24px; gap: 8px; } .panel h2 { font-size: 21px; margin-bottom: 2px; }
  #vStats { grid-template-columns: repeat(6, 1fr); } #vStats b { font-size: 16px; } #vStats span { font-size: 10px; }
  .v-txt { font-size: 13px; line-height: 1.5; }
}
/* ---------- 竖屏 ---------- */
@media (max-aspect-ratio: 1/1) {
  .hud-tc { top: calc(76px + var(--sat)); width: 92vw; }
  .bar { width: 150px; } .bar.st { width: 120px; } .xp { width: 84px; }
  .mini-wrap { width: 80px; height: 94px; }
  #toast { bottom: calc(230px + var(--sab)); max-width: 86vw; }
  #joyZone { width: 55%; height: 45%; }
  #btns { transform: scale(.88); transform-origin: 100% 100%; }
  #bossBar { bottom: auto; top: calc(146px + var(--sat)); width: 86vw; }
  #hud.bossfight #toast { bottom: calc(230px + var(--sab)); }
  #banner { top: 27%; }
  #banner.low { top: 64%; }
  #banner .b-t { font-size: 26px; padding: 6px 24px; letter-spacing: .15em; }
  #vStats { grid-template-columns: repeat(3, 1fr); }
}

#hud.bossfight #keys { display: none; }
