:root { --bg: rgba(6,8,12,.86); --ln: rgba(200,190,170,.28); --tx: #e6dfd0; --dim: #8e8778; --acc: #ffb35c; --hp: #e5484d; --mp: #4f8cff; --xp: #c9a6ff; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #05070b; overflow: hidden; color: var(--tx); font: 13px/1.35 "DejaVu Sans Mono", "Cascadia Mono", Menlo, Consolas, monospace; -webkit-user-select: none; user-select: none; touch-action: none; }
canvas#gl { position: fixed; left: 0; top: 0; image-rendering: pixelated; }
.hidden { display: none !important; }
.dim { color: var(--dim); }
.box { background: var(--bg); border: 1px solid var(--ln); }
button { font: inherit; color: var(--tx); background: rgba(20,22,28,.9); border: 1px solid var(--ln); padding: 4px 9px; cursor: pointer; }
button:hover { border-color: var(--acc); color: #fff; }
button.big { font-size: 15px; padding: 9px 22px; border-color: var(--acc); color: var(--acc); }
button.big:hover { background: var(--acc); color: #120c05; }
input { font: inherit; color: var(--tx); background: rgba(0,0,0,.6); border: 1px solid var(--ln); padding: 6px 8px; outline: none; }
input:focus { border-color: var(--acc); }

/* title */
#title { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: radial-gradient(ellipse at center, rgba(0,0,0,.15), rgba(0,0,0,.55)); }
#logo { margin: 0; font-size: 12px; line-height: 12px; letter-spacing: 1px; text-shadow: 0 0 14px rgba(255,170,80,.55); }
#tag { color: #cfc7b6; letter-spacing: 6px; font-size: 12px; text-transform: lowercase; text-shadow: 0 0 8px #000; }
#create { padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; min-width: 330px; }
#create label { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
#create input { width: 200px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sw { display: flex; gap: 5px; }
.sw b { width: 20px; height: 20px; border: 1px solid #000; cursor: pointer; outline: 1px solid transparent; }
.sw b.on { outline: 2px solid var(--acc); }
#srv { text-align: center; font-size: 12px; }
#title-help { font-size: 11px; text-align: center; padding: 0 12px; text-shadow: 0 0 6px #000; }

/* hud */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
#zone { position: absolute; left: 10px; top: 10px; padding: 6px 10px; min-width: 210px; }
#zname { color: var(--acc); letter-spacing: 2px; }
#zinfo { font-size: 11px; }
#boss { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); width: min(560px, 70vw); padding: 6px 10px 8px; }
.bhead { display: flex; justify-content: space-between; letter-spacing: 3px; text-transform: uppercase; margin-bottom: 4px; }
#bphase { color: #ff9a6a; letter-spacing: 1px; text-transform: none; font-size: 12px; }
.bbar { position: relative; height: 9px; border: 1px solid var(--ln); background: #120808; }
.bbar i { position: absolute; top: -2px; width: 1px; height: 12px; background: #ddd; opacity: .6; }
#bfill { height: 100%; width: 100%; background: repeating-linear-gradient(90deg, #c33 0 3px, #8a1f1f 3px 4px); transition: width .2s; }
#mapbox { position: absolute; right: 10px; top: 10px; padding: 4px; }
#mini { display: block; width: 150px; height: 150px; image-rendering: pixelated; }
#coords { font-size: 10px; text-align: center; }
#tracker { position: absolute; right: 10px; top: 186px; width: 270px; font-size: 12px; pointer-events: none; text-shadow: 0 0 4px #000, 0 0 2px #000; }
#tracker .q { margin-bottom: 8px; }
#tracker .qn { color: var(--acc); }
#tracker .qg.done { color: #8fd98f; }
#chat { position: absolute; left: 10px; bottom: 10px; width: min(380px, 42vw); pointer-events: none; }
#log { max-height: 150px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; font-size: 12px; text-shadow: 0 0 3px #000, 0 0 2px #000; }
#log div { padding: 1px 0; }
#log .sys { color: #b9b29f; } #log .loot { color: #ffd75e; } #log .xp { color: var(--xp); } #log .warn { color: #ff8a6a; } #log .pl b { color: #9fd0ff; font-weight: normal; }
#chatin { width: 100%; margin-top: 4px; pointer-events: auto; }
#toast { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); text-align: center; pointer-events: none; font-size: 18px; letter-spacing: 3px; color: #fff3d6; text-shadow: 0 0 12px rgba(255,180,90,.8), 0 0 3px #000; transition: opacity .6s; opacity: 0; white-space: pre; }
#toast small { display: block; font-size: 12px; letter-spacing: 1px; color: #d8cdb5; }
#prompt { position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%); padding: 4px 10px; background: var(--bg); border: 1px solid var(--acc); color: var(--acc); font-size: 12px; pointer-events: none; }
#cast { position: absolute; left: 50%; bottom: 150px; transform: translateX(-50%); width: 220px; height: 14px; border: 1px solid var(--ln); background: var(--bg); }
#castfill { height: 100%; width: 0; background: linear-gradient(90deg, #7a5a2a, var(--acc)); }
#castlbl { position: absolute; inset: 0; text-align: center; font-size: 10px; line-height: 12px; }
#bar { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); display: flex; align-items: flex-end; gap: 0; }
#lvl { position: absolute; left: 0; top: -26px; padding: 2px 8px; font-size: 12px; display: flex; gap: 10px; align-items: center; border-bottom: none; }
#xpbar { width: 70px; height: 3px; background: #1a1424; } #xpfill { height: 100%; width: 0; background: var(--xp); }
#main { display: flex; gap: 10px; padding: 7px 10px; align-items: center; }
#bars { width: 190px; }
.stat { display: flex; align-items: center; gap: 6px; font-size: 11px; margin-bottom: 4px; }
.stat span { width: 20px; color: var(--dim); }
.stat b { width: 34px; text-align: right; font-weight: normal; }
.sbar { flex: 1; height: 9px; border: 1px solid var(--ln); background: #0b0b0e; }
.sbar div { height: 100%; width: 100%; transition: width .15s; }
.sbar.hp div { background: repeating-linear-gradient(90deg, var(--hp) 0 2px, #9e2a30 2px 3px); }
.sbar.mp div { background: repeating-linear-gradient(90deg, var(--mp) 0 2px, #2c4f9a 2px 3px); }
.sub { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 190px; }
#skills { display: flex; gap: 5px; }
.sk { position: relative; width: 50px; height: 54px; border: 1px solid var(--ln); background: rgba(14,15,20,.9); display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; }
.sk .g { font-size: 22px; line-height: 26px; }
.sk .c { font-size: 10px; color: var(--dim); }
.sk .k { position: absolute; left: 3px; top: 1px; font-size: 9px; color: var(--dim); }
.sk.sel { border-color: var(--acc); box-shadow: 0 0 8px rgba(255,179,92,.35) inset; }
.sk.lock { opacity: .35; }
.sk.nomp .g { color: #6a6a80 !important; }
.cdw { position: absolute; inset: 0; background: conic-gradient(rgba(0,0,0,.72) var(--p,0%), transparent 0); pointer-events: none; }
#btns { display: grid; grid-template-columns: repeat(4, auto); gap: 3px; }
#btns button { padding: 2px 6px; font-size: 11px; text-align: left; }
#btns button.on { color: var(--acc); border-color: var(--acc); }
#potion { position: relative; width: 46px; height: 54px; margin-left: 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; }
#potion b { color: #ff7a7a; font-weight: normal; font-size: 18px; }
#potn { font-size: 11px; }

#panel { background: rgba(6,8,12,.96); position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(820px, 94vw); max-height: 84vh; display: flex; flex-direction: column; z-index: 5; }
.phead { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--ln); letter-spacing: 5px; text-transform: uppercase; }
.phead button { letter-spacing: 0; text-transform: none; }
#pbody { padding: 12px; overflow: auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, 46px); gap: 5px; }
.slot { width: 46px; height: 46px; border: 1px solid var(--ln); background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; font-size: 20px; position: relative; cursor: pointer; }
.slot:hover { border-color: var(--acc); }
.slot .n { position: absolute; right: 2px; bottom: 0; font-size: 10px; color: var(--tx); }
.eq { display: flex; gap: 14px; margin-bottom: 12px; flex-wrap: wrap; }
.eq > div { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; color: var(--dim); }
.cols { display: flex; gap: 16px; flex-wrap: wrap; }
.cols > div { flex: 1; min-width: 240px; }
.stats { font-size: 12px; line-height: 1.6; }
.stats b { font-weight: normal; color: var(--acc); }
.opts { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.opts button.on { border-color: var(--acc); color: var(--acc); }
pre.blade { margin: 10px 0 0; font-size: 13px; line-height: 14px; display: block; text-shadow: 0 0 10px currentColor; }
.dlg p { margin: 0 0 12px; line-height: 1.55; }
.dlg .who { color: var(--acc); letter-spacing: 2px; margin-bottom: 8px; }
.dlg .acts { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
#tip { position: fixed; z-index: 9; padding: 8px 10px; font-size: 12px; max-width: 280px; pointer-events: none; }
#tip .tn { margin-bottom: 4px; }
#tip .ta { color: #9fc2ff; }
#death { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(40,0,0,.35); z-index: 8; }
#death .box { padding: 22px 30px; text-align: center; }
#death h2 { margin: 0 0 8px; font-weight: normal; letter-spacing: 6px; color: #ff8080; }
#fatal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 30px; text-align: center; background: #05070b; z-index: 20; color: #ffb35c; }
.mapwrap canvas { width: 100%; max-width: 640px; image-rendering: pixelated; display: block; margin: 0 auto; border: 1px solid var(--ln); }
.kbd { display: grid; grid-template-columns: 110px 1fr; gap: 3px 12px; font-size: 12px; }
.kbd b { color: var(--acc); font-weight: normal; }

/* touch */
#touch { position: absolute; inset: 0; pointer-events: none; }
#stick { position: absolute; left: 22px; bottom: 120px; width: 120px; height: 120px; border: 1px solid var(--ln); border-radius: 50%; background: rgba(0,0,0,.25); pointer-events: auto; }
#knob { position: absolute; left: 40px; top: 40px; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--acc); background: rgba(255,179,92,.15); }
#tbtns { position: absolute; right: 14px; bottom: 110px; width: 190px; display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; pointer-events: auto; }
.tb { width: 52px; height: 46px; font-size: 18px; padding: 0; background: rgba(10,10,14,.6); }
.tb.big { width: 70px; height: 70px; font-size: 28px; border-color: var(--acc); }
body.touch #chat { width: 48vw; } body.touch #log { max-height: 80px; font-size: 10px; }
body.touch #tracker { display: none; }
body.touch #mapbox { transform: scale(.7); transform-origin: top right; }
body.touch #title-help { display: none; }
@media (max-width: 760px) {
  #btns { display: none; }
  #bars { width: 130px; }
  .sk { width: 40px; height: 44px; } .sk .g { font-size: 17px; line-height: 20px; }
  #zone { min-width: 0; transform: scale(.85); transform-origin: top left; }
  #logo { font-size: 6px; line-height: 6px; }
  #create { min-width: 0; width: 92vw; }
}

/* PREVIEW PHONE FIT (apply-cut.mjs) */
body.touch #bar { left: 6px; right: 6px; bottom: calc(6px + env(safe-area-inset-bottom)); transform: none; justify-content: center; }
body.touch #main { gap: 6px; padding: 5px 6px; }
body.touch #bars { width: 104px; } body.touch .sub { max-width: 104px; }
body.touch .sk { width: 34px; height: 40px; } body.touch .sk .g { font-size: 15px; line-height: 18px; } body.touch .sk .c { font-size: 8px; }
body.touch #skills { gap: 3px; }
body.touch #potion { display: none; }
body.touch #lvl { font-size: 10px; top: -22px; }
body.touch #chat { top: 84px; bottom: auto; width: 56vw; }
body.touch #stick { bottom: calc(110px + env(safe-area-inset-bottom)); }
body.touch #tbtns { bottom: calc(100px + env(safe-area-inset-bottom)); }
