* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: #000; overflow: hidden; height: 100%; }
body {
  font-family: Georgia, "Palatino Linotype", "Book Antiqua", Palatino, "Times New Roman", serif;
  color: #d8ccb0; user-select: none; -webkit-user-select: none;
}
canvas#game { position: fixed; inset: 0; 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='%23d9b060' stroke='%23201008' stroke-width='1.5'/></svg>") 2 2, default; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud button, #hud .belt, #hud .skill { pointer-events: auto; }
#bottombar { position: absolute; left: 0; right: 0; bottom: 0; height: 132px; display: flex; align-items: flex-end; justify-content: center; gap: 14px; padding: 0 12px 10px; }
.orb { position: relative; width: 120px; height: 120px; border-radius: 50%; background: #0a0706; border: 3px solid #5a4630; box-shadow: 0 0 0 2px #1a120a, 0 0 18px rgba(0,0,0,0.9), inset 0 0 20px rgba(0,0,0,0.9); overflow: hidden; pointer-events: auto; }
.orbfill { position: absolute; left: 0; right: 0; bottom: 0; height: 100%; transition: height 0.12s linear; }
#lifefill { background: radial-gradient(circle at 40% 30%, #ff6a5a 0%, #b01818 45%, #500808 100%); }
#manafill { background: radial-gradient(circle at 40% 30%, #6a9aff 0%, #2040b0 45%, #0a1450 100%); }
.orbshine { position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle at 35% 25%, rgba(255,255,255,0.35) 0%, rgba(255,255,255,0) 35%); }
.orbtext { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); text-align: center; font-size: 13px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px #000, 0 0 4px #000; opacity: 0.9; }
#centerbar { display: flex; flex-direction: column; align-items: center; gap: 6px; padding-bottom: 4px; }
#xpbar { position: relative; width: 560px; height: 9px; background: #120d08; border: 1px solid #4a3a26; }
#xpfill { height: 100%; background: linear-gradient(#e0b050, #8a6420); width: 0; }
#xptext { position: absolute; inset: -4px 0 0 0; text-align: center; font-size: 10px; color: #f0e0b0; text-shadow: 0 1px 2px #000; opacity: 0; transition: opacity 0.2s; }
#xpbar:hover #xptext { opacity: 1; }
#xpbar { pointer-events: auto; }
#slots { display: flex; gap: 6px; align-items: flex-end; padding: 6px 8px; background: linear-gradient(#1c1510, #0e0a07); border: 2px solid #4a3a26; box-shadow: 0 0 12px rgba(0,0,0,0.8); }
#skillslots { display: flex; gap: 6px; margin: 0 8px; }
.skill, .belt { position: relative; width: 50px; height: 50px; background: #0a0806; border: 2px solid #5a4630; cursor: pointer; }
.skill canvas, .belt canvas { width: 100%; height: 100%; display: block; }
.skill .key, .belt .key { position: absolute; left: 2px; top: 0; font-size: 11px; color: #f0e0b0; text-shadow: 0 1px 2px #000, 0 0 3px #000; font-weight: 700; }
.belt .count { position: absolute; right: 3px; bottom: 1px; font-size: 13px; color: #fff; text-shadow: 0 1px 2px #000, 0 0 3px #000; font-weight: 700; }
.skill .cd { position: absolute; inset: 0; background: rgba(0,0,0,0.7); transform-origin: bottom; }
.skill .cdtext { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 15px; color: #fff; font-weight: 700; text-shadow: 0 1px 3px #000; }
.skill.locked canvas { filter: grayscale(1) brightness(0.35); }
.skill.nomana canvas { filter: saturate(0.3) brightness(0.55) hue-rotate(180deg); }
.skill.right { border-color: #d9b060; box-shadow: 0 0 8px rgba(217,176,96,0.6); }
.skill.right::after { content: 'RMB'; position: absolute; right: 2px; top: 1px; font-size: 8px; color: #d9b060; font-weight: 700; text-shadow: 0 1px 2px #000; }
.skill:hover, .belt:hover { border-color: #b09060; }
#menubtns { display: flex; gap: 4px; }
#menubtns button { position: relative; background: linear-gradient(#2a2016, #16100a); color: #c8b890; border: 1px solid #5a4630; padding: 3px 10px; font-size: 12px; }
#menubtns button:hover { color: #fff; border-color: #a08050; }
.badge { position: absolute; top: -8px; right: -6px; background: #c83020; color: #fff; font-size: 10px; border-radius: 8px; padding: 0 5px; line-height: 15px; font-weight: 700; box-shadow: 0 0 6px rgba(255,80,40,0.7); }
.badge:empty { display: none; }

#topbar { position: absolute; top: 10px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
#targetbox, #bossbox { text-align: center; }
#targetname { font-size: 15px; font-weight: 700; color: #e8dcc0; text-shadow: 0 1px 3px #000; }
#targetmods { font-size: 11px; color: #9fb8ff; text-shadow: 0 1px 2px #000; }
.bar { width: 280px; height: 10px; background: rgba(10,6,4,0.85); border: 1px solid #5a4630; margin: 3px auto 0; position: relative; }
.bar > div { height: 100%; background: linear-gradient(#e03a2a, #8a1810); width: 100%; }
.bar.boss { width: 520px; height: 16px; border-color: #7a9aa8; }
.bar.boss > div { background: linear-gradient(#a8e8ff, #3a7a98); }
.bar.boss.molten > div { background: linear-gradient(#ffb060, #b03010); }
.bar .pip { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(0,0,0,0.8); }
#bossname { font-size: 20px; color: #cff6ff; text-shadow: 0 0 10px rgba(120,220,255,0.6), 0 2px 3px #000; letter-spacing: 1px; }

#minibox { position: absolute; top: 10px; right: 10px; text-align: center; }
#minimap { width: 200px; height: 140px; border: 2px solid #4a3a26; background: #000; display: block; box-shadow: 0 0 10px rgba(0,0,0,0.8); }
#areaname { margin-top: 3px; font-size: 13px; color: #d8c8a0; text-shadow: 0 1px 3px #000; }
#buffs { position: absolute; top: 12px; left: 12px; display: flex; gap: 6px; }
.buff { padding: 3px 8px; font-size: 12px; background: rgba(10,8,6,0.8); border: 1px solid #5a4630; color: #e8dcc0; }
#log { position: absolute; left: 14px; bottom: 150px; width: 440px; display: flex; flex-direction: column; gap: 2px; font-size: 13px; text-shadow: 0 1px 2px #000, 0 0 4px #000; }
#log div { transition: opacity 1s; }

/* ---------- Panels ---------- */
.panel { position: fixed; top: 60px; width: 340px; max-height: calc(100vh - 210px); overflow-y: auto; background: linear-gradient(#1e1610, #0f0b08); border: 2px solid #5a4630; box-shadow: 0 0 0 1px #0a0604, 0 0 30px rgba(0,0,0,0.9); padding: 14px 16px; font-size: 13px; pointer-events: auto; }
.panel.left { left: 16px; }
.panel.right { right: 16px; top: 190px; max-height: calc(100vh - 330px); }
.panel.center { left: 50%; transform: translateX(-50%); width: 520px; }
.panel.dialog { left: 50%; top: 30%; transform: translateX(-50%); width: 460px; text-align: center; }
.panel h3 { margin: 0 0 8px; font-size: 18px; color: #e8c880; text-align: center; letter-spacing: 1px; font-weight: 600; border-bottom: 1px solid #3a2e20; padding-bottom: 6px; }
.panel .close { position: absolute; right: 8px; top: 6px; background: none; border: none; color: #a08a60; font-size: 18px; }
.panel .close:hover { color: #fff; }
.row { display: flex; justify-content: space-between; align-items: center; padding: 2px 0; }
.row .v { color: #f0e6d0; font-weight: 600; }
.statrow { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid #241a12; }
.statrow .n { flex: 1; }
.statrow .v { width: 36px; text-align: right; font-weight: 700; color: #fff; }
.plus { width: 22px; height: 22px; line-height: 18px; padding: 0; border: 1px solid #a08050; background: linear-gradient(#5a4020, #2a1c0c); color: #ffd76a; font-weight: 700; font-size: 16px; }
.plus:disabled { opacity: 0.2; cursor: default; }
.pts { text-align: center; color: #ffd76a; margin: 6px 0; font-weight: 700; }
.sub { color: #a09070; font-size: 12px; }
.sect { margin-top: 10px; color: #c8a870; font-size: 12px; letter-spacing: 1px; text-transform: uppercase; border-bottom: 1px solid #3a2e20; padding-bottom: 2px; margin-bottom: 4px; }

/* inventory */
#doll { position: relative; width: 300px; height: 250px; margin: 0 auto 10px; }
.eq { position: absolute; background: rgba(0,0,0,0.5); border: 1px solid #4a3a26; display: flex; align-items: center; justify-content: center; }
.eq .ph { color: #4a3e30; font-size: 10px; text-transform: uppercase; letter-spacing: 1px; }
.eq canvas { width: 100%; height: 100%; }
.eq.ok { border-color: #5a8a4a; box-shadow: inset 0 0 10px rgba(80,160,60,0.4); }
.eq.bad { border-color: #8a3a2a; }
#grid { position: relative; width: 302px; height: 152px; margin: 0 auto; background-color: rgba(0,0,0,0.5); background-image: linear-gradient(#3a2e20 1px, transparent 1px), linear-gradient(90deg, #3a2e20 1px, transparent 1px); background-size: 30px 30px; border: 1px solid #4a3a26; }
.gi { position: absolute; }
.gi canvas { width: 100%; height: 100%; display: block; }
.gi.magic, .eq.magic { background: rgba(60,70,160,0.25); }
.gi.rare, .eq.rare { background: rgba(160,140,40,0.2); }
.gi.unique, .eq.unique { background: rgba(170,100,30,0.25); }
.gold { color: #ffd76a; }
.goldrow { text-align: center; margin-top: 8px; font-size: 15px; }

/* vendor */
.vlist { display: flex; flex-direction: column; gap: 4px; }
.vitem { display: flex; align-items: center; gap: 8px; padding: 4px; border: 1px solid #2a2016; background: rgba(0,0,0,0.3); cursor: pointer; }
.vitem:hover { border-color: #a08050; background: rgba(60,40,20,0.4); }
.vitem canvas { width: 30px; height: 30px; flex: none; object-fit: contain; }
.vitem .nm { flex: 1; font-size: 13px; }
.vitem .pr { color: #ffd76a; font-weight: 700; }
.vitem.cant .pr { color: #a04030; }
.pbtn { display: block; width: 100%; margin-top: 8px; background: linear-gradient(#3a2a16, #1a120a); color: #e8d8b0; border: 1px solid #6a5236; padding: 6px; font-size: 13px; }
.pbtn:hover { border-color: #c0a070; color: #fff; }

/* skills */
.srow { display: flex; gap: 10px; align-items: flex-start; padding: 8px 4px; border-bottom: 1px solid #2a2016; }
.srow canvas { width: 48px; height: 48px; flex: none; border: 1px solid #5a4630; }
.srow .info { flex: 1; }
.srow .nm { font-size: 15px; font-weight: 700; }
.srow .meta { font-size: 11px; color: #a09070; margin: 2px 0; }
.srow .d { font-size: 12px; color: #d0c4a8; line-height: 1.35; }
.srow.locked { opacity: 0.55; }
.srow .rk { font-size: 13px; color: #ffd76a; text-align: center; min-width: 40px; }

/* tooltip */
#tooltip { position: fixed; z-index: 50; pointer-events: none; display: flex; gap: 8px; align-items: flex-start; }
.tt { background: rgba(8,6,4,0.95); border: 1px solid #6a5236; padding: 8px 12px; min-width: 200px; max-width: 290px; font-size: 13px; text-align: center; box-shadow: 0 0 16px rgba(0,0,0,0.9); }
.tt .nm { font-size: 15px; font-weight: 700; }
.tt .bn { color: #c8bca0; font-size: 12px; }
.tt .ln { color: #e8e0d0; }
.tt .mod { color: #8fa6ff; }
.tt .dim { color: #908470; font-size: 11px; }
.tt .up { color: #6ce06c; }
.tt .down { color: #ff6a5a; }
.tt .hd { font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: #908470; margin-bottom: 4px; }
.tt .price { color: #ffd76a; margin-top: 4px; }
.tt .cmp { margin-top: 6px; border-top: 1px solid #3a2e20; padding-top: 4px; text-align: left; font-size: 12px; }
#held { position: fixed; z-index: 60; pointer-events: none; opacity: 0.92; }
#held canvas { width: 100%; height: 100%; }

/* ---------- Screens ---------- */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 40; }
.screen.dim { background: rgba(0,0,0,0.6); }
#title { background: #000; }
#titlebg { position: absolute; inset: 0; width: 100%; height: 100%; }
.titlewrap { position: relative; text-align: center; max-width: 720px; padding: 20px; }
.kicker { font-size: 14px; letter-spacing: 6px; text-transform: uppercase; color: #a08a60; }
#title h1 { font-size: 92px; margin: 6px 0 14px; letter-spacing: 12px; font-weight: 400; color: #f0dcae; text-shadow: 0 0 30px rgba(255,140,50,0.55), 0 0 2px #fff, 0 4px 8px #000; }
.lore { font-style: italic; color: #b0a080; line-height: 1.6; font-size: 16px; min-height: 80px; }
.btns { margin-top: 26px; display: flex; gap: 14px; justify-content: center; align-items: center; flex-wrap: wrap; }
.btns.col { flex-direction: column; }
button.big { min-width: 220px; padding: 12px 26px; font-size: 19px; letter-spacing: 2px; color: #f0dcae; background: linear-gradient(#4a3018, #1e130a); border: 2px solid #8a6a3a; box-shadow: 0 0 20px rgba(0,0,0,0.8), inset 0 0 12px rgba(255,160,60,0.12); }
button.big:hover { color: #fff; border-color: #d9b060; box-shadow: 0 0 22px rgba(255,150,50,0.35); }
button.small { min-width: 180px; padding: 8px 18px; font-size: 14px; color: #c8b890; background: linear-gradient(#2a2016, #140e08); border: 1px solid #5a4630; }
button.small:hover { color: #fff; border-color: #a08050; }
.foot { margin-top: 30px; color: #6a5a40; font-size: 13px; }
.card { background: linear-gradient(#1e1610, #0c0806); border: 2px solid #6a5236; padding: 28px 36px; text-align: center; max-width: 520px; box-shadow: 0 0 60px rgba(0,0,0,0.9); }
.card.wide { max-width: 720px; }
.card h2 { font-size: 36px; margin: 6px 0 12px; font-weight: 400; letter-spacing: 3px; }
h2.red { color: #e04a3a; text-shadow: 0 0 20px rgba(200,40,20,0.6); }
h2.gold { color: #f2d06b; text-shadow: 0 0 20px rgba(240,180,60,0.5); }
.card p { line-height: 1.55; color: #c8b890; }
.card .dim { color: #8a7a60; font-size: 13px; }
#death { background: radial-gradient(ellipse at center, rgba(60,0,0,0.3), rgba(0,0,0,0.85)); }
#victory { background: radial-gradient(ellipse at center, rgba(40,30,10,0.4), rgba(0,0,0,0.88)); }
#victorystats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 24px; margin: 16px auto; max-width: 440px; text-align: left; font-size: 15px; }
#victorystats b { color: #f0e0b0; float: right; }
.helpgrid { display: grid; grid-template-columns: 200px 1fr; gap: 6px 16px; text-align: left; font-size: 14px; margin: 10px 0 14px; }
.helpgrid b { color: #f0dcae; }
