@font-face { font-family: 'MZTitle'; src: url('../fonts/title.woff2') format('woff2'); font-display: block; }
@font-face { font-family: 'MZBody'; src: url('../fonts/body.woff2') format('woff2'); font-display: swap; font-weight: 400 900; }

:root { --vw: 1vw; --vh: 1vh;
  --ink: #12141a; --ink2: #1d222b; --paper: #efe6d2; --paper2: #d9ccb0; --cinnabar: #b8392c; --gold: #d8b25a; --jade: #6f9a8a;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px); --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  --u: min(calc(1 * var(--vw)), calc(1 * var(--vh)) * 0.62); /* scale unit that works in portrait and landscape */
  --stick: clamp(118px, 30vmin, 176px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #0c1016; overflow: hidden; overscroll-behavior: none; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
body { font-family: 'MZBody', 'Noto Serif SC', 'Songti SC', serif; color: var(--paper); }
canvas#gl { position: fixed; inset: 0; width: calc(100 * var(--vw)); height: calc(100 * var(--vh)); display: block; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

.screen { position: fixed; inset: 0; opacity: 0; pointer-events: none; transition: opacity .9s ease; }
.screen.show { opacity: 1; pointer-events: auto; }

/* ---------------- boot ---------------- */
#boot { background: radial-gradient(ellipse at 50% 40%, #1c2430 0%, #0c1016 70%); display: grid; place-items: center; z-index: 50; }
.boot-wrap { position: relative; width: 220px; text-align: center; }
.enso { width: 200px; height: 200px; display: block; margin: 0 auto; }
#ensoPath { transition: stroke-dashoffset .4s ease; opacity: .9; }
.boot-char { position: absolute; top: 58px; left: 0; right: 0; font-family: 'MZTitle', serif; font-size: 64px; color: var(--paper); opacity: .92; }
.boot-tip { margin-top: 18px; font-size: 15px; letter-spacing: .6em; text-indent: .6em; color: var(--paper2); }
.boot-sub { margin-top: 10px; font-size: 12px; letter-spacing: .2em; color: #8a8a86; }

/* ---------------- title ---------------- */
#title { z-index: 20; }
.title-art { position: absolute; right: calc(var(--safe-r) + calc(9 * var(--vw))); top: calc(var(--safe-t) + calc(9 * var(--vh))); display: flex; gap: 2.2vmin; align-items: flex-start; }
.title-main { margin: 0; font-family: 'MZTitle', serif; font-weight: 400; writing-mode: vertical-rl; font-size: clamp(54px, 13vmin, 120px); line-height: 1; color: var(--paper); text-shadow: 0 0 24px rgba(0,0,0,.6), 0 2px 0 rgba(0,0,0,.4); letter-spacing: .06em; }
.title-main span { display: inline-block; opacity: 0; transform: translateY(-10px) scale(1.08); filter: blur(6px); animation: inkIn 1.4s cubic-bezier(.2,.7,.2,1) forwards; }
.title-main span:nth-child(1) { animation-delay: .3s } .title-main span:nth-child(2) { animation-delay: .55s } .title-main span:nth-child(3) { animation-delay: .8s } .title-main span:nth-child(4) { animation-delay: 1.05s } .title-main span:nth-child(5) { animation-delay: 1.3s }
@keyframes inkIn { to { opacity: 1; transform: none; filter: blur(0); } }
.seal { align-self: flex-end; margin-top: 0; writing-mode: vertical-rl; font-family: 'MZTitle', serif; font-size: clamp(18px, 4vmin, 30px); color: #f3e3c8; background: var(--cinnabar); padding: .35em .22em; border-radius: 4px; box-shadow: inset 0 0 0 2px rgba(255,230,200,.35), 0 4px 18px rgba(0,0,0,.4); opacity: 0; animation: stamp .5s 2.1s cubic-bezier(.3,1.6,.5,1) forwards; transform: scale(1.6) rotate(-8deg); }
@keyframes stamp { to { opacity: .95; transform: scale(1) rotate(-4deg); } }
.title-poem { writing-mode: vertical-rl; font-size: clamp(12px, 2.4vmin, 16px); line-height: 2.1; letter-spacing: .3em; color: rgba(233,223,200,.72); margin-top: 3.5em; opacity: 0; animation: fadeIn 2s 2.4s forwards; }
@keyframes fadeIn { to { opacity: 1 } }
.tap-hint { position: absolute; left: 0; right: 0; bottom: calc(var(--safe-b) + calc(16 * var(--vh))); text-align: center; font-family: 'MZTitle', serif; font-size: clamp(20px, 4.6vmin, 30px); letter-spacing: .5em; text-indent: .5em; color: var(--paper); opacity: 0; animation: fadeIn 1.2s 2.8s forwards, breathe 2.6s 4s ease-in-out infinite; }
@keyframes breathe { 0%,100% { opacity: .9 } 50% { opacity: .35 } }
.tap-hint.gone { animation: none; opacity: 0; transition: opacity .5s; }
.menu { position: absolute; left: calc(var(--safe-l) + calc(8 * var(--vw))); bottom: calc(var(--safe-b) + calc(11 * var(--vh))); display: flex; flex-direction: column; gap: 1.6vmin; opacity: 0; pointer-events: none; transform: translateX(-12px); transition: opacity .8s, transform .8s; }
.menu.show { opacity: 1; pointer-events: auto; transform: none; }
.menu-item { position: relative; text-align: left; font-family: 'MZTitle', serif; font-size: clamp(24px, 5.4vmin, 38px); letter-spacing: .28em; padding: .32em 1.2em .32em .9em; color: var(--paper); text-shadow: 0 2px 10px rgba(0,0,0,.6); transition: color .3s, transform .3s; }
.menu-item i { position: absolute; left: 0; top: 50%; width: 100%; height: 1.15em; transform: translateY(-50%) scaleX(0); transform-origin: left; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 300 40' preserveAspectRatio='none'%3E%3Cpath d='M4 22 C40 8 120 6 200 12 C250 15 286 10 296 18 C280 30 200 34 120 32 C60 31 20 36 4 22Z' fill='%23b8392c' opacity='.85'/%3E%3C/svg%3E") center/100% 100% no-repeat; z-index: -1; transition: transform .35s cubic-bezier(.2,.8,.2,1); }
.menu-item:hover i, .menu-item:focus-visible i, .menu-item:active i { transform: translateY(-50%) scaleX(1); }
.menu-item:active { transform: translateX(6px); }
.menu-item[disabled] { opacity: .35; pointer-events: none; }
.title-foot { position: absolute; left: 0; right: 0; bottom: calc(var(--safe-b) + 14px); text-align: center; font-size: 11px; letter-spacing: .18em; color: rgba(220,210,190,.42); }

/* ---------------- cards ---------------- */
#cards { z-index: 30; background: radial-gradient(ellipse at 50% 50%, rgba(20,24,30,.55), rgba(8,10,14,.96)); display: grid; place-items: center; }
.card-text { max-width: min(calc(82 * var(--vw)), 560px); padding: 0 calc(6 * var(--vw)); font-size: clamp(18px, 4.6vmin, 28px); line-height: 2.1; letter-spacing: .16em; text-align: center; color: var(--paper); text-shadow: 0 0 20px rgba(0,0,0,.8); }
.card-text .ch { opacity: 0; display: inline-block; filter: blur(4px); transform: translateY(4px); transition: opacity .7s, filter .9s, transform .9s; }
.card-text .ch.on { opacity: 1; filter: none; transform: none; }
.card-text.out { opacity: 0; filter: blur(8px); transition: opacity .8s, filter .8s; }
.card-skip { position: absolute; bottom: calc(var(--safe-b) + calc(6 * var(--vh))); left: 0; right: 0; text-align: center; font-size: 12px; letter-spacing: .4em; color: rgba(220,210,190,.45); }

/* ---------------- chapter ---------------- */
#chapter { z-index: 31; display: flex; flex-direction: column; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 50%, rgba(10,12,16,.3), rgba(8,10,14,.85)); }
.chap-no { font-size: clamp(14px, 3.4vmin, 20px); letter-spacing: .8em; text-indent: .8em; color: var(--paper2); opacity: 0; }
.chap-name { font-family: 'MZTitle', serif; font-size: clamp(90px, 26vmin, 200px); line-height: 1.1; color: var(--paper); text-shadow: 0 0 40px rgba(0,0,0,.7); opacity: 0; transform: scale(1.15); filter: blur(10px); }
.chap-sub { font-size: clamp(12px, 3vmin, 16px); letter-spacing: .5em; text-indent: .5em; color: rgba(233,223,200,.7); opacity: 0; }
#chapter.show .chap-no { animation: fadeIn 1s .2s forwards; }
#chapter.show .chap-name { animation: inkIn 1.6s .5s cubic-bezier(.2,.7,.2,1) forwards; }
#chapter.show .chap-sub { animation: fadeIn 1s 1.4s forwards; }

/* ---------------- HUD ---------------- */
#hud { z-index: 10; transition: opacity .5s; }
#hud.cine .btns, #hud.cine .stick-zone, #hud.cine .hud-top, #hud.cine .objective, #hud.cine .bossbar { opacity: 0; pointer-events: none; }
.hud-top { position: absolute; top: calc(var(--safe-t) + 10px); left: calc(var(--safe-l) + 12px); right: calc(var(--safe-r) + 12px); display: flex; justify-content: space-between; align-items: flex-start; transition: opacity .4s; }
.hud-player { display: flex; align-items: center; gap: 10px; }
.hud-portrait { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle at 40% 35%, #2f4d5c, #16222b); box-shadow: 0 0 0 2px rgba(216,178,90,.75), 0 0 0 5px rgba(10,12,16,.55), 0 4px 14px rgba(0,0,0,.5); font-family: 'MZTitle', serif; font-size: 28px; color: var(--paper); }
.hud-bars { width: min(calc(46 * var(--vw)), 230px); }
.hud-name { font-family: 'MZTitle', serif; font-size: 17px; letter-spacing: .12em; text-shadow: 0 1px 4px #000; }
.hud-name em { font-style: normal; font-family: 'MZBody', serif; font-size: 11px; color: var(--gold); margin-left: 6px; letter-spacing: .08em; }
.hpbar { position: relative; height: 12px; margin-top: 4px; background: rgba(10,12,16,.65); border-radius: 2px; clip-path: polygon(0 20%, 3% 0, 100% 8%, 98% 100%, 2% 92%); }
.hp-fill, .hp-lag { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; transform-origin: left; }
.hp-lag { background: #e9dfc8; opacity: .65; transition: transform .6s .25s ease; }
.hp-fill { background: linear-gradient(90deg, #8a2a22, #c8463a 60%, #e06a52); transition: transform .12s; }
.hp-text { position: absolute; right: 6px; top: -1px; font-size: 10px; color: #fff; text-shadow: 0 1px 2px #000; line-height: 14px; }
.hud-ink { margin-top: 4px; font-size: 12px; color: var(--paper2); text-shadow: 0 1px 3px #000; }
.hud-ink b { font-weight: 400; color: var(--gold); margin-right: 6px; }
.hud-pause { width: 42px; height: 42px; border-radius: 50%; background: rgba(10,12,16,.55); box-shadow: 0 0 0 1.5px rgba(233,223,200,.4); display: flex; gap: 5px; align-items: center; justify-content: center; pointer-events: auto; }
.hud-pause i { width: 4px; height: 15px; background: var(--paper); border-radius: 2px; }
.objective { position: absolute; top: calc(var(--safe-t) + 84px); left: calc(var(--safe-l) + 14px); max-width: calc(70 * var(--vw)); padding: 6px 14px 6px 10px; font-size: 13px; letter-spacing: .06em; background: linear-gradient(90deg, rgba(10,12,16,.7), rgba(10,12,16,0)); border-left: 3px solid var(--cinnabar); text-shadow: 0 1px 3px #000; transition: opacity .5s, transform .5s; }
.objective b { font-weight: 400; font-family: 'MZTitle', serif; color: var(--gold); margin-right: 8px; font-size: 15px; }
.objective.flash { animation: objFlash 1.2s; }
@keyframes objFlash { 0% { transform: translateX(-20px); opacity: 0 } 30% { transform: none; opacity: 1; background-color: rgba(184,57,44,.35) } 100% { background-color: transparent } }
.objective.hide { opacity: 0; }
.bossbar { position: absolute; left: 50%; transform: translateX(-50%); top: calc(var(--safe-t) + 120px); width: min(calc(80 * var(--vw)), 520px); opacity: 0; transition: opacity .6s; pointer-events: none; }
.bossbar.show { opacity: 1; }
.boss-name { text-align: center; font-family: 'MZTitle', serif; font-size: 20px; letter-spacing: .3em; text-shadow: 0 2px 6px #000; }
.boss-name em { font-style: normal; font-family: 'MZBody', serif; font-size: 11px; color: var(--paper2); margin-left: 8px; letter-spacing: .1em; }
.boss-track { position: relative; height: 9px; margin-top: 4px; background: rgba(10,12,16,.7); clip-path: polygon(0 50%, 2% 0, 98% 0, 100% 50%, 98% 100%, 2% 100%); }
.boss-fill, .boss-lag { position: absolute; inset: 0; transform-origin: left; }
.boss-lag { background: #e9dfc8; opacity: .6; transition: transform .8s .3s; }
.boss-fill { background: linear-gradient(90deg, #4a2a6a, #8a4ad0 50%, #b88af0); transition: transform .15s; }

.offarrow { position: absolute; width: 34px; height: 34px; margin: -17px 0 0 -17px; opacity: 0; transition: opacity .3s; pointer-events: none; background: radial-gradient(circle, rgba(216,178,90,.25), transparent 70%); }
.offarrow::after { content: ''; position: absolute; inset: 8px; clip-path: polygon(50% 0, 100% 100%, 50% 75%, 0 100%); background: var(--gold); }
.offarrow.show { opacity: .9; }

.hint { position: absolute; left: 50%; bottom: calc(var(--safe-b) + var(--stick) + 64px); transform: translateX(-50%) translateY(10px); padding: 10px 20px; font-size: 14px; letter-spacing: .08em; white-space: nowrap; background: rgba(10,12,16,.72); border-top: 1px solid rgba(216,178,90,.5); border-bottom: 1px solid rgba(216,178,90,.5); opacity: 0; transition: opacity .4s, transform .4s; pointer-events: none; }
.hint.show { opacity: 1; transform: translateX(-50%); }
.hint b { color: var(--gold); font-weight: 400; }

/* joystick — fixed bottom-left */
.stick-zone { position: absolute; left: 0; bottom: 0; width: calc(46 * var(--vw)); height: calc(46 * var(--vh)); max-width: 420px; pointer-events: auto; touch-action: none; transition: opacity .4s; }
.stick { position: absolute; left: calc(var(--safe-l) + 26px); bottom: calc(var(--safe-b) + 30px); width: var(--stick); height: var(--stick); }
.stick-ring { position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle, rgba(10,12,16,.15) 40%, rgba(10,12,16,.45) 100%); box-shadow: inset 0 0 0 2px rgba(233,223,200,.28); }
.stick-ring::before { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid transparent; border-top-color: rgba(216,178,90,.55); border-left-color: rgba(216,178,90,.2); transform: rotate(-30deg); }
.stick-knob { position: absolute; left: 50%; top: 50%; width: 42%; height: 42%; margin: -21% 0 0 -21%; border-radius: 50%; background: radial-gradient(circle at 38% 35%, #f6eedb, #c9bb9a 70%); box-shadow: 0 4px 12px rgba(0,0,0,.45), inset 0 -3px 6px rgba(0,0,0,.2); transition: transform .12s; }
.stick.active .stick-knob { transition: none; }
.stick.active .stick-ring { box-shadow: inset 0 0 0 2px rgba(216,178,90,.6); }

.btns { position: absolute; right: calc(var(--safe-r) + 18px); bottom: calc(var(--safe-b) + 22px); width: calc(var(--stick) * 1.55); height: calc(var(--stick) * 1.5); transition: opacity .4s; pointer-events: none; }
.btn { position: absolute; border-radius: 50%; display: grid; place-items: center; pointer-events: auto; touch-action: none; transition: transform .08s, opacity .3s, box-shadow .2s; }
.btn.down { transform: scale(.9); }
.btn-attack { right: 0; bottom: 0; width: calc(var(--stick) * .74); height: calc(var(--stick) * .74); background: radial-gradient(circle at 40% 35%, #c8463a, #7a1f18 80%); box-shadow: 0 0 0 3px rgba(233,223,200,.55), 0 0 0 7px rgba(10,12,16,.4), 0 8px 18px rgba(0,0,0,.5); color: #f6ead0; }
.btn-attack svg { width: 52%; height: 52%; }
.btn-dodge { right: calc(var(--stick) * .86); bottom: calc(var(--stick) * -0.02); width: calc(var(--stick) * .46); height: calc(var(--stick) * .46); background: rgba(10,12,16,.6); box-shadow: 0 0 0 2px rgba(233,223,200,.45); font-family: 'MZTitle', serif; font-size: calc(var(--stick) * .2); }
.btn-skill { width: calc(var(--stick) * .5); height: calc(var(--stick) * .5); background: radial-gradient(circle at 40% 35%, #2f4d5c, #14212a 80%); box-shadow: 0 0 0 2px rgba(216,178,90,.7), 0 6px 14px rgba(0,0,0,.45); font-family: 'MZTitle', serif; font-size: calc(var(--stick) * .135); overflow: hidden; }
.btn-skill span { position: relative; z-index: 2; }
.btn-skill.s1 { right: calc(var(--stick) * .74); bottom: calc(var(--stick) * .5); }
.btn-skill.s2 { right: calc(var(--stick) * .16); bottom: calc(var(--stick) * .84); background: radial-gradient(circle at 40% 35%, #8a6a2a, #3a2a10 80%); }
.btn-skill.locked { opacity: 0; pointer-events: none; transform: scale(.4); }
.btn-skill.unlock { animation: unlockPop .9s cubic-bezier(.2,1.6,.4,1); }
@keyframes unlockPop { 0% { transform: scale(.3); box-shadow: 0 0 0 0 rgba(255,210,120,.9) } 60% { transform: scale(1.2); box-shadow: 0 0 0 26px rgba(255,210,120,0) } 100% { transform: scale(1) } }
.btn .cd { position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(rgba(8,10,14,.78) var(--p, 0%), transparent 0); z-index: 1; }
.btn.ready { animation: readyGlow .5s; }
@keyframes readyGlow { 50% { box-shadow: 0 0 0 2px #ffe3a0, 0 0 22px rgba(255,220,140,.9) } }

#dmgLayer { position: fixed; inset: 0; pointer-events: none; z-index: 12; overflow: hidden; }
.dmg { position: absolute; left: 0; top: 0; font-family: 'MZTitle', serif; font-size: 26px; color: #f6ecd6; text-shadow: 0 0 2px #000, 0 2px 6px rgba(0,0,0,.8); will-change: transform, opacity; white-space: nowrap; }
.dmg.crit { color: #ffd36a; font-size: 34px; }
.dmg.hurt { color: #ff7a6a; font-size: 22px; }
.dmg.heal { color: #9be0b0; font-size: 20px; }
.dmg.gain { color: #ffd98a; font-size: 18px; font-family: 'MZBody', serif; }

/* ---------------- dialogue ---------------- */
#letterbox i { position: fixed; left: 0; right: 0; height: 0; background: #07090c; z-index: 14; transition: height .7s cubic-bezier(.6,0,.2,1); }
#letterbox .lb-top { top: 0; } #letterbox .lb-bot { bottom: 0; }
#letterbox.on i { height: calc(9 * var(--vh)); }
.dialog { position: fixed; z-index: 15; left: 50%; bottom: calc(var(--safe-b) + calc(4 * var(--vh))); width: min(calc(92 * var(--vw)), 760px); transform: translateX(-50%) translateY(16px); opacity: 0; pointer-events: none; transition: opacity .35s, transform .35s; padding: 26px 24px 22px; background: linear-gradient(180deg, rgba(16,19,25,.88), rgba(10,12,16,.95)); border-top: 1px solid rgba(216,178,90,.55); border-bottom: 1px solid rgba(216,178,90,.25); box-shadow: 0 12px 40px rgba(0,0,0,.6); }
.dialog.show { opacity: 1; transform: translateX(-50%); pointer-events: auto; }
.dialog::before { content: ''; position: absolute; left: 0; right: 0; top: -1px; height: 1px; background: linear-gradient(90deg, transparent, rgba(216,178,90,.9), transparent); }
.dlg-name { position: absolute; top: -18px; left: 20px; padding: 4px 16px 3px; font-family: 'MZTitle', serif; font-size: 19px; letter-spacing: .2em; background: var(--cinnabar); color: #f6ead0; box-shadow: 0 4px 12px rgba(0,0,0,.4); clip-path: polygon(4% 0, 100% 0, 96% 100%, 0 100%); }
.dlg-name.n-monk { background: #8a6a3a; } .dlg-name.n-fox { background: #6f9a8a; } .dlg-name.n-boss { background: #4a2a6a; } .dlg-name.n-shen { background: #3a2a3e; } .dlg-name.n-narr { background: transparent; box-shadow: none; color: var(--paper2); font-family: 'MZBody', serif; font-size: 12px; letter-spacing: .4em; }
.dlg-text { min-height: 3.6em; font-size: clamp(15px, 4.1vmin, 19px); line-height: 1.8; letter-spacing: .05em; color: #efe6d2; }
.dlg-text .narr { color: #b9b2a2; font-style: normal; }
.dlg-next { position: absolute; right: 18px; bottom: 8px; color: var(--gold); font-size: 14px; animation: bob 1s infinite; opacity: 0; }
.dialog.done .dlg-next { opacity: 1; }
@keyframes bob { 50% { transform: translateY(4px) } }
.dlg-skip { position: absolute; top: 6px; right: 12px; font-size: 11px; letter-spacing: .3em; color: rgba(220,210,190,.5); padding: 6px; }

.banner { position: fixed; z-index: 16; left: 0; right: 0; top: calc(34 * var(--vh)); text-align: center; pointer-events: none; opacity: 0; transition: opacity .6s; }
.banner.show { opacity: 1; }
.banner-line { height: 1px; width: calc(60 * var(--vw)); margin: 0 auto 12px; background: linear-gradient(90deg, transparent, rgba(216,178,90,.8), transparent); }
.banner-text { font-family: 'MZTitle', serif; font-size: clamp(36px, 10vmin, 72px); letter-spacing: .25em; text-indent: .25em; color: var(--paper); text-shadow: 0 0 30px rgba(0,0,0,.8); }
.banner-sub { margin-top: 6px; font-size: 13px; letter-spacing: .5em; text-indent: .5em; color: var(--gold); }
.banner.show .banner-text { animation: inkIn 1.2s cubic-bezier(.2,.7,.2,1) both; }

.toast { position: fixed; z-index: 17; left: 50%; top: calc(var(--safe-t) + calc(26 * var(--vh))); transform: translate(-50%, 10px); padding: 12px 26px; background: rgba(10,12,16,.82); border: 1px solid rgba(216,178,90,.6); font-size: 15px; letter-spacing: .1em; opacity: 0; transition: opacity .4s, transform .4s; pointer-events: none; text-align: center; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast b { display: block; font-family: 'MZTitle', serif; font-weight: 400; font-size: 24px; color: var(--gold); letter-spacing: .3em; margin-bottom: 2px; }

/* ---------------- panels ---------------- */
.panel-wrap { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(6,8,10,.6); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: opacity .35s; }
.panel-wrap.show { opacity: 1; pointer-events: auto; }
.panel { position: relative; width: min(calc(86 * var(--vw)), 420px); max-height: calc(86 * var(--vh)); padding: 34px 28px 26px; color: var(--ink); background:
  radial-gradient(ellipse at 30% 20%, rgba(255,255,255,.35), transparent 60%),
  repeating-linear-gradient(0deg, rgba(120,100,70,.035) 0 2px, transparent 2px 4px),
  var(--paper); box-shadow: 0 20px 60px rgba(0,0,0,.6), inset 0 0 0 1px rgba(120,90,50,.25), inset 0 0 60px rgba(160,130,80,.25); text-align: center; }
.panel::before, .panel::after { content: ''; position: absolute; left: -10px; right: -10px; height: 14px; background: linear-gradient(180deg, #3a2a20, #1e1612); border-radius: 7px; box-shadow: 0 3px 6px rgba(0,0,0,.4); }
.panel::before { top: -7px; } .panel::after { bottom: -7px; }
.panel.scroll { overflow: auto; }
.panel h2 { margin: 0 0 18px; font-family: 'MZTitle', serif; font-weight: 400; font-size: 32px; letter-spacing: .3em; text-indent: .3em; color: var(--ink); }
.pbtn { display: block; width: 100%; margin: 10px 0; padding: 12px 0; font-family: 'MZTitle', serif; font-size: 22px; letter-spacing: .3em; text-indent: .3em; color: var(--paper); background: var(--ink2); box-shadow: inset 0 0 0 1px rgba(216,178,90,.4); clip-path: polygon(2% 0, 100% 4%, 98% 100%, 0 94%); transition: background .2s, transform .1s; }
.pbtn:active { transform: scale(.97); background: var(--cinnabar); }
.row { display: flex; align-items: center; justify-content: space-between; margin: 14px 4px; gap: 16px; }
.row label { font-family: 'MZTitle', serif; font-size: 20px; min-width: 3em; text-align: left; }
.seg { display: flex; gap: 6px; }
.seg button { padding: 6px 14px; font-family: 'MZTitle', serif; font-size: 18px; color: var(--ink); box-shadow: inset 0 0 0 1px rgba(30,30,30,.35); }
.seg button.on { background: var(--cinnabar); color: var(--paper); box-shadow: none; }
input[type=range] { flex: 1; accent-color: var(--cinnabar); height: 28px; }
.about p { text-align: left; line-height: 1.9; font-size: 15px; letter-spacing: .04em; margin: 8px 0; }
.about p.small { font-size: 12px; color: #5a5246; }
.death { background: radial-gradient(ellipse at 50% 30%, rgba(184,57,44,.25), transparent 60%), var(--paper); }
.death-big { font-family: 'MZTitle', serif; font-size: 48px; letter-spacing: .2em; color: var(--cinnabar); margin-bottom: 8px; }
.death p { font-size: 15px; letter-spacing: .06em; }

/* ---------------- ending ---------------- */
#ending { z-index: 35; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 45%, rgba(20,24,30,.6), rgba(8,10,14,.95)); }
.end-wrap { text-align: center; width: min(calc(86 * var(--vw)), 460px); }
.end-big { font-family: 'MZTitle', serif; font-size: clamp(40px, 11vmin, 76px); letter-spacing: .12em; color: var(--paper); }
.end-seal { display: inline-block; margin: 10px 0 20px; font-family: 'MZTitle', serif; font-size: 34px; color: #f6e3c8; background: var(--cinnabar); padding: 8px 14px; border-radius: 4px; transform: rotate(-6deg); box-shadow: inset 0 0 0 2px rgba(255,230,200,.35); }
.end-stats { font-size: 14px; line-height: 2; letter-spacing: .1em; color: var(--paper2); margin-bottom: 18px; }
.end-next { font-family: 'MZTitle', serif; font-size: 22px; letter-spacing: .2em; color: var(--gold); margin-bottom: 22px; }
.end-next span { font-family: 'MZBody', serif; font-size: 13px; color: rgba(233,223,200,.7); letter-spacing: .12em; }
#ending .pbtn { width: 70%; margin: 10px auto 0; }
#ending .pbtn.hot, .pbtn.hot { background: var(--cinnabar); }
.menu-item.hidden { display: none; }

/* ---------------- responsive ---------------- */
@media all {
  .title-art { right: calc(var(--safe-r) + calc(12 * var(--vw))); top: calc(var(--safe-t) + calc(8 * var(--vh))); }
  .menu { bottom: calc(var(--safe-b) + calc(12 * var(--vh))); }
  .tap-hint { bottom: calc(var(--safe-b) + calc(10 * var(--vh))); }
  .objective { top: calc(var(--safe-t) + 80px); }
  .bossbar { top: calc(var(--safe-t) + 14px); }
  .dialog { bottom: calc(var(--safe-b) + calc(3 * var(--vh))); }
  #letterbox.on i { height: calc(7 * var(--vh)); }
  .stick-zone { width: calc(40 * var(--vw)); height: calc(60 * var(--vh)); }
}
/* tablets */
html.tablet { --stick: clamp(150px, 20vmin, 190px); }
html.tablet .hud-portrait { width: 64px; height: 64px; font-size: 34px; }
html.tablet .hud-bars { width: 300px; } html.tablet .hpbar { height: 15px; }
html.tablet .hud-name { font-size: 20px; }
html.tablet .objective { font-size: 15px; top: calc(var(--safe-t) + 100px); }
html.tablet .dlg-text { font-size: 20px; }
/* small landscape phones */
html.small { --stick: 112px; }
html.small .hud-portrait { width: 40px; height: 40px; font-size: 22px; }
html.small .objective { top: calc(var(--safe-t) + 62px); font-size: 12px; }
html.small .dialog { padding: 20px 18px 14px; }
html.small .dlg-text { min-height: 2.6em; font-size: 15px; line-height: 1.6; }
#title::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 22%; pointer-events: none; z-index: 0; background: linear-gradient(to top, rgba(6,8,12,.82), rgba(6,8,12,0)); }
#title .title-foot { z-index: 2; text-shadow: 0 1px 6px #000; }

/* ================= M1：成长与刷宝 ================= */
.xpbar { position: relative; height: 3px; margin-top: 3px; background: rgba(10,12,16,.6); overflow: hidden; }
.xpbar i { position: absolute; inset: 0; background: linear-gradient(90deg, #a8862e, #f0cf7a); transform-origin: left; transform: scaleX(0); transition: transform .3s; }
.hud-rt { display: flex; gap: 10px; align-items: center; pointer-events: auto; }
.hud-bag { position: relative; width: 42px; height: 42px; border-radius: 50%; background: rgba(10,12,16,.55); box-shadow: 0 0 0 1.5px rgba(216,178,90,.6); font-family: 'MZTitle', serif; font-size: 20px; color: var(--gold); }
.hud-bag b { position: absolute; top: 1px; right: 1px; width: 10px; height: 10px; border-radius: 50%; background: var(--cinnabar); box-shadow: 0 0 0 2px #0c1016; display: none; }
.hud-bag b.on { display: block; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { transform: scale(1.35); } }
.loot-feed { position: absolute; left: calc(var(--safe-l) + 12px); top: calc(var(--safe-t) + 124px); display: flex; flex-direction: column; gap: 4px; pointer-events: none; }
.loot-item { padding: 4px 12px 4px 8px; font-size: 13px; letter-spacing: .05em; background: linear-gradient(90deg, rgba(10,12,16,.75), rgba(10,12,16,0)); border-left: 3px solid currentColor; text-shadow: 0 1px 3px #000; animation: lootIn .35s ease-out; transition: opacity .5s, transform .5s; }
.loot-item i { font-style: normal; font-size: 11px; margin-right: 6px; opacity: .85; }
.loot-item.out { opacity: 0; transform: translateX(-20px); }
.loot-item.r0 { color: #d8d2c4; } .loot-item.r1 { color: #7cc98a; } .loot-item.r2 { color: #6aa8e8; } .loot-item.r3 { color: #b685e8; } .loot-item.r4 { color: #f0b54a; }
@keyframes lootIn { from { opacity: 0; transform: translateX(-24px); } }

/* 行囊 */
.bag-wrap { position: fixed; inset: 0; z-index: 42; display: flex; align-items: flex-end; justify-content: center; background: rgba(6,8,10,.55); opacity: 0; pointer-events: none; transition: opacity .3s; }
.bag-wrap.show { opacity: 1; pointer-events: auto; }
.bag-panel { position: relative; width: min(calc(100 * var(--vw)), 620px); height: min(calc(92 * var(--vh)), 860px); padding: calc(var(--safe-t) * 0 + 14px) 14px calc(var(--safe-b) + 12px); display: flex; flex-direction: column; color: var(--ink);
  background: radial-gradient(ellipse at 30% 10%, rgba(255,255,255,.35), transparent 60%), repeating-linear-gradient(0deg, rgba(120,100,70,.035) 0 2px, transparent 2px 4px), var(--paper);
  box-shadow: 0 -10px 50px rgba(0,0,0,.6), inset 0 0 60px rgba(160,130,80,.22); border-radius: 14px 14px 0 0; transform: translateY(30px); transition: transform .3s; }
.bag-wrap.show .bag-panel { transform: none; }
@media all { .bag-wrap { align-items: center; } .bag-panel { border-radius: 10px; height: min(calc(94 * var(--vh)), 720px); } }
.bag-head { display: flex; align-items: center; gap: 12px; padding: 0 4px 10px; border-bottom: 1px solid rgba(60,40,20,.2); }
.bag-who { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.bag-lv { font-family: 'MZTitle', serif; font-size: 22px; }
.bag-xp { position: relative; flex: 0 1 90px; height: 4px; background: rgba(30,20,10,.15); overflow: hidden; }
.bag-xp i { position: absolute; inset: 0; background: #b8902e; transform-origin: left; }
.bag-pow { font-size: 13px; color: #6a5236; white-space: nowrap; }
.bag-ink { font-size: 14px; white-space: nowrap; } .bag-ink b { font-weight: 400; color: #9a7020; margin-right: 4px; }
.bag-x { width: 36px; height: 36px; font-size: 28px; line-height: 1; color: #3a2a20; }
.bag-tabs { display: flex; gap: 4px; margin: 10px 0 8px; }
.bag-tabs button { flex: 1; padding: 8px 0; font-family: 'MZTitle', serif; font-size: 18px; letter-spacing: .1em; color: #5a4a36; border-bottom: 2px solid transparent; }
.bag-tabs button.on { color: var(--ink); border-bottom-color: var(--cinnabar); }
.dot-n { display: inline-block; min-width: 18px; height: 18px; margin-left: 4px; padding: 0 4px; border-radius: 9px; background: var(--cinnabar); color: #fff; font: 12px/18px 'MZBody', serif; vertical-align: 2px; }
.bag-body { flex: 1; overflow: auto; padding: 2px 2px 8px; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.bag-h { margin: 14px 2px 6px; font-family: 'MZTitle', serif; font-weight: 400; font-size: 17px; letter-spacing: .2em; color: #5a4022; }
.gear-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.gslot { display: flex; gap: 8px; align-items: center; padding: 6px; background: rgba(255,255,255,.35); box-shadow: inset 0 0 0 1px rgba(80,60,30,.15); }
.gname { min-width: 0; display: flex; flex-direction: column; font-size: 13px; }
.gname b { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 0 1px rgba(0,0,0,.35); filter: brightness(.75) saturate(1.3); }
.gname b.dim { color: #8a7a62; filter: none; }
.gname em { font-style: normal; font-size: 12px; color: #6a5a44; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; font-size: 14px; }
.stat-grid div { display: flex; justify-content: space-between; padding: 4px 2px; border-bottom: 1px dashed rgba(80,60,30,.18); }
.stat-grid span { color: #6a5a44; }
.leg-list { margin: 0; padding: 0 0 0 4px; list-style: none; font-size: 13px; line-height: 1.6; }
.leg-list b { color: #a8661a; margin-right: 6px; }
.itile { position: relative; width: 52px; height: 52px; flex: none; display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, #2a3038, #141820); box-shadow: inset 0 0 0 2px var(--rc, #888), 0 2px 4px rgba(0,0,0,.25); }
.itile.empty { background: rgba(40,30,20,.12); box-shadow: inset 0 0 0 1px rgba(80,60,30,.3); }
.itile.empty .ig { color: rgba(80,60,30,.35); }
.itile.r0 { --rc: #a9a294; } .itile.r1 { --rc: #5fb26f; } .itile.r2 { --rc: #4f8fd6; } .itile.r3 { --rc: #a06ad8; } .itile.r4 { --rc: #f0b54a; background: radial-gradient(circle at 50% 40%, #4a3618, #1c140a); }
.ig { font-family: 'MZTitle', serif; font-size: 24px; color: var(--rc, #e9dfc8); text-shadow: 0 0 8px rgba(0,0,0,.6); }
.ig.big { font-size: 34px; }
.ip { position: absolute; right: 3px; bottom: 1px; font-size: 11px; color: #f0d890; }
.iup { position: absolute; left: 3px; bottom: 1px; font-size: 10px; color: #6fd07a; }
.inew { position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: #e85a4a; }
.ilock { position: absolute; top: 1px; left: 3px; font-size: 10px; color: #e0c070; }
.ileg { position: absolute; inset: 0; box-shadow: inset 0 0 12px rgba(240,181,74,.7); pointer-events: none; animation: legGlow 2s infinite; }
@keyframes legGlow { 50% { box-shadow: inset 0 0 20px rgba(240,181,74,.95); } }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.chips button { padding: 4px 12px; font-size: 14px; border-radius: 14px; box-shadow: inset 0 0 0 1px rgba(60,40,20,.3); }
.chips button.on { background: var(--ink2); color: var(--paper); box-shadow: none; }
.igrid { display: grid; grid-template-columns: repeat(auto-fill, 52px); gap: 8px; justify-content: space-between; }
.empty-tip { grid-column: 1 / -1; text-align: center; color: #7a6a52; font-size: 14px; padding: 30px 0; }
.salv-bar { position: sticky; bottom: -8px; margin-top: 12px; padding: 10px 0 4px; background: linear-gradient(180deg, rgba(239,230,210,0), var(--paper) 30%); display: flex; flex-direction: column; gap: 8px; }
.salv-bar .seg button { flex: 1; font-size: 15px; padding: 6px 4px; }
.salv-bar .seg button.on { background: var(--ink2); }
.salv-go { padding: 10px; font-family: 'MZTitle', serif; font-size: 18px; letter-spacing: .1em; color: var(--paper); background: var(--cinnabar); clip-path: polygon(1% 0, 100% 6%, 99% 100%, 0 92%); }
.salv-go:disabled { background: #9a8e7a; }
.pbtn.small { display: inline-block; width: auto; flex: 1; margin: 4px; padding: 9px 6px; font-size: 16px; letter-spacing: .08em; text-indent: 0; }
.pbtn.small.hot { background: var(--cinnabar); }
.pbtn:disabled { opacity: .45; }
.idetail { position: absolute; inset: 0; z-index: 2; display: flex; align-items: flex-end; padding: 10px; background: rgba(20,14,8,.35); border-radius: inherit; }
.icard { width: 100%; padding: 14px 14px 8px; color: var(--paper); background: linear-gradient(180deg, #232a34, #151a22); box-shadow: inset 0 0 0 2px var(--rc), 0 -6px 30px rgba(0,0,0,.5); animation: lootIn .2s; }
.icard.r0 { --rc: #a9a294; } .icard.r1 { --rc: #5fb26f; } .icard.r2 { --rc: #4f8fd6; } .icard.r3 { --rc: #a06ad8; } .icard.r4 { --rc: #f0b54a; }
.ic-top { display: flex; gap: 12px; align-items: center; }
.ic-top h3 { margin: 0; font-family: 'MZTitle', serif; font-weight: 400; font-size: 24px; letter-spacing: .06em; }
.ic-top p { margin: 2px 0 0; font-size: 12px; color: #a9a090; }
.ic-main { margin: 10px 0 4px; font-size: 16px; color: #f2e6c8; }
.ic-aff { margin: 0; padding: 0 0 0 18px; font-size: 14px; line-height: 1.7; color: #9fc4e8; }
.ic-leg { margin: 8px 0 0; padding: 8px 10px; font-size: 13px; line-height: 1.6; color: #f6dfa8; background: rgba(240,181,74,.12); border-left: 3px solid #f0b54a; }
.ic-leg b { margin-right: 6px; color: #f0b54a; }
.cmp { margin-top: 8px; font-size: 13px; } .cmp.up { color: #7cd08a; } .cmp.down { color: #e88a7a; }
.ic-btns { display: flex; flex-wrap: wrap; margin: 8px -4px 0; }
.bag-flash { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); z-index: 5; padding: 10px 22px; font-family: 'MZTitle', serif; font-size: 20px; color: var(--paper); background: rgba(18,20,26,.88); animation: lootIn .2s; pointer-events: none; }
.tal-top { display: flex; justify-content: space-between; align-items: center; font-size: 15px; }
.tal-top b { font-size: 20px; color: var(--cinnabar); }
.tal-top .pbtn.small { flex: none; padding: 7px 14px; font-size: 15px; }
.tcols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.tcol h5 { margin: 0 0 6px; padding: 6px 0; text-align: center; font-family: 'MZTitle', serif; font-weight: 400; font-size: 19px; letter-spacing: .2em; color: var(--paper); background: var(--tc); clip-path: polygon(3% 0, 100% 6%, 97% 100%, 0 90%); }
.tcol h5 em { font-style: normal; font-family: 'MZBody', serif; font-size: 12px; margin-left: 2px; letter-spacing: 0; opacity: .85; }
.tnode { display: flex; flex-direction: column; width: 100%; margin-bottom: 6px; padding: 7px 6px; text-align: left; background: rgba(255,255,255,.45); box-shadow: inset 0 0 0 1px rgba(80,60,30,.2); min-height: 74px; }
.tnode .tn { font-family: 'MZTitle', serif; font-size: 16px; }
.tnode .tr { font-size: 11px; color: #7a6a52; }
.tnode .td { font-size: 11px; line-height: 1.4; color: #5a4a36; margin-top: 2px; }
.tnode.has { box-shadow: inset 0 0 0 2px var(--tc); background: rgba(255,255,255,.7); }
.tnode.can { box-shadow: inset 0 0 0 2px var(--tc); animation: canGlow 1.4s infinite; }
@keyframes canGlow { 50% { background: rgba(255,240,200,.85); } }
.tnode.locked { opacity: .45; }
.tnode.ult .tn { color: var(--tc); filter: brightness(.7); }
.tal-tip { font-size: 12px; color: #7a6a52; margin-top: 10px; text-align: center; }
/* 夜巡 */
.patrol-desc { font-size: 14px; line-height: 1.7; text-align: left; margin: 0 0 12px; color: #3a3026; }
.diff-card { display: block; width: 100%; margin: 8px 0; padding: 10px 14px; text-align: left; background: rgba(255,255,255,.45); box-shadow: inset 0 0 0 1px rgba(80,60,30,.3); color: var(--ink); }
.diff-card b { display: block; font-family: 'MZTitle', serif; font-weight: 400; font-size: 24px; letter-spacing: .2em; }
.diff-card span { display: block; font-size: 12px; color: #5a4a36; margin-top: 2px; }
.diff-card em { display: block; font-style: normal; font-size: 12px; color: var(--cinnabar); margin-top: 2px; }
.diff-card:active { background: rgba(184,57,44,.15); }
.diff-card.locked { opacity: .5; }
.patrol-stats { font-size: 14px; line-height: 1.9; color: #3a3026; }
.patrol-stats b { color: var(--cinnabar); }
.patrol-loot { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 12px; margin: 12px 0; padding: 10px; background: #1a1f27; font-size: 14px; }
.patrol-loot .dim { color: #8a8070; }
#saveText { width: 100%; height: 110px; padding: 8px; font: 12px/1.4 monospace; color: var(--ink); background: rgba(255,255,255,.6); border: 1px solid rgba(80,60,30,.3); resize: none; user-select: text; -webkit-user-select: text; word-break: break-all; }
.save-err { min-height: 18px; margin: 6px 0 0; font-size: 13px; color: var(--cinnabar); }

/* 战斗中的随口台词：小气泡，放在屏幕上方，不挡摇杆和技能 */
.dialog.bark { top: calc(var(--safe-t, 0px) + 92px); bottom: auto; width: auto; max-width: min(calc(70 * var(--vw)), 420px); padding: 14px 18px 8px; background: rgba(16,18,26,.72); border-radius: 4px; }
.dialog.bark .dlg-text { min-height: 0; font-size: 14px; line-height: 1.5; }
.dialog.bark .dlg-name { top: -14px; left: 10px; font-size: 13px; padding: 2px 10px 1px; }
.dialog.bark .dlg-next, .dialog.bark .dlg-skip { display: none; }
html.short .dialog.bark { top: calc(var(--safe-t, 0px) + 70px); }

.iset { position: absolute; left: 4px; bottom: 4px; width: 8px; height: 8px; transform: rotate(45deg); box-shadow: 0 0 0 1px rgba(0,0,0,.35); }
.set-li b { color: var(--sc) !important; filter: brightness(.75); }
.set-li span { display: block; font-size: 13px; color: #8a7a66; }
.set-li span.on { color: #3a2a1a; }
.set-list { margin-top: 6px; }

.map-tabs { display: flex; gap: 8px; margin: 4px 0 10px; }
.map-tabs button { flex: 1; padding: 8px 4px; font-family: 'MZTitle', serif; font-size: 19px; letter-spacing: .15em; color: #5a4a36; box-shadow: inset 0 0 0 1px rgba(80,60,30,.3); background: rgba(255,255,255,.3); }
.map-tabs button.on { color: #f6ead0; background: var(--cinnabar); box-shadow: none; }
.map-tabs button.locked { opacity: .5; }
.map-tabs button em { display: block; font-style: normal; font-family: 'MZBody', serif; font-size: 11px; letter-spacing: 0; }

/* ---------------- forced landscape ---------------- */
html.rot body { position: fixed; top: 0; left: 100vw; width: 100vh; height: 100vw; transform-origin: 0 0; transform: rotate(90deg); overflow: hidden; }
html, body { overscroll-behavior: none; }
