:root {
  --gold: #ffcf4a; --gold-d: #b8860b; --pan: rgba(28, 22, 52, .92); --pan2: #2b2250; --line: #5a4a9a; --txt: #f4f0ff; --mut: #b9b0d8;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px); --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  font-family: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #120f22; color: var(--txt); overscroll-behavior: none; }
body { position: fixed; inset: 0; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#app { position: fixed; inset: 0; overflow: hidden; touch-action: none; }
html.pseudo-fs, html.pseudo-fs body { height: 100vh; height: 100dvh; }
#gl { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
button, a.btn { font: inherit; color: inherit; touch-action: manipulation; }
[hidden] { display: none !important; }

/* ---------- 触控层 / 摇杆 ---------- */
#touch { position: absolute; inset: 0; z-index: 2; display: none; touch-action: none; }
body.playing #touch { display: block; }
#joy { position: absolute; left: 0; top: 0; z-index: 3; pointer-events: none; opacity: 0; transition: opacity .12s; }
#joy.on { opacity: 1; }
#joy .base { position: absolute; width: 132px; height: 132px; margin: -66px 0 0 -66px; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.08) 40%, rgba(255,255,255,.18) 70%, rgba(255,255,255,.04) 72%); border: 3px solid rgba(255,255,255,.35); }
#joy .knob { position: absolute; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #fff, #c9bfff 45%, #7c5cff); box-shadow: 0 0 18px rgba(140, 110, 255, .8); }

/* ---------- 伤害数字 / 血条 ---------- */
#fx { position: absolute; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.dmg { position: absolute; left: 0; top: 0; margin: -14px 0 0 -30px; width: 60px; text-align: center; font-weight: 900; font-size: 20px; color: #fff; will-change: transform, opacity;
  text-shadow: 0 2px 0 #000, 0 0 3px #000, 1px 1px 0 #000, -1px -1px 0 #000; white-space: nowrap; }
.dmg.crit { color: #ffd84a; font-size: 27px; }
.dmg.hurt { color: #ff4d5e; font-size: 22px; }
.dmg.heal { color: #5dff8a; }
.dmg.fire { color: #ff9a4a; font-size: 16px; }
.dmg.poison { color: #a6ff4a; font-size: 16px; }
.dmg.ult { color: #c9a8ff; font-size: 24px; }
.dmg.dodge { color: #cfe8ff; font-size: 18px; }
.hbar { position: absolute; left: 0; top: 0; width: 54px; height: 8px; margin: -4px 0 0 -27px; background: rgba(0,0,0,.65); border: 1px solid rgba(0,0,0,.9); border-radius: 4px; overflow: hidden; will-change: transform; }
.hbar i { position: absolute; inset: 0; background: linear-gradient(#ff7a7a, #e0242f); transform-origin: left center; }
.hbar.hero { width: 76px; height: 16px; margin: -8px 0 0 -38px; border-radius: 6px; border: 2px solid #1a1a1a; }
.hbar.hero i { background: linear-gradient(#8dff5a, #2fae1d); }
.hbar.hero b { position: absolute; inset: 0; text-align: center; font-size: 12px; line-height: 12px; font-weight: 800; color: #fff; text-shadow: 0 1px 0 #000, 0 0 2px #000; }

/* ---------- 抬头显示 ---------- */
#hud { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.hud-top { position: absolute; left: 0; right: 0; top: 0; padding: calc(10px + var(--sat)) calc(12px + var(--sar)) 0 calc(12px + var(--sal)); display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.hud-left { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.hud-right { flex: 1; display: flex; justify-content: flex-end; }
.hud-mid { flex: none; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.hbtn { pointer-events: auto; width: 54px; height: 54px; border-radius: 14px; border: 3px solid #5a3818; background: linear-gradient(#ffb067, #d9772e); color: #fff; font-size: 20px; font-weight: 900; box-shadow: 0 3px 0 #5a3818; cursor: pointer; text-shadow: 0 1px 0 #6a3a10; }
.hbtn.small { width: 40px; height: 40px; border-radius: 11px; font-size: 18px; opacity: .85; background: linear-gradient(#8a7bd8, #5a48b0); border-color: #2a2060; box-shadow: 0 3px 0 #2a2060; }
#lvl { display: flex; align-items: center; }
#lvl .star { width: 54px; height: 54px; flex: none; position: relative; z-index: 1; display: grid; place-items: center; background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M50 4l13 29 31 3-23 21 7 31-28-16-28 16 7-31L6 36l31-3z' fill='%23ffc928' stroke='%238a5a00' stroke-width='5' stroke-linejoin='round'/%3E%3C/svg%3E"); }
#lvl .star span { font-weight: 900; font-size: 18px; color: #5a3500; margin-top: 4px; }
.xpbar { width: min(46vw, 260px); height: 22px; margin-left: -12px; background: #23213a; border: 3px solid #12101e; border-radius: 0 10px 10px 0; overflow: hidden; position: relative; }
.xpbar i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(#7af0ff, #2a9fd8); transition: width .25s; }
#stage { background: rgba(20, 18, 34, .85); border: 2px solid #0c0b16; border-radius: 6px; padding: 3px 16px; font-weight: 800; font-size: 16px; text-shadow: 0 1px 0 #000; }
#coins { display: flex; align-items: center; background: rgba(20, 18, 34, .85); border: 3px solid #0c0b16; border-radius: 12px; padding: 4px 14px 4px 6px; gap: 8px; font-weight: 900; font-size: 20px; min-width: 96px; }
.coin { display: inline-block; width: 26px; height: 26px; vertical-align: middle; background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M50 6l44 44-44 44L6 50z' fill='%23ffc928' stroke='%238a5a00' stroke-width='6'/%3E%3Cpath d='M50 26l24 24-24 24-24-24z' fill='none' stroke='%23b37a00' stroke-width='6'/%3E%3C/svg%3E"); }
#boss { position: absolute; left: 50%; top: calc(124px + var(--sat)); transform: translateX(-50%); width: min(80vw, 460px); text-align: center; }
#boss b { display: block; font-size: 15px; text-shadow: 0 1px 0 #000, 0 0 4px #000; margin-bottom: 3px; color: #ffd0d0; }
#boss .bar { height: 14px; background: rgba(0,0,0,.7); border: 2px solid #000; border-radius: 7px; overflow: hidden; }
#boss .bar i { display: block; height: 100%; width: 100%; background: linear-gradient(#ff5a5a, #b0141c); transition: width .15s; }
#b-ult { pointer-events: auto; position: absolute; right: calc(22px + var(--sar)); bottom: calc(28px + var(--sab)); width: 96px; height: 96px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  background: radial-gradient(circle at 40% 35%, #b9a3ff, #6a44e0 55%, #2c1a7a); box-shadow: 0 4px 0 #1a1050, 0 0 22px rgba(130, 90, 255, .6); color: #fff; touch-action: none; }
#b-ult svg { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); transform: rotate(-90deg); }
#b-ult .trk { fill: none; stroke: rgba(0,0,0,.45); stroke-width: 7; }
#b-ult .prg { fill: none; stroke: #ffd84a; stroke-width: 7; stroke-linecap: round; stroke-dasharray: 276.5; stroke-dashoffset: 0; }
#b-ult .ico { position: absolute; left: 0; right: 0; top: 18px; font-size: 34px; line-height: 1; text-shadow: 0 0 10px #fff; }
#b-ult .lbl { position: absolute; left: 0; right: 0; bottom: 16px; font-weight: 900; font-size: 15px; }
#b-ult em { position: absolute; inset: 0; display: grid; place-items: center; font-style: normal; font-weight: 900; font-size: 30px; background: rgba(10, 6, 30, .55); border-radius: 50%; }
#b-ult em:empty { display: none; }
#b-ult.ready { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 4px 0 #1a1050, 0 0 38px rgba(255, 216, 74, .9); } }
#b-ult:active { transform: scale(.94); }
#hint { position: absolute; left: 50%; bottom: calc(150px + var(--sab)); transform: translateX(-50%); max-width: 86vw; text-align: center; font-weight: 800; font-size: 19px; text-shadow: 0 2px 0 #000, 0 0 6px #000; opacity: 0; transition: opacity .3s; }
#hint.on { opacity: 1; }
#banner { position: absolute; left: 0; right: 0; top: 34%; text-align: center; font-weight: 900; font-size: 42px; color: #ffe27a; text-shadow: 0 3px 0 #6a3a00, 0 0 18px rgba(255, 180, 40, .8); opacity: 0; transform: scale(.7); transition: opacity .25s, transform .25s; }
#banner.on { opacity: 1; transform: scale(1); }
#fade { position: absolute; inset: 0; z-index: 6; background: #000; opacity: 0; pointer-events: none; transition: opacity .3s; }
#fade.on { opacity: 1; }

/* ---------- 界面 ---------- */
.scr { position: absolute; inset: 0; z-index: 8; display: none; touch-action: pan-y; }
.scr.on { display: flex; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 0 20px; border-radius: 12px; border: 2px solid #1b1440; cursor: pointer;
  background: linear-gradient(#5e4fb8, #3d2f8a); box-shadow: 0 4px 0 #1b1440; font-size: 17px; font-weight: 800; color: #fff; text-decoration: none; text-shadow: 0 1px 0 #1b1440; }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #1b1440; }
.btn.gold { background: linear-gradient(#ffe07a, #f0a420); color: #4a2a00; border-color: #6a4000; box-shadow: 0 4px 0 #6a4000; text-shadow: 0 1px 0 #fff3c0; }
.btn.big { min-height: 58px; font-size: 21px; }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 15px; }
.btn.ghost { background: rgba(255,255,255,.08); box-shadow: none; border-color: rgba(255,255,255,.2); }
.btn.danger { background: linear-gradient(#ff7a7a, #c02a2a); }
.btn:disabled { opacity: .45; filter: grayscale(.6); }
.btn.tog.on { background: linear-gradient(#5fe08a, #239a4a); }
.muted { color: var(--mut); }

#scr-title { align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 40%, rgba(18,15,34,0) 30%, rgba(18,15,34,.75) 75%); }
.title-box { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 20px; margin-top: 36vh; }
.logo { text-align: center; }
.logo b { display: block; font-size: clamp(38px, 8vw, 64px); font-weight: 900; letter-spacing: 4px; color: #ffe27a; text-shadow: 0 4px 0 #7a3c00, 0 0 24px rgba(255, 170, 40, .7); }
.logo span { display: inline-block; margin-top: 6px; font-size: 16px; font-weight: 700; color: #d9ceff; background: rgba(60, 40, 140, .6); padding: 4px 14px; border-radius: 20px; }
.logo.small b { font-size: 34px; }
.menu-col { display: flex; flex-direction: column; gap: 12px; width: min(78vw, 320px); }
.menu-col .btn { width: 100%; }
.row2 { display: flex; gap: 10px; } .row2 .btn { flex: 1; padding: 0 8px; }
.foot { margin: 0; color: var(--mut); font-size: 15px; display: flex; align-items: center; gap: 4px; }
@media (orientation: landscape) {
  .title-box { flex-direction: row; gap: 48px; margin-top: 0; margin-left: 46vw; align-items: center; flex-wrap: wrap; justify-content: center; }
  .title-box .foot { width: 100%; justify-content: center; }
  .title-box .logo { width: 100%; }
}
@media (orientation: landscape) and (max-height: 560px) { .title-box { gap: 10px; } .menu-col { gap: 7px; } .btn { min-height: 40px; } .btn.big { min-height: 46px; } .logo b { font-size: 34px; } }

.panel-scr, .side-scr { flex-direction: column; background: linear-gradient(rgba(18,15,34,.92), rgba(18,15,34,.97)); padding: calc(10px + var(--sat)) calc(14px + var(--sar)) calc(10px + var(--sab)) calc(14px + var(--sal)); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.side-scr { background: none; overflow: hidden; }
header { display: flex; align-items: center; gap: 12px; flex: none; margin-bottom: 10px; }
header h2 { margin: 0; flex: 1; font-size: 22px; text-shadow: 0 2px 0 #000; }
.hdr-r { display: flex; align-items: center; gap: 6px; font-weight: 900; font-size: 18px; background: rgba(0,0,0,.4); padding: 4px 12px; border-radius: 10px; }
.cur-hero { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; color: var(--mut); }
.cur-hero b { color: #fff; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 12px; padding-bottom: 20px; }
.lv { position: relative; text-align: left; padding: 14px; border-radius: 14px; border: 2px solid #3a2f70; background: linear-gradient(135deg, #2e2560, #1d173e); box-shadow: 0 4px 0 #120d2a; cursor: pointer; color: #fff; font: inherit; min-height: 104px; }
.lv.lava { background: linear-gradient(135deg, #5a2414, #2a1008); border-color: #7a3418; }
.lv.tutorial { background: linear-gradient(135deg, #1f3a5a, #142238); border-color: #2a5a8a; }
.lv b { display: block; font-size: 19px; margin-bottom: 4px; }
.lv .meta { font-size: 13px; color: var(--mut); line-height: 1.6; }
.lv .badge { position: absolute; right: 10px; top: 10px; font-size: 12px; padding: 2px 8px; border-radius: 10px; background: rgba(0,0,0,.4); }
.lv .done { color: #6dff9a; }
.lv.locked { filter: grayscale(.8) brightness(.6); cursor: not-allowed; }
.lv.locked::after { content: "🔒 通关上一关后解锁"; position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; font-weight: 800; font-size: 14px; }

.hero-panel { position: absolute; display: flex; flex-direction: column; gap: 10px; background: rgba(18, 15, 34, .9); border: 2px solid #3a2f70; border-radius: 16px; padding: 12px; overflow: hidden; }
@media (orientation: portrait) { .hero-panel { left: calc(10px + var(--sal)); right: calc(10px + var(--sar)); bottom: calc(10px + var(--sab)); top: 52%; } }
@media (orientation: landscape) { .hero-panel { right: calc(12px + var(--sar)); top: calc(64px + var(--sat)); bottom: calc(12px + var(--sab)); width: min(52vw, 560px); } }
#hero-info { flex: none; }
#hero-info h3 { margin: 0 0 6px; font-size: 22px; color: #ffe27a; }
#hero-info .st { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; }
#hero-info .st div { background: rgba(255,255,255,.07); border-radius: 8px; padding: 4px 6px; text-align: center; font-size: 12px; color: var(--mut); }
#hero-info .st b { display: block; font-size: 17px; color: #fff; }
#hero-info .act { display: flex; gap: 10px; flex-wrap: wrap; }
#hero-info .act .btn { flex: 1; min-width: 130px; }
#hero-list { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; align-content: start; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.hc { font: inherit; color: #fff; text-align: left; padding: 8px 10px; border-radius: 10px; border: 2px solid #3a2f70; background: #241d4a; cursor: pointer; min-height: 52px; }
.hc.sel { border-color: var(--gold); background: #3a2f70; }
.hc b { display: block; font-size: 15px; } .hc small { color: var(--mut); font-size: 12px; }
.hc .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

.text { max-width: 760px; width: 100%; margin: 0 auto; line-height: 1.75; font-size: 16px; }
.text h3 { color: #ffe27a; margin: 14px 0 4px; }
.text ul { padding-left: 22px; margin: 0; }
.settings .row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,.08); font-weight: 700; }
.settings .row .btn { min-width: 110px; }

.modal { align-items: center; justify-content: center; background: rgba(8, 6, 20, .66); padding: 16px; }
.card { background: linear-gradient(#2e2462, #1c1640); border: 3px solid #5a4ab0; border-radius: 20px; padding: 20px; box-shadow: 0 8px 0 #0e0a24, 0 0 40px rgba(120, 90, 255, .35); text-align: center; max-height: 100%; overflow-y: auto; width: min(92vw, 380px); }
.card.wide { width: min(96vw, 860px); }
.card h2 { margin: 0 0 6px; font-size: 30px; color: #ffe27a; text-shadow: 0 3px 0 #6a3a00; }
.card .menu-col { margin: 14px auto 0; }
#sk-cards { display: flex; gap: 12px; justify-content: center; margin: 14px 0; flex-wrap: wrap; }
.sk { font: inherit; color: #fff; flex: 1 1 200px; max-width: 260px; min-height: 200px; padding: 16px 12px; border-radius: 16px; border: 3px solid #6a5ac8; background: linear-gradient(#3d3180, #251d55); cursor: pointer; box-shadow: 0 5px 0 #120d2a; display: flex; flex-direction: column; align-items: center; gap: 8px; animation: pop .35s backwards; }
.sk:nth-child(2) { animation-delay: .08s; } .sk:nth-child(3) { animation-delay: .16s; }
@keyframes pop { from { transform: scale(.6) translateY(30px); opacity: 0; } }
.sk:active { transform: scale(.97); }
.sk .ic { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-size: 30px; font-weight: 900; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.45); box-shadow: inset 0 -4px 0 rgba(0,0,0,.3), 0 0 16px var(--c); border: 3px solid rgba(255,255,255,.55); }
.sk b { font-size: 19px; } .sk p { margin: 0; font-size: 14px; color: #d9d2f5; line-height: 1.5; }
.sk .lv-n { font-size: 12px; color: var(--gold); }
.sk .key { font-size: 11px; color: var(--mut); }
@media (orientation: portrait) and (max-width: 600px) { .sk { flex-basis: 100%; max-width: none; min-height: 0; flex-direction: row; text-align: left; } .sk .ic { flex: none; width: 52px; height: 52px; font-size: 26px; } .sk div { flex: 1; } }
.stats { display: grid; grid-template-columns: auto auto; gap: 6px 18px; justify-content: center; font-size: 17px; margin: 12px 0 0; }
.stats dt { color: var(--mut); text-align: right; } .stats dd { margin: 0; font-weight: 800; text-align: left; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 6px 0; }
.chips span { font-size: 12px; background: rgba(255,255,255,.1); border-radius: 10px; padding: 2px 8px; }

#scr-loading { align-items: center; justify-content: center; background: radial-gradient(ellipse at center, #241c4a, #0c0a18); z-index: 9; }
.load-box { width: min(80vw, 420px); text-align: center; }
.pbar { height: 16px; margin: 20px 0 10px; background: rgba(0,0,0,.6); border: 2px solid #000; border-radius: 9px; overflow: hidden; }
.pbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #7c5cff, #ffd84a); transition: width .2s; }
#ld-text { color: var(--mut); margin: 0; }
#err { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(0,0,0,.8); }
.noscript { position: fixed; inset: 0; display: grid; place-items: center; font-size: 20px; }

/* 横屏：抬头信息靠两侧，大招按钮更大 */
@media (orientation: landscape) {
  #b-ult { width: 112px; height: 112px; right: calc(34px + var(--sar)); bottom: calc(34px + var(--sab)); }
  #b-ult .ico { top: 22px; font-size: 38px; } #b-ult .lbl { bottom: 20px; }
  #hint { bottom: calc(40px + var(--sab)); }
  #boss { top: calc(104px + var(--sat)); }
}
@media (max-width: 420px) { .xpbar { width: 40vw; } #coins { min-width: 0; font-size: 17px; padding-right: 10px; } .hbtn { width: 46px; height: 46px; } #lvl .star { width: 46px; height: 46px; } #b-ult { width: 84px; height: 84px; } #b-ult .ico { top: 14px; font-size: 28px; } }
