html, body { margin: 0; height: 100%; overflow: hidden; background: #e8a868; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; }
#ui { position: fixed; inset: 0; pointer-events: none; font-family: 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif; color: #fff; }
button { font: inherit; cursor: pointer; pointer-events: auto; color: inherit; }

/* fight HUD */
.hud { position: absolute; top: env(safe-area-inset-top, 0); left: 0; right: 0; display: none; gap: 10px; align-items: flex-start; padding: 7px 8px 14px; background: linear-gradient(rgba(40,20,14,.6), rgba(40,20,14,0)); text-shadow: 0 1px 2px #000; }
.hud.on { display: flex; }
.hud .bar { width: 36%; max-width: 260px; }
.hud .bar b { display: block; font-size: 10px; letter-spacing: 1.2px; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud .bar.foe { margin-left: auto; text-align: right; }
.hud .hull { height: 9px; border-radius: 5px; background: rgba(0,0,0,.45); overflow: hidden; box-shadow: 0 0 0 1.5px rgba(255,255,255,.55); }
.hud .hull i { display: block; height: 100%; width: 100%; background: linear-gradient(#a8f0a0, #4fae5a); transition: width .2s; }
.hud .hull i.low { background: linear-gradient(#ff9a7a, #d33a2a); animation: blink .4s infinite alternate; }
.hud .bar.foe .hull i { background: linear-gradient(#ffb090, #c8442a); margin-left: auto; }
.hud .gold, .hud .crew { display: inline-block; margin-top: 4px; font-size: 13px; font-weight: 800; }
.hud .gold { color: #ffd84a; }
.hud .gold::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #ffd040; box-shadow: inset -2px -2px 0 #b8862a; margin-right: 5px; vertical-align: -1px; }
.hud .crew { opacity: .9; font-size: 11px; letter-spacing: 1px; }
.hud .menu { width: 30px; height: 30px; flex: none; border-radius: 50%; border: 2px solid rgba(255,255,255,.7); background: rgba(40,20,14,.45); font-weight: 900; font-size: 11px; }
@keyframes blink { to { opacity: .5 } }

.btns { position: absolute; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom, 0px) + 10px); display: none; align-items: flex-end; gap: 10px; padding: 0 10px; }
.btns.on { display: flex; }
.btns .bs, .btns .keg { position: relative; width: 70px; height: 70px; border-radius: 50%; border: 3px solid #fff3d8; background: radial-gradient(circle at 35% 30%, #8a6a5a, #3a2620); font-weight: 900; font-size: 10px; letter-spacing: .5px; opacity: .55; box-shadow: 0 4px 0 rgba(0,0,0,.35); transition: opacity .2s, transform .1s; }
.btns .keg { width: 58px; height: 58px; }
.btns .ready { opacity: 1; background: radial-gradient(circle at 35% 30%, #ff9a4a, #c2401a); animation: ready 1s infinite alternate; }
.btns button:active { transform: scale(.94); }
.btns svg { position: absolute; inset: -3px; width: calc(100% + 6px); height: calc(100% + 6px); transform: rotate(-90deg); pointer-events: none; }
.btns circle { fill: none; stroke: rgba(0,0,0,.55); stroke-width: 4; stroke-dasharray: 113; }
.btns span { position: relative; }
.btns .cn { display: block; line-height: 1; font-size: 9px; }
.btns .cn svg { position: static; display: inline-block; width: 30px; height: 20px; transform: none; margin-bottom: 1px; }
.btns .keg .cn svg { width: 20px; height: 20px; }
@keyframes ready { to { box-shadow: 0 4px 0 rgba(0,0,0,.35), 0 0 18px #ffb050; } }
.btns .home { margin-left: auto; display: none; padding: 12px 16px; border-radius: 26px; border: 3px solid #fff3d8; background: linear-gradient(#5a8aa8, #2a5a7a); font-weight: 900; font-size: 14px; letter-spacing: .5px; box-shadow: 0 4px 0 rgba(0,0,0,.35); }
.btns .home.on { display: block; }
.btns .home.alarm { background: linear-gradient(#ff7a5a, #c2301a); animation: alarm .5s infinite alternate; }
@keyframes alarm { to { transform: scale(1.06); } }

.hint { position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 92px); transform: translateX(-50%); max-width: 86vw; width: max-content; padding: 8px 14px; border-radius: 16px; background: rgba(40,20,14,.82); font-size: 14px; text-align: center; opacity: 0; transition: opacity .3s; }
.hint.on { opacity: 1; }
.banner { position: absolute; top: 20%; left: 0; right: 0; text-align: center; opacity: 0; transition: opacity .4s; }
.banner.on { opacity: 1; animation: bannerIn 2.6s ease-out; }
.banner div { display: inline-block; font-size: clamp(26px, 8.5vw, 52px); font-weight: 900; letter-spacing: 2px; color: #fff3d8; text-shadow: 0 3px 0 #8a3a1a, 0 6px 14px rgba(0,0,0,.45); -webkit-text-stroke: 1.5px #2a1408; }
.banner small { display: block; font-size: .32em; letter-spacing: 2px; -webkit-text-stroke: 0; text-shadow: 0 1px 3px #000; margin-top: 4px; }
@keyframes bannerIn { 0% { transform: scale(1.8); opacity: 0 } 12% { transform: scale(.96); opacity: 1 } 20% { transform: scale(1) } }

/* sheets */
.modal { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: flex-end; padding: 12px; box-sizing: border-box; padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); }
.modal.on { display: flex; pointer-events: auto; }
.modal.pause, .modal.over { justify-content: center; background: rgba(20,10,6,.35); }
@media (min-aspect-ratio: 9/10) { .modal.chart, .modal.port, .modal.spoils { align-items: flex-end; justify-content: center; } }
.sheet { width: min(94vw, 440px); max-height: 52vh; overflow-y: auto; padding: 14px 14px 12px; border-radius: 16px; background: linear-gradient(#f8ecd4, #ead6ae); color: #2a1e14; box-shadow: 0 10px 30px rgba(0,0,0,.4), inset 0 0 0 3px #8a5a34; }
@media (min-aspect-ratio: 9/10) { .sheet { max-height: 88vh; } }
.modal.pause .sheet, .modal.over .sheet { max-height: 80vh; }
.sheet h2 { margin: 0 0 6px; font-size: 22px; color: #6a2e1a; letter-spacing: .5px; }
.sheet p { margin: 5px 0; line-height: 1.4; font-size: 14.5px; }
.sheet .stat { font-weight: 700; }
.sheet .g, .sheet .loot .g { color: #a86a00; font-weight: 900; }
.sheet .ups { font-size: 12px; opacity: .75; }
.sheet .pick { font-weight: 700; margin-top: 8px; }
.choices { display: flex; flex-direction: column; gap: 7px; margin-top: 10px; }
.choice { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 11px; border: 2px solid #8a5a34; background: #fff8ea; color: #2a1e14; font-size: 15px; text-align: left; }
.choice:active { transform: scale(.98); }
.choice b { display: block; font-size: 15.5px; }
.choice small { display: block; font-size: 12.5px; margin-top: 2px; opacity: .85; }
.choice .ic { flex: none; width: 34px; height: 34px; }
.choice .ic svg { width: 100%; height: 100%; }
.choice:disabled { opacity: .45; }
.choice.big { justify-content: center; background: linear-gradient(#e9773a, #c24a22); color: #fff; font-size: 18px; font-weight: 900; border-color: #7a2a12; }
.choice.skip { padding: 6px 12px; opacity: .8; }
.choice.node.boss { background: #2a2a3a; color: #f0d070; border-color: #f0c040; }
.route { display: flex; gap: 4px; margin: 6px 0; }
.route i { flex: 1; height: 8px; border-radius: 4px; background: rgba(90,50,20,.18); position: relative; }
.route i.done { background: #b87a3a; }
.route i.now { background: #e8602a; box-shadow: 0 0 0 2px #fff; }
.route i svg { position: absolute; width: 22px; height: 22px; right: -4px; top: -8px; }
.pop { animation: popIn .4s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes popIn { from { transform: scale(.7) translateY(20px); opacity: 0 } }

/* title */
.modal.title { justify-content: space-between; padding: 0; }
.titlebox { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 22px); }
.titlebox .art { position: absolute; inset: 0; background: url(art/keyart.webp) center / cover; z-index: -1; }
.titlebox .art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(20,10,6,.4), rgba(0,0,0,0) 30%, rgba(0,0,0,0) 50%, rgba(30,14,6,.9)); }
.titlebox .logo { margin-top: calc(env(safe-area-inset-top, 0px) + 5vh); text-align: center; }
.titlebox h1 { margin: 0; font-size: clamp(46px, 15vw, 100px); letter-spacing: 4px; color: #fff3d8; text-shadow: 0 5px 0 #8a3a1a, 0 10px 0 rgba(0,0,0,.25); -webkit-text-stroke: 2px #2a1408; }
.titlebox .logo p { margin: 4px 16px 0; letter-spacing: 2px; text-transform: uppercase; font-size: 13px; text-shadow: 0 1px 4px #000; }
.titlebox .menu { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.titlebox .big { border: 3px solid #fff3d8; border-radius: 30px; padding: 14px 44px; background: linear-gradient(#e9773a, #c24a22); font-size: 22px; font-weight: 900; letter-spacing: 2px; box-shadow: 0 6px 0 #7a2a12; }
.titlebox .tip { max-width: 360px; text-align: center; font-size: 13.5px; line-height: 1.45; margin: 4px 18px 0; text-shadow: 0 1px 3px #000; }
.titlebox .best { margin: 0; font-size: 13px; opacity: .85; }
