:root {
  --panel-bg: rgba(18, 16, 22, 0.72);
  --panel-border: #8a6d3b;
  --gold: #e6c47a;
  --text: #efe6d2;
  --muted: #b6a888;
  --slot-bg: rgba(10, 9, 14, 0.8);
  --slot-flash: #f3d27d;
  --ok: #8fd18a;
  --bad: #e08a7a;
  font-family: Georgia, "Palatino Linotype", "Book Antiqua", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #1a1820;
  color: var(--text);
}

#game {
  width: 100vw;
  height: 100vh;
  display: block;
  outline: none;
  touch-action: none;
}

#hud { position: fixed; inset: 0; pointer-events: none; }

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.top-left { position: absolute; top: 12px; left: 12px; padding: 8px 12px; min-width: 220px; }
.title { font-size: 20px; color: var(--gold); letter-spacing: 1px; }
.sub { font-size: 12px; color: var(--muted); }
.stats { margin-top: 4px; font-size: 12px; font-family: Consolas, monospace; }
.stats .ok { color: var(--ok); }
.stats .bad { color: var(--bad); }

.help {
  position: absolute; top: 12px; right: 12px;
  font-size: 12px; color: var(--muted);
  background: var(--panel-bg); padding: 6px 10px; border-radius: 6px;
}

.bars {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); pointer-events: auto;  /* #hud is pointer-events:none; bars take clicks + item drops */
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}

.hotbar, .consumables { display: flex; gap: 4px; padding: 5px; }
.hotbar { background: var(--panel-bg); border: 1px solid var(--panel-border); border-radius: 6px; }

.slot {
  position: relative;
  width: 48px; height: 48px;
  background: var(--slot-bg);
  border: 1px solid #4b3d24;
  border-radius: 4px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.slot.small { width: 38px; height: 38px; border-color: #3d4b5a; }
.slot .key {
  position: absolute; top: 2px; left: 4px;
  font-size: 11px; font-family: Consolas, monospace; color: var(--muted);
}
.slot.pressed { border-color: var(--slot-flash); box-shadow: 0 0 10px var(--slot-flash) inset; }

#loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: #15131b;
  transition: opacity 0.4s;
}
#loading.hidden { opacity: 0; }
.loading-box { text-align: center; }
.loading-title { font-size: 42px; color: var(--gold); letter-spacing: 4px; }
#loading-text { margin-top: 8px; color: var(--muted); }
#loading.error #loading-text { color: var(--bad); white-space: pre-wrap; max-width: 80vw; }

@media (max-width: 720px) {
  .slot { width: 32px; height: 32px; }
  .slot.small { width: 28px; height: 28px; }
  .help { display: none; }
}

/* ------------------------------------------------------------------ M2 menus */
[hidden] { display: none !important; }

#menus { position: fixed; inset: 0; pointer-events: none; }
.screen { position: absolute; inset: 0; }
.screen.center { display: flex; align-items: center; justify-content: center; }
.screen * { pointer-events: auto; }

.menu-panel {
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 8px;
  background: rgba(16, 14, 20, 0.86);
  backdrop-filter: blur(3px);
}
.auth-panel { width: min(360px, calc(100vw - 32px)); }
.side { position: absolute; top: 16px; bottom: 16px; width: min(330px, calc(100vw - 32px)); overflow-y: auto; }
.side.left { left: 16px; }
.side.right { right: 16px; }
.brand { font-size: 40px; color: var(--gold); letter-spacing: 4px; text-align: center; }
.tagline { text-align: center; color: var(--muted); font-style: italic; margin-bottom: 8px; }
.panel-title { font-size: 22px; color: var(--gold); }
.section { margin-top: 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); }
.subtle { font-size: 12px; color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); }
.info { font-size: 13px; line-height: 1.4; min-height: 2.8em; }
.form-error { min-height: 1.2em; color: var(--bad); font-size: 13px; white-space: pre-wrap; }
.row { display: flex; gap: 8px; justify-content: space-between; align-items: center; margin-top: 6px; }

.field { display: block; }
.menu-panel input {
  width: 100%; padding: 10px 12px; font: inherit; font-size: 15px;
  color: var(--text); background: rgba(0, 0, 0, 0.45);
  border: 1px solid #4b3d24; border-radius: 4px; outline: none;
}
.menu-panel input:focus { border-color: var(--gold); }

button {
  font: inherit; font-size: 14px; color: var(--text); cursor: pointer;
  padding: 8px 14px; border-radius: 4px;
  background: rgba(40, 34, 48, 0.9); border: 1px solid #5a4a2e;
}
button:hover:not(:disabled) { border-color: var(--gold); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: linear-gradient(#8a6a2e, #5e4519); border-color: var(--gold); color: #fff6dc; }
button.big { padding: 12px 28px; font-size: 18px; letter-spacing: 1px; }
button.danger { background: rgba(110, 30, 26, 0.9); border-color: #b0493c; }
button.small { padding: 5px 10px; font-size: 12px; }
button.link { background: none; border: none; padding: 4px 0; color: var(--muted); text-decoration: underline; }
button.link:hover { color: var(--gold); }
.top-left button.link { pointer-events: auto; font-size: 12px; margin-top: 4px; }

.tabs { display: flex; gap: 4px; }
.tab { flex: 1; background: transparent; border-color: transparent; border-bottom: 2px solid #3a3040; border-radius: 0; }
.tab.active { border-bottom-color: var(--gold); color: var(--gold); }

.char-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.char-card { text-align: left; padding: 10px 12px; border-left: 4px solid #5a4a2e; }
.char-card[data-faction="dawn_accord"] { border-left-color: #5a8fd8; }
.char-card[data-faction="ashen_pact"] { border-left-color: #c0473a; }
.char-card.selected { border-color: var(--gold); box-shadow: 0 0 10px rgba(230, 196, 122, 0.35) inset; }
.char-card.empty { color: var(--muted); border-style: dashed; text-align: center; }
.char-name { font-size: 17px; color: var(--gold); }
.char-meta { font-size: 13px; }
.char-faction { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }

.bottom-center {
  position: absolute; bottom: 28px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}

.choice-grid { display: grid; gap: 6px; }
.choice-grid.two { grid-template-columns: 1fr 1fr; }
.choice.selected { border-color: var(--gold); color: var(--gold); box-shadow: 0 0 8px rgba(230, 196, 122, 0.3) inset; }
.choice[data-faction="dawn_accord"] { border-left: 3px solid #5a8fd8; }
.choice[data-faction="ashen_pact"] { border-left: 3px solid #c0473a; }

.faction-badge { align-self: flex-start; font-size: 12px; padding: 3px 10px; border-radius: 10px; letter-spacing: 1px; }
.faction-badge[data-faction="dawn_accord"] { background: rgba(90, 143, 216, 0.25); color: #a9c8f2; }
.faction-badge[data-faction="ashen_pact"] { background: rgba(192, 71, 58, 0.25); color: #f0a99e; }

.modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.55); }
.modal .menu-panel { width: min(380px, calc(100vw - 32px)); }

.nameplate {
  position: absolute; left: 0; top: 0; pointer-events: none; white-space: nowrap;
  font-size: 14px; color: #f3e6c4; text-shadow: 0 1px 3px #000, 0 0 2px #000;
}
.nameplate[data-faction="dawn_accord"] { color: #b9d3f7; }
.nameplate[data-faction="ashen_pact"] { color: #f5b4a8; }

@media (max-width: 720px) {
  .side { top: auto; bottom: 90px; max-height: 55vh; }
  .bottom-center { bottom: 16px; }
  .brand { font-size: 32px; }
}

/* ------------------------------------------------------------------ M3 world: nameplates, chat */
#plates { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.plate { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; white-space: nowrap; }
.plate-name { font-size: 13px; color: #f3e6c4; text-shadow: 0 1px 3px #000, 0 0 2px #000; }
.plate[data-faction="dawn_accord"] .plate-name { color: #b9d3f7; }
.plate[data-faction="ashen_pact"] .plate-name { color: #f5b4a8; }
.plate.mob .plate-name { color: #f0d080; font-size: 12px; }
.plate.mob.hostile .plate-name { color: #ff9a8a; }
.plate.npc .plate-name { color: #9ef08a; font-size: 12px; }   /* friendly NPCs: green name, no health bar (Chain #2) */
.plate.npc .plate-bar { display: none; }
.plate.self .plate-name { color: #9be89b; }
.plate-bar { width: 56px; height: 5px; background: rgba(0, 0, 0, 0.6); border: 1px solid rgba(0, 0, 0, 0.8); border-radius: 2px; overflow: hidden; }
.plate-fill { height: 100%; background: #5fc65f; transition: width 0.15s; }
.plate.mob.hostile .plate-fill { background: #d4473a; }
.plate.dead { opacity: 0.45; }

.chat {
  position: absolute; left: 12px; bottom: 14px; width: min(380px, calc(100vw - 24px));
  padding: 6px; pointer-events: auto; display: flex; flex-direction: column; gap: 4px;
  background: rgba(18, 16, 22, 0.55);
}
.chat-log { height: 150px; overflow-y: auto; font-size: 13px; line-height: 1.35; font-family: Georgia, serif; }
.chat-line { overflow-wrap: anywhere; text-shadow: 0 1px 2px #000; }
.chat-line.say { color: #f3eee0; }
.chat-line.zone { color: #f2c98a; }
.chat-line.whisper { color: #e59be8; }
.chat-line.system { color: #f5e27a; font-style: italic; }
.chat-input {
  width: 100%; padding: 6px 8px; font: inherit; font-size: 13px; color: var(--text);
  background: rgba(0, 0, 0, 0.6); border: 1px solid var(--gold); border-radius: 3px; outline: none;
}
.stats .warn { color: #f5c26b; }
@media (max-width: 720px) { .chat { bottom: 120px; } .chat-log { height: 90px; } }

/* ------------------------------------------------------------------ M4 combat UI */
#fct-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.fct { position: absolute; left: 0; top: 0; font-weight: bold; font-size: 18px; text-shadow: 0 1px 3px #000, 0 0 2px #000; white-space: nowrap; }
.fct.dmg { color: #fff3d6; }
.fct.crit { color: #ffd23a; font-size: 26px; }
.fct.self_dmg { color: #ff6a5a; }
.fct.heal { color: #7cff7c; }
.fct.miss { color: #c0c0c0; font-size: 15px; }
.fct.xp { color: #c89cff; font-size: 15px; }
.fct.level { color: #ffe28a; font-size: 28px; letter-spacing: 1px; }

.unit-frame { position: absolute; top: 112px; width: 230px; padding: 6px 8px; pointer-events: none; }
.player-frame { left: 12px; }
.target-frame { left: 254px; }
.target-frame.hostile .uf-fill { background: linear-gradient(#e0574a, #a3281f); }
.uf-head { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--gold); margin-bottom: 4px; }
.uf-level { display: inline-block; min-width: 22px; text-align: center; font-size: 12px; background: rgba(0,0,0,0.6); border: 1px solid #5a4a2e; border-radius: 10px; color: var(--text); }
.uf-bar { position: relative; height: 14px; background: rgba(0,0,0,0.6); border: 1px solid #000; border-radius: 3px; overflow: hidden; margin-bottom: 3px; }
.uf-bar.res { height: 9px; --res: #4f7fd8; }
.uf-fill { height: 100%; background: linear-gradient(#58c858, #2f8a2f); transition: width 0.12s; }
.uf-bar.res .uf-fill { background: var(--res); }
.uf-text { position: absolute; inset: 0; text-align: center; font-size: 10px; line-height: 14px; font-family: Consolas, monospace; text-shadow: 0 1px 1px #000; }
.uf-bar.res .uf-text { line-height: 9px; font-size: 8px; }
.auras { display: flex; flex-wrap: wrap; gap: 3px; }
.aura { font-size: 10px; padding: 1px 5px; border-radius: 8px; background: rgba(90, 143, 216, 0.4); text-transform: capitalize; }

.slot .glyph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.slot.filled { border-color: #8a6d3b; background: radial-gradient(circle, rgba(70,55,35,0.95), rgba(18,14,10,0.95)); }
.slot .cd { position: absolute; inset: 0; border-radius: 3px; pointer-events: none; }
.slot .cd-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: bold; text-shadow: 0 1px 2px #000; }
.slot .key { z-index: 1; }

.cast-bar { position: absolute; left: 50%; bottom: 150px; transform: translateX(-50%); width: 260px; height: 18px;
  background: rgba(0,0,0,0.7); border: 1px solid var(--gold); border-radius: 3px; overflow: hidden; }
.cast-fill { height: 100%; width: 0; background: linear-gradient(#f0c35a, #b88620); }
.cast-bar span { position: absolute; inset: 0; text-align: center; font-size: 12px; line-height: 18px; text-shadow: 0 1px 2px #000; }
.cast-bar.failed .cast-fill { background: #a3281f; width: 100% !important; }
.combat-error { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); color: #ff5a4a; font-size: 18px; text-shadow: 0 1px 3px #000; opacity: 0; pointer-events: none; }
.combat-error.show { animation: errfade 1.6s ease-out; }
@keyframes errfade { 0% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }
.xp-bar { position: absolute; left: 50%; bottom: 4px; transform: translateX(-50%); width: min(560px, calc(100vw - 24px)); height: 8px;
  background: rgba(0,0,0,0.6); border: 1px solid #000; border-radius: 3px; overflow: hidden; }
.xp-fill { height: 100%; width: 0; background: linear-gradient(#b48cff, #6a3fc0); transition: width 0.3s; }
.xp-bar span { position: absolute; inset: 0; font-size: 8px; line-height: 8px; text-align: center; color: #e8dcff; }
.bars { bottom: 18px; }
.death-overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(40, 0, 0, 0.35); pointer-events: auto; }
.death-box { padding: 18px 26px; text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.death-title { font-size: 26px; color: #e08a7a; }
@media (max-width: 720px) { .unit-frame { top: 100px; width: 170px; } .target-frame { left: 190px; } }

/* ------------------------------------------------------------------ region banner (big world) */
.region-banner { position: absolute; left: 50%; top: 16%; transform: translateX(-50%); font-size: 30px; letter-spacing: 3px;
  color: var(--gold); text-shadow: 0 2px 6px #000, 0 0 2px #000; opacity: 0; pointer-events: none; white-space: nowrap; }
.region-banner.show { animation: regionfade 3.2s ease-out; }
@keyframes regionfade { 0% { opacity: 0; } 15% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }

/* bosses (Sunken Reliquary) */
.plate[data-mob="hollowed_abbot"] .plate-name, .plate[data-mob="marrowmaw"] .plate-name, .plate[data-mob="pale_warden"] .plate-name {
  color: #ffd86a; font-size: 16px; letter-spacing: 1px; }
.plate[data-mob="hollowed_abbot"] .plate-bar, .plate[data-mob="marrowmaw"] .plate-bar, .plate[data-mob="pale_warden"] .plate-bar { width: 110px; height: 7px; }

/* ------------------------------------------------------------------ Chain #2: bags, character, loot, dialogue, vendor, quests, party (src/adventure.js) */
.adv { position: absolute; inset: 0; pointer-events: none; }
.adv > * { pointer-events: auto; }
.win { position: absolute; background: rgba(20, 17, 24, 0.95); min-width: 240px; max-height: 70vh; display: flex; flex-direction: column; padding: 0; border-radius: 6px; }
.win-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; border-bottom: 1px solid #4b3d24; color: var(--gold); font-size: 15px; }
.win-close { padding: 0 8px; font-size: 18px; line-height: 20px; }
.win-body { padding: 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.bag-win { right: 12px; bottom: 150px; width: 262px; }
.char-win { left: 260px; top: 200px; width: 330px; }
.log-win { left: 50%; top: 90px; transform: translateX(-50%); width: 360px; }
.dialog-win, .vendor-win { left: 12px; top: 200px; width: 340px; }
.vendor-win { left: 364px; }
.loot-win { left: 50%; top: 38%; width: 240px; }
.bag-grid { display: flex; flex-direction: column; gap: 4px; max-height: 62vh; overflow-y: auto; }
.bag-cells { display: grid; grid-template-columns: repeat(5, 44px); gap: 4px; }
.bag-slots { display: flex; gap: 6px; padding-bottom: 4px; border-bottom: 1px solid #3a3326; }
.bag-slots .eq-empty { font-size: 10px; color: var(--muted); }
.bag-title { font-size: 12px; color: var(--gold); margin-top: 2px; }
.islot { position: relative; width: 44px; height: 44px; background: var(--slot-bg); border: 1px solid #3a3326; border-radius: 4px; display: flex; align-items: center; justify-content: center; cursor: default; }
.islot img { width: 100%; height: 100%; object-fit: cover; border-radius: 3px; pointer-events: none; }
.islot .iglyph { font-size: 13px; color: var(--muted); }
.islot .icount { position: absolute; right: 3px; bottom: 1px; font-size: 11px; font-weight: bold; text-shadow: 0 1px 2px #000, 0 0 2px #000; }
.islot.over { box-shadow: 0 0 8px var(--gold) inset; }
.islot.small { width: 38px; height: 38px; }
.islot.empty { opacity: 0.4; }
.islot.pickable { cursor: pointer; }
.islot.picked { box-shadow: 0 0 10px var(--gold); outline: 2px solid var(--gold); }
.bar-slot { cursor: pointer; overflow: hidden; }
.bar-slot .key { position: absolute; top: 1px; left: 3px; font-size: 10px; font-family: Consolas, monospace; color: var(--muted); text-shadow: 0 1px 1px #000; }
.bar-slot .cd { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(0, 0, 0, 0.6); pointer-events: none; }
.gold-line { color: var(--gold); text-align: right; font-family: Consolas, monospace; }
.eq-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.eq-cell { display: flex; align-items: center; gap: 6px; min-width: 0; }
.eq-label { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eq-empty { font-size: 9px; color: #6d6450; text-align: center; }
.stat-list { margin-top: 6px; border-top: 1px solid #4b3d24; padding-top: 6px; }
.stat-row { display: flex; justify-content: space-between; font-size: 12px; }
.stat-row .v { color: var(--gold); font-family: Consolas, monospace; }
/* above every window: wm.js raises windows with an ever-growing z-index (20, 21, 22…), so overlays sit far above that range */
.tooltip { position: fixed; z-index: 2000000000; max-width: 260px; padding: 6px 9px; font-size: 12px; pointer-events: none !important; }
.tip-name { font-size: 14px; font-weight: bold; }
.tip-line { color: var(--text); }
.tip-line.muted { color: var(--muted); }
.tip-line.quest { color: #f5e27a; }
.tip-stat { color: #8fd18a; }
.tip-use { color: #8fd18a; font-style: italic; }
.loot-row { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 2px; border-radius: 4px; }
.loot-row:hover { background: rgba(230, 196, 122, 0.12); }
.dialog-text { margin: 0; line-height: 1.45; font-family: Georgia, serif; white-space: pre-wrap; }
.dialog-opt { text-align: left; }
.dialog-opt.quest_offer, .dialog-opt.quest_turnin { color: #f5e27a; }
.dialog-opt.quest_progress { color: var(--muted); }
.quest-title { color: var(--gold); font-size: 15px; }
.objective { font-size: 12px; }
.reward-items { display: flex; gap: 4px; flex-wrap: wrap; }
.dialog-buttons { display: flex; gap: 6px; justify-content: flex-end; margin-top: 4px; }
.vendor-row { display: flex; align-items: center; gap: 8px; }
.vendor-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vendor-price { color: var(--gold); font-family: Consolas, monospace; font-size: 12px; }
.small-btn { padding: 2px 8px; font-size: 12px; }
.adv-toolbar { position: absolute; right: 12px; bottom: 14px; display: flex; gap: 4px; }
.interact-prompt { position: absolute; left: 50%; top: 62%; transform: translateX(-50%); padding: 5px 12px; border-radius: 6px; background: var(--panel-bg); border: 1px solid var(--gold); color: var(--gold); font-size: 14px; pointer-events: none !important; }
.quest-tracker { position: absolute; right: 12px; top: 120px; width: 240px; display: flex; flex-direction: column; gap: 6px; pointer-events: none !important; }
.quest-tracker .tq { pointer-events: auto; cursor: pointer; border-radius: 4px; padding: 1px 4px; }
.quest-tracker .tq:hover { background: rgba(0, 0, 0, 0.35); }
.tq-name { color: var(--gold); font-size: 13px; text-shadow: 0 1px 2px #000; }
.tq-name.ready { color: #8fd18a; }
.tq-obj { font-size: 12px; color: var(--text); text-shadow: 0 1px 2px #000; padding-left: 8px; }
.log-q { border-bottom: 1px solid #3a3326; padding-bottom: 6px; display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.party-frames { position: absolute; left: 12px; top: 200px; width: 170px; display: flex; flex-direction: column; gap: 4px; }
.pf { padding: 4px 6px; cursor: pointer; }
.pf-head { font-size: 12px; color: var(--gold); }
.pf-lvl { color: var(--muted); font-size: 11px; }
.pf.offline, .pf.dead { opacity: 0.5; }
.pf-note { font-size: 10px; color: var(--muted); }
.invite { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); padding: 10px 14px; display: flex; gap: 8px; align-items: center; }
.plate-mark { font-size: 22px; font-weight: bold; line-height: 1; text-shadow: 0 1px 3px #000, 0 0 3px #000; }
.plate-mark.offer, .plate-mark.ready { color: #ffd23a; }
.plate-mark.grey { color: #a8a8a8; }
.plate.lootable .plate-name::after { content: " \2726"; color: #ffd86a; }
.chat-line.party { color: #8fb8ff; }
.hotbar-sep { width: 8px; }
.gear-slot { border-color: #3d5a4a; }
.spell-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.spell-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.gear-ability { display: flex; align-items: center; gap: 4px; }
.ability-chip { padding: 3px 8px; border: 1px solid #3d5a4a; border-radius: 10px; background: rgba(60, 110, 90, 0.35); font-size: 12px; cursor: grab; }
.key-btn { padding: 1px 6px; min-width: 22px; }
.key-btn.bound { border-color: var(--gold); color: var(--gold); }
.tip-bonus { color: #7fc8ff; }
.tip-desc { color: var(--muted); font-size: 11px; padding-left: 6px; }

/* ------------------------------------------------------------------ window manager (wm.js) */
.wm .win-head.wm-drag { cursor: move; user-select: none; }
.win-head { gap: 4px; }
.win-head .win-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.win-btn { padding: 0 7px; font-size: 13px; line-height: 20px; min-width: 24px; }
.win.resizable, .chat.resizable { resize: both; overflow: hidden; max-height: 92vh; }
.win.resizable .win-body { flex: 1; min-height: 0; }
.wm.minimized { height: auto !important; min-height: 0 !important; resize: none; }
.wm.expanded { resize: none; }
.chat .chat-head { padding: 2px 6px; font-size: 12px; border-bottom: 1px solid #3a3326; }
.chat.resizable .chat-log { flex: 1; height: auto; min-height: 40px; }
.chat.resizable { height: 210px; }

/* ------------------------------------------------------------------ minimap + world map (map.js) */
.minimap { position: absolute; right: 12px; top: 44px; width: 192px; padding: 0; border-radius: 6px;
  background: var(--panel-bg); border: 1px solid var(--panel-border); }
.minimap .win-head { padding: 3px 6px; font-size: 12px; }
.minimap-body { position: relative; padding: 5px; }
.minimap-canvas { display: block; width: 180px; height: 180px; border-radius: 50%; border: 2px solid #6b5a3a; background: #121014; }
.mm-zoom { position: absolute; width: 22px; height: 22px; padding: 0; font-size: 14px; line-height: 20px; border-radius: 50%; }
.mm-zoom.in { right: 4px; top: 4px; }
.mm-zoom.out { right: 4px; top: 30px; }
.mm-zoom.map { left: 4px; top: 4px; font-size: 11px; }
.mm-coords { position: absolute; left: 0; right: 0; bottom: 6px; text-align: center; font-size: 10px; font-family: Consolas, monospace; color: var(--muted); text-shadow: 0 1px 2px #000; }
.quest-tracker { top: 270px; }
.worldmap-win { left: 50%; top: 60px; transform: translateX(-50%); width: min(820px, 92vw); height: min(680px, 84vh); }
.worldmap-canvas { display: block; width: 100%; flex: 1; min-height: 200px; border: 1px solid #3a3326; cursor: grab; image-rendering: pixelated; }
.map-legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 11px; color: var(--muted); }
.map-legend .lg::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }
.lg.me::before { background: #fff; } .lg.party::before { background: #5fe06a; } .lg.player::before { background: #6aa8ff; }
.lg.npc::before { background: #e8d070; } .lg.quest::before { background: #ffd23a; box-shadow: 0 0 4px #ffd23a; }
.lg.mob::before { background: #e04a3a; } .lg.portal::before { border: 2px solid #c58cff; background: none; }

/* ------------------------------------------------------------------ trade (trade.js) */
.trade-win { left: 50%; top: 22%; transform: translateX(-50%); width: 470px; }
.trade-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.trade-side { border: 1px solid #3a3326; border-radius: 6px; padding: 6px; display: flex; flex-direction: column; gap: 6px; }
.trade-side.ok { border-color: #8fd18a; box-shadow: 0 0 8px rgba(143, 209, 138, 0.35) inset; }
.trade-grid { display: grid; grid-template-columns: repeat(3, 44px); gap: 4px; }
.trade-gold { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; }
.gold-in { width: 46px; padding: 2px 4px; font: inherit; font-size: 12px; color: var(--text); background: rgba(0,0,0,0.5); border: 1px solid #5a4a2e; border-radius: 3px; }
.gold-unit { color: var(--gold); font-size: 11px; margin-right: 4px; }
.trade-their-gold { color: var(--gold); font-family: Consolas, monospace; }
.player-menu { position: fixed; z-index: 1999999999; display: flex; flex-direction: column; gap: 3px; padding: 6px; min-width: 130px; }
.pm-name { color: var(--gold); font-size: 13px; margin-bottom: 2px; }

/* ------------------------------------------------------------------ Chain #3: monster levels, danger colours, elites/rares */
.plate-lvl { display: inline-block; min-width: 16px; padding: 0 3px; margin-right: 2px; font-size: 10px; text-align: center;
  border-radius: 7px; background: rgba(0, 0, 0, 0.55); border: 1px solid rgba(255, 255, 255, 0.25); }
.plate.mob.lv-grey .plate-name { color: #a0a0a0; }
.plate.mob.lv-green .plate-name { color: #6fdc6f; }
.plate.mob.lv-yellow .plate-name { color: #f2d45a; }
.plate.mob.lv-orange .plate-name { color: #ff9a3a; }
.plate.mob.lv-red .plate-name { color: #ff4a3a; }
.plate.elite .plate-name::before { content: "\25C6 "; color: #ffd23a; }
.plate.elite .plate-bar { border-color: #c9a54a; box-shadow: 0 0 4px rgba(255, 210, 58, 0.6); width: 76px; }
.plate.rare .plate-name::before { content: "\2726 "; color: #d8e4f0; }
.plate.rare .plate-bar { border-color: #b8c4d0; }

/* ------------------------------------------------------------------ Chain #3 Stage 3: spell book, 6 spell slots, waystones */
.slot.locked, .islot.locked { opacity: 0.45; filter: grayscale(1); }
.slot.locked .glyph { font-size: 11px; }
.spell-row { flex-wrap: wrap; }
.book-win { left: 50%; top: 80px; transform: translateX(-50%); width: 440px; }
.book-win .win-body { max-height: 70vh; overflow-y: auto; }
.book-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.book-row { display: flex; gap: 8px; align-items: flex-start; padding: 6px; border: 1px solid #3a3326; border-radius: 5px; background: rgba(0, 0, 0, 0.25); }
.book-row.future { opacity: 0.6; }
.book-icon { flex: 0 0 36px; height: 36px; display: flex; align-items: center; justify-content: center; font-size: 18px;
  background: var(--slot-bg); border: 1px solid #5a4a30; border-radius: 4px; color: var(--gold); }
.book-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.book-head { display: flex; justify-content: space-between; gap: 8px; }
.book-name { color: var(--gold); font-size: 13px; }
.book-lvl { color: var(--muted); font-size: 11px; }
.book-desc { font-size: 12px; color: var(--text); }
.book-where { display: flex; gap: 8px; align-items: center; font-size: 11px; }
.book-where .ok { color: #8fd18a; }
.book-where .muted { color: var(--muted); }
.waystone-win { left: 50%; top: 120px; transform: translateX(-50%); width: 360px; }
.ws-row { display: flex; gap: 8px; align-items: center; padding: 4px 2px; border-bottom: 1px solid #3a3326; font-size: 13px; }
.ws-row .ws-name { flex: 1; color: var(--text); }
.ws-row .ws-lvl { color: var(--muted); font-size: 11px; width: 44px; }
.ws-row .ws-state { color: var(--muted); font-size: 11px; }
.ws-row.here .ws-name { color: var(--gold); }
.ws-row.unknown .ws-name { color: #777; }

/* ------------------------------------------------------------------ Chain #3 Stage 4: raids & world bosses window */
.events-win { left: 50%; top: 90px; transform: translateX(-50%); width: 470px; }
.events-win .win-body { max-height: 70vh; overflow-y: auto; }
.ev-row { display: flex; gap: 8px; align-items: center; padding: 4px 2px; border-bottom: 1px solid #3a3326; font-size: 13px; }
.ev-row .ev-name { flex: 1; color: var(--text); }
.ev-row .ev-lvl, .ev-row .ev-where { color: var(--muted); font-size: 11px; }
.ev-row .ev-state { color: var(--muted); font-size: 11px; min-width: 120px; text-align: right; }
.ev-row.warning .ev-state { color: #ff9a3a; }
.ev-row.up .ev-state, .ev-row.engaged .ev-state { color: #ff6a5a; font-weight: bold; }
.ev-row.raid.up .ev-state { color: #8fd18a; }
.ev-bosses { display: flex; flex-wrap: wrap; gap: 4px; margin: 3px 0 6px 8px; }
.ev-boss { font-size: 11px; padding: 1px 6px; border-radius: 8px; background: rgba(0, 0, 0, 0.35); color: var(--text); }
.ev-boss.locked { color: #8a8a8a; text-decoration: line-through; }

.plate.mob.lv-skull .plate-lvl { color: #ff4a3a; border-color: #ff4a3a; font-weight: bold; }


/* ---------------------------------------------------------------- Chain #3 Stage 6: bank, mail, auction, guild, group finder */
.ui-input, .ui-select { background: #15120d; color: var(--text, #f0ece0); border: 1px solid #4a4030; border-radius: 4px; padding: 3px 6px; font: inherit; font-size: 12px; }
.ui-input[type=number] { width: 58px; }
.ui-check { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.ui-tabs { display: flex; gap: 2px; margin-bottom: 6px; border-bottom: 1px solid #3a3326; }
.ui-tab { background: transparent; border: 1px solid transparent; border-bottom: none; border-radius: 5px 5px 0 0; padding: 4px 10px; font-size: 12px; color: var(--muted); cursor: pointer; }
.ui-tab.on { color: var(--gold); border-color: #4a4030; background: rgba(255, 255, 255, 0.04); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 6px; }
.ui-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 3px 0; justify-content: flex-start; }
.ui-row .lbl { width: 110px; font-size: 12px; color: var(--muted); }
.money-input { display: inline-flex; align-items: center; gap: 2px; }
.money-input .ui-input { width: 52px; }
.money-input .coin { font-size: 11px; font-weight: bold; margin-right: 4px; }
.money-input .coin.g { color: #f2c94c; } .money-input .coin.s { color: #c8c8d0; } .money-input .coin.c { color: #c27c46; }

.bank-win { left: 12px; top: 120px; width: 530px; }
.bank-filters { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 6px; }
.bank-filters .ui-input { width: 120px; }
.bank-grid { display: grid; grid-template-columns: repeat(10, 44px); gap: 4px; max-height: 52vh; overflow-y: auto; }
.islot.dim { opacity: 0.22; }
.islot.match { box-shadow: 0 0 6px var(--gold); }

.mail-win { left: 12px; top: 120px; width: 380px; }
.mail-content { max-height: 60vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.mail-row { display: flex; justify-content: space-between; gap: 8px; padding: 6px; border: 1px solid #3a3326; border-radius: 5px; background: rgba(0, 0, 0, 0.25); cursor: pointer; }
.mail-row:hover { border-color: var(--gold); }
.mail-row.unread .mail-subj { color: var(--gold); font-weight: bold; }
.mail-from { font-size: 12px; color: var(--muted); }
.mail-side { text-align: right; font-size: 12px; }
.mail-gold { color: #f2c94c; font-family: Consolas, monospace; }
.mail-gold-row { display: flex; gap: 8px; align-items: center; margin: 4px 0; }
.mail-text { white-space: pre-wrap; }
.mail-form { display: flex; flex-direction: column; gap: 5px; }
.mail-body { min-height: 80px; resize: vertical; }
.empty-attach { opacity: 0.45; }
.mail-icon { position: absolute; right: 14px; top: 214px; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; font-size: 20px; color: var(--gold); border: 1px solid var(--gold); border-radius: 6px; animation: mailpulse 2s ease-in-out infinite; pointer-events: auto; }
@keyframes mailpulse { 50% { box-shadow: 0 0 10px var(--gold); } }

.ah-win { left: 12px; top: 80px; width: 600px; }
.ah-content { max-height: 66vh; overflow-y: auto; }
.ah-filters { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 6px; }
.ah-filters .ui-input:first-child { width: 150px; }
.ah-table { display: flex; flex-direction: column; gap: 3px; }
.ah-row { display: grid; grid-template-columns: 44px 1fr 130px 120px; gap: 8px; align-items: center; padding: 3px 4px; border: 1px solid #3a3326; border-radius: 5px; background: rgba(0, 0, 0, 0.22); }
.ah-info { display: flex; flex-direction: column; font-size: 13px; }
.ah-price { font-family: Consolas, monospace; font-size: 12px; color: #f2c94c; }
.ah-acts { display: flex; gap: 3px; flex-wrap: wrap; justify-content: flex-end; }
.ah-sell-item { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.ah-sell-form { display: flex; flex-direction: column; gap: 4px; }

.guild-win { left: 50%; top: 90px; transform: translateX(-50%); width: 560px; }
.guild-win .win-body { max-height: 72vh; overflow-y: auto; }
.guild-motd { width: 100%; min-height: 50px; box-sizing: border-box; }
.guild-list { display: flex; flex-direction: column; gap: 2px; }
.guild-row { display: grid; grid-template-columns: 1fr 28px 70px 60px 1fr auto; gap: 6px; align-items: center; font-size: 13px; padding: 2px 4px; border-radius: 4px; }
.guild-row:nth-child(odd) { background: rgba(255, 255, 255, 0.03); }
.guild-row.offline { opacity: 0.55; }
.g-name { color: var(--text, #f0ece0); font-weight: bold; }
.g-rank { font-size: 11px; text-transform: capitalize; color: var(--muted); }
.g-rank.leader { color: var(--gold); } .g-rank.officer { color: #7fc4ff; }
.g-acts { display: flex; gap: 2px; flex-wrap: wrap; justify-content: flex-end; }
.guild-foot { display: flex; gap: 6px; align-items: center; margin-top: 8px; flex-wrap: wrap; }

.finder-win { left: 50%; top: 90px; transform: translateX(-50%); width: 580px; }
.finder-content { max-height: 66vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.lfg-form { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.lfg-form .ui-input { flex: 1; min-width: 160px; }
.lfg-roles { display: inline-flex; gap: 6px; }
.lfg-row { display: grid; grid-template-columns: 170px 1fr auto; gap: 8px; align-items: center; padding: 4px; border: 1px solid #3a3326; border-radius: 5px; background: rgba(0, 0, 0, 0.22); font-size: 13px; }
.lfg-kind { font-size: 11px; font-weight: bold; padding: 0 4px; border-radius: 3px; background: #2b4a2b; }
.lfg-kind.lfm { background: #4a3a1e; }
.lfg-acts { display: flex; gap: 3px; }
.signup-raid { padding: 6px; border: 1px solid #3a3326; border-radius: 5px; background: rgba(0, 0, 0, 0.22); }
.signup-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.signup-row { font-size: 12px; padding: 1px 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.05); }
.signup-row.tank { border-left: 3px solid #7fc4ff; } .signup-row.heal { border-left: 3px solid #3fd34f; } .signup-row.dps { border-left: 3px solid #e05a4a; }
.raid-group { padding: 4px 6px; border: 1px dashed #4a4030; border-radius: 5px; min-height: 40px; }
.raid-row { display: flex; gap: 6px; align-items: center; font-size: 13px; padding: 2px 0; }
.raid-row.offline { opacity: 0.55; }
.pf-raid, .pf-group { font-size: 11px; color: var(--gold); margin-top: 2px; }
.dialog-opt.service { color: #7fc4ff; }
.confirm-box { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); z-index: 1999999998; min-width: 260px; max-width: 420px; padding: 14px 16px; pointer-events: auto; text-align: center; }
.confirm-box .confirm-text { margin-bottom: 10px; }
.confirm-box .dialog-buttons { justify-content: center; }

/* ---- D-031 professions: skills + perks (P), crafting, trainer, fishing prompt */
.skills-win { width: 640px; }
.skills-wrap, .craft-wrap { display: flex; gap: 10px; max-height: 60vh; }
.skills-list { width: 210px; overflow-y: auto; padding-right: 4px; }
.skills-group { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 6px 0 3px; }
.skill-row { display: grid; grid-template-columns: 1fr auto auto; gap: 2px 6px; align-items: center; padding: 3px 6px; border-radius: 4px; cursor: pointer; font-size: 13px; }
.skill-row:hover { background: rgba(255, 255, 255, 0.05); }
.skill-row.on { background: rgba(240, 195, 90, 0.12); outline: 1px solid #4a4030; }
.skill-lvl { color: var(--gold); font-weight: 600; }
.skill-pts { color: #3fd34f; font-size: 11px; font-weight: 700; }
.skill-bar { grid-column: 1 / -1; height: 4px; background: rgba(0, 0, 0, 0.5); border-radius: 2px; overflow: hidden; }
.skill-fill { height: 100%; background: linear-gradient(90deg, #b88620, #f0c35a); }
.skills-detail, .craft-detail { flex: 1; overflow-y: auto; padding-right: 4px; }
.skill-title, .craft-title { font-size: 16px; color: var(--gold); margin-bottom: 2px; }
.skill-how { font-size: 12px; margin: 6px 0; color: #d8d0bc; }
.skill-sub { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 10px 0 4px; border-bottom: 1px solid #3a3326; }
.perk-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.perk-row.has .perk-name { color: #3fd34f; }
.perk-pips { display: flex; gap: 2px; width: 46px; }
.pip { width: 10px; height: 10px; border-radius: 50%; border: 1px solid #6a5a3a; background: rgba(0, 0, 0, 0.4); }
.pip.on { background: #f0c35a; border-color: #f0c35a; }
.perk-text { flex: 1; }
.perk-name { font-size: 13px; }
.perk-desc { font-size: 11px; color: var(--muted); }
.perk-add { min-width: 28px; font-weight: 700; color: #3fd34f; }
.milestone { font-size: 12px; color: var(--muted); padding: 1px 0; }
.milestone.reached { color: #3fd34f; }
.craft-win { width: 600px; }
.craft-head { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.craft-list, .trainer-list { width: 250px; overflow-y: auto; padding-right: 4px; }
.trainer-list { width: auto; max-height: 52vh; }
.craft-row, .trainer-row { display: flex; align-items: center; gap: 6px; padding: 2px 4px; border-radius: 4px; cursor: pointer; font-size: 13px; }
.craft-row:hover { background: rgba(255, 255, 255, 0.05); }
.craft-row.on { background: rgba(240, 195, 90, 0.12); outline: 1px solid #4a4030; }
.craft-row.none { opacity: 0.6; }
.islot.craft-icon, .islot.mat-icon { width: 28px; height: 28px; flex: none; }
.islot.craft-big { width: 52px; height: 52px; float: left; margin-right: 8px; }
.craft-name { flex: 1; }
.craft-tag { font-size: 10px; color: #b65cff; border: 1px solid #5a3a7a; border-radius: 3px; padding: 0 3px; }
.d-red { color: #ff5a4a; } .d-orange { color: #ff9a3a; } .d-yellow { color: #ffe04a; } .d-green { color: #3fd34f; } .d-grey { color: #9d9d9d; }
.craft-mw { clear: both; font-size: 12px; color: #b65cff; margin-top: 6px; }
.mat-row { display: flex; align-items: center; gap: 6px; font-size: 13px; padding: 1px 0; }
.mat-row .mat-name { flex: 1; }
.mat-row.short .mat-count { color: #ff5a4a; }
.mat-row.ok .mat-count { color: #3fd34f; }
.craft-buttons { display: flex; gap: 6px; align-items: center; margin: 10px 0 4px; flex-wrap: wrap; }
.craft-n { width: 52px; }
.trainer-win { width: 460px; }
.trainer-row { cursor: default; }
.trainer-row.known { opacity: 0.55; }
.trainer-row.locked .trainer-lvl { color: #ff5a4a; }
.trainer-lvl { font-size: 11px; color: var(--muted); }
.trainer-known { font-size: 11px; color: #3fd34f; }
.trainer-reset { margin-top: 8px; }
.fish-prompt { position: absolute; left: 50%; bottom: 190px; transform: translateX(-50%); padding: 8px 18px; border-radius: 6px; font-size: 15px;
  background: rgba(0, 0, 0, 0.65); border: 1px solid #4a6a8a; color: #cfe6ff; pointer-events: auto; cursor: pointer; text-shadow: 0 1px 2px #000; }
.fish-prompt.bite { border-color: #ffd24a; color: #ffe28a; font-size: 20px; font-weight: 700; animation: bite 0.35s ease-in-out infinite alternate; }
@keyframes bite { from { transform: translateX(-50%) scale(1); } to { transform: translateX(-50%) scale(1.08); } }
