:root {
  --gold: #e8c060;
  --gold-d: #9a7428;
  --ink: #f2e8d0;
  --dim: #a89c84;
  --panel: rgba(22, 18, 12, .94);
  --panel2: #2a2218;
  --edge: #6b5430;
  --green: #1eff00;
  --red: #ff4a3a;
  --hp: #2fbf3a;
  --mana: #2f7dff;
  --rage: #d4382c;
  --energy: #f2d03a;
  --serif: Cinzel, Georgia, 'Times New Roman', serif;
  --sans: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0e0c08; color: var(--ink); font: 14px/1.4 var(--sans); overscroll-behavior: none; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
canvas { display: block; }
.y { color: #ffd23a; } .g { color: #3aff3a; } .r { color: #ff5a4a; } .dim { color: var(--dim); } .small { font-size: 12px; }

#loading { position: fixed; inset: 0; display: grid; place-items: center; font: 700 22px var(--serif); color: var(--gold); }
#world { position: fixed; inset: 0; touch-action: none; }

/* ---------- money ---------- */
.money { display: inline-flex; gap: 6px; align-items: center; font-weight: 700; white-space: nowrap; }
.coin { display: inline-flex; align-items: center; gap: 3px; }
.coin::after { content: ''; width: 11px; height: 11px; border-radius: 50%; box-shadow: inset -2px -2px 0 rgba(0,0,0,.3), 0 0 0 1px rgba(0,0,0,.4); }
.coin.g::after { background: radial-gradient(circle at 35% 35%, #fff3a0, #e0a800 60%, #8a6000); }
.coin.s::after { background: radial-gradient(circle at 35% 35%, #fff, #c8ccd4 60%, #6a7078); }
.coin.c::after { background: radial-gradient(circle at 35% 35%, #ffc8a0, #c0702a 60%, #6a3410); }

/* ---------- buttons ---------- */
.btn { background: linear-gradient(#5a4428, #3a2a16); border: 1px solid #8a6a3a; border-radius: 8px; padding: 8px 14px; font-weight: 600; color: var(--ink); box-shadow: inset 0 1px 0 rgba(255,255,255,.15), 0 2px 4px rgba(0,0,0,.4); transition: transform .08s, filter .15s; }
.btn:hover:not(:disabled) { filter: brightness(1.2); }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.98); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: linear-gradient(#c0302a, #7a1410); border-color: #ff8a5a; font-family: var(--serif); letter-spacing: .5px; }
.btn.gold { background: linear-gradient(#a8801c, #6a4a08); border-color: #ffd86a; }
.btn.danger { background: linear-gradient(#4a2a2a, #2a1414); border-color: #8a4a4a; }
.btn.big { width: 100%; padding: 12px 16px; font-size: 16px; margin: 6px 0; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btnrow { display: flex; gap: 8px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.sh { font: 700 13px var(--serif); color: var(--gold); margin: 12px 0 6px; letter-spacing: .5px; }
.hint { color: var(--dim); font-size: 12px; text-align: center; margin: 10px 0 0; }

/* ---------- bars ---------- */
.bar { position: relative; height: 16px; background: rgba(0,0,0,.65); border: 1px solid rgba(0,0,0,.8); border-radius: 4px; overflow: hidden; box-shadow: inset 0 1px 3px rgba(0,0,0,.6); }
.bar .fill { position: absolute; inset: 0 auto 0 0; width: 100%; transition: width .3s ease-out; z-index: 2; }
.bar .ghost { position: absolute; inset: 0 auto 0 0; width: 100%; background: #fff4b0; transition: width .5s ease-in; z-index: 1; }
.bar span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 10.5px; font-weight: 700; text-shadow: 0 1px 2px #000, 0 0 2px #000; z-index: 3; }
.bar.hp .fill { background: linear-gradient(#5ae85a, #1a9a24 60%, #127a1a); }
.bar.res .fill, .bar.mana .fill { background: linear-gradient(#6aa8ff, #2a6adf 60%, #1a4aaf); }
.bar.rage .fill { background: linear-gradient(#ff6a5a, #c0281e 60%, #8a1810); }
.bar.energy .fill { background: linear-gradient(#fff07a, #e0bc1a 60%, #a8880a); }
.bar.xp .fill { background: linear-gradient(#c88aff, #8a3ad0 60%, #5a1a9a); }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
.pframe { position: absolute; left: max(8px, env(safe-area-inset-left)); top: max(8px, env(safe-area-inset-top)); display: flex; align-items: center; gap: 6px; padding: 5px 10px 5px 5px; background: linear-gradient(rgba(30,24,16,.9), rgba(18,14,10,.9)); border: 1px solid var(--edge); border-radius: 40px 10px 10px 40px; box-shadow: 0 3px 10px rgba(0,0,0,.5); }
.portrait { width: 52px; height: 52px; border-radius: 50%; border: 2px solid var(--gold); box-shadow: 0 0 0 2px #1a140a, 0 0 12px rgba(232,192,96,.3); }
.lvlbadge { position: absolute; left: 40px; top: 42px; min-width: 22px; height: 22px; padding: 0 4px; border-radius: 11px; background: radial-gradient(#5a4428, #2a1e10); border: 2px solid var(--gold); display: grid; place-items: center; font: 700 11px var(--sans); color: #ffe7a0; }
.pf-bars { width: 150px; display: grid; gap: 3px; }
.pf-name { font: 700 13px var(--serif); color: #ffe7a0; text-shadow: 0 1px 2px #000; }
.pf-bars .bar { height: 14px; }
.topright { position: absolute; right: max(8px, env(safe-area-inset-right)); top: max(8px, env(safe-area-inset-top)); display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.mm-wrap { position: relative; border: 2px solid var(--edge); border-radius: 10px; overflow: hidden; box-shadow: 0 3px 10px rgba(0,0,0,.5); cursor: pointer; background: #000; }
.minimap { width: 180px; height: 135px; transition: width .25s, height .25s; }
.mm-wrap.big .minimap { width: min(420px, 92vw); height: min(315px, 69vw); }
.mm-zone { position: absolute; left: 0; right: 0; top: 0; text-align: center; font: 700 11px var(--serif); color: #ffe7a0; background: linear-gradient(rgba(0,0,0,.75), rgba(0,0,0,0)); padding: 3px 0 8px; text-shadow: 0 1px 2px #000; }
.purse { background: rgba(18,14,10,.85); border: 1px solid var(--edge); border-radius: 8px; padding: 4px 10px; font-size: 13px; }
.tracker { position: absolute; right: max(8px, env(safe-area-inset-right)); top: 190px; width: 210px; display: grid; gap: 6px; pointer-events: none !important; }
.tq { background: linear-gradient(90deg, rgba(0,0,0,0), rgba(0,0,0,.55) 25%); padding: 4px 8px; text-align: right; border-radius: 6px; text-shadow: 0 1px 2px #000; }
.tq-t { font: 700 12.5px var(--serif); color: #ffd23a; }
.tq-o { font-size: 11.5px; color: #ddd; }
.tq-o.ok { color: #7aff7a; }
.tq.done .tq-t::after { content: ' ✓'; color: #7aff7a; }
.bottombar { position: absolute; left: 0; right: 0; bottom: 0; padding-bottom: env(safe-area-inset-bottom); display: flex; flex-direction: column; align-items: center; gap: 4px; background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.6)); }
.menubar { display: flex; gap: 6px; padding: 0 6px; }
.mbtn { position: relative; width: 54px; height: 54px; padding: 0; border: 2px solid #5a4428; border-radius: 10px; background: #111; overflow: visible; box-shadow: 0 3px 8px rgba(0,0,0,.6); transition: transform .1s, border-color .15s; }
.mbtn img { width: 100%; height: 100%; border-radius: 8px; display: block; }
.mbtn:hover { border-color: var(--gold); transform: translateY(-2px); }
.mbtn .lbl { position: absolute; left: 0; right: 0; bottom: 1px; font-size: 9px; font-weight: 700; text-shadow: 0 1px 2px #000, 0 0 3px #000; }
.mbtn .badge { position: absolute; top: -7px; right: -7px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: #d42a1a; color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; box-shadow: 0 0 0 2px #1a0a0a; animation: pulse 1.2s infinite; }
.mbtn .badge.dim { background: rgba(0,0,0,.8); animation: none; font-size: 9px; top: auto; bottom: -6px; right: 50%; transform: translateX(50%); height: 15px; box-shadow: none; }
.mbtn .badge.full { background: #a82a1a; animation: none; font-size: 9px; top: auto; bottom: -6px; right: 50%; transform: translateX(50%); height: 15px; }
@keyframes pulse { 50% { transform: scale(1.15); box-shadow: 0 0 0 2px #1a0a0a, 0 0 12px #ff4a2a; } }
.xpbar { width: min(560px, calc(100vw - 16px)); height: 13px; margin-bottom: 6px; }
.xpbar .fill { background: linear-gradient(#c88aff, #8a3ad0 60%, #5a1a9a); }
.xpbar span { font-size: 9.5px; }

/* ---------- panels ---------- */
#panels { position: fixed; inset: 0 0 calc(76px + env(safe-area-inset-bottom)) 0; display: none; align-items: center; justify-content: center; padding: 10px; background: rgba(0,0,0,.35); z-index: 20; }
#panels.open { display: flex; }
.panel { width: min(720px, 100%); max-height: calc(100% - 10px); display: flex; flex-direction: column; background: var(--panel); border: 2px solid var(--edge); border-radius: 14px; box-shadow: 0 0 0 1px #000, 0 20px 50px rgba(0,0,0,.7), inset 0 0 40px rgba(232,192,96,.06); animation: pop .22s ease-out; }
.panel.narrow { width: min(460px, 100%); }
.panel.wide { width: min(560px, 100%); }
@keyframes pop { from { transform: scale(.92); opacity: 0; } }
.p-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 8px 16px; border-bottom: 1px solid rgba(232,192,96,.25); background: linear-gradient(rgba(232,192,96,.12), rgba(0,0,0,0)); border-radius: 12px 12px 0 0; }
.p-head h2 { margin: 0; font: 700 18px var(--serif); color: var(--gold); text-shadow: 0 2px 4px #000; }
.p-head h2 small { font-size: 12px; color: var(--dim); margin-left: 6px; font-family: var(--sans); font-weight: 500; }
.x { width: 34px; height: 34px; border-radius: 8px; border: 1px solid #6a4a2a; background: #2a1a10; font-size: 16px; }
.p-body { padding: 12px 14px 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.npc-say { font-style: italic; color: #e8dcc0; background: rgba(232,192,96,.07); border-left: 3px solid var(--gold-d); padding: 8px 10px; border-radius: 6px; margin-bottom: 10px; }

/* slots */
.slot { position: relative; width: 48px; height: 48px; border-radius: 8px; border: 2px solid #3a3020; background: rgba(0,0,0,.55); overflow: hidden; cursor: pointer; flex: none; }
.slot img { width: 100%; height: 100%; display: block; }
.slot.empty { cursor: default; box-shadow: inset 0 0 10px rgba(0,0,0,.8); }
.slot .sl { position: absolute; inset: 0; display: grid; place-items: center; font-size: 8.5px; color: #6a5a40; text-align: center; line-height: 1.1; padding: 2px; }
.slot .cnt { position: absolute; right: 3px; bottom: 1px; font-size: 12px; text-shadow: 0 0 3px #000, 0 1px 1px #000; }
.slot.q0 { border-color: #6a6a6a; } .slot.q1 { border-color: #c8c8c8; } .slot.q2 { border-color: #1eff00; box-shadow: 0 0 8px rgba(30,255,0,.35); } .slot.q3 { border-color: #3a8bff; box-shadow: 0 0 10px rgba(58,139,255,.5); } .slot.q4 { border-color: #b552ff; box-shadow: 0 0 12px rgba(181,82,255,.6); }
.slot.unusable img { filter: sepia(1) hue-rotate(-40deg) saturate(3) brightness(.7); }
.slot.upgrade::after { content: '▲'; position: absolute; left: 3px; top: 1px; font-size: 11px; color: #3aff3a; text-shadow: 0 0 3px #000; }
.slot.junk img { filter: grayscale(.4) brightness(.85); }
.slot:not(.empty):hover { filter: brightness(1.25); }
.baggrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 6px; justify-items: center; }
.bagfoot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; padding: 6px 8px; background: rgba(0,0,0,.35); border-radius: 8px; font-size: 13px; color: var(--dim); }

/* tooltips */
.tt { font-size: 13px; line-height: 1.45; min-width: 190px; max-width: 280px; }
.tt-name { font-weight: 700; font-size: 14.5px; }
.tt-row { display: flex; justify-content: space-between; gap: 14px; }
.tt-cmp { margin-top: 8px; padding-top: 6px; border-top: 1px solid rgba(255,255,255,.12); font-size: 12px; }
.tt-cmp-h { color: #c8c8d8; font-weight: 600; margin-bottom: 2px; }
.cmp-row { display: flex; justify-content: space-between; gap: 12px; }
.cmp-row b { font-variant-numeric: tabular-nums; }
.tt-pair { display: flex; gap: 10px; align-items: flex-start; }
.tt-cur { padding-left: 10px; border-left: 1px solid rgba(255,255,255,.12); opacity: .92; }
.tt-cur .tt { font-size: 12px; }
.tt-eq { display: inline-block; font: 700 10px var(--sans); letter-spacing: 1px; text-transform: uppercase; color: #b8b8c8; background: rgba(255,255,255,.08); border-radius: 4px; padding: 1px 6px; margin: 0 0 4px; }
.tt-cur .tt + .tt-eq { margin-top: 8px; }
@media (max-width: 600px) {
  .tt-pair { flex-direction: column; gap: 8px; }
  .tt-cur { padding: 8px 0 0; border-left: 0; border-top: 1px dashed rgba(255,255,255,.18); width: 100%; }
}
.popover { max-height: calc(100vh - 12px); overflow-y: auto; }
.tt-price { margin-top: 6px; color: #ddd; font-size: 12px; }
.hovertip, .popover { position: fixed; z-index: 75; background: linear-gradient(#141826f2, #0a0c14f2); border: 1px solid #5a6a8a; border-radius: 8px; padding: 10px 12px; box-shadow: 0 8px 24px rgba(0,0,0,.7); }
.hovertip { pointer-events: none; }
.pop-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.pop-actions .btn { flex: 1; padding: 7px 10px; font-size: 13px; }

/* character */
.char-sub { text-align: center; color: var(--dim); margin: -4px 0 8px; }
.doll { display: flex; justify-content: center; gap: 8px; }
.dcol { display: grid; gap: 6px; align-content: start; }
.dmid { flex: 1; max-width: 220px; display: flex; flex-direction: column; align-items: center; }
.dollcv { width: 100%; max-width: 200px; aspect-ratio: 300/360; height: auto; }
.dweap { display: flex; gap: 8px; margin-top: 4px; }
.statsbox { margin-top: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 3px 16px; background: rgba(0,0,0,.3); padding: 10px 12px; border-radius: 10px; }
.srow { display: flex; justify-content: space-between; font-size: 13px; border-bottom: 1px dotted rgba(255,255,255,.07); }
.srow b { color: #fff; }

/* abilities */
.abrow { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; background: rgba(0,0,0,.28); margin-bottom: 6px; }
.abrow.locked { opacity: .7; }
.abrow.locked .abi { filter: grayscale(.8); }
.abi { width: 44px; height: 44px; border-radius: 8px; border: 2px solid #5a4428; flex: none; }
.ab-info { flex: 1; min-width: 0; }
.ab-name { font-weight: 700; color: #ffe7a0; }
.ab-meta { font-size: 11px; color: var(--dim); }
.ab-desc { font-size: 12.5px; color: #ddd; }
.ab-train { text-align: center; flex: none; min-width: 70px; display: grid; gap: 4px; justify-items: center; font-size: 12px; }
.ab-train .price { font-size: 12px; }

/* talents */
.tal-head { display: flex; justify-content: space-between; padding: 6px 10px; background: rgba(0,0,0,.3); border-radius: 8px; margin-bottom: 10px; }
.tree { display: grid; gap: 14px; padding: 10px 0; background: radial-gradient(ellipse at center, rgba(232,192,96,.08), rgba(0,0,0,0) 70%); }
.trow { display: flex; justify-content: center; gap: 20px; }
.tnode { position: relative; width: 74px; display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.tnode img { width: 52px; height: 52px; border-radius: 10px; border: 2px solid #4a4a4a; filter: grayscale(1) brightness(.6); transition: .2s; }
.tnode.can img { filter: none; border-color: #3aff3a; box-shadow: 0 0 10px rgba(58,255,58,.45); }
.tnode.has img { filter: none; border-color: #ffd23a; box-shadow: 0 0 10px rgba(255,210,58,.5); }
.tnode.maxed img { border-color: #ffd23a; box-shadow: 0 0 14px rgba(255,210,58,.8); }
.tnode .tr { position: absolute; top: 38px; right: 6px; background: #111; border: 1px solid #555; border-radius: 6px; font-size: 10px; padding: 0 4px; }
.tnode.has .tr { color: #ffd23a; border-color: #ffd23a; } .tnode.can .tr { color: #3aff3a; }
.tnode .tn { font-size: 10.5px; text-align: center; line-height: 1.15; margin-top: 4px; color: #ddd; }

/* quests */
.qcard { background: rgba(0,0,0,.28); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.qcard.done { border: 1px solid rgba(255,210,58,.5); }
.qcard h3, .p-body h3 { margin: 0 0 6px; font: 700 15px var(--serif); color: #ffd23a; }
.qtext { color: #e8dcc0; margin: 0 0 8px; }
.qobj div { font-size: 13px; } .qobj .ok { color: #7aff7a; }
.qrew { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.qlist { display: grid; gap: 6px; }
.qbtn { text-align: left; padding: 10px 12px; border-radius: 8px; border: 1px solid #5a4428; background: rgba(0,0,0,.35); font-weight: 600; color: #ffe7a0; }
.qbtn b { font: 900 18px var(--serif); margin-right: 6px; }
.qbtn:hover { background: rgba(232,192,96,.12); }
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.choice { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; border-radius: 10px; border: 2px solid transparent; background: rgba(0,0,0,.3); cursor: pointer; text-align: center; }
.choice.sel { border-color: #ffd23a; background: rgba(255,210,58,.1); }
.cname { font-size: 11.5px; line-height: 1.2; }

/* vendor */
.vlist { display: grid; gap: 6px; }
.vrow { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 8px; background: rgba(0,0,0,.28); }
.vinfo { flex: 1; font-size: 13px; }

/* help */
.help p { margin: 0 0 10px; }

/* ---------- toasts / banner ---------- */
#toasts { position: fixed; left: 50%; top: max(80px, calc(env(safe-area-inset-top) + 70px)); transform: translateX(-50%); display: grid; gap: 6px; justify-items: center; z-index: 70; pointer-events: none; width: min(92vw, 440px); }
.toast { background: rgba(14,10,6,.92); border: 1px solid var(--edge); border-radius: 10px; padding: 7px 14px; font-size: 13px; text-align: center; box-shadow: 0 4px 14px rgba(0,0,0,.5); animation: tin .3s ease-out; transition: opacity .5s, transform .5s; }
.toast.good { border-color: #ffd23a; color: #fff3c8; }
.toast.quest { border-color: #ffd23a; color: #ffd23a; font-weight: 600; }
.toast.err { border-color: #ff4a3a; color: #ffb0a8; }
.toast.out { opacity: 0; transform: translateY(-10px); }
@keyframes tin { from { opacity: 0; transform: translateY(10px) scale(.95); } }
.banner { position: fixed; left: 0; right: 0; top: 30%; text-align: center; padding: 18px 0; background: radial-gradient(ellipse at center, rgba(0,0,0,.5), rgba(0,0,0,0) 65%); z-index: 65; pointer-events: none; opacity: 0; transform: scale(.8); transition: opacity .4s, transform .5s cubic-bezier(.2, 1.6, .4, 1); }
.banner.show { opacity: 1; transform: scale(1); }
.b-title { font: 900 clamp(30px, 9vw, 56px) var(--serif); color: #ffd23a; text-shadow: 0 0 20px rgba(255,180,40,.8), 0 4px 0 #6a3a00, 0 6px 12px #000; letter-spacing: 1px; }
.b-sub { font: 600 clamp(14px, 4vw, 18px) var(--serif); color: #fff3c8; text-shadow: 0 2px 6px #000; margin-top: 4px; }
.banner.zone { top: 22%; z-index: 15; }
.banner.zone .b-title { font-size: clamp(26px, 7vw, 42px); color: #fff3c8; text-shadow: 0 0 14px rgba(0,0,0,.8), 0 3px 6px #000; }
.banner.zone .b-sub { color: #e8c060; }
.banner.level .b-title { font-size: clamp(40px, 12vw, 72px); animation: shine 1.2s ease-in-out infinite alternate; }
@keyframes shine { to { text-shadow: 0 0 40px rgba(255,220,100,1), 0 4px 0 #6a3a00, 0 6px 12px #000; } }
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 66; overflow: hidden; }
.spark { position: absolute; width: 7px; height: 7px; border-radius: 2px; animation: sparkfly 1.4s cubic-bezier(.2, .8, .4, 1) forwards; box-shadow: 0 0 8px currentColor; }
@keyframes sparkfly { to { transform: translate(var(--dx), var(--dy)) rotate(540deg); opacity: 0; } }
#swipe { position: fixed; inset: 0; z-index: 40; pointer-events: none; opacity: 0; background: radial-gradient(circle, rgba(255,255,255,0) 20%, rgba(255,240,200,.9) 70%); }
#swipe.go { animation: swipe .55s ease-out; }
@keyframes swipe { 0% { opacity: 0; transform: scale(1.6); } 40% { opacity: 1; transform: scale(1); } 100% { opacity: 0; } }

/* ---------- combat ---------- */
#combat { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; background: #000; }
#combat.entering { animation: cin .5s ease-out; }
#combat.leaving { animation: cout .35s ease-in forwards; }
@keyframes cin { from { opacity: 0; transform: scale(1.04); } }
@keyframes cout { to { opacity: 0; } }
#ccv { flex: 1; width: 100%; min-height: 0; }
.c-top { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 0; right: 0; display: flex; justify-content: center; pointer-events: none; }
.unitframe { background: linear-gradient(rgba(30,24,16,.9), rgba(14,10,6,.92)); border: 1px solid var(--edge); border-radius: 10px; padding: 6px 8px; box-shadow: 0 4px 14px rgba(0,0,0,.5); }
.unitframe.enemy { width: min(340px, 92vw); position: relative; }
.uf-name { display: flex; align-items: center; gap: 6px; font: 700 14px var(--serif); color: #ffe7a0; margin-bottom: 4px; }
.uf-name .lvl { min-width: 22px; height: 20px; border-radius: 10px; color: #000; font: 700 11px var(--sans); display: grid; place-items: center; padding: 0 4px; }
.unitframe .bar.hp { height: 18px; }
.unitframe .bar span { font-size: 11px; }
.auras { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; min-height: 0; }
.aura { position: relative; width: 24px; height: 24px; }
.aura img { width: 24px; height: 24px; border-radius: 5px; border: 1px solid #000; }
.aura b { position: absolute; right: -2px; bottom: -3px; font-size: 10px; text-shadow: 0 0 3px #000, 0 0 2px #000; }
.intent { display: none; margin-top: 6px; padding: 4px 8px; border-radius: 6px; background: rgba(160,20,10,.6); border: 1px solid #ff5a3a; color: #ffe0c8; font-size: 12px; font-weight: 600; animation: blink .8s infinite alternate; }
.intent.show { display: block; }
@keyframes blink { to { background: rgba(220,40,20,.75); } }
.c-bottom { position: relative; background: linear-gradient(#1a140c, #0e0a06); border-top: 2px solid var(--edge); padding: 8px 10px max(10px, env(safe-area-inset-bottom)); display: grid; gap: 8px; }
.unitframe.player { padding: 6px 8px; max-width: 640px; width: 100%; margin: 0 auto; }
.uf-row { display: flex; align-items: center; gap: 8px; }
.uf-row .bar { flex: 1; }
.unitframe.player .bar.res { margin-top: 4px; height: 14px; }
.cps { display: flex; gap: 3px; }
.cps i { width: 12px; height: 12px; border-radius: 50%; background: #2a1a10; border: 1px solid #6a4a2a; }
.cps i.on { background: radial-gradient(circle at 35% 35%, #ffd0a0, #ff5a1a); border-color: #ffb07a; box-shadow: 0 0 8px #ff5a1a; }
.turnflag { position: absolute; top: -32px; left: 50%; transform: translateX(-50%) scale(.8); opacity: 0; font: 700 14px var(--serif); color: #ffd23a; background: rgba(0,0,0,.75); border: 1px solid #ffd23a; border-radius: 14px; padding: 3px 14px; transition: .2s; pointer-events: none; white-space: nowrap; }
.turnflag.show { opacity: 1; transform: translateX(-50%) scale(1); }
.actionbar { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; max-width: 640px; width: 100%; margin: 0 auto; }
.actionbar.many { grid-template-columns: repeat(8, 1fr); max-width: 800px; }
.ab { position: relative; aspect-ratio: 1; padding: 0; border: 2px solid #8a6a3a; border-radius: 10px; background: #000; overflow: hidden; box-shadow: 0 3px 8px rgba(0,0,0,.6); transition: transform .08s, filter .15s; max-height: 84px; }
.ab img { width: 100%; height: 100%; display: block; }
.ab .abn { position: absolute; left: 0; right: 0; bottom: 0; font-size: 9.5px; font-weight: 700; line-height: 1.1; padding: 2px 1px 3px; background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.85)); text-shadow: 0 1px 2px #000; }
.ab .cost { position: absolute; top: 2px; right: 4px; font-size: 11px; font-weight: 800; text-shadow: 0 0 3px #000, 0 1px 2px #000; }
.ab .cost.mana { color: #8ac0ff; } .ab .cost.rage { color: #ff8a7a; } .ab .cost.energy { color: #fff07a; }
.ab .cd { position: absolute; inset: 0; display: grid; place-items: center; font: 900 26px var(--serif); color: #fff; text-shadow: 0 0 6px #000; }
.ab.oncd img { filter: grayscale(1) brightness(.4); }
.ab.nores img { filter: saturate(.3) brightness(.5) sepia(.3) hue-rotate(180deg); }
.ab:not(:disabled):hover { transform: translateY(-2px); filter: brightness(1.2); border-color: #ffd23a; }
.ab:not(:disabled):active { transform: scale(.94); }
.ab:disabled { cursor: default; }
.ab.ready { border-color: #ff3a2a; box-shadow: 0 0 14px #ff3a2a; animation: pulse 0.8s infinite; }
.utilbar { display: flex; gap: 6px; justify-content: center; align-items: center; flex-wrap: wrap; }
.pots { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; }
.util.pot { position: relative; padding: 0 8px 0 3px; gap: 4px; }
.util .pa { position: absolute; left: 2px; bottom: -3px; font-size: 9px; font-weight: 800; padding: 0 3px; border-radius: 4px; background: rgba(0,0,0,.8); }
.util .pa.h { color: #8aff8a; } .util .pa.m { color: #8ab8ff; }
.util { display: flex; align-items: center; gap: 6px; height: 38px; padding: 0 12px 0 4px; border-radius: 10px; border: 1px solid #6a4a2a; background: #2a1a10; font-weight: 700; }
.util img { width: 30px; height: 30px; border-radius: 6px; }
.util.flee { padding: 0 14px; }
.util:disabled { opacity: .45; }
.clog { font-size: 11.5px; color: #c8bca0; min-height: 3.6em; max-width: 640px; width: 100%; margin: 0 auto; }
.clog div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clog div:last-child { color: #fff; }

/* ---------- loot ---------- */
#loot { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(0,0,0,.5); padding: 12px; }
#loot .loot-card { width: min(380px, 100%); background: var(--panel); border: 2px solid #ffd23a; border-radius: 16px; padding: 16px; box-shadow: 0 0 40px rgba(255,200,60,.35), 0 20px 50px #000; transform: scale(.7); opacity: 0; transition: .35s cubic-bezier(.2, 1.5, .4, 1); }
#loot.show .loot-card { transform: none; opacity: 1; }
.loot-title { font: 900 32px var(--serif); text-align: center; color: #ffd23a; text-shadow: 0 0 16px rgba(255,180,40,.7), 0 3px 0 #6a3a00; }
.loot-sub { text-align: center; color: var(--dim); margin-bottom: 10px; }
.loot-xp { display: flex; align-items: center; gap: 10px; font-weight: 700; color: #d8a8ff; }
.loot-xp .bar { flex: 1; height: 12px; }
.loot-money { text-align: center; font-size: 20px; margin: 10px 0; animation: coinpop .5s .2s both cubic-bezier(.2, 1.8, .4, 1); }
@keyframes coinpop { from { transform: scale(0); } }
.loot-items { display: grid; gap: 6px; margin-bottom: 8px; }
.loot-item { display: flex; align-items: center; gap: 10px; padding: 4px; border-radius: 10px; background: rgba(0,0,0,.3); animation: slidein .35s both ease-out; font-weight: 600; }
.loot-item.q2 { background: linear-gradient(90deg, rgba(30,255,0,.15), rgba(0,0,0,.3)); }
.loot-item.q3 { background: linear-gradient(90deg, rgba(58,139,255,.25), rgba(0,0,0,.3)); }
.loot-item.q4 { background: linear-gradient(90deg, rgba(181,82,255,.3), rgba(0,0,0,.3)); }
@keyframes slidein { from { opacity: 0; transform: translateX(-30px); } }

/* ---------- death ---------- */
#death { position: fixed; inset: 0; z-index: 55; display: grid; place-items: center; background: radial-gradient(circle, rgba(40,40,60,.6), rgba(0,0,0,.9)); backdrop-filter: grayscale(1); }
.death-card { text-align: center; padding: 20px; }
.d-title { font: 900 38px var(--serif); color: #c8d8ff; text-shadow: 0 0 20px #6a8aff; }

/* ---------- create ---------- */
#create { position: fixed; inset: 0; overflow-y: auto; background: radial-gradient(ellipse at 50% 30%, #3a5a3a 0%, #1a2a1a 50%, #0a0e08 100%); z-index: 80; }
#create::before { content: ''; position: fixed; inset: 0; background: radial-gradient(circle at 70% 20%, rgba(255,220,140,.25), rgba(0,0,0,0) 40%); pointer-events: none; }
.cc { position: relative; max-width: 760px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px 24px; }
.logo { text-align: center; margin: 8px 0 14px; }
.logo .l1 { display: block; font: 900 clamp(38px, 11vw, 64px) var(--serif); color: #ffd86a; text-shadow: 0 0 24px rgba(255,190,60,.6), 0 4px 0 #6a3a00, 0 8px 16px #000; letter-spacing: 1px; }
.logo .l2 { display: block; font: 600 clamp(13px, 3.6vw, 16px) var(--serif); color: #e8dcc0; letter-spacing: 3px; text-transform: uppercase; margin-top: 2px; }
.cc-cont { max-width: 420px; margin: 0 auto 10px; text-align: center; }
.cc-cont small { font-family: var(--sans); opacity: .8; }
.or { color: var(--dim); font-size: 12px; margin: 4px 0; }
.cc-grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: 16px; background: rgba(14,10,6,.7); border: 1px solid var(--edge); border-radius: 16px; padding: 14px; }
.cc-preview { display: flex; flex-direction: column; align-items: center; }
#ccprev { width: 100%; max-width: 230px; height: auto; aspect-ratio: 260/300; }
.cc-desc { font-size: 12.5px; color: #ddd; text-align: center; }
.cc-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pickb { padding: 10px 6px; border-radius: 10px; border: 2px solid #4a3a24; background: rgba(0,0,0,.4); font: 700 14px var(--serif); transition: .15s; }
.pickb.on { border-color: #ffd23a; background: rgba(255,210,58,.14); box-shadow: 0 0 12px rgba(255,210,58,.3); }
.cc-name { display: flex; gap: 6px; }
.cc-name input { flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px; border: 2px solid #4a3a24; background: rgba(0,0,0,.5); color: #fff; font: 600 16px var(--sans); user-select: text; -webkit-user-select: text; }
#enter { margin-top: 14px; }

/* ---------- small screens ---------- */
@media (max-width: 600px) {
  .pf-bars { width: 112px; }
  .portrait { width: 44px; height: 44px; }
  .lvlbadge { left: 34px; top: 36px; }
  .pf-name { font-size: 12px; }
  .minimap { width: 104px; height: 78px; }
  .purse { font-size: 12px; padding: 3px 8px; }
  .tracker { top: auto; bottom: 96px; right: 6px; width: 170px; }
  .tq-t { font-size: 11.5px; } .tq-o { font-size: 10.5px; }
  .mbtn { width: 48px; height: 48px; }
  .menubar { gap: 5px; }
  .cc-grid { grid-template-columns: 1fr; }
  #ccprev { max-width: 160px; }
  .actionbar { grid-template-columns: repeat(3, 1fr); }
  .actionbar.many { grid-template-columns: repeat(4, 1fr); }
  .ab { aspect-ratio: auto; height: 58px; }
  .ab img { object-fit: cover; }
  .ab .abn { font-size: 10px; }
  .p-body { padding: 10px; }
  .slot { width: 44px; height: 44px; }
  .baggrid { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); }
  .doll { gap: 4px; }
  .trow { gap: 10px; }
  .tnode { width: 66px; }
  .tnode img { width: 46px; height: 46px; }
  .tnode .tr { top: 33px; right: 4px; }
  .statsbox { gap: 2px 10px; padding: 8px; }
  .srow { font-size: 12px; }
}
@media (max-width: 380px) {
  .mbtn { width: 46px; height: 46px; }
  .mbtn .lbl { display: none; }
  .pf-bars { width: 100px; }
  .tracker { width: 150px; }
  .dmid { max-width: 160px; }
  #panels { padding: 4px; }
}
@media (max-height: 560px) and (min-width: 600px) {
  .ab { aspect-ratio: auto; height: 56px; }
  .tracker { top: 160px; }
}
@media (max-height: 640px) and (max-width: 600px) {
  .ab { height: 50px; }
  .ab .abn { font-size: 9px; }
  .c-bottom { gap: 6px; padding-top: 6px; }
  .clog { min-height: 2.4em; font-size: 11px; }
  .clog div:first-child:not(:last-child):not(:nth-last-child(2)) { display: none; }
  .util { height: 34px; }
  .unitframe .bar.hp { height: 16px; }
  .uf-name { font-size: 13px; margin-bottom: 2px; }
}
.gate-prog { margin: 10px 0 6px; }
.gate-prog .gp-label { font-size: 13px; margin-bottom: 6px; }
.gate-left { margin: 8px 0 0 18px; padding: 0; font-size: 13px; line-height: 1.6; }
.gate-left .dim { opacity: .6; }

/* ---------- hero select, save import/export ---------- */
.sel-box { max-width: 520px; margin: 0 auto; background: rgba(14,10,6,.75); border: 1px solid var(--edge); border-radius: 16px; padding: 14px; }
.sel-list { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 12px; }
.sel-row { display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 6px; border-radius: 12px; border: 2px solid #4a3a24; background: rgba(0,0,0,.4); cursor: pointer; transition: .15s; }
.sel-row:hover, .sel-row.last { border-color: #c9a227; background: rgba(255,210,58,.08); }
.sel-pic { width: 64px; height: 64px; flex: none; border-radius: 10px; background: radial-gradient(circle at 50% 70%, rgba(255,220,140,.25), rgba(0,0,0,0) 70%); }
.sel-info { flex: 1; min-width: 0; }
.sel-name { font: 700 18px var(--serif); color: #ffe6a0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sel-sub { font-size: 12.5px; color: #ddd; }
.sel-del { padding: 6px 10px; }
.sel-actions { justify-content: center; }
.cc-top { justify-content: center; margin-bottom: 10px; }
.modal-wrap { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 12px; background: rgba(0,0,0,.6); }
.savecode { width: 100%; min-height: 110px; margin: 8px 0; padding: 8px; border-radius: 10px; border: 2px solid #4a3a24; background: rgba(0,0,0,.5); color: #e8dcc0; font: 11px/1.35 ui-monospace, Menlo, monospace; word-break: break-all; resize: vertical; user-select: text; -webkit-user-select: text; }
.err-msg { color: #ff7a6a; font-size: 13px; min-height: 1em; margin: 0 0 6px; }
@media (max-width: 380px) { .sel-pic { width: 52px; height: 52px; } .sel-name { font-size: 16px; } .sel-row .btn.primary { padding: 8px 10px; } }
.mountbtn { width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--edge); background: rgba(18,14,10,.85); font-size: 20px; display: grid; place-items: center; padding: 0; box-shadow: 0 3px 8px rgba(0,0,0,.5); }
.mountbtn.on { border-color: #ffd23a; box-shadow: 0 0 10px rgba(255,210,58,.6); }
.mount-card { display: flex; gap: 12px; align-items: center; background: rgba(0,0,0,.3); border-radius: 12px; padding: 8px; margin: 8px 0; flex-wrap: wrap; justify-content: center; font-size: 13px; line-height: 1.5; }
.mount-card canvas { width: 220px; height: 150px; background: radial-gradient(circle at 50% 70%, rgba(255,220,140,.25), rgba(0,0,0,0) 70%); border-radius: 10px; }

/* ---------- version + loading screen ---------- */
.version { text-align: center; margin: 14px 0 6px; font-size: 12px; color: var(--dim); letter-spacing: .5px; }
#loading .ld-box { width: min(86vw, 360px); text-align: center; }
#loading .ld-title { font: 900 clamp(30px, 9vw, 44px) var(--serif); color: var(--gold); text-shadow: 0 2px 10px rgba(0,0,0,.8); }
#loading .ld-hero { font: 500 14px var(--sans); color: #e8dcc0; margin: 6px 0 18px; min-height: 1em; }
#loading .ld-bar { height: 12px; border-radius: 6px; background: #1a1610; border: 1px solid #6a5630; overflow: hidden; box-shadow: inset 0 1px 3px rgba(0,0,0,.7); }
#loading .ld-fill { height: 100%; width: 0; background: linear-gradient(90deg, #b8862a, #ffe08a); box-shadow: 0 0 10px #ffcf5a; transition: width .15s ease-out; }
#loading .ld-label { font: 500 13px var(--sans); color: var(--dim); margin-top: 10px; }
#loading { z-index: 90; background: radial-gradient(ellipse at 50% 30%, #3a5a3a 0%, #1a2a1a 50%, #0a0e08 100%); transition: opacity .35s; }
#loading.done { opacity: 0; pointer-events: none; }
.hovertip .ab-tt { max-width: 260px; }
.hovertip .ab-tt .tt-name .dim { font-size: 12px; font-weight: 500; }
.ab-tt-desc { margin-top: 4px; }

/* combat performance: scenery on its own layer, world hidden while fighting */
#ccbg { position: absolute; z-index: -1; pointer-events: none; }
#combat { overflow: hidden; }
body.fighting #game { visibility: hidden; }
#worldfx { position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 50% 50%, rgba(0,0,0,0) 35vmin, rgba(0,0,0,.42) 75vmax),
    linear-gradient(to bottom right, rgba(255,230,160,.16), rgba(255,230,160,0) 50%, rgba(40,20,60,.12)); }
/* second enemy in a two-mob fight: a compact frame you can click to switch target */
.c-top { gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.unitframe.enemy2 { pointer-events: auto; cursor: pointer; width: min(190px, 40vw); padding: 5px 7px; color: inherit; text-align: left; opacity: .88; font: inherit; }
.unitframe.enemy2:hover { opacity: 1; border-color: #ffd23a; }
.unitframe.enemy2[hidden] { display: none; }
.unitframe.enemy2 .uf-name { font-size: 12px; margin-bottom: 3px; white-space: nowrap; overflow: hidden; }
.unitframe.enemy2 .bar.hp { height: 13px; }
.unitframe.enemy2 .bar span { font-size: 10px; }
@media (max-width: 600px) {
  .unitframe.enemy2 { width: min(340px, 92vw); display: flex; align-items: center; gap: 8px; padding: 4px 7px; }
  .unitframe.enemy2 .uf-name { margin: 0; flex: 0 1 auto; max-width: 55%; }
  .unitframe.enemy2 .bar.hp { flex: 1; }
}

/* vendor: shop tabs on the left, your bags on the right */
.panel.vendor { width: min(1040px, 100%); }
.vwrap { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; align-items: start; }
.vtabs { display: flex; gap: 4px; margin-bottom: 8px; border-bottom: 1px solid var(--edge); }
.vtab { flex: 0 1 auto; padding: 7px 12px; border: 1px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0; background: transparent; color: var(--dim); font: 700 13px var(--serif); cursor: pointer; margin-bottom: -1px; }
.vtab:hover:not(:disabled) { color: #ffe7a0; }
.vtab.on { background: rgba(0,0,0,.3); border-color: var(--edge); color: #ffd23a; }
.vtab:disabled { opacity: .4; cursor: default; }
.vtab .dim { font: 500 11px var(--sans); margin-left: 2px; }
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; }
.vgrid .vinfo { flex: 1; min-width: 0; }
.vgrid .vname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vbags { background: rgba(0,0,0,.22); border-radius: 10px; padding: 8px; }
.vbags .sh { margin-top: 0; }
.vbags .sh .dim { font: 500 11px var(--sans); text-transform: none; letter-spacing: 0; margin-left: 4px; }
.vfoot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 8px; }
@media (max-width: 760px) {
  .vwrap { grid-template-columns: 1fr; }
  .vgrid { grid-template-columns: 1fr; }
  .vtab { padding: 6px 8px; font-size: 12px; }
}
.c-top .others { display: flex; flex-direction: column; gap: 4px; }
.c-top .others:empty { display: none; }
@media (max-width: 600px) { .c-top .others { width: min(340px, 92vw); } .c-top .others .unitframe.enemy2 { width: 100%; } }
