/* Core HUD Stylesheet — fonts injected dynamically by active Mod Pack */
:root {
  --hud-scale: 0.84;
  --panel-scale: 0.78;
  --font-title: 'GameDisplay', 'GameBody', 'GameFallback', Georgia, serif;
  --font-ui: 'GameBody', 'GameSerif', 'GameFallback', Georgia, serif;
}

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  height: 100%;
  background: #000;
  overflow: hidden;
  user-select: none;
  font: 13px/1.38 var(--font-ui);
  color: #c7b377;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: url('../../assets/ui/cursor_hand.webp') 6 2, pointer;
}
body.identify-cursor #game,
body.identify-cursor .ui-panel {
  cursor: crosshair !important;
}
body.repair-cursor #game,
body.repair-cursor .ui-panel,
body.imbue-cursor #game,
body.imbue-cursor .ui-panel {
  cursor: url('../../assets/ui/cursor_buysell.webp') 12 12, pointer !important;
}

#loading {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 50%, #0d0806 0%, #020101 80%);
  z-index: 200;
  opacity: 1;
  transition: opacity 0.28s ease-out;
}
#loading.fade-out {
  opacity: 0;
  pointer-events: none;
}
#transition-flash {
  position: fixed;
  inset: 0;
  z-index: 195;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, rgba(12, 8, 6, 0.72) 0%, rgba(2, 1, 1, 0.92) 85%);
  opacity: 0;
  transition: opacity 0.15s ease-out;
}
#transition-flash.on {
  opacity: 1;
  transition: none;
}
#loading-stage {
  position: relative;
  width: min(96vw, calc(94vh * 800 / 540));
  aspect-ratio: 800 / 540;
  background: radial-gradient(circle at 50% 42%, #1a1612 0%, #090807 72%, #040303 100%);
  border: 1px solid rgba(180, 150, 96, 0.28);
  border-radius: 6px;
  box-shadow: 0 0 90px rgba(0, 0, 0, 0.96), 0 12px 42px rgba(0, 0, 0, 0.92);
}
#loading-header {
  position: absolute;
  top: 5.4%;
  left: 9%;
  right: 9%;
  text-align: center;
  pointer-events: none;
}
#loading-act {
  font: 11.5px/1.2 var(--font-title);
  letter-spacing: 3.5px;
  color: #bda062;
  text-transform: uppercase;
  text-shadow: 0 2px 6px #000, 0 0 12px #000;
}
#loading-area {
  margin-top: 4px;
  font: 700 clamp(20px, 2.9vw, 34px)/1.15 var(--font-title);
  letter-spacing: 3px;
  color: #f2da99;
  text-transform: uppercase;
  text-shadow: 0 0 22px rgba(210, 96, 24, 0.78), 0 3px 8px #000, -1px -1px 0 #000, 1px -1px 0 #000;
}
#loading-plaque {
  position: absolute;
  left: 38.0%;
  width: 24.0%;
  top: 89.1%;
  height: 8.6%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 3px;
  box-sizing: border-box;
  text-align: center;
}
#loading-text {
  margin: 0;
  color: #e4cb8e;
  font: 9.8px/1.15 var(--font-title);
  letter-spacing: 0.25px;
  text-shadow: 0 1px 3px #000;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
#loading-bar-wrap {
  position: relative;
  width: 88%;
  height: 7px;
  background: rgba(16, 14, 12, 0.92);
  border: 1px solid rgba(186, 148, 76, 0.55);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.85) inset;
}
#loading-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #7a140c 0%, #dc351f 60%, #ffbe55 100%);
  box-shadow: 0 0 10px rgba(255, 118, 38, 0.75);
  transition: width 0.1s ease-out;
}

#area-banner {
  position: fixed;
  top: 19.5vh;
  left: 50%;
  transform: translateX(-50%);
  z-index: 14;
  pointer-events: none;
  text-align: center;
  padding: 8px 28px 10px;
  background: radial-gradient(ellipse at 50% 50%, rgba(12, 8, 5, 0.72) 0%, rgba(12, 8, 5, 0) 76%);
}
#area-banner-sub {
  font: 11px/1.2 var(--font-title);
  letter-spacing: 3px;
  color: #c5a86a;
  text-transform: uppercase;
  text-shadow: 0 2px 5px #000, 0 0 8px #000;
}
#area-banner-title {
  margin-top: 3px;
  font: 700 clamp(22px, 2.7vw, 32px)/1.15 var(--font-title);
  letter-spacing: 3.2px;
  color: #f4df9e;
  text-transform: uppercase;
  text-shadow: 0 0 18px rgba(204, 110, 28, 0.7), 0 2px 6px #000, -1px -1px 0 #000, 1px -1px 0 #000;
}
.area-banner-rule {
  width: min(260px, 48vw);
  height: 1px;
  margin: 6px auto 0;
  background: linear-gradient(90deg, transparent, #d6b162 30%, #ffe6a3 50%, #d6b162 70%, transparent);
  box-shadow: 0 0 8px rgba(230, 180, 80, 0.55);
}

/* ---------------- Ground Loot Labels ---------------- */
#loot-labels {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}
.loot-label {
  position: absolute;
  transform: translate(-50%, -100%);
  padding: 2px 9px 2px;
  background: rgba(6, 5, 4, 0.84);
  border: 1px solid rgba(128, 106, 68, 0.55);
  font: 12.5px/1.25 var(--font-title);
  letter-spacing: 0.35px;
  white-space: nowrap;
  text-shadow: 0 1px 2px #000, 0 0 4px #000;
  pointer-events: auto;
  cursor: pointer;
  transition: background 0.08s ease, border-color 0.08s ease;
}
.loot-label:hover,
.loot-label.hovered {
  background: rgba(34, 24, 12, 0.95);
  border-color: #e6c675;
  z-index: 6;
}
.loot-label.q-unique { border-color: rgba(199, 179, 119, 0.85); box-shadow: 0 0 9px rgba(199, 179, 119, 0.32); }
.loot-label.q-set    { border-color: rgba(44, 230, 78, 0.8); box-shadow: 0 0 9px rgba(44, 230, 78, 0.25); }
.loot-label.q-rare   { border-color: rgba(255, 255, 100, 0.78); }
.loot-label.q-magic  { border-color: rgba(112, 144, 255, 0.72); }

/* ---------------- Floating Combat Damage Numbers ---------------- */
#dmg-numbers {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 7;
  overflow: hidden;
}
.dmg-num {
  position: absolute;
  transform: translate(-50%, -50%);
  font: 700 16px/1 var(--font-title);
  letter-spacing: 0.5px;
  white-space: nowrap;
  text-shadow: 0 2px 3px #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
  will-change: transform, left, top, opacity;
}
.dmg-num.phys  { color: #f6efe0; }
.dmg-num.crit  { color: #ffd454; font-size: 23px; text-shadow: 0 0 10px rgba(255, 140, 20, 0.85), 0 2px 4px #000, -1px -1px 0 #000, 1px 1px 0 #000; }
.dmg-num.fire  { color: #ff7838; }
.dmg-num.cold  { color: #6cd6ff; }
.dmg-num.ltng  { color: #fff275; }
.dmg-num.pois  { color: #54e868; }
.dmg-num.hero  { color: #ff4a4a; font-size: 17px; }
.dmg-num.block { color: #d8cfa8; font-size: 13px; font-family: var(--font-ui); }

/* ---------------- HUD Root & Top Nameplates ---------------- */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}
#hud a,
#hud button,
.ui-panel,
.panel-float,
.npc-dialog,
.char-modal-backdrop,
#minimap-wrap,
#skill-popup,
#quick-skill-bar,
#belt-bar,
#belt-tray {
  pointer-events: auto;
}
#hud a { color: #b5a484; }

#top-bar {
  position: fixed;
  top: 10px;
  left: 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  z-index: 11;
}
#stats {
  text-shadow: 0 1px 3px #000, 0 0 5px #000;
  white-space: pre;
  font-size: 12.5px;
  color: #dfd0aa;
}
.top-pills {
  display: flex;
  flex-wrap: wrap;
  max-width: min(760px, calc(100vw - 410px));
  gap: 5px;
  align-items: center;
}
.lang-pill {
  background: rgba(20, 15, 11, 0.88);
  color: #ebd38c;
  border: 1px solid #6e593b;
  padding: 2px 8px;
  font: 11px/1.3 var(--font-ui);
  cursor: pointer;
  letter-spacing: 0.4px;
}
.lang-pill.active-pill {
  background: rgba(44, 31, 14, 0.94);
  color: #ffe294;
  border-color: #d6af5c;
  box-shadow: 0 0 8px rgba(230, 182, 82, 0.25);
}
.lang-pill.muted {
  color: #9c8f78;
  border-color: #4b3f2f;
}
.lang-pill:hover {
  background: #2c2217;
  border-color: #c8a45c;
}

#automap-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 8;
}
#automap-overlay[hidden],
#minimap-wrap[hidden] {
  display: none !important;
}

#top-right-hud {
  position: fixed;
  top: 10px;
  right: 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  z-index: 11;
  pointer-events: none;
}

#gear {
  text-align: right;
  color: #d8c9a3;
  font: 11.5px/1.4 var(--font-ui);
  white-space: pre;
  text-shadow: 0 1px 3px #000, 0 0 5px #000;
  pointer-events: none;
}

/* ---------------- Authentic ARPG Circular Mini-map Frame ---------------- */
#minimap-wrap {
  position: relative;
  width: 194px;
  height: 190px;
  box-sizing: border-box;
  user-select: none;
  pointer-events: auto;
  margin-top: 4px;
}
.mm-circle {
  position: absolute;
  left: 0;
  top: 6px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.9);
  background: #050403;
}
#minimap-canvas {
  display: block;
  width: 180px;
  height: 180px;
  cursor: pointer;
  border-radius: 50%;
}
.mm-actions {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.mm-action-btn {
  position: absolute;
  width: 25px;
  height: 25px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 45% 40%, #292015 0%, #120e09 100%);
  border: 1.8px solid #9e8156;
  color: #dfc794;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.8), inset 0 1px 1px rgba(255, 235, 175, 0.2);
  pointer-events: auto;
  cursor: pointer;
  z-index: 3;
  transition: transform 0.12s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.mm-action-btn:hover {
  border-color: #e5c378;
  color: #fff6d9;
  box-shadow: 0 0 8px rgba(229, 195, 120, 0.5), 0 3px 8px rgba(0, 0, 0, 0.85);
  transform: scale(1.08);
}
.mm-action-btn:active {
  transform: scale(0.94);
}
.mm-action-btn svg {
  width: 13px;
  height: 13px;
  display: block;
  pointer-events: none;
}
.mm-btn-settings { left: 110px; top: 0px; }
.mm-btn-overlay  { left: 142px; top: 21px; }
.mm-btn-zoomin   { left: 164px; top: 57px; }
.mm-btn-zoomout  { left: 166px; top: 98px; }
.mm-btn-hide     { left: 151px; top: 135px; }

.mm-tooltip {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translate(-50%, 100%);
  background: rgba(14, 11, 8, 0.94);
  border: 1px solid #8a6e43;
  color: #ffe28c;
  font: 11px/1.3 var(--font-ui);
  padding: 3px 8px;
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.85);
  z-index: 5;
}

/* Monster / Object Target Bar (backed by hud_monster_hp.webp) */
#target {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 280px;
  max-width: 480px;
  text-align: center;
  background: rgba(10, 8, 6, 0.86);
  border: 1px solid #635139;
  padding: 4px 16px 6px;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.85);
}
#target-name {
  font: 14px/1.25 var(--font-title);
  color: #f3e6c8;
  letter-spacing: 0.9px;
  text-shadow: 0 1px 3px #000;
}
#target-name.champion { color: #7594ff; }
#target-name.unique   { color: #dec078; }
#target-name.minion   { color: #e2cfa2; }
#target-name.npc      { color: #9be884; }
#target-name.waypoint { color: #6cd4ff; }
#target-name.shrine   { color: #ffd96a; }
#target-name.object   { color: #f0dfb4; }

#target .bar {
  position: relative;
  width: 260px;
  height: 12px;
  margin: 4px auto 0;
  background: #1a0c09;
  border: 1px solid #4c3b28;
  overflow: hidden;
}
#target-hp {
  height: 100%;
  width: 100%;
  background: url('../../assets/ui/hud_monster_hp.webp') left center / 260px 12px no-repeat, linear-gradient(90deg, #6e0e08, #b81e12);
}
#target-sub {
  color: #c2b292;
  font-size: 11px;
  margin-top: 3px;
}

/* ---------------- Authentic 1411×208 Bottom HUD Bar ---------------- */
#ui-hud-bar {
  position: fixed;
  left: 50%;
  bottom: 0;
  width: 1411px;
  height: 208px;
  transform: translateX(-50%) scale(var(--hud-scale));
  transform-origin: bottom center;
  pointer-events: none;
  z-index: 12;
}
#ui-hud-bar button,
#ui-hud-bar #xp-bar,
#ui-hud-bar #stamina-bar,
#ui-hud-bar .ui-globe,
#ui-hud-bar #belt-bar,
#ui-hud-bar #belt-tray,
#ui-hud-bar #quick-skill-bar,
#ui-hud-bar #skill-popup {
  pointer-events: auto;
}

/* Animated 16-frame Health & Mana Globes (174×175 per frame, 2784×175 strip) */
@keyframes globeSpin {
  from { background-position-x: 0px; }
  to   { background-position-x: -2784px; }
}

.ui-globe {
  position: absolute;
  top: 32.5px;
  width: 174px;
  height: 175px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 32%, #1d1714, #060504 75%);
  overflow: hidden;
  z-index: 1;
}
.ui-globe.hp { left: 130px; }
.ui-globe.mp { left: 1117px; }

.ui-globe .globe-clip {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 100%;
  overflow: hidden;
  transition: height 0.1s linear;
}
.ui-globe .globe-anim {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 174px;
  height: 175px;
  background-repeat: no-repeat;
  background-size: 2784px 175px;
  animation: globeSpin 1.45s steps(16) infinite;
}
.ui-globe.hp .globe-anim {
  background-image: url('../../assets/ui/globe_health.webp');
  filter: brightness(1.18) saturate(1.12);
}
.ui-globe.mp .globe-anim {
  background-image: url('../../assets/ui/globe_mana.webp');
  filter: brightness(1.22) saturate(1.15);
}
/* Crisp meniscus highlight line along top of liquid level */
.ui-globe .globe-clip::before {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 2px;
  background: rgba(255, 230, 200, 0.55);
  z-index: 2;
}
.ui-globe.mp .globe-clip::before {
  background: rgba(160, 215, 255, 0.6);
}

.hud-frame-overlay {
  position: absolute;
  inset: 0;
  background: url('../../assets/ui/hud_front_panel.webp') 0 0 / 1411px 208px no-repeat;
  z-index: 2;
  pointer-events: none;
}

.globe-val {
  position: absolute;
  top: 10px;
  width: 174px;
  text-align: center;
  font: 13px/1 var(--font-title);
  color: #f4e8cd;
  text-shadow: 0 1px 3px #000, 0 0 6px #000;
  z-index: 4;
  pointer-events: none;
}
.globe-val.hp { left: 130px; }
.globe-val.mp { left: 1117px; }

/* StatUp / SkillUp Alert Buttons (hud_quest_btn.webp: 60×60 × 3 frames) */
.hud-alert-btn {
  position: absolute;
  top: -54px;
  width: 60px;
  height: 60px;
  padding: 0;
  border: 0;
  background: url('../../assets/ui/hud_quest_btn.webp') 0 0 / 180px 60px no-repeat transparent;
  cursor: pointer;
  z-index: 5;
  filter: drop-shadow(0 0 8px rgba(255, 90, 50, 0.65));
}
.hud-alert-btn:hover  { background-position-x: -60px; }
.hud-alert-btn:active { background-position-x: -120px; }
.hud-alert-btn.stat  { left: 186px; }
.hud-alert-btn.quest { left: 254px; filter: drop-shadow(0 0 10px rgba(255, 215, 95, 0.85)); }
.hud-alert-btn.skill { left: 1174px; }
.hud-alert-btn .badge {
  position: absolute;
  right: 2px;
  bottom: 2px;
  min-width: 18px;
  padding: 1px 4px;
  border-radius: 9px;
  background: #7c140c;
  border: 1px solid #f0c86e;
  color: #fff2cc;
  font: bold 11px/1.1 var(--font-ui);
}

/* XP Bar (x=330, y=117, 764×10) */
#xp-bar {
  position: absolute;
  left: 330px;
  top: 117px;
  width: 764px;
  height: 10px;
  background: rgba(8, 7, 5, 0.85);
  z-index: 3;
  overflow: hidden;
}
#xp-fill {
  height: 100%;
  width: 0%;
  background: url('../../assets/ui/hud_exp_bar.webp') left center / 764px 10px no-repeat, linear-gradient(90deg, #987a32, #f2d888);
  transition: width 0.2s ease;
}
#lvl-badge {
  position: absolute;
  left: 492px;
  top: 168px;
  width: 96px;
  text-align: center;
  font: 12.5px/1.2 var(--font-title);
  color: #ebd69c;
  text-shadow: 0 1px 3px #000;
  z-index: 4;
}

/* Run/Walk Button (20×20 × 2 frames) + Stamina Bar (216×8 × 3 frames) */
.hud-run-btn {
  position: absolute;
  left: 342px;
  top: 140px;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  background: url('../../assets/ui/hud_sprint_btn.webp') 0 0 / 40px 20px no-repeat transparent;
  cursor: pointer;
  z-index: 4;
}
.hud-run-btn.running { background-position-x: -20px; }

#stamina-bar {
  position: absolute;
  left: 365.5px;
  top: 146px;
  width: 216px;
  height: 8px;
  background: rgba(12, 9, 6, 0.8);
  z-index: 4;
  overflow: hidden;
}
#stamina-fill {
  height: 100%;
  width: 100%;
  background: url('../../assets/ui/hud_stamina_bar.webp') 0 0 / 648px 8px no-repeat, linear-gradient(90deg, #9e6b1e, #f0b844);
}

/* MiniMenu Buttons (36×36 × 3 frames) */
.hud-mini-btn {
  position: absolute;
  top: 162px;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  background-size: 108px 36px;
  background-repeat: no-repeat;
  background-color: transparent;
  cursor: pointer;
  z-index: 4;
}
.hud-mini-btn:hover { background-position-x: -36px; filter: brightness(1.18); }
.hud-mini-btn:active,
.hud-mini-btn.open { background-position-x: -72px; filter: drop-shadow(0 0 6px #e6be5c); }
.hud-mini-btn.char  { left: 340px; background-image: url('../../assets/ui/hud_btn_char.webp'); }
.hud-mini-btn.skill { left: 382px; background-image: url('../../assets/ui/hud_btn_skill.webp'); }
.hud-mini-btn.inv   { left: 424px; background-image: url('../../assets/ui/hud_btn_inv.webp'); }

/* Left & Right 65×65 Skill Icons */
.ui-skill-btn {
  position: absolute;
  top: 135.5px;
  width: 65px;
  height: 65px;
  padding: 0;
  border: 1px solid rgba(120, 98, 62, 0.55);
  background-color: #120e0a;
  background-repeat: no-repeat;
  cursor: pointer;
  z-index: 4;
}
.ui-skill-btn.left  { left: 611.5px; }
.ui-skill-btn.right { left: 747px; }
.ui-skill-btn:hover { border-color: #ebd082; filter: brightness(1.12); }
.ui-skill-btn.aura-on { box-shadow: 0 0 12px #4cc3ff, inset 0 0 10px rgba(76, 195, 255, 0.55); border-color: #7ad8ff; }

.ui-skill-btn .sk-badge {
  position: absolute;
  right: 3px;
  bottom: 2px;
  font: bold 11px/1 var(--font-ui);
  color: #f5e9c9;
  text-shadow: 0 1px 3px #000, 0 0 4px #000;
  pointer-events: none;
}
.ui-skill-btn .sk-hk {
  position: absolute;
  left: 3px;
  top: 2px;
  font: bold 10px/1 var(--font-ui);
  color: #e6c675;
  text-shadow: 0 1px 3px #000, 0 0 4px #000;
  pointer-events: none;
}

/* ARPG Quick-Cast Skill Bar (keyboard F1–F8 / controller X·Y·B·RB, above center XP bar) */
.hud-quick-skills {
  position: absolute;
  left: 712px;
  top: 52px;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 4px 6px;
  background: linear-gradient(180deg, rgba(18, 14, 10, 0.92), rgba(8, 6, 4, 0.95));
  border: 1px solid rgba(154, 124, 72, 0.72);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.88), inset 0 0 0 1px rgba(235, 200, 118, 0.12);
  z-index: 6;
}
.qsk-slot {
  position: relative;
  width: 50px;
  height: 50px;
  padding: 0;
  border: 1px solid #6b5636;
  background-color: #120e0a;
  background-repeat: no-repeat;
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.08s ease, filter 0.08s ease;
}
.qsk-slot:hover {
  border-color: #f0d07a;
  filter: brightness(1.14);
}
.qsk-slot:active,
.qsk-slot.flash {
  transform: scale(0.94);
  border-color: #fff0b3;
  box-shadow: 0 0 12px rgba(255, 212, 110, 0.7);
}
.qsk-slot.empty {
  border-style: dashed;
  border-color: #4b3d28;
  background: radial-gradient(circle at 50% 50%, #1c1610, #0d0a07);
}
.qsk-slot.oom {
  filter: saturate(0.35) brightness(0.72);
  border-color: #3e4d6b;
}
.qsk-slot.aura-on {
  box-shadow: 0 0 11px #4cc3ff, inset 0 0 9px rgba(76, 195, 255, 0.55);
  border-color: #7ad8ff;
}
.qsk-slot .qsk-key {
  position: absolute;
  left: 2px;
  top: 1px;
  padding: 1px 3px;
  background: rgba(10, 8, 5, 0.78);
  border: 1px solid rgba(190, 155, 88, 0.45);
  font: bold 9.5px/1 var(--font-ui);
  color: #ffd97d;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}
.qsk-slot .qsk-lv {
  position: absolute;
  right: 2px;
  bottom: 1px;
  font: bold 10px/1 var(--font-ui);
  color: #f5e9c9;
  text-shadow: 0 1px 3px #000, 0 0 4px #000;
  pointer-events: none;
}
.qsk-slot .qsk-mana {
  position: absolute;
  left: 3px;
  bottom: 1px;
  font: bold 9.5px/1 var(--font-ui);
  color: #7cc4ff;
  text-shadow: 0 1px 3px #000, 0 0 4px #000;
  pointer-events: none;
}
.qsk-slot.oom .qsk-mana {
  color: #ff6e6e;
}
.qsk-slot .qsk-empty-plus {
  font: 16px/1 var(--font-title);
  color: #7d6a49;
  pointer-events: none;
}

/* Speed-bar Skill Picker Popup above Quick-Cast / Right Skill Button */
#skill-popup {
  position: absolute;
  left: 712px;
  bottom: 162px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 7px 8px;
  background: rgba(12, 9, 7, 0.97);
  border: 1px solid #9c7e4e;
  box-shadow: 0 8px 26px #000;
  z-index: 9;
}
#skill-popup .sk-pop-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font: 11px/1.2 var(--font-title);
  color: #ebd086;
  padding-bottom: 3px;
  border-bottom: 1px solid rgba(138, 112, 70, 0.4);
  white-space: nowrap;
}
#skill-popup .sk-pop-row {
  display: flex;
  gap: 5px;
}
#skill-popup[hidden] { display: none !important; }
.sk-pop-cell {
  position: relative;
  width: 56px;
  height: 56px;
  border: 1px solid #4e3f2a;
  background-color: #14100c;
  background-repeat: no-repeat;
  cursor: pointer;
}
.sk-pop-cell:hover,
.sk-pop-cell.selected {
  border-color: #f0cf78;
  box-shadow: 0 0 8px rgba(240, 207, 120, 0.45);
}

/* Belt Bar (4 slots inside 246×56 at x=835, y=139) + Expandable Multi-Row Belt Tray */
.hud-belt-arrow {
  position: absolute;
  left: 830.5px;
  top: 124px;
  width: 257px;
  height: 14px;
  padding: 0;
  border: 0;
  background: url('../../assets/ui/hud_belt_arrow.webp') center / 257px 14px no-repeat transparent;
  cursor: pointer;
  z-index: 4;
  opacity: 0.85;
}
.hud-belt-arrow:hover { opacity: 1; filter: brightness(1.3); }

.hud-belt-main {
  position: absolute;
  left: 835px;
  top: 139px;
  width: 246px;
  height: 56px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  z-index: 4;
}
.belt-cell {
  position: relative;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.belt-cell:hover {
  background: rgba(235, 205, 130, 0.12);
}
.belt-cell img {
  width: 46px;
  height: 46px;
  object-fit: contain;
  pointer-events: none;
}
.belt-cell .b-key {
  position: absolute;
  left: 4px;
  bottom: 2px;
  font: bold 10.5px/1 var(--font-ui);
  color: #cbb98e;
  text-shadow: 0 1px 2px #000, 0 0 4px #000;
  pointer-events: none;
}

.hud-belt-tray {
  position: absolute;
  left: 835px;
  bottom: 70px;
  width: 246px;
  z-index: 7;
  box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.85);
}
.hud-belt-tray .tray-cap {
  width: 257px;
  height: 8px;
  margin-left: -5.5px;
  background: url('../../assets/ui/hud_belt_cap.webp') 0 0 / 257px 8px no-repeat;
}
.hud-belt-tray .tray-row {
  width: 246px;
  height: 56px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: url('../../assets/ui/hud_belt_row.webp') 0 0 / 246px 56px no-repeat;
}

/* ---------------- 581×754 Authentic Sprite Panels (Inventory, Stash, Vendor, CharSheet, Waypoints) ---------------- */
.ui-panel {
  position: fixed;
  top: 42px;
  width: 581px;
  height: 754px;
  background-size: 581px 754px;
  background-repeat: no-repeat;
  transform: scale(var(--panel-scale));
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.92);
  z-index: 15;
}
.ui-panel.left-dock {
  left: 16px;
  transform-origin: top left;
}
.ui-panel.right-dock {
  right: 16px;
  transform-origin: top right;
}

#inv-panel                 { background-image: url('../../assets/ui/panel_inventory.webp'); }
#stash-panel               { background-image: url('../../assets/ui/panel_stash.webp'); }
#stash-panel.shared,
#stash-panel.tab-shared    { background-image: url('../../assets/ui/panel_stash_shared.webp'); }
#stash-panel.tab-gems      { background-image: url('../../assets/ui/panel_stash_gems.webp'); }
#stash-panel.tab-materials { background-image: url('../../assets/ui/panel_stash_materials.webp'); }
#stash-panel.tab-runes     { background-image: url('../../assets/ui/panel_stash_runes.webp'); }
#vendor-panel              { background-image: url('../../assets/ui/panel_vendor.webp'); }
#vendor-panel.forge { background-image: url('../../assets/ui/panel_vendor_forge.webp'); }
#char-panel     { background-image: url('../../assets/ui/panel_charsheet.webp'); }
#merc-panel     { background-image: url('../../assets/ui/panel_hireling.webp'); }
#waypoint-panel { background-image: url('../../assets/ui/panel_waypoints.webp'); }
#quest-panel    { background-image: url('../../assets/ui/panel_questlog.webp'); }

.ui-panel-title {
  position: absolute;
  left: 45.5px;
  top: 32px;
  width: 486px;
  height: 35.5px;
  display: grid;
  place-items: center;
  font: 18px/1.1 var(--font-title);
  color: #dfca92;
  letter-spacing: 1.2px;
  text-shadow: 0 2px 4px #000;
  pointer-events: none;
}

/* Close X button (42×42 × 3 frames at x=537.5, y=4.5) */
.ui-close-btn {
  position: absolute;
  left: 537.5px;
  top: 4.5px;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  background: url('../../assets/ui/btn_close.webp') 0 0 / 126px 42px no-repeat transparent;
  cursor: pointer;
}
.ui-close-btn:hover  { background-position-x: -42px; }
.ui-close-btn:active { background-position-x: -84px; }

/* Gold readout & button */
.ui-gold-box {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 8px;
  font: 13.5px/1 var(--font-ui);
  color: #f0d788;
  text-shadow: 0 1px 2px #000;
}
.ui-gold-btn {
  position: absolute;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  background: url('../../assets/ui/btn_gold.webp') 0 0 / 96px 24px no-repeat transparent;
  cursor: pointer;
}
.ui-gold-btn:hover    { background-position-x: -72px; filter: brightness(1.08); }
.ui-gold-btn:active   { background-position-x: -24px; }
.ui-gold-btn:disabled { background-position-x: -48px; cursor: default; filter: none; }

/* Weapon Swap I / II Tabs above RHand & LHand */
.wswap-bar {
  position: absolute;
  top: 84px;
  width: 98px;
  height: 28px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
}
.wswap-bar.left  { left: 54px; }
.wswap-bar.right { left: 430px; }
.wswap-tab {
  border: 1px solid #594832;
  background: #1a140e;
  color: #a89674;
  font: bold 12px/1 var(--font-title);
  cursor: pointer;
}
.wswap-tab.active {
  background: #332718;
  border-color: #d9b86c;
  color: #ffe8a3;
}

/* Paperdoll Equipment Slots (exact 0.5x coordinates from playerinventoryoriginallayouthd.json) */
.equip-slot {
  position: absolute;
  display: grid;
  place-items: center;
  cursor: pointer;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}
.equip-slot:hover {
  background-color: rgba(215, 185, 110, 0.12);
  outline: 1px solid rgba(225, 195, 120, 0.45);
}
.equip-slot.occupied {
  background-image: none !important;
  background-color: rgba(22, 34, 58, 0.36);
}
.equip-slot.broken {
  background-color: rgba(145, 24, 18, 0.48);
}
.equip-slot img {
  max-width: 96%;
  max-height: 96%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.8));
}

.equip-slot[data-slot="head"]   { left: 241px;   top: 92.5px;  width: 98px; height: 98px;  background-image: url('../../assets/ui/paperdoll_head.webp'); }
.equip-slot[data-slot="neck"]   { left: 359px;   top: 176.5px; width: 49px; height: 49px;  background-image: url('../../assets/ui/paperdoll_neck.webp'); }
.equip-slot[data-slot="torso"]  { left: 241px;   top: 214px;   width: 98px; height: 147px; background-image: url('../../assets/ui/paperdoll_torso.webp'); }
.equip-slot[data-slot="rhand"]  { left: 54px;    top: 116px;   width: 98px; height: 196px; background-image: url('../../assets/ui/paperdoll_weapon.webp'); }
.equip-slot[data-slot="lhand"]  { left: 430px;   top: 116px;   width: 98px; height: 196px; background-image: url('../../assets/ui/paperdoll_shield.webp'); }
.equip-slot[data-slot="gloves"] { left: 53.5px;  top: 336px;   width: 98px; height: 98px;  background-image: url('../../assets/ui/paperdoll_gloves.webp'); }
.equip-slot[data-slot="ringL"]  { left: 172px;   top: 385px;   width: 49px; height: 49px;  background-image: url('../../assets/ui/paperdoll_ring.webp'); }
.equip-slot[data-slot="belt"]   { left: 241.5px; top: 384.5px; width: 98px; height: 49px;  background-image: url('../../assets/ui/paperdoll_belt.webp'); }
.equip-slot[data-slot="ringR"]  { left: 359px;   top: 385px;   width: 49px; height: 49px;  background-image: url('../../assets/ui/paperdoll_ring.webp'); }
.equip-slot[data-slot="boots"]  { left: 429.5px; top: 336px;   width: 98px; height: 98px;  background-image: url('../../assets/ui/paperdoll_boots.webp'); }

/* Hireling sheet slots (hirelinginventorypanelhd.json ×0.5: head 481,193 196² · torso 481,433 196×294; weapon = left arm frame) */
#merc-panel .equip-slot[data-slot="head"]  { left: 240.5px; top: 96.5px;  width: 98px; height: 98px; }
#merc-panel .equip-slot[data-slot="torso"] { left: 240.5px; top: 216.5px; width: 98px; height: 147px; }
#merc-panel .equip-slot[data-slot="rhand"] { left: 54.5px;  top: 168px;   width: 98px; height: 196px; }
#merc-panel .ms-name, #merc-panel .ms-sub, #merc-panel .ms-hint, #merc-panel .ms-skills,
#merc-panel .ms-label, #merc-panel .ms-val { position: absolute; text-shadow: 0 1px 2px #000; }
#merc-panel .ms-name { text-align: center; font: 16px/1.2 var(--font-title); color: #ebd28e; }
#merc-panel .ms-sub { text-align: center; font: 12.5px/1.2 var(--font-ui); color: #d8c69a; }
#merc-panel .ms-xp { position: absolute; height: 6px; background: url('../../assets/ui/hireling_expbar.webp') 0 0 / 100% 100% no-repeat; }
#merc-panel .ms-xp > div { height: 100%; background: linear-gradient(90deg, #a8822f, #f1cf6f); opacity: 0.9; }
#merc-panel .ms-label { height: 30px; display: flex; align-items: center; gap: 5px; font: 12px/1.15 var(--font-ui); color: #cbb88e; }
#merc-panel .ms-label img { width: 15px; height: 18px; }
#merc-panel .ms-val { height: 30px; display: flex; align-items: center; justify-content: flex-end; font: 13.5px/1.15 var(--font-ui); color: #f0e4c8; }
#merc-panel .ms-skills { height: 34px; display: flex; align-items: center; justify-content: center; text-align: center; font: 12px/1.2 var(--font-ui); color: #cbb88e; }
#merc-panel .ms-skills b { color: #ebd086; }
#merc-panel .ms-hint { text-align: center; font: 11px/1.2 var(--font-ui); color: #9a8b70; }
#merc-panel .ms-empty { position: absolute; left: 60px; top: 470px; width: 460px; text-align: center; font: 14px/1.5 var(--font-ui); color: #cbb88e; text-shadow: 0 1px 2px #000; }
#merc-panel .ms-empty b { color: #ebd086; }

/* Item Grid (cell pitch = 49×49 px at 0.5x!) */
.ui-grid {
  position: absolute;
  cursor: pointer;
}
.ui-grid.inv-grid {
  left: 46.5px;
  top: 448.5px;
  width: 490px;  /* 10 × 49 */
  height: 196px; /* 4 × 49 */
}
.ui-grid.big-grid {
  left: 45.5px;
  top: 116.5px;
  width: 490px;  /* 10 × 49 */
  height: 490px; /* 10 × 49 */
}
.ui-grid.stash-grid {
  left: 44.5px;
  top: 109.5px;
  width: 490px;  /* 10 × 49 */
  height: 490px; /* 10 × 49 */
}

.grid-item {
  position: absolute;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  background: rgba(20, 32, 58, 0.34);
  border: 1px solid rgba(110, 145, 220, 0.25);
  pointer-events: none;
}
.grid-item.unid {
  background: rgba(92, 18, 18, 0.38);
  border-color: rgba(215, 70, 70, 0.45);
}
.grid-item.q-unique { background: rgba(78, 60, 22, 0.38); border-color: rgba(205, 178, 108, 0.48); }
.grid-item.q-set    { background: rgba(18, 68, 28, 0.38); border-color: rgba(50, 220, 82, 0.45); }
.grid-item.q-rare   { background: rgba(76, 72, 16, 0.36); border-color: rgba(240, 230, 88, 0.44); }
.grid-item img {
  max-width: 96%;
  max-height: 96%;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.85));
}
.grid-item .qty-tag {
  position: absolute;
  right: 3px;
  bottom: 1px;
  font: bold 11px/1 var(--font-ui);
  color: #f3e6c8;
  text-shadow: 0 1px 2px #000, 0 0 3px #000;
}

.grid-hover-rect {
  position: absolute;
  pointer-events: none;
  box-sizing: border-box;
  border: 1px solid rgba(120, 230, 130, 0.75);
  background: rgba(60, 175, 75, 0.22);
}
.grid-hover-rect.invalid {
  border-color: rgba(235, 80, 80, 0.85);
  background: rgba(185, 35, 35, 0.28);
}

/* Stash & Vendor Tabs (above 10x10 grid at y=74..82) */
.ui-tabs {
  position: absolute;
  left: 45.5px;
  top: 78px;
  width: 490px;
  height: 36px;
  display: flex;
  gap: 4px;
}
.ui-tab-btn {
  flex: 1;
  background: rgba(24, 18, 13, 0.92);
  border: 1px solid #5c4a33;
  border-bottom-color: #2b2218;
  color: #ab9875;
  font: 12.5px/1 var(--font-title);
  cursor: pointer;
  letter-spacing: 0.5px;
}
.ui-tab-btn:hover { color: #e8d39a; background: #261d14; }
.ui-tab-btn.active {
  background: linear-gradient(180deg, #3c2e1d, #211910);
  border-color: #c8a65a;
  color: #ffe7a0;
}

/* Vendor Repair / Repair All / Refresh (58×58 × 3 frames) */
.vendor-act-btn {
  position: absolute;
  top: 636px;
  width: 58px;
  height: 58px;
  padding: 0;
  border: 0;
  background-size: 174px 58px;
  background-repeat: no-repeat;
  background-color: transparent;
  cursor: pointer;
}
.vendor-act-btn:hover  { background-position-x: -58px; filter: brightness(1.15); }
.vendor-act-btn:active,
.vendor-act-btn.active { background-position-x: -116px; filter: drop-shadow(0 0 6px #f0ca6a); }
.vendor-act-btn.repair     { left: 84.5px;  background-image: url('../../assets/ui/btn_repair.webp'); }
.vendor-act-btn.repair-all { left: 438.5px; background-image: url('../../assets/ui/btn_repairall.webp'); }
.vendor-act-btn.refresh    { left: 438.5px; background-image: url('../../assets/ui/btn_refresh.webp'); }

/* RotW Stash: 5-Tab Bar, Shared Page Arrows, Stackable Slots, Embedded Cube & Gold Modal */
.stash-tab-bar {
  position: absolute;
  left: 41px;
  top: 73px;
  width: 487.5px;
  height: 36px;
  display: grid;
  grid-template-columns: repeat(5, 97.5px);
  z-index: 2;
}
.stash-tab-btn {
  position: relative;
  width: 97.5px;
  height: 36px;
  padding: 0 3px 3px;
  border: 0;
  background: url('../../assets/ui/stash_tabs.webp') 0 0 / 200% 100% no-repeat transparent;
  color: #a99774;
  font: 10.5px/1.1 var(--font-title);
  letter-spacing: 0.2px;
  text-shadow: 0 1px 2px #000, 0 0 4px #000;
  cursor: pointer;
  white-space: nowrap;
  overflow: visible;
}
.stash-tab-btn:hover { color: #ebd8a0; filter: brightness(1.1); }
.stash-tab-btn.active {
  background-position: 100% 0;
  color: #ffe8a3;
  filter: none;
}
.stash-tab-btn.notify::after {
  content: '';
  position: absolute;
  left: 0;
  top: 2px;
  width: 97.5px;
  height: 31px;
  background: url('../../assets/ui/stash_notify.webp') 0 0 / 100% 100% no-repeat;
  pointer-events: none;
  animation: stashNotifyFade 1.5s ease-out forwards;
}
@keyframes stashNotifyFade {
  0%   { opacity: 0.96; }
  65%  { opacity: 0.85; }
  100% { opacity: 0; }
}

.stash-nav {
  position: absolute;
  left: 184.5px;
  top: 605.5px;
  width: 210px;
  height: 46.5px;
}
.stash-arrow {
  position: absolute;
  top: 6.5px;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  background-size: 128px 32px;
  background-repeat: no-repeat;
  background-color: transparent;
  cursor: pointer;
}
.stash-arrow.left  { left: 14.5px;  background-image: url('../../assets/ui/stash_arrow_l.webp'); }
.stash-arrow.right { left: 163.5px; background-image: url('../../assets/ui/stash_arrow_r.webp'); }
.stash-arrow:hover:not(:disabled)  { background-position-x: -32px; }
.stash-arrow:active:not(:disabled) { background-position-x: -64px; }
.stash-arrow:disabled              { background-position-x: -96px; cursor: default; }
.stash-page-label {
  position: absolute;
  left: 47.5px;
  top: 6.5px;
  width: 115px;
  height: 32px;
  display: grid;
  place-items: center;
  font: 12.5px/1 var(--font-title);
  color: #dfca92;
  text-shadow: 0 1px 3px #000;
  pointer-events: none;
}
.stash-sort-btn {
  position: absolute;
  left: 432px;
  top: 678px;
  height: 24px;
}

.stash-adv-surface {
  position: absolute;
  left: 36px;
  top: 109px;
  width: 509px;
  height: 280px;
}
.adv-slot {
  position: absolute;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  cursor: pointer;
}
.adv-slot:hover {
  background: rgba(215, 185, 110, 0.14);
  outline: 1px solid rgba(235, 202, 122, 0.55);
}
.adv-slot img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.88));
}
.adv-slot.empty img {
  opacity: 0.24;
  filter: grayscale(0.6) brightness(0.75);
}
.adv-slot .adv-qty {
  position: absolute;
  right: 3px;
  bottom: 1px;
  font: bold 11px/1 var(--font-ui);
  color: #f3e6c8;
  text-shadow: 0 1px 2px #000, 0 0 3px #000;
  pointer-events: none;
}
.adv-slot.maxed .adv-qty {
  color: #ffd878;
}

.ui-grid.stash-cube-grid {
  left: 215.5px;
  top: 392px;
  width: 147px;  /* 3 × 49 */
  height: 196px; /* 4 × 49 */
  background: transparent;
  border: 0;
}
.stash-cube-transmute {
  position: absolute;
  left: 260px;
  top: 619.5px;
  width: 58px;
  height: 58px;
  padding: 0;
  border: 0;
  background: url('../../assets/ui/btn_transmute.webp') 0 0 / 174px 58px no-repeat transparent;
  cursor: pointer;
}
.stash-cube-transmute:hover  { background-position-x: -116px; filter: brightness(1.08); }
.stash-cube-transmute:active { background-position-x: -58px; }
.stash-cube-transmute.ready  { filter: drop-shadow(0 0 6px rgba(240, 202, 106, 0.65)); }
.stash-cube-cover {
  position: absolute;
  left: 216px;
  top: 393px;
  width: 148px;
  height: 196.5px;
  background: url('../../assets/ui/stash_cube_cover.webp') 0 0 / 100% 100% no-repeat;
}
.stash-cube-hint {
  position: absolute;
  left: 90px;
  top: 595px;
  width: 400px;
  text-align: center;
  font: 11px/1.25 var(--font-ui);
  color: #bda980;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stash-cube-hint.ready { color: #ffe294; }

/* ============================================================================
 * Core Unified Modal & Dialog Design System (100% original CSS, zero external sprites)
 * ============================================================================ */

.ui-modal-dialog,
.gold-modal-card,
.char-modal-box,
.npc-dialog {
  position: relative;
  background: linear-gradient(180deg, rgba(20, 22, 29, 0.97) 0%, rgba(11, 12, 17, 0.98) 100%);
  border: 1px solid rgba(196, 166, 108, 0.32);
  border-radius: 10px;
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.85),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 1px 0 rgba(255, 232, 180, 0.14) inset;
  padding: 24px 28px 26px;
  box-sizing: border-box;
  backdrop-filter: blur(10px);
}

.ui-modal-dialog::before,
.gold-modal-card::before,
.char-modal-box::before,
.npc-dialog::before {
  display: none;
}

.ui-modal-dialog > :not(.ui-modal-close):not(.set-confirm-wrap),
.gold-modal-card > :not(.ui-modal-close):not(.set-confirm-wrap),
.char-modal-box > :not(.ui-modal-close):not(.set-confirm-wrap),
.npc-dialog > :not(.ui-modal-close) {
  position: relative;
  z-index: 1;
}

/* Clean CSS close button (zero external sprites) */
.ui-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: #c7bba3;
  cursor: pointer;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.14s, border-color 0.14s, color 0.14s;
}
.ui-modal-close::before,
.ui-modal-close::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}
.ui-modal-close::before { transform: rotate(45deg); }
.ui-modal-close::after  { transform: rotate(-45deg); }
.ui-modal-close:hover {
  background: rgba(210, 74, 74, 0.24);
  border-color: rgba(235, 110, 110, 0.55);
  color: #fff2e8;
}
.ui-modal-close:active {
  background: rgba(210, 74, 74, 0.38);
}

/* Clean Login Screen card styling */
.realm-auth-box {
  width: min(520px, calc(100vw - 32px));
  padding: 26px 28px 24px;
  background: linear-gradient(165deg, rgba(22, 26, 36, 0.98) 0%, rgba(12, 14, 20, 0.99) 100%);
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 14px;
  box-shadow:
    0 28px 72px rgba(0, 0, 0, 0.88),
    0 1px 0 rgba(255, 255, 255, 0.08) inset;
}
.realm-mod-pass-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 240px;
}
.realm-mod-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 6px;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(74, 222, 128, 0.35);
  color: #bbf7d0;
  font-size: 12px;
  text-align: left;
  word-break: break-all;
}

.ui-modal-dialog,
.gold-modal-card {
  width: min(520px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.ui-modal-title,
.gold-modal-title {
  margin: 0 0 8px;
  width: 100%;
  height: 39px;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 17px/1.15 var(--font-title);
  color: #dfca92;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  text-shadow: 0 2px 4px #000;
  box-sizing: border-box;
  padding: 0 28px;
}

.ui-modal-sub,
.gold-modal-sub {
  font-size: 12.5px;
  line-height: 1.45;
  color: #c2b8a3;
}

.ui-modal-divider {
  width: 100%;
  height: 1px;
  margin: 4px 0 6px;
  background: linear-gradient(90deg, transparent, rgba(196, 166, 108, 0.45), transparent);
}
/* Sculpted stone header bar already separates the title from body content */
.ui-modal-title + .ui-modal-divider,
.gold-modal-title + .ui-modal-divider,
.npc-dialog > h3 + .ui-modal-divider {
  display: none;
}

/* 2. ARPG Table Form (.ui-table-form) — dark charcoal stone slots matching TÚI ĐỒ */
.ui-table-form {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
  box-sizing: border-box;
}

.ui-table-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 12px;
  background: rgba(11, 13, 18, 0.84);
  border: 1px solid #353840;
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.65);
  box-sizing: border-box;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
  text-align: left;
}

.ui-table-row:nth-child(even) {
  background: rgba(15, 17, 22, 0.86);
}

.ui-table-row:hover {
  background: rgba(24, 27, 34, 0.92);
  border-color: #6f5d3e;
  box-shadow: inset 0 0 10px rgba(215, 182, 108, 0.08);
}

.ui-table-row:focus-within,
.ui-table-row.set-focus {
  border-color: #d9b86c;
  background: linear-gradient(90deg, rgba(46, 38, 22, 0.88), rgba(18, 20, 26, 0.92));
  box-shadow: 0 0 10px rgba(217, 184, 108, 0.35), inset 0 0 12px rgba(217, 184, 108, 0.14);
}

.ui-row-label {
  font: 13.5px/1.25 var(--font-title);
  color: #e6dac0;
  letter-spacing: 0.4px;
  text-shadow: 0 1px 2px #000;
}

.ui-row-desc {
  font-size: 11.5px;
  line-height: 1.35;
  color: #969186;
  margin-top: 2px;
}

.ui-row-ctrl {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.ui-row-val {
  font-size: 13px;
  color: #e8dbb8;
  text-align: right;
  text-shadow: 0 1px 2px #000;
}

.ui-cost-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: rgba(8, 9, 12, 0.92);
  border: 1px solid #6b593a;
  color: #ebd086;
  font: 11.5px/1.1 var(--font-title);
  letter-spacing: 0.5px;
}
.ui-cost-badge.free {
  border-color: #46783d;
  color: #b4f29c;
  background: rgba(14, 28, 14, 0.88);
}

/* 3. ARPG Standard Data Table (.ui-data-table) */
.ui-data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
  color: #d4cab4;
  background: rgba(10, 12, 16, 0.88);
  border: 1px solid #3a3d45;
  margin: 6px 0;
  box-sizing: border-box;
}

.ui-data-table thead th {
  position: sticky;
  top: 0;
  padding: 8px 10px;
  font: 12px/1.2 var(--font-title);
  letter-spacing: 1px;
  color: #dfca92;
  text-transform: uppercase;
  background: rgba(18, 20, 24, 0.98);
  border-bottom: 1px solid #594b34;
  text-align: left;
  text-shadow: 0 1px 2px #000;
  z-index: 2;
}

.ui-data-table tbody tr {
  background: rgba(12, 14, 18, 0.7);
  transition: background 0.1s;
}

.ui-data-table tbody tr:nth-child(even) {
  background: rgba(17, 19, 24, 0.82);
}

.ui-data-table tbody tr:hover {
  background: rgba(34, 30, 22, 0.9);
  color: #fff2c4;
}

.ui-data-table tbody td {
  padding: 6px 10px;
  border-bottom: 1px solid rgba(60, 62, 70, 0.45);
  vertical-align: middle;
}

.ui-data-table td.num,
.ui-data-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* 4. ARPG Carved Stone Input Slot */
.ui-input-slot {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(6, 7, 10, 0.95);
  border: 1px solid #45474f;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.9);
  padding: 2px 4px;
  box-sizing: border-box;
}

.ui-input-slot:focus-within {
  border-color: #d9b86c;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.9), 0 0 8px rgba(217, 184, 108, 0.35);
}

.gold-bar-wrap {
  position: relative;
  width: 371px;
  max-width: 100%;
  height: 56px;
  background: url('../../assets/ui/gold_drop_bar.webp') center / 371px 56px no-repeat;
  display: flex;
  align-items: center;
  padding: 0 18px 0 58px;
  box-sizing: border-box;
}
.gold-bar-coin {
  position: absolute;
  left: 16px;
  top: 14px;
  width: 28px;
  height: 28px;
  background: url('../../assets/ui/coins_icon.webp') 0 0 / 28px 28px no-repeat;
  pointer-events: none;
}
.gold-bar-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: none;
  color: #f4df9b;
  font: 18px/1 var(--font-title);
  letter-spacing: 0.8px;
  text-align: right;
  text-shadow: 0 1px 3px #000;
}
.gold-bar-input::-webkit-outer-spin-button,
.gold-bar-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.gold-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
}

.gold-quick-amounts {
  display: flex;
  gap: 5px;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
  margin-top: 2px;
}

.ui-modal-btn,
.ui-small-btn {
  background: linear-gradient(180deg, #211f1d, #121110);
  color: #e6cf91;
  border: 1px solid #6b5839;
  padding: 6px 14px;
  font: 12.5px/1.2 var(--font-title);
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 2px 4px rgba(0, 0, 0, 0.75);
  transition: border-color 0.12s, background 0.12s, color 0.12s, box-shadow 0.12s;
  text-shadow: 0 1px 2px #000;
}
.ui-modal-btn:hover,
.ui-small-btn:hover {
  background: linear-gradient(180deg, #352c1f, #1b1712);
  border-color: #d9b86a;
  color: #fff4cb;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 0 10px rgba(217, 184, 106, 0.35);
}
.ui-modal-btn:disabled,
.ui-small-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: #141518;
  border-color: #3a3c42;
  color: #7c7a74;
  box-shadow: none;
}
.ui-modal-btn.primary {
  background: linear-gradient(180deg, #3a2d1b, #1c160e);
  border-color: #b5924d;
  color: #f6df9e;
}
.ui-modal-btn.primary:not(:disabled):hover {
  background: linear-gradient(180deg, #523d21, #2a1f10);
  border-color: #ebd082;
  color: #fff6d8;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 0 12px rgba(235, 208, 130, 0.45);
}
.ui-modal-btn.danger {
  background: linear-gradient(180deg, #421b16, #1f0d0a);
  border-color: #91382d;
  color: #ffc4ba;
}
.ui-modal-btn.danger:hover {
  background: linear-gradient(180deg, #5c241c, #2e120e);
  border-color: #cf4f3e;
  color: #ffe3de;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 0 12px rgba(207, 79, 62, 0.45);
}

#death-modal {
  z-index: 29;
  background: radial-gradient(ellipse at center, rgba(28, 6, 6, 0.78), rgba(4, 3, 2, 0.92));
}
body.mobile-mode #death-modal {
  z-index: 70;
}
.death-modal-card {
  width: min(540px, calc(100vw - 32px));
  gap: 10px;
}
.death-modal-title {
  color: #e8725e;
  font-size: 18px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.98), 0 0 12px rgba(210, 56, 38, 0.38);
}
.death-modal-sub {
  font-size: 13px;
  line-height: 1.45;
  color: #cfc0a1;
  text-align: center;
}
.death-modal-sub.pvp {
  color: #f09084;
}
.death-table-form {
  margin: 6px 0;
}
.death-modal-actions {
  width: 100%;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.death-modal-btn {
  width: 100%;
  min-height: 38px;
  padding: 8px 14px;
  font: 13.5px/1.25 var(--font-title);
  letter-spacing: 0.5px;
}

/* ---------------- Character Sheet Overlay Fields (panel_charsheet.webp 581×754) ---------------- */
.cs-field {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 13.5px/1.15 var(--font-ui);
  color: #f0e4c8;
  text-shadow: 0 1px 2px #000;
}
.cs-field.blue { color: #7ca0ff; }
.cs-label {
  position: absolute;
  display: flex;
  align-items: center;
  font: 12px/1.15 var(--font-ui);
  color: #cbb88e;
  text-shadow: 0 1px 2px #000;
}
.cs-plus-btn {
  position: absolute;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  background: url('../../assets/ui/btn_levelup.webp') 0 0 / 126px 42px no-repeat transparent;
  background-size: 108px 36px;
  cursor: pointer;
}
.cs-plus-btn:hover  { background-position-x: -36px; filter: brightness(1.18); }
.cs-plus-btn:active { background-position-x: -72px; }

/* ---------------- Waypoints Panel (panel_waypoints.webp 581×754) ---------------- */
.wp-act-tabs { position: absolute; left: 76px; top: 104px; display: flex; gap: 6px; }
.wp-list {
  position: absolute;
  left: 76px;
  top: 138px;
  width: 429px;
  max-height: 560px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.wp-list::-webkit-scrollbar { display: none; }
.wp-entry {
  position: relative;
  flex: 0 0 58px;
  width: 429px;
  height: 58px;
  border: 0;
  padding: 0 22px 0 68px;
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: url('../../assets/ui/wp_btn_active.webp') 0 0 / 858px 58px no-repeat transparent;
  color: #ebd7a0;
  font: 14px/1.2 var(--font-title);
  cursor: pointer;
}
.wp-entry:hover:not(.locked):not(.current) {
  background-position-x: -429px;
  color: #fff2c6;
}
.wp-entry.current {
  background-position-x: -429px;
  color: #7ad4ff;
  cursor: default;
}
.wp-entry.locked {
  background: url('../../assets/ui/wp_btn_disabled.webp') 0 0 / 429px 58px no-repeat transparent;
  color: #7c715e;
  cursor: not-allowed;
}
.wp-entry small {
  font: 11.5px/1.2 var(--font-ui);
  color: #ab9a78;
}

/* ---------------- Skill Panel (Right-dock / Float with HD Skill Icons) ---------------- */
.panel-float {
  position: fixed;
  top: 52px;
  right: 18px;
  width: 360px;
  background: #0b0c0e;
  border: 0;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.95);
  padding: 22px 36px 32px;
  box-sizing: border-box;
  z-index: 16;
}
.panel-float::before {
  content: '';
  position: absolute;
  inset: 0;
  border-style: solid;
  border-width: 66px 50px 46px 50px;
  border-image-source: url('../../assets/ui/panel_bg.webp');
  border-image-slice: 78 66 60 66 fill;
  border-image-repeat: stretch;
  pointer-events: none;
  z-index: 0;
}
.panel-float > * {
  position: relative;
  z-index: 1;
}
.panel-float h3 {
  margin: 0 0 12px;
  height: 39px;
  font: 16px/1.15 var(--font-title);
  color: #dfca92;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-shadow: 0 2px 4px #000;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sk-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 6px;
  margin-bottom: 4px;
  background: rgba(28, 22, 16, 0.75);
  border: 1px solid #433625;
  cursor: pointer;
}
.sk-row:hover { border-color: #9e8150; background: #261e15; }
.sk-row.active { border-color: #e6c36a; background: #2f2416; }
.sk-row-icon {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border: 1px solid #5c4b34;
  background-repeat: no-repeat;
}
.sk-row-body { flex: 1; min-width: 0; }
.sk-row-title { font: 13px/1.2 var(--font-title); color: #f0dfba; }
.sk-row-meta { font-size: 11px; color: #9ab8f5; margin-top: 2px; }
.sk-bind-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 4px;
}
.sk-bind-chip {
  padding: 1px 5px;
  border: 1px solid #57462f;
  background: rgba(16, 12, 8, 0.9);
  color: #b8a582;
  font: bold 10px/1.25 var(--font-ui);
  cursor: pointer;
}
.sk-bind-chip:hover {
  border-color: #d6b162;
  color: #fff0c2;
}
.sk-bind-chip.bound {
  border-color: #f0cb72;
  background: #423015;
  color: #ffe294;
}
.sk-plus {
  width: 28px;
  height: 28px;
  border: 1px solid #c9a153;
  background: #6e1d14;
  color: #fff0c2;
  font: bold 15px/1 var(--font-title);
  cursor: pointer;
}
.sk-plus:hover { background: #94281b; }

/* ---------------- Center NPC Dialogue Menu & Speech Scroll ---------------- */
.npc-dialog {
  position: fixed;
  top: 74px;
  left: 50%;
  transform: translateX(-50%);
  width: min(490px, calc(100vw - 24px));
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
  z-index: 18;
  text-align: center;
}
.npc-dialog h3 {
  margin: 0 0 8px;
  height: 39px;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 18px/1.15 var(--font-title);
  color: #dfca92;
  letter-spacing: 1.2px;
  text-shadow: 0 2px 4px #000;
  text-transform: uppercase;
  padding: 0 24px;
}
.npc-role {
  font-size: 12px;
  color: #b7a47e;
  margin-top: 2px;
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}
.npc-service-note {
  margin: 6px 0 8px;
  padding: 6px 10px;
  background: rgba(16, 30, 16, 0.85);
  border: 1px solid #46783d;
  color: #bdfaa2;
  font-size: 12px;
}
.npc-speech {
  margin: 8px 0 12px;
  padding: 12px 14px;
  background: rgba(8, 10, 14, 0.88);
  border: 1px solid #353840;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.85);
  color: #e8dec6;
  font-size: 13.5px;
  line-height: 1.55;
  text-align: left;
  max-height: 185px;
  overflow-y: auto;
}
.npc-menu {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 0;
  max-height: min(44vh, 320px);
  overflow-y: auto;
  padding: 2px;
}
.npc-menu-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, rgba(24, 26, 32, 0.92), rgba(12, 14, 18, 0.94));
  border: 1px solid #42454e;
  color: #e4d098;
  padding: 7px 14px;
  font: 13.5px/1.25 var(--font-title);
  letter-spacing: 0.6px;
  cursor: pointer;
  text-shadow: 0 1px 2px #000;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 2px 4px rgba(0, 0, 0, 0.6);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  text-align: left;
}
.npc-menu-btn:hover {
  background: linear-gradient(180deg, rgba(46, 38, 22, 0.95), rgba(22, 18, 12, 0.95));
  border-color: #d9b86a;
  color: #fff6d2;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 0 10px rgba(217, 184, 106, 0.32);
}

/* ---------------- Rich Centered ARPG Item Tooltip & Cursor Item ---------------- */
#item-tooltip {
  position: fixed;
  z-index: 30;
  min-width: 190px;
  max-width: 340px;
  padding: 8px 13px 9px;
  background: rgba(5, 4, 4, 0.94);
  border: 1px solid #7d6742;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.95);
  text-align: center;
  font: 12.5px/1.42 var(--font-ui);
  color: #e8dec6;
  pointer-events: none;
}
#item-tooltip .tt-price {
  color: #f2d67d;
  font-size: 12px;
  margin-bottom: 4px;
  padding-bottom: 3px;
  border-bottom: 1px solid #3c3122;
}
#item-tooltip .tt-title {
  font: 14.5px/1.25 var(--font-title);
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}
#item-tooltip .tt-sub {
  font: 12.5px/1.2 var(--font-title);
  margin-bottom: 4px;
}
#item-tooltip .tt-muted { color: #aca089; font-size: 11.5px; }
#item-tooltip .tt-mods  { margin-top: 4px; color: #7090ff; }
#item-tooltip .tt-unid  { margin-top: 5px; color: #e65858; font-weight: bold; }
#item-tooltip .tt-set   { margin-top: 5px; color: #2ce64e; }
#item-tooltip .tt-hint  { margin-top: 5px; color: #9f9278; font-size: 11px; font-style: italic; }

#cursor-item {
  position: fixed;
  z-index: 35;
  pointer-events: none;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.95));
}
#cursor-item img {
  display: block;
}

/* ---------------- Toast, Message & Help Footer ---------------- */
#toast {
  position: fixed;
  bottom: calc(268px * var(--hud-scale));
  left: 50%;
  transform: translateX(-50%);
  color: #ffe28c;
  font: 14.5px/1.3 var(--font-title);
  letter-spacing: 0.7px;
  text-shadow: 0 2px 6px #000, 0 0 8px #000;
  pointer-events: none;
  z-index: 20;
}
#help {
  text-align: right;
  max-width: 340px;
  color: rgba(185, 172, 146, 0.78);
  font-size: 10.5px;
  line-height: 1.35;
  text-shadow: 0 1px 3px #000, 0 0 5px #000;
}
#message {
  position: fixed;
  top: 28%;
  left: 50%;
  transform: translateX(-50%);
  font: 28px/1.3 var(--font-title);
  letter-spacing: 2.5px;
  color: #d43622;
  text-shadow: 0 2px 12px #000, 0 0 18px #000;
  text-align: center;
  white-space: pre-line;
  z-index: 22;
}

/* ---------------- Quest Log Panel (panel_questlog.webp 581×754) ---------------- */
.ql-act-bar {
  position: absolute;
  left: 44px;
  top: 76px;
  width: 493px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  box-sizing: border-box;
  font: 13.5px/1.1 var(--font-title);
  color: #ebd391;
  letter-spacing: 0.8px;
  text-shadow: 0 1px 3px #000;
}
.ql-act-bar span.ql-prog {
  font: 12px/1 var(--font-ui);
  color: #bcae8b;
}
.ql-gem {
  position: absolute;
  width: 30px;
  height: 28px;
  background: url('../../assets/ui/quest_gem.webp') -30px 0 / 60px 28px no-repeat transparent;
  pointer-events: none;
  z-index: 2;
}
.ql-gem.lit {
  background-position-x: 0px;
}
.ql-slot-btn {
  position: absolute;
  width: 86px;
  height: 86px;
  padding: 0;
  border: 0;
  background-size: 258px 86px;
  background-repeat: no-repeat;
  background-color: transparent;
  cursor: pointer;
  z-index: 2;
  transition: filter 0.1s ease;
}
.ql-slot-btn:hover {
  filter: brightness(1.16);
}
.ql-gold-frame {
  position: absolute;
  width: 114px;
  height: 140px;
  background: url('../../assets/ui/quest_goldframe.webp') -114px 0 / 228px 140px no-repeat transparent;
  pointer-events: none;
  z-index: 3;
  filter: drop-shadow(0 0 8px rgba(240, 205, 110, 0.45));
}
.ql-short-desc {
  position: absolute;
  left: 122px;
  top: 439px;
  width: 337px;
  height: 34px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 0 10px;
  box-sizing: border-box;
  font: 14.5px/1.15 var(--font-title);
  color: #f3dc98;
  letter-spacing: 0.6px;
  text-shadow: 0 1px 3px #000;
}
.ql-long-desc {
  position: absolute;
  left: 62px;
  top: 504px;
  width: 457px;
  height: 196px;
  padding: 12px 16px;
  box-sizing: border-box;
  overflow-y: auto;
  font: 13.5px/1.55 var(--font-ui);
  color: #e8dcc2;
  text-shadow: 0 1px 2px #000;
}
.ql-long-desc .ql-sub-obj {
  margin-bottom: 8px;
  padding: 5px 10px;
  background: rgba(38, 30, 16, 0.72);
  border-left: 2px solid #d9b45b;
  color: #ffe294;
  font: 12.5px/1.35 var(--font-title);
}

/* ---------------- Multi-Character Roster & Save Modal ---------------- */
.char-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 3, 2, 0.82);
  display: grid;
  place-items: center;
  z-index: 28;
}
.char-modal-backdrop[hidden] {
  display: none !important;
}
.char-modal-box {
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
}
.char-modal-head {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 39px;
  margin-bottom: 10px;
  padding: 0 28px;
  box-sizing: border-box;
  position: relative;
}
.char-modal-head h3 {
  margin: 0;
  font: 17.5px/1.15 var(--font-title);
  color: #dfca92;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  text-shadow: 0 2px 4px #000;
  text-align: center;
}
.char-roster-list {
  margin: 10px 0;
  max-height: 290px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.char-roster-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 13px;
  background: rgba(12, 14, 18, 0.85);
  border: 1px solid #383b43;
}
.char-roster-card.active {
  background: linear-gradient(90deg, rgba(44, 36, 20, 0.9), rgba(16, 18, 24, 0.92));
  border-color: #c8a454;
  box-shadow: inset 0 0 10px rgba(200, 164, 84, 0.14);
}
.char-card-main {
  min-width: 0;
  flex: 1;
}
.char-card-title {
  font: 15px/1.25 var(--font-title);
  color: #f4e2b0;
}
.char-card-meta {
  font-size: 12px;
  color: #b7a685;
  margin-top: 2px;
}
.char-card-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.char-create-form {
  margin-top: 6px;
  padding-top: 12px;
  border-top: 1px solid #4c3c27;
}
.char-create-title {
  font: 14px/1.2 var(--font-title);
  color: #dfc580;
  margin-bottom: 8px;
}
.char-class-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  margin-bottom: 10px;
}
.char-cls-btn {
  padding: 6px 4px;
  background: rgba(24, 18, 12, 0.9);
  border: 1px solid #57452d;
  color: #c7b48b;
  font: 11.5px/1.2 var(--font-title);
  cursor: pointer;
  text-align: center;
}
.char-cls-btn:hover {
  border-color: #ab8c52;
  color: #f0deb0;
}
.char-cls-btn.selected {
  background: linear-gradient(180deg, #4b381f, #241b0f);
  border-color: #ebd082;
  color: #fff2c2;
}
.char-create-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.char-name-input {
  flex: 1;
  background: rgba(8, 6, 4, 0.94);
  border: 1px solid #6e5839;
  color: #f5e8c8;
  padding: 7px 11px;
  font: 13.5px/1.2 var(--font-ui);
  outline: none;
}
.char-name-input:focus {
  border-color: #e2bf6a;
}
.char-shared-note {
  margin-top: 9px;
  font-size: 11.5px;
  color: #9e9177;
  display: flex;
  justify-content: space-between;
}

/* ---------------- FPS Badge & Graphics / Chrome Diagnostics Modal ---------------- */
.fps-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  background: rgba(10, 8, 6, 0.88);
  border: 1px solid #635035;
  color: #98e68b;
  font: 11.5px/1.15 monospace;
  letter-spacing: 0.2px;
  pointer-events: none;
  white-space: nowrap;
}
.fps-badge.warn { color: #f2cf66; border-color: #8f7230; }
.fps-badge.low  { color: #f58676; border-color: #8d3c32; }

.gfx-gpu-banner {
  margin: 11px 0 10px;
  padding: 9px 12px;
  background: rgba(20, 29, 18, 0.82);
  border: 1px solid #4a7842;
  font-size: 12px;
  line-height: 1.45;
  color: #cfe8c7;
}
.gfx-gpu-banner.warn {
  background: rgba(44, 33, 12, 0.88);
  border-color: #b58932;
  color: #f6df9d;
}
.gfx-gpu-banner.danger {
  background: rgba(52, 16, 14, 0.92);
  border-color: #cc4a3e;
  color: #ffd0ca;
}
.gfx-gpu-title {
  font: 12.5px/1.25 var(--font-title);
  color: #fff2c2;
  margin-bottom: 3px;
}
.gfx-preset-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-bottom: 11px;
}
.gfx-preset-btn {
  padding: 8px 8px;
  background: rgba(14, 16, 21, 0.92);
  border: 1px solid #3c3f48;
  color: #c4b898;
  cursor: pointer;
  text-align: center;
  font: 13px/1.2 var(--font-title);
}
.gfx-preset-btn:hover {
  border-color: #9e834e;
  color: #f5e5ba;
}
.gfx-preset-btn.active {
  background: linear-gradient(180deg, #3c2f1c, #1a1610);
  border-color: #d9b86c;
  color: #fff4c8;
  box-shadow: inset 0 0 10px rgba(217, 184, 108, 0.18);
}
.gfx-preset-sub {
  display: block;
  font: 11px/1.2 var(--font-ui);
  color: #969186;
  margin-top: 3px;
}
.gfx-rows {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}
.gfx-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 11px;
  background: rgba(11, 13, 18, 0.84);
  border: 1px solid #353840;
}
.gfx-row-label {
  font: 13px/1.25 var(--font-title);
  color: #e6dac0;
}
.gfx-row-desc {
  font-size: 11.5px;
  color: #969186;
  margin-top: 1px;
}
.gfx-seg {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.gfx-seg-btn {
  padding: 5px 9px;
  background: rgba(12, 14, 18, 0.95);
  border: 1px solid #40434c;
  color: #b5a98e;
  font: 11.5px/1.15 var(--font-ui);
  cursor: pointer;
}
.gfx-seg-btn:hover {
  border-color: #ae8d4f;
  color: #f3e2b5;
}
.gfx-seg-btn.on {
  background: linear-gradient(180deg, #3d2f1b, #1c160e);
  border-color: #d9b86c;
  color: #fff2c4;
  font-weight: bold;
}
.gfx-tips {
  margin-top: 10px;
  padding: 9px 12px;
  background: rgba(10, 12, 16, 0.92);
  border: 1px solid #383b44;
  font-size: 11.5px;
  line-height: 1.48;
  color: #b0a792;
}
.gfx-tips code {
  background: rgba(255, 224, 140, 0.11);
  border: 1px solid rgba(210, 175, 95, 0.28);
  padding: 1px 5px;
  color: #f6df98;
  font-family: monospace;
  user-select: all;
}

/* ---------------- Co-op Party Frames, Overhead Ally Nameplates & Lobby Modal ---------------- */
.lang-pill.coop-online {
  border-color: #5ca653;
  color: #b7f5a8;
  background: rgba(18, 36, 16, 0.9);
}

#party-labels {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}
.party-ally-label {
  position: absolute;
  left: 0;
  top: 0;
  padding: 2px 8px 4px;
  background: rgba(7, 14, 7, 0.84);
  border: 1px solid rgba(108, 198, 96, 0.65);
  border-radius: 2px;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}
.party-ally-label .pal-name {
  font: 11.5px/1.2 var(--font-title);
  color: #9ff08e;
  letter-spacing: 0.3px;
  text-shadow: 0 1px 2px #000;
}
.party-ally-label .pal-name span {
  font-family: var(--font-ui);
  color: #d7e8c8;
  font-size: 10.5px;
}
.party-ally-label .pal-bar {
  width: 68px;
  height: 4px;
  margin: 2px auto 0;
  background: #24100d;
  border: 1px solid #483825;
}
.party-ally-label .pal-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #3ba832, #7ce868);
}

#party-frames {
  position: fixed;
  top: 134px;
  left: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 8;
}
.party-frame-card {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 196px;
  padding: 5px 9px;
  background: rgba(12, 10, 8, 0.88);
  border: 1px solid #5d7849;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.82);
}
.party-frame-badge {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #2b3c22, #151f10);
  border: 1px solid #78b368;
  font: 12px/1 var(--font-title);
  color: #d6f7cb;
  flex-shrink: 0;
}
.party-frame-body {
  flex: 1;
  min-width: 0;
}
.party-frame-title {
  font: 12px/1.2 var(--font-title);
  color: #b7f5a8;
  display: flex;
  justify-content: space-between;
  gap: 6px;
}
.party-frame-hp {
  height: 5px;
  margin: 3px 0 2px;
  background: #26100d;
  border: 1px solid #4f3d28;
}
.party-frame-hp > div {
  height: 100%;
  background: linear-gradient(90deg, #359c2d, #79e668);
}
.party-frame-sub {
  font-size: 10.5px;
  color: #b8ad92;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}
.coop-room-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
}
.coop-pill-tag {
  display: inline-block;
  padding: 2px 7px;
  font-size: 11px;
  border: 1px solid #59854a;
  background: rgba(24, 45, 20, 0.85);
  color: #b5f2a6;
}
.coop-pill-tag.ws {
  border-color: #9e8238;
  background: rgba(45, 35, 14, 0.85);
  color: #f5df9b;
}

/* ---------------- Online Realm Server Realm Login / Register Modal ---------------- */
.realm-auth-box {
  max-width: 560px;
}
.realm-auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 10px 0 12px;
}
.realm-auth-form {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.realm-field-label {
  display: block;
  font: 12px/1.2 var(--font-title);
  color: #e6cf91;
  margin-bottom: 4px;
}
.realm-auth-err {
  padding: 7px 10px;
  background: rgba(68, 18, 15, 0.9);
  border: 1px solid #c64b3e;
  color: #ffd3cc;
  font-size: 12px;
}
.realm-auth-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.realm-primary-btn {
  flex: 1;
  padding: 9px 14px;
  background: linear-gradient(180deg, #5c411d, #2b1d0c);
  border: 1px solid #e3be68;
  color: #fff3c4;
  font: 13.5px/1.2 var(--font-title);
  letter-spacing: 0.5px;
  cursor: pointer;
}
.realm-primary-btn:hover {
  background: linear-gradient(180deg, #735224, #382610);
  border-color: #ffe394;
}
.realm-divider {
  margin: 12px 0 10px;
  border-top: 1px solid #473824;
  padding-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: #a99a7c;
}

/* ---------------- M9 MMO Social: Hostile Nameplates, 3D Speech Bubbles, Chat Dock, Inspect & Trade ---------------- */
.party-ally-label.hostile {
  background: rgba(28, 7, 7, 0.9);
  border-color: rgba(220, 68, 54, 0.85);
}
.party-ally-label.hostile .pal-name {
  color: #ff8275;
}
.party-ally-label.hostile .pal-bar i {
  background: linear-gradient(90deg, #9e1b12, #eb4638);
}
.party-ally-label.party-member {
  border-color: rgba(118, 232, 104, 0.85);
}
#target-name.hostile {
  color: #ff6e60;
}

#speech-bubbles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 6;
}
.speech-bubble {
  position: absolute;
  left: 0;
  top: 0;
  max-width: 260px;
  padding: 5px 10px;
  background: rgba(12, 10, 8, 0.92);
  border: 1px solid #b89854;
  border-radius: 4px;
  color: #f6ebd0;
  font: 12px/1.35 var(--font-ui);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.88);
  white-space: normal;
  word-break: break-word;
  text-align: center;
}
.speech-bubble::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%);
  border-width: 6px 6px 0 6px;
  border-style: solid;
  border-color: #b89854 transparent transparent transparent;
}
.speech-bubble.ch-party { border-color: #6bc960; }
.speech-bubble.ch-party::after { border-top-color: #6bc960; }
.speech-bubble.ch-zone  { border-color: #6ab4e8; }
.speech-bubble.ch-zone::after  { border-top-color: #6ab4e8; }
.speech-bubble .sb-author {
  font-family: var(--font-title);
  color: #ebd086;
}
.speech-bubble .sb-item { font-weight: bold; color: #789cff; }
.speech-bubble .sb-item.q-rare      { color: #f6e266; }
.speech-bubble .sb-item.q-unique    { color: #d6b26e; }
.speech-bubble .sb-item.q-set       { color: #54e854; }
.speech-bubble .sb-item.q-normal,
.speech-bubble .sb-item.q-superior  { color: #f2ead8; }

#chat-dock {
  position: fixed;
  left: 14px;
  bottom: calc(272px * var(--hud-scale) + 12px);
  width: min(392px, calc(100vw - 28px));
  display: flex;
  flex-direction: column;
  gap: 7px;
  z-index: 14;
  pointer-events: none;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
#chat-dock .chat-invite-banner,
#chat-dock .chat-log,
#chat-dock .chat-bar,
#chat-dock .chat-toggle-pill {
  pointer-events: auto;
}
.chat-invite-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(24, 18, 10, 0.94);
  border: 1px solid #dcb75e;
  border-radius: 4px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.85);
  font-size: 12px;
  color: #f7e8be;
  box-sizing: border-box;
}
.chat-invite-banner > span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-invite-banner > div {
  flex-shrink: 0;
}
.chat-log {
  max-height: 120px;
  overflow-y: auto;
  padding: 7px 10px;
  background: rgba(8, 7, 5, 0.74);
  border: 1px solid rgba(122, 98, 58, 0.5);
  border-radius: 4px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12.5px;
  line-height: 1.38;
  color: #f2ead8;
  text-shadow: 0 1px 2px #000;
}
.chat-log:empty {
  display: none;
}
.chat-msg {
  word-break: break-word;
}
.chat-msg .ch-tag,
.chat-line .ch-tag {
  font-weight: 700;
  font-size: 12px;
  margin-right: 4px;
}
.chat-msg.ch-world .ch-tag,
.chat-line.ch-world .ch-tag { color: #ebd086; }
.chat-msg.ch-zone .ch-tag,
.chat-line.ch-zone .ch-tag  { color: #7ac4ff; }
.chat-msg.ch-party .ch-tag,
.chat-line.ch-party .ch-tag { color: #84ed78; }
.chat-msg.ch-whisper, .chat-line.ch-whisper { color: #e6b3ff; }
.chat-msg.ch-whisper .ch-tag, .chat-line.ch-whisper .ch-tag { color: #d38cff; }
.chat-msg .ch-author,
.chat-line .ch-sender {
  font-weight: 600;
  color: #f0dfc0;
}
.chat-item-link {
  display: inline-block;
  padding: 0 4px;
  margin-left: 3px;
  border-radius: 3px;
  background: rgba(25, 32, 48, 0.78);
  border: 1px solid rgba(145, 175, 240, 0.45);
  color: #84a4ff;
  font-weight: 600;
  cursor: pointer;
}
.chat-item-link:hover { filter: brightness(1.22); }
.chat-item-link.q-rare   { color: #f8e468; border-color: rgba(248, 228, 104, 0.5); }
.chat-item-link.q-unique { color: #dfb86e; border-color: rgba(223, 184, 110, 0.55); }
.chat-item-link.q-set    { color: #5ce85c; border-color: rgba(92, 232, 92, 0.5); }
.chat-item-link.q-normal,
.chat-item-link.q-superior { color: #f2ead8; border-color: rgba(220, 208, 185, 0.4); }

.chat-bar {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 8px;
  background: rgba(12, 9, 6, 0.94);
  border: 1px solid #8a6f44;
  border-radius: 4px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.88);
}
.chat-bar[hidden] { display: none !important; }
.chat-bar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.chat-ch-tabs {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.chat-ch-btn {
  padding: 4px 11px;
  border-radius: 3px;
  background: linear-gradient(180deg, rgba(36, 28, 18, 0.94) 0%, rgba(20, 15, 10, 0.96) 100%);
  border: 1px solid #59462d;
  box-shadow: inset 0 1px 0 rgba(235, 208, 134, 0.08), 0 1px 2px rgba(0, 0, 0, 0.65);
  color: #bda982;
  font: 600 12px/1.25 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease, filter 0.12s ease;
}
.chat-ch-btn:hover {
  border-color: #9c7e4c;
  color: #f3e0b2;
}
.chat-ch-btn.active {
  background: linear-gradient(180deg, rgba(84, 62, 28, 0.96) 0%, rgba(52, 38, 17, 0.96) 100%);
  border-color: #e6c56e;
  box-shadow: inset 0 1px 0 rgba(255, 238, 180, 0.35), 0 1px 4px rgba(0, 0, 0, 0.72);
  color: #fff2c4;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}
.chat-attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: 3px;
  background: rgba(30, 42, 68, 0.86);
  border: 1px solid #7598ec;
  color: #bfd4ff;
  font-size: 11px;
  max-width: 165px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-attach-chip button {
  background: none;
  border: none;
  color: inherit;
  padding: 0;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}
.chat-bar-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
}
.chat-input {
  flex: 1;
  min-width: 0;
  height: 30px;
  box-sizing: border-box;
  padding: 0 10px;
  background: rgba(5, 4, 3, 0.95);
  border: 1px solid #695335;
  border-radius: 3px;
  color: #f6ebd0;
  font: 12.5px/1.2 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.chat-input::placeholder {
  color: #8f7f64;
}
.chat-input:focus {
  border-color: #e5c36b;
  box-shadow: 0 0 0 1px rgba(229, 195, 107, 0.22);
}
.chat-send-btn {
  flex: 0 0 38px;
  height: 30px;
  box-sizing: border-box;
  padding: 0;
  border-radius: 3px;
  background: linear-gradient(180deg, rgba(84, 62, 28, 0.96) 0%, rgba(50, 36, 16, 0.96) 100%);
  border: 1px solid #c9a658;
  box-shadow: inset 0 1px 0 rgba(255, 238, 180, 0.32), 0 1px 3px rgba(0, 0, 0, 0.7);
  color: #fff2c4;
  font-size: 13px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: filter 0.12s ease, border-color 0.12s ease;
}
.chat-send-btn:hover {
  border-color: #e6c56e;
  filter: brightness(1.12);
}
.chat-send-btn:active {
  filter: brightness(0.92);
}
.chat-toggle-pill {
  align-self: flex-start;
  padding: 4px 10px;
  border-radius: 3px;
  background: rgba(12, 9, 6, 0.78);
  border: 1px solid #5d4a30;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.65);
  color: #cbb890;
  font: 600 11.5px/1.2 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease;
}
.chat-toggle-pill:hover {
  border-color: #cba659;
  color: #fff0be;
}

/* Inspect Paperdoll & Atomic Direct Trade Left-Docked Panels (581×754) */
#inspect-panel {
  background-image: url('../../assets/ui/panel_inventory.webp');
}
.inspect-info-box {
  position: absolute;
  left: 46px;
  top: 448px;
  width: 490px;
  height: 248px;
  padding: 12px 14px;
  box-sizing: border-box;
  background: linear-gradient(180deg, rgba(16, 12, 8, 0.96), rgba(9, 7, 5, 0.98));
  border: 1px solid #6e5737;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #e8d8b4;
  font-size: 12.5px;
}
.inspect-gear-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  font-size: 11.5px;
  max-height: 132px;
  overflow-y: auto;
}

#trade-panel {
  background-image: url('../../assets/ui/panel_bg.webp');
  box-sizing: border-box;
}
.trade-body {
  position: absolute;
  left: 34px;
  top: 78px;
  width: 513px;
  height: 646px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.trade-half {
  flex: 1;
  padding: 10px 14px;
  background: rgba(10, 12, 16, 0.86);
  border: 1px solid #3a3d45;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.trade-half.locked {
  border-color: #67b85c;
  box-shadow: inset 0 0 16px rgba(103, 184, 92, 0.16);
}
.trade-half-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font: 13.5px/1.2 var(--font-title);
  color: #ebd086;
}
.trade-half-content {
  display: flex;
  gap: 16px;
  align-items: center;
}
.ui-grid.trade-grid {
  position: relative;
  width: 196px;  /* 4 × 49 */
  height: 196px; /* 4 × 49 */
  background-color: rgba(8, 6, 4, 0.95);
  background-image:
    linear-gradient(to right, rgba(135, 108, 65, 0.28) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(135, 108, 65, 0.28) 1px, transparent 1px);
  background-size: 49px 49px;
  border: 1px solid #785f3b;
  flex-shrink: 0;
}
.trade-side-controls {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  color: #cbb994;
}
.grid-item.trade-offered {
  outline: 2px solid #f0cb69;
  background: rgba(86, 66, 20, 0.52);
}
.grid-item .offered-tag {
  position: absolute;
  left: 2px;
  top: 2px;
  padding: 0 4px;
  background: rgba(20, 15, 6, 0.9);
  border: 1px solid #e6c365;
  color: #ffe89c;
  font: bold 9.5px/1.2 var(--font-ui);
  pointer-events: none;
}

/* Socket indicator on bag / stash items: filled = used, hollow = empty */
.grid-item .socket-tag { position: absolute; left: 2px; bottom: 1px; font-size: 9px; line-height: 1; letter-spacing: 1px; color: #cfd6e6; text-shadow: 0 0 3px #000, 0 0 3px #000; pointer-events: none; }

/* Quick-sort button in the inventory panel (below the 10×4 grid, right of gold) */
.sort-btn { position: absolute; left: 400px; top: 673px; height: 24px; }

.belt-cell { position: relative; }
.belt-cell .qty-tag {
  position: absolute;
  right: 3px;
  bottom: 1px;
  font: bold 11px/1 var(--font-ui);
  color: #f3e6c8;
  text-shadow: 0 1px 2px #000, 0 0 3px #000;
  pointer-events: none;
}

/* Gamepad compare mode: new item | equipped item side by side */
#item-tooltip.cmp { display: flex; gap: 14px; max-width: 720px; align-items: flex-start; }
#item-tooltip.cmp .tt-col { min-width: 180px; }
#item-tooltip.cmp .tt-equipped { border-left: 1px solid #5b4a30; padding-left: 14px; }

/* ---- Worlds modal: tabs + leaderboard ---- */
.worlds-tabs { display: flex; gap: 6px; margin: 10px 0 0; }
.worlds-tab {
  flex: 1; padding: 7px 10px; cursor: pointer;
  font: 13.5px/1.2 var(--font-title); color: #b5a98e;
  background: rgba(14, 16, 21, 0.88); border: 1px solid #3c3f48;
}
.worlds-tab.on { color: #f4e2b0; border-color: #c8a454; background: linear-gradient(180deg, rgba(52, 40, 22, 0.95), rgba(20, 18, 14, 0.95)); }
.lb-chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 10px 0 0; }
.lb-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; cursor: pointer;
  font: 12px/1.2 var(--font-title); color: #b5a98e; text-transform: capitalize;
  background: rgba(14, 16, 21, 0.88); border: 1px solid #3c3f48; border-radius: 11px;
}
.lb-chip.on { color: #fff0bd; border-color: #c8a454; }
.lb-ico { width: 16px; height: 16px; background-size: cover; background-position: center; border-radius: 50%; }
.lb-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; color: #d4cab4; background: rgba(10, 12, 16, 0.88); border: 1px solid #3a3d45; margin: 8px 0; }
.lb-table th { position: sticky; top: 0; text-align: left; padding: 7px 10px; color: #dfca92; background: rgba(18, 20, 24, 0.98); font: 12px/1.2 var(--font-title); letter-spacing: 0.8px; text-transform: uppercase; border-bottom: 1px solid #594b34; text-shadow: 0 1px 2px #000; z-index: 2; }
.lb-table td { padding: 6px 10px; border-bottom: 1px solid rgba(60, 62, 70, 0.45); text-transform: capitalize; vertical-align: middle; }
.lb-table tr:nth-child(even) td { background: rgba(17, 19, 24, 0.72); }
.lb-table tr:hover td { background: rgba(38, 32, 22, 0.9); color: #fff2c4; }
.lb-table td.rk, .lb-table td.num, .lb-table th:nth-child(5), .lb-table th:nth-child(6) { text-align: right; }
.lb-table td.acc { color: #8fd4ff; text-transform: none; }
.lb-table tr.me td { background: rgba(217, 181, 98, 0.22); color: #fff5ce; font-weight: bold; border-color: rgba(217, 181, 98, 0.4); }
.lb-tag { font-size: 10.5px; padding: 0 5px; color: #9f9278; border: 1px solid #5b4a33; border-radius: 8px; text-transform: none; }
.lb-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; font-size: 12px; color: #9f9278; }
.lb-foot .ui-small-btn[disabled] { opacity: 0.4; cursor: default; }

/* Horadric Cube (3x4 grid, cube.js) */
#cube-panel { background-image: url('../../assets/ui/panel_bg.webp'); box-sizing: border-box; }
.cube-body { position: absolute; left: 34px; top: 78px; width: 513px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.ui-grid.cube-grid {
  position: relative; width: 147px; height: 196px; /* 3 x 4 cells of 49px */
  background-color: rgba(8, 10, 14, 0.92);
  background-image: linear-gradient(to right, rgba(110, 115, 128, 0.25) 1px, transparent 1px), linear-gradient(to bottom, rgba(110, 115, 128, 0.25) 1px, transparent 1px);
  background-size: 49px 49px; border: 1px solid #484b54; flex-shrink: 0;
}
.cube-info { width: 100%; min-height: 54px; font-size: 12.5px; line-height: 1.4; color: #b8aa8d; text-align: center; }
.cube-info.ready { color: #d9c98a; }

.ql-acts { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.ql-act-town { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ql-act-tab { background: rgba(20, 15, 10, 0.8); border: 1px solid #57442b; color: #b8aa8d; font: inherit; font-size: 12px; padding: 2px 9px; min-width: 28px; text-align: center; white-space: nowrap; cursor: pointer; }
.ql-act-tab.on { border-color: #cfa858; color: #fff0bd; }

@media (max-width: 640px), (max-height: 460px) {
  .ui-modal-dialog,
  .gold-modal-card,
  .char-modal-box,
  .npc-dialog {
    padding: 16px 28px 24px;
  }
  .ui-modal-dialog::before,
  .gold-modal-card::before,
  .char-modal-box::before,
  .npc-dialog::before {
    border-width: 50px 38px 36px 38px;
  }
  .ui-modal-title,
  .gold-modal-title,
  .char-modal-head,
  .npc-dialog h3 {
    height: 30px;
    font-size: 14.5px;
    margin-bottom: 6px;
  }
  .ui-modal-close {
    width: 28px;
    height: 28px;
    background-size: 84px 28px;
  }
  .ui-modal-close:hover  { background-position-x: -28px; }
  .ui-modal-close:active { background-position-x: -56px; }
}
