/* THE ONE — cosmic gothic UI. System fonts only (no external requests). */
:root {
  --font: "Segoe UI", "Leelawadee UI", "Noto Sans Thai", "Sarabun", Tahoma, system-ui, sans-serif;
  --serif: "Palatino Linotype", "Book Antiqua", Georgia, "Times New Roman", serif;
  --ink: #f4eeff; --ink2: #c9bde6; --ink3: #8f84b0;
  --gold: #f2c25a; --gold2: #ffe39a; --violet: #9b5cff; --violet2: #c49bff; --cyan: #5ad8ff; --pink: #ff7ac8;
  --hp1: #ff5a8a; --hp2: #c21f5a; --mp1: #6fd0ff; --mp2: #5a3cff; --xp1: #ffe39a; --xp2: #f2a93b;
  --panel: rgba(16, 10, 34, 0.78); --panel2: rgba(30, 20, 60, 0.72);
  --line: rgba(196, 155, 255, 0.35); --glow: 0 0 18px rgba(155, 92, 255, 0.45);
  --r: 14px;
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #07040f; color: var(--ink); font-family: var(--font); -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none; touch-action: none; }
#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; outline: none; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui button, #ui input, #ui select, .panel, .tab, #dialogue, .screen:not(#loading) { pointer-events: auto; }
.hidden { display: none !important; }
button { font-family: var(--font); cursor: pointer; }
kbd { font-family: var(--font); font-size: 10px; padding: 1px 5px; border-radius: 5px; background: rgba(8, 5, 20, .85); border: 1px solid var(--line); color: var(--gold2); }

/* ---------- shared bits */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
.screen.dim { background: radial-gradient(ellipse at center, rgba(20, 10, 45, .55), rgba(5, 2, 14, .82)); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.panel { background: linear-gradient(160deg, rgba(34, 22, 70, .92), rgba(12, 8, 28, .94)); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 20px 60px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .06), var(--glow); position: relative; }
.panel::before { content: ""; position: absolute; inset: 5px; border-radius: 14px; border: 1px solid rgba(242, 194, 90, .18); pointer-events: none; }
.brand-small { letter-spacing: .38em; font-size: 12px; color: var(--gold2); opacity: .85; text-shadow: 0 0 10px rgba(242, 194, 90, .5); }
.logo { font-family: var(--serif); font-weight: 700; font-size: 64px; letter-spacing: .12em; margin: 6px 0 2px; line-height: 1;
  background: linear-gradient(100deg, #fff6d6 0%, #f2c25a 22%, #fff 36%, #c49bff 55%, #7fd8ff 75%, #fff6d6 100%); background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 18px rgba(196, 155, 255, .55)) drop-shadow(0 4px 2px rgba(0, 0, 0, .6)); animation: shimmer 7s linear infinite; }
.logo.big { font-size: clamp(56px, 9vw, 112px); }
@keyframes shimmer { to { background-position: -250% 0; } }
.logo-sub { font-size: 17px; color: var(--ink2); letter-spacing: .08em; text-shadow: 0 2px 8px rgba(0, 0, 0, .8); }

.tbtn { display: flex; align-items: center; gap: 12px; min-width: 280px; padding: 13px 22px; margin: 7px 0; border-radius: 999px; font-size: 17px; color: var(--ink);
  background: linear-gradient(90deg, rgba(40, 24, 84, .85), rgba(20, 12, 44, .6)); border: 1px solid var(--line); text-align: left; transition: transform .18s, box-shadow .18s, background .18s, color .18s; box-shadow: 0 6px 18px rgba(0, 0, 0, .35); }
.tbtn span { color: var(--gold); width: 20px; text-align: center; font-size: 18px; }
.tbtn:hover, .tbtn:focus-visible { transform: translateX(8px); background: linear-gradient(90deg, rgba(120, 70, 220, .9), rgba(50, 26, 110, .6)); box-shadow: 0 0 24px rgba(155, 92, 255, .6); outline: none; color: #fff; }
.tbtn.primary { background: linear-gradient(90deg, rgba(242, 194, 90, .95), rgba(196, 120, 255, .85)); color: #1b0f30; font-weight: 700; border-color: rgba(255, 240, 200, .7); }
.tbtn.primary span { color: #1b0f30; }
.tbtn.primary:hover { box-shadow: 0 0 32px rgba(242, 194, 90, .7); color: #1b0f30; }
.tbtn:disabled { opacity: .4; pointer-events: none; }
.mbtn { padding: 10px 18px; border-radius: 10px; border: 1px solid var(--line); background: rgba(40, 26, 80, .8); color: var(--ink); font-size: 15px; transition: .15s; }
.mbtn:hover { background: rgba(110, 64, 210, .85); box-shadow: 0 0 16px rgba(155, 92, 255, .5); }
.mbtn.primary { background: linear-gradient(90deg, #f2c25a, #c47bff); color: #1b0f30; font-weight: 700; border-color: #ffe9b8; }
.mbtn.danger:hover { background: rgba(200, 50, 100, .8); }
.round-btn { position: absolute; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--gold2); font-size: 18px; }

/* ---------- loading */
#loading { background: radial-gradient(ellipse at 70% 40%, #2a1558 0%, #120a2c 45%, #05030c 100%); z-index: 50; pointer-events: auto; }
.load-stars, #title::before { position: absolute; inset: 0; background-image:
  radial-gradient(1.5px 1.5px at 12% 22%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 32% 72%, #fff 50%, transparent 51%),
  radial-gradient(1.8px 1.8px at 62% 14%, #ffe9b8 50%, transparent 51%), radial-gradient(1px 1px at 82% 62%, #cfe6ff 50%, transparent 51%),
  radial-gradient(1.2px 1.2px at 48% 42%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 22% 88%, #e5d4ff 50%, transparent 51%),
  radial-gradient(1.4px 1.4px at 90% 30%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 72% 86%, #fff 50%, transparent 51%);
  background-size: 420px 420px; animation: twinkle 6s ease-in-out infinite alternate; opacity: .8; }
@keyframes twinkle { from { opacity: .45; } to { opacity: .95; } }
.load-art { position: absolute; right: 4vw; bottom: -2vh; height: 96vh; max-width: 55vw; object-fit: contain; filter: drop-shadow(0 0 40px rgba(155, 92, 255, .5)); animation: floaty 5s ease-in-out infinite; }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }
.load-box { position: relative; margin-right: 40vw; width: min(520px, 90vw); text-align: left; }
.load-bar { position: relative; height: 10px; border-radius: 99px; background: rgba(255, 255, 255, .08); border: 1px solid var(--line); margin: 28px 0 10px; overflow: visible; }
.load-fill { position: absolute; inset: 0 auto 0 0; width: 0%; border-radius: 99px; background: linear-gradient(90deg, #7d4dff, #c49bff, #f2c25a); box-shadow: 0 0 14px rgba(196, 155, 255, .8); transition: width .25s; }
.load-star { position: absolute; top: 50%; left: 0; transform: translate(-50%, -52%); color: var(--gold2); font-size: 22px; text-shadow: 0 0 12px #f2c25a; transition: left .25s; }
.load-text { color: var(--ink2); font-size: 14px; }
.load-tip { margin-top: 26px; color: var(--ink3); font-size: 14px; line-height: 1.6; min-height: 3em; }

/* ---------- title */
#title { justify-content: flex-start; background: linear-gradient(90deg, rgba(8, 4, 22, .85) 0%, rgba(8, 4, 22, .35) 45%, rgba(8, 4, 22, 0) 70%); }
#title::before { content: ""; opacity: .35; pointer-events: none; }
.title-left { position: relative; padding-left: max(7vw, 24px); z-index: 2; }
.title-menu { margin-top: 34px; display: flex; flex-direction: column; align-items: flex-start; }
.title-foot { margin-top: 28px; color: var(--ink3); font-size: 12px; letter-spacing: .04em; }
.title-art { position: absolute; right: 1vw; top: 50%; height: 82vh; max-width: 58vw; object-fit: contain; transform: translateY(-50%); filter: drop-shadow(0 0 50px rgba(155, 92, 255, .55)); animation: titleFloat 6s ease-in-out infinite; pointer-events: none; }
@keyframes titleFloat { 0%, 100% { transform: translateY(-50%) rotate(-1.5deg); } 50% { transform: translateY(-53%) rotate(1deg); } }

/* ---------- HUD */
#hud { position: fixed; inset: 0; }
#hud-player { position: absolute; left: calc(18px + var(--safe-l)); top: 16px; display: flex; gap: 12px; align-items: center; filter: drop-shadow(0 4px 12px rgba(0, 0, 0, .5)); }
.portrait { position: relative; width: 84px; height: 84px; border-radius: 50%; padding: 3px; background: conic-gradient(from 200deg, #f2c25a, #c49bff, #5ad8ff, #ff7ac8, #f2c25a); box-shadow: 0 0 22px rgba(155, 92, 255, .6); }
.portrait img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; object-position: 50% 20%; background: #1a1030; display: block; }
.portrait .lv { position: absolute; right: -4px; bottom: -2px; min-width: 30px; height: 30px; padding: 0 6px; border-radius: 15px; display: grid; place-items: center; font-weight: 800; font-size: 14px; color: #1b0f30; background: linear-gradient(#ffe9a8, #f2a93b); border: 2px solid #fff4d0; }
.bars { width: 250px; }
.pname { font-size: 15px; margin-bottom: 4px; text-shadow: 0 2px 4px #000; } .pname small { color: var(--ink3); font-size: 11px; letter-spacing: .1em; }
.bar { position: relative; height: 16px; border-radius: 8px; background: rgba(8, 5, 20, .75); border: 1px solid rgba(255, 255, 255, .14); overflow: hidden; margin-bottom: 5px; }
.bar i { position: absolute; inset: 0 auto 0 0; width: 100%; transition: width .18s; border-radius: 8px; }
.bar span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; font-weight: 700; text-shadow: 0 1px 2px #000, 0 0 4px #000; }
.bar.hp i:last-of-type { background: linear-gradient(180deg, #ff8fb0, var(--hp1) 45%, var(--hp2)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4); }
.bar.hp #hud-hp-lag { background: rgba(255, 240, 200, .75); transition: width .8s .25s; }
.bar.mp i { background: linear-gradient(180deg, #a8e6ff, var(--mp1) 45%, var(--mp2)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4); }
.bar.xp { height: 6px; margin-bottom: 4px; } .bar.xp i { background: linear-gradient(90deg, var(--xp2), var(--xp1)); box-shadow: 0 0 8px #f2c25a; }
.bar.hp.low { animation: lowhp 0.9s infinite; } @keyframes lowhp { 50% { box-shadow: 0 0 14px #ff3a6a; } }
.buffs { display: flex; gap: 5px; } .buff { font-size: 11px; padding: 2px 7px; border-radius: 8px; background: rgba(90, 216, 255, .18); border: 1px solid rgba(90, 216, 255, .5); color: #bff0ff; }

#hud-target { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); width: 300px; text-align: center; filter: drop-shadow(0 3px 8px #000); }
.t-name { font-size: 14px; margin-bottom: 4px; } .t-name small { color: var(--gold2); }
.bar.enemy { height: 10px; } .bar.enemy i { background: linear-gradient(180deg, #ffb07a, #e84a4a); }
#hud-boss { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); width: min(620px, 70vw); text-align: center; filter: drop-shadow(0 4px 12px #000); }
.boss-name { font-family: var(--serif); font-size: 22px; letter-spacing: .08em; margin-bottom: 6px; } .boss-name span { color: var(--cyan); } .boss-name small { color: var(--ink2); font-size: 13px; }
.bar.boss { height: 18px; border: 1px solid rgba(122, 232, 255, .5); box-shadow: 0 0 20px rgba(90, 216, 255, .35); }
.bar.boss #boss-hp { background: linear-gradient(180deg, #c9f6ff, #5ad8ff 40%, #6a3cff); } .bar.boss #boss-lag { background: rgba(255, 255, 255, .6); transition: width 1s .3s; }

#hud-map { position: absolute; right: calc(18px + var(--safe-r)); top: 16px; text-align: center; filter: drop-shadow(0 4px 12px rgba(0, 0, 0, .6)); }
.map-ring { position: relative; width: 176px; height: 176px; border-radius: 50%; padding: 4px; background: conic-gradient(from 0deg, #f2c25a, #9b5cff, #5ad8ff, #9b5cff, #f2c25a); }
#minimap { width: 168px; height: 168px; border-radius: 50%; display: block; background: #0c0820; }
.map-n { position: absolute; top: -6px; left: 50%; transform: translateX(-50%); font-weight: 800; font-size: 12px; color: #1b0f30; background: var(--gold); border-radius: 50%; width: 20px; height: 20px; display: grid; place-items: center; }
.zone { margin-top: 8px; font-size: 14px; font-weight: 600; color: var(--gold2); text-shadow: 0 2px 4px #000; }
.clock { font-size: 12px; color: var(--ink2); text-shadow: 0 1px 3px #000; }

#hud-quest { position: absolute; right: calc(18px + var(--safe-r)); top: 250px; width: 260px; padding: 12px 14px; border-radius: 12px; background: linear-gradient(160deg, rgba(34, 22, 70, .6), rgba(12, 8, 28, .55)); border: 1px solid var(--line); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); transition: box-shadow .3s; }
#hud-quest.flash { box-shadow: 0 0 26px rgba(242, 194, 90, .8); }
.q-head { font-size: 11px; letter-spacing: .25em; color: var(--gold); } .q-title { font-size: 15px; font-weight: 700; margin: 3px 0 5px; } .q-obj { font-size: 13px; color: var(--ink2); line-height: 1.45; }
.q-prog { margin-top: 8px; height: 4px; border-radius: 3px; background: rgba(255, 255, 255, .1); overflow: hidden; } .q-prog i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #c49bff, #f2c25a); transition: width .4s; }

#hud-skills { position: absolute; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translateX(-50%); display: flex; gap: 8px; align-items: flex-end; padding: 10px 14px; border-radius: 18px; background: linear-gradient(180deg, rgba(20, 12, 44, .35), rgba(10, 6, 24, .75)); border: 1px solid var(--line); box-shadow: 0 8px 30px rgba(0, 0, 0, .5); }
.slot { position: relative; width: 58px; height: 58px; border-radius: 14px; background: radial-gradient(circle at 50% 35%, rgba(90, 60, 170, .9), rgba(16, 10, 36, .95)); border: 1px solid rgba(196, 155, 255, .5); box-shadow: inset 0 0 12px rgba(0, 0, 0, .6); overflow: hidden; }
.slot.small { width: 46px; height: 46px; border-radius: 12px; }
.slot.ult { width: 64px; height: 64px; border-color: rgba(242, 194, 90, .8); box-shadow: 0 0 16px rgba(242, 194, 90, .35), inset 0 0 12px rgba(0, 0, 0, .6); }
.slot .ic { position: absolute; inset: 7px; } .slot .ic svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 0 4px rgba(255, 255, 255, .35)); }
.slot kbd { position: absolute; left: 3px; top: 3px; z-index: 3; }
.slot .cd { position: absolute; inset: 0; z-index: 2; background: conic-gradient(rgba(5, 3, 14, .78) var(--p, 0%), transparent 0); pointer-events: none; }
.slot em { position: absolute; inset: auto 0 3px 0; z-index: 3; text-align: center; font-style: normal; font-size: 13px; font-weight: 800; text-shadow: 0 1px 3px #000; }
.slot .count { position: absolute; right: 4px; bottom: 2px; z-index: 3; font-size: 12px; text-shadow: 0 1px 2px #000; color: #fff; }
.slot.nomp .ic { filter: saturate(.2) brightness(.6); } .slot.nomp { border-color: rgba(90, 120, 255, .8); }
.slot.locked .ic { opacity: .18; } .slot.locked::after { content: attr(data-lock); position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; color: var(--ink2); z-index: 4; }
.slot.fire { animation: fire .35s; } @keyframes fire { 0% { box-shadow: 0 0 0 rgba(242, 194, 90, 0); } 40% { box-shadow: 0 0 26px rgba(242, 194, 90, 1); transform: scale(1.1); } }
.slot.ready { animation: ready .6s; } @keyframes ready { 40% { box-shadow: 0 0 24px #fff; } }
.slot.ult.void { border-color: rgba(200, 155, 255, .85); box-shadow: 0 0 16px rgba(155, 92, 255, .45), inset 0 0 12px rgba(0, 0, 0, .6); }
.sep { width: 1px; height: 44px; background: var(--line); margin: 0 4px; align-self: center; }
/* eight skills in one row: tighten up before the bar meets the edges of a narrow window */
@media (max-width: 1180px) {
  #hud-skills { gap: 5px; padding: 8px 10px; }
  .slot { width: 46px; height: 46px; border-radius: 11px; } .slot.ult { width: 50px; height: 50px; } .slot.small { width: 38px; height: 38px; }
  .slot kbd { font-size: 9px; padding: 0 3px; } .slot .ic { inset: 5px; } .slot em { font-size: 11px; } .sep { margin: 0 1px; height: 34px; }
}
#hud-gold { position: absolute; left: calc(50% + 250px); bottom: calc(26px + var(--safe-b)); display: flex; gap: 6px; align-items: center; font-weight: 700; color: var(--gold2); text-shadow: 0 1px 3px #000; }
#hud-gold .coin svg { width: 22px; height: 22px; display: block; }

#hud-prompt { position: absolute; left: 50%; bottom: 140px; transform: translateX(-50%); padding: 9px 18px; border-radius: 999px; background: var(--panel); border: 1px solid rgba(242, 194, 90, .6); font-size: 15px; box-shadow: 0 0 20px rgba(242, 194, 90, .35); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 30px rgba(242, 194, 90, .65); } }
#hud-toasts { position: absolute; right: calc(18px + var(--safe-r)); top: 400px; width: 300px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast { padding: 9px 14px; border-radius: 10px; background: var(--panel); border-left: 3px solid var(--violet2); font-size: 13px; animation: toastIn .35s ease-out, toastOut .5s ease-in forwards; animation-delay: 0s, var(--life, 4s); box-shadow: 0 4px 14px rgba(0, 0, 0, .4); }
.toast.quest { border-color: var(--gold); } .toast.good { border-color: #6fe8a0; } .toast.info { border-color: var(--cyan); }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } } @keyframes toastOut { to { opacity: 0; transform: translateY(-10px); } }
#hud-loot { position: absolute; left: calc(18px + var(--safe-l)); bottom: 150px; display: flex; flex-direction: column; gap: 4px; }
.loot { font-size: 13px; padding: 4px 10px; border-radius: 8px; background: rgba(10, 6, 24, .6); animation: toastIn .3s, toastOut .6s forwards 2.6s; text-shadow: 0 1px 2px #000; }
.loot.gold { color: var(--gold2); } .loot.relic { color: #ffb8f0; font-weight: 700; } .loot.item { color: #bff0ff; } .loot.xp { color: #e8d8ff; }
#hud-banner { position: absolute; left: 50%; top: 24%; transform: translateX(-50%); text-align: center; animation: bannerIn .6s ease-out; pointer-events: none; width: 90vw; }
#hud-banner.out { animation: bannerOut .8s forwards; }
.b-t { font-family: var(--serif); font-size: clamp(30px, 5vw, 54px); font-weight: 700; letter-spacing: .06em; background: linear-gradient(180deg, #fffbe8, #f2c25a 60%, #c47b2a); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 16px rgba(242, 194, 90, .6)) drop-shadow(0 3px 2px #000); }
.b-s { margin-top: 6px; font-size: 16px; color: var(--ink); text-shadow: 0 2px 6px #000; }
#hud-banner.relic .b-t { background-image: linear-gradient(180deg, #fff, #ff9be0 55%, #9b5cff); } #hud-banner.boss .b-t { background-image: linear-gradient(180deg, #e8fdff, #5ad8ff 55%, #6a3cff); }
@keyframes bannerIn { from { opacity: 0; transform: translate(-50%, 20px) scale(.9); letter-spacing: .3em; } }
@keyframes bannerOut { to { opacity: 0; transform: translate(-50%, -20px); } }
#hud-warn { position: absolute; left: 50%; bottom: 150px; transform: translateX(-50%); font-size: 15px; color: #ffb3c8; text-shadow: 0 2px 4px #000; transition: opacity .3s; opacity: 0; }
#hud-warn.on { opacity: 1; }
#crosshair { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: rgba(255, 255, 255, .7); box-shadow: 0 0 6px #c49bff; opacity: 0; transition: opacity .2s; }
body.locked #crosshair { opacity: .8; }
#fps { position: absolute; left: 50%; top: 4px; transform: translateX(-50%); font: 11px monospace; color: #bfb; text-shadow: 0 1px 2px #000; }
#btn-menu { right: calc(206px + var(--safe-r)); top: 16px; }

/* floating numbers & enemy bars */
#float-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.fnum { position: absolute; left: 0; top: 0; font-weight: 900; font-size: 20px; color: #fff; text-shadow: 0 2px 0 #3a1470, 0 0 8px rgba(155, 92, 255, .9), 0 0 2px #000; white-space: nowrap; will-change: transform, opacity; }
.fnum.crit { font-size: 30px; color: #ffe39a; text-shadow: 0 2px 0 #7a3a00, 0 0 12px rgba(255, 180, 60, .9); }
.fnum.crit::after { content: " ✦"; font-size: .7em; }
.fnum.hurt { color: #ff7a9a; text-shadow: 0 2px 0 #4a0018, 0 0 8px rgba(255, 60, 100, .8); }
.fnum.heal { color: #8affb8; } .fnum.mana { color: #8ad8ff; } .fnum.shield { color: #bff0ff; font-size: 16px; } .fnum.dodge { color: #e8d8ff; font-size: 16px; font-style: italic; } .fnum.immune { color: #9adfff; font-size: 16px; }
.fnum.xp { color: #f2c25a; font-size: 15px; }
.ebar { position: absolute; left: 0; top: 0; width: 64px; will-change: transform; }
.ebar .n { font-size: 11px; text-align: center; text-shadow: 0 1px 2px #000, 0 0 3px #000; white-space: nowrap; margin-bottom: 2px; }
.ebar .n b { color: var(--gold2); font-weight: 700; }
.ebar .h { height: 6px; border-radius: 3px; background: rgba(0, 0, 0, .6); border: 1px solid rgba(255, 255, 255, .25); overflow: hidden; }
.ebar .h i { display: block; height: 100%; background: linear-gradient(180deg, #ffb07a, #e84a4a); transition: width .15s; }
.ebar.target .h { border-color: var(--gold); box-shadow: 0 0 8px var(--gold); }
.ebar.elite .n { color: #e4c8ff; }

/* ---------- dialogue */
#dialogue { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); width: min(980px, 94vw); display: flex; align-items: flex-end; gap: 0; animation: dlgIn .35s ease-out; }
@keyframes dlgIn { from { opacity: 0; transform: translate(-50%, 30px); } }
.d-portrait { width: 250px; height: 330px; margin-right: -30px; flex: none; position: relative; z-index: 2; pointer-events: none; }
.d-portrait img { width: 100%; height: 100%; object-fit: contain; object-position: bottom; filter: drop-shadow(0 0 22px rgba(155, 92, 255, .5)); animation: portraitIn .4s ease-out; }
@keyframes portraitIn { from { opacity: 0; transform: translateX(-20px); } }
.d-portrait .oracle { width: 100%; height: 100%; display: grid; place-items: end center; padding-bottom: 20px; }
.d-portrait .oracle svg { width: 200px; height: 260px; filter: drop-shadow(0 0 30px rgba(90, 216, 255, .7)); animation: floaty 4s ease-in-out infinite; }
.d-box { flex: 1; min-height: 170px; position: relative; padding: 22px 30px 26px 56px; border-radius: 18px; background: linear-gradient(160deg, rgba(34, 22, 70, .95), rgba(12, 8, 28, .95)); border: 1px solid var(--line); box-shadow: 0 16px 50px rgba(0, 0, 0, .6), var(--glow); cursor: pointer; }
.d-name { position: absolute; top: -18px; left: 44px; padding: 5px 18px; border-radius: 999px; font-weight: 700; font-size: 16px; color: #1b0f30; background: linear-gradient(90deg, #ffe39a, #f2c25a); box-shadow: 0 4px 14px rgba(0, 0, 0, .4); }
.d-name.astra { background: linear-gradient(90deg, #bff0ff, #7ab8ff); } .d-name.sys { background: linear-gradient(90deg, #d8c8ff, #9b7bff); }
.d-text { font-size: 18px; line-height: 1.7; min-height: 3.4em; color: var(--ink); }
.d-text.sys { color: #d8ccff; font-size: 15px; }
.d-next { position: absolute; right: 22px; bottom: 12px; color: var(--gold); animation: bob 1s infinite; }
@keyframes bob { 50% { transform: translateY(4px); } }
.d-choices { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.d-choices button { text-align: left; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line); background: rgba(50, 30, 100, .6); color: var(--ink); font-size: 15px; transition: .15s; }
.d-choices button:hover, .d-choices button.sel { background: rgba(120, 70, 220, .85); transform: translateX(6px); }

/* ---------- menu */
.menu-panel { width: min(960px, 94vw); height: min(640px, 90vh); display: flex; flex-direction: column; overflow: hidden; animation: panelIn .3s ease-out; }
@keyframes panelIn { from { opacity: 0; transform: scale(.96); } }
.menu-tabs { display: flex; gap: 4px; padding: 14px 18px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.menu-tabs button { padding: 10px 16px; border: 0; border-radius: 10px 10px 0 0; background: transparent; color: var(--ink3); font-size: 15px; border-bottom: 2px solid transparent; }
.menu-tabs button:hover { color: var(--ink); } .menu-tabs button.on { color: var(--gold2); border-bottom-color: var(--gold); background: rgba(155, 92, 255, .12); }
.menu-body { flex: 1; overflow: auto; padding: 20px 24px; }
.menu-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.stat-grid { display: grid; grid-template-columns: 220px 1fr; gap: 24px; }
.stat-art { width: 100%; max-height: 420px; object-fit: contain; filter: drop-shadow(0 0 20px rgba(155, 92, 255, .5)); }
.stat-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 20px; }
.stat { display: flex; justify-content: space-between; padding: 8px 12px; border-radius: 10px; background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .06); font-size: 14px; }
.stat b { color: var(--gold2); } .stat .bonus { color: #8affb8; font-size: 12px; margin-left: 6px; }
h3 { font-size: 15px; letter-spacing: .12em; color: var(--gold); margin: 18px 0 10px; font-weight: 600; }
.skill-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.skill-card { display: flex; gap: 12px; padding: 10px; border-radius: 12px; background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .07); }
.skill-card .ic { width: 46px; height: 46px; flex: none; } .skill-card .ic svg { width: 100%; height: 100%; }
.skill-card.locked { opacity: .45; } .skill-card b { font-size: 14px; } .skill-card p { margin: 3px 0 0; font-size: 12px; color: var(--ink2); line-height: 1.45; } .skill-card small { color: var(--gold2); }
.bag-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 10px; }
.item { position: relative; aspect-ratio: 1; border-radius: 14px; background: radial-gradient(circle at 50% 35%, rgba(90, 60, 170, .6), rgba(16, 10, 36, .9)); border: 1px solid rgba(196, 155, 255, .35); padding: 14px; transition: .15s; }
.item:hover { border-color: var(--gold); box-shadow: 0 0 16px rgba(242, 194, 90, .4); transform: translateY(-2px); }
.item svg { width: 100%; height: 100%; } .item .q { position: absolute; right: 7px; bottom: 5px; font-weight: 800; font-size: 13px; }
.item.rare { border-color: rgba(122, 200, 255, .6); } .item.epic { border-color: rgba(200, 130, 255, .8); } .item.legend { border-color: rgba(242, 194, 90, .9); box-shadow: 0 0 14px rgba(242, 194, 90, .35); }
.item.empty { opacity: .25; }
.item-info { margin-top: 16px; min-height: 60px; padding: 12px 14px; border-radius: 12px; background: rgba(255, 255, 255, .04); font-size: 14px; line-height: 1.6; color: var(--ink2); }
.item-info b { color: var(--ink); font-size: 16px; }
.quest-log .qe { padding: 12px 14px; border-radius: 12px; margin-bottom: 10px; background: rgba(255, 255, 255, .04); border-left: 3px solid var(--line); }
.quest-log .qe.cur { border-color: var(--gold); background: rgba(242, 194, 90, .07); } .quest-log .qe.done { opacity: .55; }
.quest-log .qe b { font-size: 15px; } .quest-log .qe p { margin: 4px 0 0; font-size: 13px; color: var(--ink2); }
#tab-map { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; justify-content: center; }
#bigmap { width: min(520px, 80vw); height: auto; aspect-ratio: 1; border-radius: 16px; border: 1px solid var(--line); background: #0c0820; }
.map-legend { font-size: 13px; line-height: 2; color: var(--ink2); }
.map-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 8px; vertical-align: -1px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 11px 4px; border-bottom: 1px solid rgba(255, 255, 255, .06); font-size: 15px; }
.set-row small { display: block; color: var(--ink3); font-size: 12px; }
.set-row select, .set-row input[type=range] { accent-color: var(--violet); }
.set-row select { background: #1d1440; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-family: var(--font); font-size: 14px; }
.set-row input[type=range] { width: 200px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { padding: 6px 12px; border: 0; background: transparent; color: var(--ink2); font-size: 13px; }
.seg button.on { background: linear-gradient(90deg, #9b5cff, #c47bff); color: #fff; }
.howto { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px 20px; }
.howto div { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-radius: 10px; background: rgba(255, 255, 255, .04); font-size: 14px; }
.howto kbd { font-size: 12px; padding: 3px 8px; }
.tips { margin-top: 16px; font-size: 14px; line-height: 1.8; color: var(--ink2); }
.side-panel { width: min(760px, 94vw); max-height: 86vh; display: flex; flex-direction: column; animation: panelIn .3s ease-out; }
.side-panel header { display: flex; justify-content: space-between; align-items: center; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.side-panel h2 { margin: 0; font-size: 20px; color: var(--gold2); font-weight: 600; }
.side-panel .x { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: transparent; color: var(--ink); }
.panel-body { padding: 18px 24px; overflow: auto; }
.confirm-panel { padding: 26px 30px; width: min(440px, 90vw); text-align: center; }
.confirm-panel p { font-size: 16px; line-height: 1.6; } .confirm-panel .row { display: flex; gap: 12px; justify-content: center; margin-top: 18px; }
#confirm, #fatal { z-index: 80; }
.credits-body p { line-height: 1.8; color: var(--ink2); }

/* ---------- death / ending */
#death { background: radial-gradient(ellipse at center, rgba(40, 10, 40, .35), rgba(5, 2, 12, .85)); animation: fadeIn 1.2s; }
@keyframes fadeIn { from { opacity: 0; } }
.death-box { text-align: center; } .death-box h2 { font-family: var(--serif); font-size: 46px; margin: 0; color: #e8c8ff; text-shadow: 0 0 20px rgba(155, 92, 255, .8); } .death-box p { color: var(--ink2); margin: 10px 0 24px; }
.death-box .tbtn { margin: 0 auto; justify-content: center; }
#ending { background: radial-gradient(ellipse at 30% 40%, rgba(60, 30, 120, .75), rgba(5, 2, 14, .92)); z-index: 40; animation: fadeIn 1.5s; }
.end-art { position: absolute; left: 3vw; bottom: 0; height: 92vh; max-width: 45vw; object-fit: contain; filter: drop-shadow(0 0 40px rgba(242, 194, 90, .5)); animation: floaty 5s ease-in-out infinite; }
.end-box { margin-left: 40vw; width: min(560px, 90vw); }
.end-box h2 { font-family: var(--serif); font-size: 40px; margin: 10px 0; color: var(--gold2); text-shadow: 0 0 20px rgba(242, 194, 90, .5); }
.end-box p { color: var(--ink2); font-size: 16px; }
.end-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 18px 0; }
.credits { margin: 18px 0 24px; display: grid; gap: 8px; } .credits div { display: flex; flex-direction: column; padding: 8px 12px; border-radius: 10px; background: rgba(255, 255, 255, .05); }
.credits b { font-size: 13px; color: var(--gold); letter-spacing: .06em; } .credits span { font-size: 14px; color: var(--ink2); }

#fade { position: fixed; inset: 0; background: #05030c; opacity: 0; transition: opacity .8s; pointer-events: none; z-index: 60; }
#fade.on { opacity: 1; } #fade.white { background: #fff; }

/* ---------- touch */
#touch-ui { display: none; }
body.touch #touch-ui { display: block; }
body.touch.playing #touch-ui { pointer-events: auto; }
#touch-look { position: fixed; right: 0; top: 0; width: 55vw; height: 100vh; pointer-events: auto; }
#touch-stick { position: fixed; left: calc(34px + var(--safe-l)); bottom: calc(34px + var(--safe-b)); width: 140px; height: 140px; border-radius: 50%; background: radial-gradient(circle, rgba(155, 92, 255, .15), rgba(155, 92, 255, .05)); border: 1px solid var(--line); pointer-events: auto; }
#touch-knob { position: absolute; left: 50%; top: 50%; width: 60px; height: 60px; margin: -30px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #c49bff, #5a2aa0); box-shadow: 0 0 16px rgba(155, 92, 255, .7); }
.tbtns button { position: fixed; width: 58px; height: 58px; border-radius: 50%; border: 1px solid var(--line); background: rgba(24, 14, 52, .72); color: var(--ink); font-size: 20px; pointer-events: auto; padding: 10px; }
.tbtns button svg { width: 100%; height: 100%; }
.tbtns button.on { background: rgba(155, 92, 255, .8); }
.t-attack { right: calc(26px + var(--safe-r)); bottom: calc(40px + var(--safe-b)); width: 84px !important; height: 84px !important; }
.t-jump { right: calc(122px + var(--safe-r)); bottom: calc(30px + var(--safe-b)); }
.t-dash { right: calc(30px + var(--safe-r)); bottom: calc(136px + var(--safe-b)); }
.t-s1 { right: calc(186px + var(--safe-r)); bottom: calc(30px + var(--safe-b)); width: 50px !important; height: 50px !important; }
.t-s2 { right: calc(176px + var(--safe-r)); bottom: calc(92px + var(--safe-b)); width: 50px !important; height: 50px !important; }
.t-s3 { right: calc(130px + var(--safe-r)); bottom: calc(142px + var(--safe-b)); width: 50px !important; height: 50px !important; }
.t-s4 { right: calc(80px + var(--safe-r)); bottom: calc(196px + var(--safe-b)); width: 50px !important; height: 50px !important; }
.t-pot { left: calc(190px + var(--safe-l)); bottom: calc(40px + var(--safe-b)); width: 48px !important; height: 48px !important; }
.t-int { left: calc(190px + var(--safe-l)); bottom: calc(100px + var(--safe-b)); width: 48px !important; height: 48px !important; font-weight: 800; color: var(--gold2) !important; }
.t-tgt { right: calc(30px + var(--safe-r)); bottom: calc(210px + var(--safe-b)); width: 46px !important; height: 46px !important; }
.t-swap { right: calc(246px + var(--safe-r)); bottom: calc(34px + var(--safe-b)); width: 44px !important; height: 44px !important; padding: 0 !important; color: var(--gold2) !important; }
.t-swap.alt { background: rgba(155, 92, 255, .8) !important; color: #fff !important; }
body.touch #hud-skills, body.touch #hud-gold, body.touch #crosshair, body.touch #hud-prompt kbd { display: none; }
.tbtns button { overflow: hidden; }
.tbtns button .tcd { position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(rgba(5, 3, 14, .78) var(--p, 0%), transparent 0); pointer-events: none; }
.tbtns button.locked { opacity: .3; }
body.touch #hud-prompt { bottom: 45vh; }
#rotate-hint { display: none; z-index: 90; background: rgba(5, 3, 14, .88); pointer-events: auto; }
.rot-icon { font-size: 44px; animation: floaty 2s ease-in-out infinite; }
/* phones & tablets: landscape only */
@media (orientation: portrait) and (pointer: coarse) { #rotate-hint { display: flex; } }
body.touch.portrait #rotate-hint { display: flex; }

/* ---------- responsive */
@media (max-width: 900px) {
  .logo.big { font-size: 58px; }
  .title-art { opacity: .35; right: -10vw; max-width: 90vw; }
  .load-art { opacity: .3; max-width: 90vw; } .load-box { margin-right: 0; }
  #hud-quest { top: auto; bottom: 110px; right: 12px; width: 220px; }
  .bars { width: 170px; } .portrait { width: 64px; height: 64px; }
  .map-ring { width: 120px; height: 120px; } #minimap { width: 112px; height: 112px; }
  #btn-menu { right: 146px; }
  #hud-toasts { top: 190px; }
  .stat-grid { grid-template-columns: 1fr; } .stat-art { display: none; } .skill-list, .stat-list { grid-template-columns: 1fr; }
  .d-portrait { width: 140px; height: 200px; } .d-text { font-size: 16px; }
  .end-art { opacity: .3; } .end-box { margin-left: 0; }
  #hud-gold { left: auto; right: 14px; bottom: 90px; }
}
@media (max-height: 560px) { #hud-quest { display: none; } }
