:root {
  --bg: #07060a;
  --panel: rgba(18, 14, 12, 0.92);
  --panel-2: rgba(32, 25, 20, 0.95);
  --line: #6b5532;
  --line-hi: #c9a45c;
  --gold: #e8c87a;
  --text: #e9e1d2;
  --dim: #9c9282;
  --red: #e04848;
  --blue: #4a7cff;
  --green: #5ee07a;
  --exc: #6cff86;
  --cyan: #7ad8ff;
  --danger: #e05050;
  --slot: rgba(0, 0, 0, 0.45);
  --font-title: "Cinzel", Georgia, serif;
  --font: "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 13px/1.4 var(--font); user-select: none; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24'><path d='M2 2 L20 9 L12 12 L9 20 Z' fill='%23e8c87a' stroke='%23201508' stroke-width='1.5'/></svg>") 2 2, default; }
canvas#overlay { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
canvas#game.attack { cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='26' height='26'><path d='M3 3 L18 18 M18 18 L22 14 M18 18 L14 22 M3 3 L8 3 M3 3 L3 8' stroke='%23ff5040' stroke-width='3' fill='none' stroke-linecap='round'/></svg>") 3 3, crosshair; }
canvas#game.talk { cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='26' height='26'><path d='M3 4 h18 v12 h-10 l-5 5 v-5 h-3 z' fill='%23ffe9a0' stroke='%23201508' stroke-width='1.5'/></svg>") 3 3, pointer; }
canvas#game.grab { cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='26' height='26'><path d='M6 12 v-6 a2 2 0 0 1 4 0 v4 v-6 a2 2 0 0 1 4 0 v6 v-4 a2 2 0 0 1 4 0 v8 c0 5 -3 8 -7 8 c-3 0 -5 -2 -6 -4 l-3 -5 a2 2 0 0 1 3 -2 z' fill='%23ffe9a0' stroke='%23201508' stroke-width='1.3'/></svg>") 8 4, pointer; }

.hidden { display: none !important; }
.dim { color: var(--dim); font-weight: 400; }
button { font: 600 13px var(--font); color: #1a1208; background: linear-gradient(#f0d48a, #b88a3a); border: 1px solid #5a4320; border-radius: 4px; padding: 7px 14px; cursor: pointer; text-shadow: 0 1px 0 rgba(255,255,255,.3); }
button:hover { filter: brightness(1.12); }
button.ghost { background: rgba(255,255,255,.04); color: var(--gold); border-color: var(--line); text-shadow: none; }
button.ghost:hover { background: rgba(232,200,122,.1); }
button.danger { color: var(--danger); border-color: #6a2a2a; }
input { font: 14px var(--font); color: var(--text); background: rgba(0,0,0,.55); border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px; outline: none; }
input:focus { border-color: var(--line-hi); box-shadow: 0 0 0 2px rgba(201,164,92,.2); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.msg { min-height: 18px; margin-top: 10px; color: #ff8a7a; }
.msg.ok { color: var(--green); }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 16px; overflow: auto;
  background: radial-gradient(ellipse at 50% 30%, rgba(80,40,20,.35), transparent 60%), radial-gradient(ellipse at 50% 120%, rgba(160,60,20,.35), transparent 60%), rgba(5,4,8,.55); }
.logo { font: 800 64px/1 var(--font-title); letter-spacing: 3px; color: var(--gold); text-align: center;
  background: linear-gradient(#fff3c8, #e8c87a 45%, #8a5a20); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 #2a1806) drop-shadow(0 0 24px rgba(255,160,60,.35)); }
.logo small { display: block; font: 600 14px var(--font-title); letter-spacing: 6px; margin-top: 10px; text-transform: uppercase; color: var(--dim); -webkit-text-fill-color: var(--dim); }
.logo.small { font-size: 38px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 20px 22px; box-shadow: 0 10px 40px rgba(0,0,0,.6), inset 0 0 0 1px rgba(255,220,150,.05); }
.panel h2 { margin: 0 0 14px; font: 700 18px var(--font-title); color: var(--gold); letter-spacing: 1px; }
.panel.login { width: min(340px, 100%); display: flex; flex-direction: column; gap: 12px; }
.panel.login label { display: flex; flex-direction: column; gap: 5px; color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.panel.wide { width: min(820px, 100%); }
.conn { color: var(--dim); font-size: 12px; }

.char-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; min-height: 120px; }
.char-card { border: 1px solid var(--line); border-radius: 6px; background: rgba(0,0,0,.35); padding: 8px; cursor: pointer; text-align: center; transition: border-color .15s, background .15s; }
.char-card:hover { border-color: var(--line-hi); }
.char-card.sel { border-color: var(--gold); background: rgba(232,200,122,.1); box-shadow: 0 0 16px rgba(232,200,122,.2); }
.char-card canvas { width: 120px; height: 120px; display: block; margin: 0 auto; }
.char-card b { display: block; color: var(--gold); font-size: 14px; }
.char-card span { color: var(--dim); font-size: 12px; }
.empty-note { color: var(--dim); padding: 30px; grid-column: 1/-1; text-align: center; }

.class-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 640px) { .class-pick { grid-template-columns: 1fr; } }
.class-card { border: 1px solid var(--line); border-radius: 6px; padding: 10px; cursor: pointer; background: rgba(0,0,0,.35); text-align: center; }
.class-card.sel { border-color: var(--gold); background: rgba(232,200,122,.1); }
.class-card canvas { width: 140px; height: 140px; }
.class-card b { display: block; color: var(--gold); font: 700 15px var(--font-title); }
.class-card p { margin: 6px 0 0; color: var(--dim); font-size: 12px; }

#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
#topLeft { position: absolute; left: 14px; top: 10px; pointer-events: none; text-shadow: 0 1px 2px #000, 0 0 6px #000; }
#mapName { font: 700 18px var(--font-title); color: var(--gold); letter-spacing: 1px; }
#coords { color: var(--dim); font-size: 12px; }
#miniWrap { position: absolute; right: 12px; top: 10px; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; pointer-events: none; }
#minimap { display: block; width: 220px; height: 120px; }
#sysMsgs { position: absolute; top: 64px; left: 50%; transform: translateX(-50%); width: min(560px, 90vw); text-align: center; pointer-events: none; display: flex; flex-direction: column; gap: 3px; }
#sysMsgs div { color: #ffe27a; font-weight: 600; text-shadow: 0 1px 2px #000, 0 0 8px #000; animation: fade 5s forwards; }
#sysMsgs div.good { color: var(--exc); }
#sysMsgs div.bad { color: #ff7a6a; }
@keyframes fade { 0%,75% { opacity: 1; } 100% { opacity: 0; } }
#buffs { position: absolute; left: 14px; top: 58px; display: flex; gap: 4px; pointer-events: none; }
.buff { width: 30px; height: 30px; border-radius: 4px; border: 1px solid var(--line-hi); display: grid; place-items: center; font: 700 10px var(--font); color: #fff; text-shadow: 0 1px 1px #000; position: relative; }
.buff small { position: absolute; bottom: -14px; font-size: 10px; color: var(--dim); }
#partyPanel { position: absolute; left: 14px; top: 110px; display: flex; flex-direction: column; gap: 5px; width: 170px; }
.pm { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 4px 6px; font-size: 12px; }
.pm b { color: var(--gold); }
.pm .bar { height: 5px; background: #300; margin-top: 3px; border-radius: 2px; overflow: hidden; }
.pm .bar i { display: block; height: 100%; background: linear-gradient(90deg, #c22, #f55); }
.pm .lead { color: var(--gold); }
.pm button { padding: 1px 6px; font-size: 10px; float: right; }

#chat { position: absolute; left: 12px; bottom: 112px; width: min(420px, 60vw); }
#chatLog { pointer-events: none; scrollbar-width: none; max-height: 190px; overflow-y: auto; padding: 4px 6px; font-size: 12.5px; text-shadow: 0 1px 2px #000, 0 0 4px #000; display: flex; flex-direction: column; mask-image: linear-gradient(transparent, #000 25px); }
#chatLog div { word-wrap: break-word; }
#chatLog .n { color: #fff; font-weight: 600; }
#chatLog .party { color: #8af0ff; }
#chatLog .post { color: #ff9ad8; }
#chatLog .sys { color: #ffe27a; }
#chatLog .loot { color: #c8e0a0; }
#chatLog .err { color: #ff7a6a; }
#chatInput { width: 100%; display: none; margin-top: 4px; background: rgba(0,0,0,.75); }
#chatInput.open { display: block; }

#bottom { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); width: min(760px, 100vw); height: 104px; display: flex; align-items: flex-end; justify-content: space-between; padding: 0 6px 16px;
  background: linear-gradient(transparent, rgba(10,8,6,.85) 40%); }
.orb { position: relative; width: 88px; height: 88px; border-radius: 50%; overflow: hidden; border: 3px solid #4a3a20; box-shadow: 0 0 0 1px #c9a45c, 0 4px 16px rgba(0,0,0,.8), inset 0 0 18px rgba(0,0,0,.9); background: #120808; flex: none; }
.orb.mp { background: #080818; }
.orb .fill { position: absolute; left: 0; right: 0; bottom: 0; height: 100%; transition: height .15s; }
.orb.hp .fill { background: radial-gradient(circle at 40% 35%, #ff6a5a, #b81818 55%, #500808); }
.orb.mp .fill { background: radial-gradient(circle at 40% 35%, #7aa0ff, #2040c0 55%, #081050); }
.orb .gloss { position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle at 35% 25%, rgba(255,255,255,.45), transparent 35%); }
.orb span { position: absolute; inset: 0; display: grid; place-items: center; font: 700 12px var(--font); text-shadow: 0 1px 2px #000, 0 0 4px #000; }
#center { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 0 8px; }
#skillBar { display: flex; gap: 4px; }
.sk { position: relative; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 5px; background: var(--slot); cursor: pointer; overflow: hidden; }
.sk canvas { width: 100%; height: 100%; display: block; }
.sk .key { position: absolute; left: 2px; top: 0; font: 700 10px var(--font); color: #fff; text-shadow: 0 1px 1px #000; }
.sk .cd { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.65); }
.sk.sel { border-color: var(--gold); box-shadow: 0 0 10px rgba(232,200,122,.6), inset 0 0 8px rgba(232,200,122,.4); }
.sk.locked { filter: grayscale(1) brightness(.45); }
.sk.locked::after { content: attr(data-lvl); position: absolute; inset: 0; display: grid; place-items: center; font: 700 11px var(--font); color: #ddd; }
#lowRow { display: flex; gap: 10px; align-items: center; }
#potBar { display: flex; gap: 4px; }
.pot { position: relative; width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 4px; background: var(--slot); cursor: pointer; background-size: 80%; background-position: center; background-repeat: no-repeat; }
.pot .key { position: absolute; left: 2px; top: -1px; font: 700 10px var(--font); color: #fff; text-shadow: 0 1px 1px #000; }
.pot .cnt { position: absolute; right: 2px; bottom: 0; font: 700 10px var(--font); color: #fff; text-shadow: 0 1px 1px #000; }
#menuBtns { display: flex; gap: 4px; }
#menuBtns button { width: 30px; height: 30px; padding: 0; font: 700 13px var(--font-title); }
#expBar { position: absolute; left: 6px; right: 6px; bottom: 3px; height: 9px; background: #120f08; border: 1px solid #4a3a20; border-radius: 3px; overflow: hidden; }
#expFill { height: 100%; width: 0; background: linear-gradient(#ffe48a, #c99a2a); transition: width .3s; }
#expSeg { position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), rgba(0,0,0,.6) calc(10% - 1px) 10%); }
#expText { position: absolute; inset: 0; text-align: center; font: 700 8px/9px var(--font); color: #fff; text-shadow: 0 0 2px #000; }

.win { position: absolute; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.7); min-width: 220px; }
.win-h { font: 700 14px var(--font-title); color: var(--gold); padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: move; letter-spacing: 1px; background: linear-gradient(rgba(255,220,150,.08), transparent); }
.win-h .x { float: right; cursor: pointer; color: var(--dim); font-family: var(--font); }
.win-h .x:hover { color: #fff; }
.win-b { padding: 10px 12px; }
.hint { color: var(--dim); font-size: 11px; margin-top: 8px; max-width: 340px; }

#charBody { width: 300px; }
.cw-head { text-align: center; margin-bottom: 8px; }
.cw-head b { font: 700 18px var(--font-title); color: var(--gold); display: block; }
.stat { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-bottom: 1px solid rgba(107,85,50,.35); }
.stat .lbl { width: 92px; color: var(--dim); }
.stat .val { flex: 1; font-weight: 700; }
.stat button { padding: 1px 8px; font-size: 14px; line-height: 18px; }
.derived { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; margin-top: 8px; font-size: 12px; }
.derived span:nth-child(odd) { color: var(--dim); }
.pts { color: var(--exc); font-weight: 700; text-align: center; margin: 6px 0; }

#equipGrid { display: grid; grid-template-columns: repeat(3, 60px); grid-template-rows: 60px 70px 60px; gap: 6px; justify-content: center; margin-bottom: 10px; }
.slot { position: relative; background: var(--slot); border: 1px solid #3e3220; border-radius: 4px; background-size: 82%; background-repeat: no-repeat; background-position: center; }
.slot:hover { border-color: var(--line-hi); }
.slot .ph { position: absolute; inset: 0; display: grid; place-items: center; color: #4e4232; font-size: 10px; text-transform: uppercase; letter-spacing: 1px; pointer-events: none; }
.slot .cnt { position: absolute; right: 2px; bottom: 0; font: 700 10px var(--font); color: #fff; text-shadow: 0 1px 1px #000; }
.slot .lv { position: absolute; left: 2px; top: 0; font: 700 10px var(--font); color: #ffe48a; text-shadow: 0 1px 1px #000; }
.slot.exc { box-shadow: inset 0 0 10px rgba(108,255,134,.45); border-color: #3a7a44; }
.slot.glow7 { box-shadow: inset 0 0 10px rgba(140,190,255,.5); }
.slot.glow9 { box-shadow: inset 0 0 12px rgba(255,210,90,.6); }
.slot.bad { background-color: rgba(120,20,20,.45); }
.slot.picked { opacity: .3; }
#invGrid { display: grid; grid-template-columns: repeat(8, 38px); grid-auto-rows: 38px; gap: 2px; }
.zen { display: flex; justify-content: space-between; margin-top: 8px; padding: 5px 8px; background: rgba(0,0,0,.4); border: 1px solid #3e3220; border-radius: 4px; }
.zen span { color: var(--dim); }
.zen b { color: var(--gold); }

#vaultGrid { display: grid; grid-template-columns: repeat(8, 38px); grid-auto-rows: 38px; gap: 2px; max-height: 330px; overflow-y: auto; padding-right: 4px; }
.vault-zen { margin-top: 6px; }
.vault-zen input { width: 110px; padding: 5px 8px; }
.vault-zen button { padding: 5px 10px; }
.gender-pick { display: flex; gap: 8px; margin-bottom: 12px; }
.gender-pick.small { margin: 8px 0 4px; }
.gender-pick.small button { font-size: 12px; padding: 5px; }
.panel.wide.create { width: min(1180px, 100%); }
.create-layout { display: grid; grid-template-columns: minmax(260px, 400px) 1fr; gap: 18px; align-items: start; }
.create-preview { position: relative; border: 1px solid var(--line); border-radius: 8px; background: radial-gradient(ellipse at 50% 85%, rgba(232,200,122,.18), rgba(0,0,0,.45) 70%); }
.create-preview canvas { display: block; width: 100%; aspect-ratio: 3 / 4; }
#createPreviewName { position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; color: var(--gold); font: 700 18px var(--font-title); text-shadow: 0 2px 4px #000; }
.pick-label { color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; margin: 0 0 6px; }
.create-side .class-pick { margin-bottom: 4px; }
.create-side .class-card canvas { width: 110px; height: 110px; }
@media (max-width: 760px) { .create-layout { grid-template-columns: 1fr; } .create-preview { max-width: 320px; margin: 0 auto; } }
.gender-pick button { flex: 1; background: rgba(255,255,255,.04); color: var(--gold); border-color: var(--line); text-shadow: none; font-size: 14px; padding: 9px; }
.gender-pick button.sel { background: linear-gradient(#f0d48a, #b88a3a); color: #1a1208; border-color: #5a4320; }
#shopGrid { display: grid; grid-template-columns: repeat(5, 60px); gap: 4px; max-height: 392px; overflow-y: auto; padding-right: 4px; }
#shopGrid .slot { height: 60px; }
#shopGrid .price { position: absolute; bottom: 0; left: 0; right: 0; text-align: center; font: 600 9px var(--font); color: var(--gold); background: rgba(0,0,0,.6); }

#warpList { display: flex; flex-direction: column; gap: 4px; width: 300px; }
.warp { display: flex; justify-content: space-between; padding: 7px 10px; border: 1px solid #3e3220; border-radius: 4px; cursor: pointer; background: rgba(0,0,0,.3); }
.warp:hover { border-color: var(--line-hi); }
.warp.no { opacity: .45; cursor: not-allowed; }
.warp b { color: var(--gold); }
.warp span { color: var(--dim); font-size: 12px; }

.help p { margin: 0 0 8px; }
.help code { background: rgba(0,0,0,.5); padding: 1px 4px; border-radius: 3px; color: var(--cyan); }
.c-bless { color: #60b0ff; } .c-soul { color: #ffe040; } .c-life { color: #ff6080; } .c-chaos { color: #c070ff; }

#ctxMenu { position: absolute; background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px; padding: 4px; display: flex; flex-direction: column; min-width: 140px; z-index: 30; }
#ctxMenu .t { color: var(--gold); font-weight: 700; padding: 4px 8px; border-bottom: 1px solid var(--line); margin-bottom: 3px; }
#ctxMenu div.i { padding: 5px 8px; cursor: pointer; border-radius: 3px; }
#ctxMenu div.i:hover { background: rgba(232,200,122,.15); }
#invitePop { position: absolute; top: 120px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line-hi); border-radius: 6px; padding: 14px 18px; z-index: 30; text-align: center; }
#deathOverlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: radial-gradient(transparent 30%, rgba(80,0,0,.55)); pointer-events: none; }
#deathOverlay div { font: 800 48px var(--font-title); color: #ff5a4a; text-shadow: 0 3px 0 #300, 0 0 30px #f00; }
#deathOverlay small { color: #ddd; text-shadow: 0 1px 2px #000; }

#tip { position: fixed; z-index: 100; pointer-events: none; background: rgba(8,6,4,.96); border: 1px solid var(--line); border-radius: 5px; padding: 8px 12px; max-width: 300px; text-align: center; font-size: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.7); }
#tip .nm { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
#tip .nm.exc { color: var(--exc); }
#tip .nm.hi { color: #ffe48a; }
#tip .nm.mid { color: #8ab8ff; }
#tip .ln { color: #e9e1d2; }
#tip .opt { color: #7aa8ff; }
#tip .ex { color: var(--exc); }
#tip .rq { color: #c8c0b0; }
#tip .rq.bad { color: #ff6a5a; }
#tip .pr { color: var(--gold); margin-top: 4px; }
#tip .ds { color: var(--dim); }
#held { position: fixed; z-index: 99; width: 40px; height: 40px; pointer-events: none; background-size: contain; background-repeat: no-repeat; filter: drop-shadow(0 4px 6px rgba(0,0,0,.8)); }

@media (max-width: 700px) {
  #chat { bottom: 120px; width: 70vw; }
  #miniWrap { transform: scale(.7); transform-origin: top right; }
  .orb { width: 70px; height: 70px; }
}
