* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; overflow: hidden; background: #1b2433; color: #f4efe2; font: 15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }

#hud { position: fixed; inset: 0; pointer-events: none; }
#bars { position: absolute; left: max(12px, env(safe-area-inset-left)); top: max(12px, env(safe-area-inset-top)); width: min(260px, 46vw); }
.bar { position: relative; height: 16px; background: rgba(10, 14, 22, .62); border-radius: 4px; overflow: hidden; margin-bottom: 5px; }
.bar i { position: absolute; inset: 0 auto 0 0; width: 100%; transition: width .15s; }
.bar.hp i { background: linear-gradient(#e2574c, #b8342b); }
.bar.xp { height: 9px; }
.bar.xp i { background: linear-gradient(#f2c94c, #c79a1e); }
.bar span { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 16px; font-weight: 600; text-shadow: 0 1px 2px #000; }
.bar.xp span { line-height: 9px; font-size: 8px; }
#gold { font-size: 13px; font-weight: 600; text-shadow: 0 1px 3px #000; }
#gold::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #f2c94c; margin-right: 6px; vertical-align: -1px; box-shadow: inset -2px -2px 0 #b8891a; }

#place { position: absolute; top: 16%; left: 0; right: 0; text-align: center; font-size: clamp(22px, 4vw, 38px); font-weight: 700; letter-spacing: .04em; text-shadow: 0 2px 8px rgba(0, 0, 0, .8); opacity: 0; transition: opacity .8s; }
#place.on { opacity: 1; }
#place small { display: block; font-size: .45em; font-weight: 500; opacity: .85; letter-spacing: .1em; text-transform: uppercase; }
#quest { position: absolute; right: max(12px, env(safe-area-inset-right)); top: 204px; width: min(240px, 44vw); font-size: 13px; text-shadow: 0 1px 3px #000; text-align: right; }
#quest b { display: block; color: #f2c94c; }
#mini { position: absolute; right: max(12px, env(safe-area-inset-right)); top: max(12px, env(safe-area-inset-top)); width: 180px; height: 180px; border-radius: 50%; border: 2px solid rgba(244, 239, 226, .7); background: #24406a; box-shadow: 0 2px 10px rgba(0, 0, 0, .5); }
#labels { position: absolute; inset: 0; overflow: hidden; }
#labels > div { position: absolute; left: 0; top: 0; white-space: nowrap; font-size: 12px; font-weight: 600; text-align: center; text-shadow: 0 1px 2px #000, 0 0 4px #000; will-change: transform; }
#labels span { display: block; }
#labels .boss span { color: #ff9b6a; font-size: 14px; }
#labels em { display: block; font-style: normal; font-size: 22px; font-weight: 900; color: #f2c94c; line-height: 1; }
#labels .hpb { width: 46px; height: 5px; background: rgba(0, 0, 0, .6); border-radius: 2px; overflow: hidden; margin: 2px auto 0; }
#labels .hpb i { display: block; height: 100%; background: #e2574c; }
#labels .dmg { color: #ffd76a; font-size: 16px; font-weight: 800; }
#labels .dmg.me { color: #ff6b5e; }
#labels .dmg.crit { color: #ffb02e; font-size: 20px; }
#labels .dmg.gold { color: #f2c94c; font-size: 13px; }
#hurt { position: absolute; inset: 0; box-shadow: inset 0 0 90px rgba(200, 20, 10, .75); opacity: 0; }
#hurt.on { animation: hurt .45s ease-out; }
@keyframes hurt { from { opacity: 1; } to { opacity: 0; } }
#touch button.glow { border-color: #f2c94c; background: rgba(242, 201, 76, .3); }
#talk { cursor: pointer; }
#toast { position: absolute; left: 50%; bottom: 22%; transform: translateX(-50%); font-size: 15px; font-weight: 600; text-align: center; text-shadow: 0 1px 4px #000; opacity: 0; transition: opacity .4s; max-width: 90vw; }
#toast.on { opacity: 1; }
#talk { position: absolute; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(620px, 94vw); background: rgba(14, 18, 28, .86); border: 1px solid rgba(244, 239, 226, .25); border-radius: 10px; padding: 14px 18px; pointer-events: auto; }
#talk b { color: #f2c94c; display: block; margin-bottom: 4px; }
#talk p { font-size: 16px; }
#talk small { display: block; margin-top: 8px; opacity: .65; font-size: 12px; }
#prompt { position: absolute; left: 50%; top: 62%; transform: translateX(-50%); background: rgba(14, 18, 28, .72); padding: 6px 12px; border-radius: 6px; font-size: 14px; }
#cross { position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px; border-radius: 50%; background: rgba(255, 255, 255, .5); display: none; }
body.locked #cross { display: block; }

#touch { position: fixed; inset: 0; pointer-events: none; }
#stick { position: absolute; left: max(28px, env(safe-area-inset-left)); bottom: max(28px, env(safe-area-inset-bottom)); width: 130px; height: 130px; border-radius: 50%; background: rgba(255, 255, 255, .1); border: 2px solid rgba(255, 255, 255, .25); }
#stick i { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px; border-radius: 50%; background: rgba(255, 255, 255, .35); }
#touch button { position: absolute; pointer-events: auto; width: 64px; height: 64px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .35); background: rgba(20, 26, 38, .45); color: #fff; padding: 16px; touch-action: none; }
#touch button svg { width: 100%; height: 100%; display: block; }
#touch button.on { background: rgba(242, 201, 76, .55); }
#b-atk { right: max(26px, env(safe-area-inset-right)); bottom: max(34px, env(safe-area-inset-bottom)); width: 84px !important; height: 84px !important; padding: 22px !important; }
#b-jump { right: max(124px, calc(env(safe-area-inset-right) + 98px)); bottom: max(26px, env(safe-area-inset-bottom)); }
#b-use { right: max(40px, env(safe-area-inset-right)); bottom: max(134px, calc(env(safe-area-inset-bottom) + 108px)); }
#b-run { right: max(128px, calc(env(safe-area-inset-right) + 102px)); bottom: max(108px, calc(env(safe-area-inset-bottom) + 82px)); width: 52px !important; height: 52px !important; padding: 13px !important; }
#b-map { right: calc(max(14px, env(safe-area-inset-right)) + 188px); top: max(14px, env(safe-area-inset-top)); width: 44px !important; height: 44px !important; padding: 10px !important; }

#map { position: fixed; inset: 0; background: rgba(8, 12, 20, .92); display: flex; align-items: center; justify-content: center; z-index: 5; }
#map canvas { max-width: 96vw; max-height: 96vh; aspect-ratio: 1; width: min(96vw, 96vh); border-radius: 8px; touch-action: none; }
#map-x { position: absolute; top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .15); color: #fff; font-size: 26px; line-height: 44px; cursor: pointer; }

#start { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: radial-gradient(ellipse at 50% 40%, rgba(40, 60, 90, .55), rgba(10, 14, 22, .9)); text-align: center; padding: 20px; z-index: 6; }
#start h1 { font-size: clamp(34px, 7vw, 64px); letter-spacing: .03em; text-shadow: 0 3px 0 #0b0f18, 0 6px 18px rgba(0, 0, 0, .6); }
#start h1 span { color: #f2c94c; }
#start #go { font: 700 20px system-ui, sans-serif; padding: 14px 46px; border-radius: 10px; border: 0; background: #f2c94c; color: #1b2433; cursor: pointer; box-shadow: 0 4px 0 #a37c14; }
#start #go:active { transform: translateY(3px); box-shadow: 0 1px 0 #a37c14; }
#start .keys { opacity: .7; font-size: 13px; max-width: 460px; }
body.mobile .keys.pc, body:not(.mobile) .keys.mob { display: none; }
@media (max-width: 640px), (max-height: 500px) {
  #mini { width: 112px; height: 112px; }
  #quest { top: 132px; font-size: 12px; }
  #b-map { right: calc(max(14px, env(safe-area-inset-right)) + 120px); }
}
.nw { white-space: nowrap; }
