html, body { margin: 0; height: 100%; overflow: hidden; background: #e8c890; 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; }

.top { position: absolute; top: env(safe-area-inset-top, 0); left: 0; right: 0; height: 0; }
.top .bar { position: absolute; top: 8px; font-size: 12px; text-shadow: 0 1px 2px #000; }
.top .bar.me { left: 8px; }
.top .bar.foe { right: 8px; text-align: right; }
.top .bar b { display: block; margin-bottom: 3px; letter-spacing: .5px; }
.top .hull { display: flex; flex-wrap: wrap; gap: 2px; max-width: 46vw; }
.top .bar.foe .hull { justify-content: flex-end; }
.top .hull i { width: 6px; height: 11px; border-radius: 2px; background: rgba(30,20,15,.6); box-shadow: inset 0 0 0 1px rgba(255,255,255,.35); }
.top .bar.me .hull i.on { background: #7dff9e; }
.top .bar.foe .hull i.on { background: #ff6b5b; }
.top .scrap { position: absolute; top: 52px; left: 8px; font-weight: 900; font-size: 15px; color: #ffd23f; text-shadow: 0 1px 2px #000; }
.top .scrap small { font-size: 11px; color: #fff; font-weight: 400; }
.top .alt { position: absolute; right: 6px; top: 70px; width: 8px; height: 34vh; border-radius: 4px; background: linear-gradient(#bfe6ff, #fff6d8 60%, #9aa0b8 78%, #4a4a60); box-shadow: 0 0 0 2px rgba(0,0,0,.25); }
.top .alt .cloud { position: absolute; left: -4px; right: -4px; top: 78%; height: 2px; background: rgba(255,255,255,.9); }
.top .alt .m { position: absolute; left: -9px; width: 0; height: 0; border-top: 6px solid transparent; border-bottom: 6px solid transparent; transform: translateY(-6px); transition: top .3s; }
.top .alt .m.me { border-left: 9px solid #7dff9e; }
.top .alt .m.foe { border-left: 9px solid #ff6b5b; }
.maphud { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; text-shadow: 0 1px 3px #000; font-size: 13px; }
.maphud b { font-size: 17px; width: 100%; letter-spacing: 1px; color: #ffe8b0; }

.panel { position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 6px calc(env(safe-area-inset-bottom, 0px) + 6px); background: linear-gradient(rgba(40,26,16,.88), rgba(28,18,10,.96)); border-top: 3px solid #8a5a34; box-sizing: border-box; }
.panel .crew { display: flex; gap: 4px; overflow-x: auto; }
.panel .mate { flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 3px; padding: 3px; border-radius: 8px; border: 2px solid rgba(255,255,255,.25); background: rgba(255,255,255,.06); text-align: left; }
.panel .mate span { min-width: 0; flex: 1; }
.panel .mate b { display: block; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel .mate small { display: block; font-size: 9px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel .mate i, .panel .gun i { display: block; height: 4px; background: rgba(0,0,0,.5); border-radius: 2px; margin-top: 2px; overflow: hidden; }
.panel .mate u { display: block; height: 100%; background: #7dff9e; }
.panel .mate.sel { border-color: #7dff9e; background: rgba(125,255,158,.18); }
.panel .mate.dead { opacity: .35; }
.panel .face { flex: none; }
.panel .row { display: flex; gap: 4px; margin-top: 5px; align-items: stretch; }
.panel .guns { display: flex; gap: 4px; flex: 1; }
.panel .gun { flex: 1; min-width: 0; padding: 6px 4px; border-radius: 8px; border: 2px solid rgba(255,180,90,.5); background: rgba(255,140,40,.12); font-size: 11px; }
.panel .gun b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel .gun u { display: block; height: 100%; background: #ff9a3c; }
.panel .gun.ready u { background: #ffd23f; }
.panel .gun.sel { border-color: #fff; background: rgba(255,210,63,.3); }
.panel .gun.off { opacity: .45; }
.panel .act { padding: 4px 7px; border-radius: 8px; border: 2px solid rgba(255,255,255,.3); background: rgba(255,255,255,.08); font-size: 11px; font-weight: 800; }
.panel .act em { font-style: normal; color: #ffd23f; }
.panel .act.on { background: rgba(125,255,158,.25); border-color: #7dff9e; }
.panel .pause.on { background: rgba(255,210,63,.35); border-color: #ffd23f; }

.toast { position: absolute; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 78px); transform: translateX(-50%); max-width: 86vw; padding: 7px 14px; border-radius: 16px; background: rgba(25,15,10,.85); font-size: 13px; text-align: center; opacity: 0; transition: opacity .2s; }
.toast.on { opacity: 1; }

.modal { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; padding: 16px; box-sizing: border-box; }
.modal.on { display: flex; pointer-events: auto; }
.sheet { width: min(92vw, 440px); max-height: 86vh; overflow-y: auto; padding: 16px; border-radius: 16px; background: linear-gradient(#f6ead2, #e9d6b0); color: #2a1e14; box-shadow: 0 10px 30px rgba(0,0,0,.4), inset 0 0 0 3px #8a5a34; }
.sheet h2 { margin: 0 0 8px; font-size: 22px; color: #6a2e1a; }
.sheet p { margin: 6px 0; line-height: 1.4; font-size: 15px; }
.sheet .gain { font-weight: 900; color: #3a7a3a; }
.choices { display: flex; flex-direction: column; gap: 7px; margin-top: 12px; }
.choice { padding: 10px 12px; border-radius: 10px; border: 2px solid #8a5a34; background: #fff8ea; color: #2a1e14; font-weight: 700; font-size: 15px; text-align: left; }
.choice.off { opacity: .4; }
.choice.big { background: linear-gradient(#e9773a, #c24a22); color: #fff; text-align: center; font-size: 18px; border-color: #7a2a12; }
.gcard { padding: 8px 10px; border-radius: 10px; background: rgba(138,90,52,.15); margin: 6px 0; }
.gcard b { display: block; font-size: 16px; } .gcard small { display: block; font-size: 13px; } .gcard em { font-size: 12px; font-style: normal; font-weight: 800; color: #8a3a1a; }
.cline { display: flex; gap: 8px; align-items: center; margin: 6px 0; } .cline b { display: block; } .cline small { font-size: 12px; }
.pop { animation: popIn .45s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes popIn { from { transform: scale(.6); opacity: 0 } }

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