:root{
  /* Additional palette tokens for the panel chrome (new, do not clash with existing) */
  --panel-bg: rgba(20,16,12,.96);
  --panel-bg-2: rgba(28,22,16,.96);
  --gold-trim: #c8a838;      /* bright gold trim/hairline */
  --gold-dark: #6a5a3a;      /* darker structural border */
  --gold-deep: #3a3018;      /* deepest inset border */
  --cream: #d8c9a8;          /* body/dialog text */
  --muted: #9a8a6a;          /* subdued labels, ranks, descriptions */
  --slot-bg: #14100a;        /* empty icon/slot interior */
  --ok-green: #3ee065;       /* completed objective / turn-in */
  --panel-shadow: 0 10px 34px rgba(0,0,0,.72), 0 0 0 1px rgba(0,0,0,.6);
}

/* ============================================================
   1. GENERIC PANEL WINDOW
   Draggable, toggleable leather-and-gold window frame.
   Toggle open/closed by adding/removing the existing .hidden class.
   ============================================================ */

/* Absolutely-positioned floating window; pointer-events on so it
   catches drags/clicks even when the world beneath ignores them. */
.panel{
  position: absolute;
  top: 80px;
  left: 80px;
  min-width: 260px;
  max-width: 420px;
  max-height: 560px;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, rgba(60,48,32,.35), rgba(0,0,0,.25)),
    var(--panel-bg);
  border: 2px solid var(--gold-dark);
  border-radius: 8px;
  box-shadow: var(--panel-shadow);
  color: var(--cream);
  font-family: var(--font-chat), Arial, sans-serif;
  pointer-events: auto;
  user-select: none;
  z-index: 500;
}
/* Inner gold hairline to read as tooled metal trim over the leather */
.panel::before{
  content: "";
  position: absolute;
  inset: 2px;
  border: 1px solid var(--gold-deep);
  border-radius: 6px;
  pointer-events: none;
}

/* Gold serif title bar — also the drag handle */
.panel-header{
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 34px 8px 14px;
  min-height: 34px;
  font-family: var(--font-wow), "Palatino Linotype", serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .3px;
  color: var(--gold);
  text-align: center;
  text-shadow: 0 2px 3px #000, 0 0 6px rgba(0,0,0,.9);
  background:
    linear-gradient(180deg, rgba(90,72,44,.55), rgba(30,22,12,.55));
  border-bottom: 2px solid var(--gold-dark);
  border-radius: 6px 6px 0 0;
  cursor: move;
}
.panel-header::after{
  /* thin bright rule beneath the title band */
  content: "";
  position: absolute;
  left: 6px; right: 6px; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-trim), transparent);
  opacity: .6;
}

/* Round red close button — mirrors the existing .loot-close treatment */
.panel-close{
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-family: var(--font-wow), serif;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  color: #ffdede;
  background: radial-gradient(circle at 50% 35%, #ff5a5a, #b00000 70%);
  border: 1px solid #7a0000;
  border-radius: 50%;
  box-shadow: inset 0 1px 1px rgba(255,255,255,.35), 0 1px 2px rgba(0,0,0,.6);
  text-shadow: 0 1px 1px #000;
  cursor: pointer;
}
.panel-close:hover{
  background: radial-gradient(circle at 50% 35%, #ff7a7a, #d01010 70%);
}
.panel-close:active{ transform: translateY(-50%) scale(.92); }

/* Panel content region */
.panel-body{
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 10px 12px 12px;
}

/* Internal scroll area with hidden scrollbar */
.panel-scroll{
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
  scrollbar-width: none;              /* Firefox */
  -ms-overflow-style: none;           /* legacy Edge */
}
.panel-scroll::-webkit-scrollbar{ width: 0; height: 0; display: none; }

/* ============================================================
   2. SPELLBOOK — scrollable list of learned abilities
   ============================================================ */

.spellbook{
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* One ability row: icon + text stack */
.spell-entry{
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 10px;
  align-items: center;
  padding: 6px;
  background: rgba(0,0,0,.28);
  border: 1px solid var(--gold-deep);
  border-radius: 5px;
}
.spell-entry:hover{ border-color: var(--gold-dark); background: rgba(40,32,20,.4); }

/* 40px gold-framed icon box */
.spell-icon{
  width: 40px;
  height: 40px;
  background: var(--slot-bg) center/cover no-repeat;
  border: 1px solid var(--gold-trim);
  border-radius: 4px;
  box-shadow: inset 0 0 6px rgba(0,0,0,.8);
}
.spell-name{
  font-family: var(--font-wow), serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 1px 2px #000;
}
.spell-rank{
  font-size: 11px;
  color: var(--muted);
  margin-left: 6px;
}
.spell-desc{
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--cream);
  opacity: .82;
  margin-top: 2px;
}

/* Locked ability: desaturated and dimmed with a red requirement line */
.spell-entry.locked{ opacity: .6; filter: grayscale(1) brightness(.75); }
.spell-entry.locked .spell-name{ color: #b7b7b7; }
.spell-req{
  display: block;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 700;
  color: var(--err);
  text-shadow: 0 1px 1px #000;
}

/* ============================================================
   3. TALENTS — column-based talent tree
   ============================================================ */

/* Header showing remaining talent points */
.talent-points{
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  font-family: var(--font-wow), serif;
  font-size: 13px;
  color: var(--cream);
  border-bottom: 1px solid var(--gold-deep);
}
.talent-points b{ color: var(--gold); text-shadow: 0 1px 2px #000; }

/* Tree body: side-by-side columns */
.talents{
  display: flex;
  gap: 18px;
  justify-content: center;
  padding: 4px 2px;
}
.talent-col{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* A single talent node — 44px icon box, states below */
.talent{
  position: relative;
  width: 44px;
  height: 44px;
  background: var(--slot-bg) center/cover no-repeat;
  border: 2px solid var(--gold-deep);
  border-radius: 5px;
  box-shadow: inset 0 0 8px rgba(0,0,0,.85);
  cursor: pointer;
}
/* Learned: solid bright-gold ring */
.talent.learned{
  border-color: var(--gold-trim);
  box-shadow: inset 0 0 6px rgba(0,0,0,.7), 0 0 8px rgba(255,209,0,.4);
}
/* Available to spend a point: pulsing green-gold glow */
.talent.available{
  border-color: #6ecb52;
  animation: talent-glow 1.4s ease-in-out infinite;
}
@keyframes talent-glow{
  0%,100%{ box-shadow: inset 0 0 6px rgba(0,0,0,.7), 0 0 6px rgba(110,203,82,.5); }
  50%    { box-shadow: inset 0 0 6px rgba(0,0,0,.7), 0 0 14px rgba(110,203,82,.9); }
}
/* Locked: dark and desaturated */
.talent.locked{ filter: grayscale(1) brightness(.5); cursor: default; }

/* Corner rank badge, e.g. "1/3" */
.talent-rank{
  position: absolute;
  right: -4px;
  bottom: -5px;
  min-width: 16px;
  padding: 0 3px;
  font-family: var(--font-chat), Arial, sans-serif;
  font-size: 10px;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
  color: var(--gold);
  background: #100c08;
  border: 1px solid var(--gold-trim);
  border-radius: 3px;
  text-shadow: 0 1px 1px #000;
}
.talent.locked .talent-rank{ color: var(--muted); border-color: var(--gold-deep); }

/* Optional connector line drawn between vertically stacked nodes */
.talent-col .talent + .talent::before{
  content: "";
  position: absolute;
  left: 50%;
  top: -22px;
  width: 2px;
  height: 20px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, var(--gold-deep), var(--gold-dark));
}

/* ============================================================
   4. QUEST LOG — objective list + detail pane
   ============================================================ */

.questlog{
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* One tracked quest */
.quest-entry{
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
}
.quest-entry:hover{ background: rgba(40,32,20,.4); border-color: var(--gold-deep); }
.q-name{
  font-family: var(--font-wow), serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 1px 2px #000;
}
/* Objective lines: muted, then white->green when finished */
.q-obj{
  display: block;
  margin: 2px 0 0 8px;
  font-size: 11.5px;
  color: var(--muted);
}
.q-obj.done{ color: var(--ok-green); text-shadow: 0 1px 1px #000; }
.q-obj.done::before{ content: "\2713 "; }   /* leading checkmark */

/* Completed quest gets a gold "(Complete)" tag appended to its title */
.q-entry.complete .q-name::after,
.quest-entry.complete .q-name::after{
  content: " (Complete)";
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
}

/* Selected-quest description / reward area */
.q-detail{
  margin-top: 10px;
  padding: 10px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--cream);
  background: rgba(0,0,0,.32);
  border: 1px solid var(--gold-deep);
  border-radius: 5px;
}

/* ============================================================
   5. BAG / INVENTORY — slot grid + coin readout
   ============================================================ */

.bag{ display: flex; flex-direction: column; gap: 10px; }

/* Fixed-cell grid of item slots */
.bag-grid{
  display: grid;
  grid-template-columns: repeat(auto-fill, 40px);
  gap: 5px;
  justify-content: center;
}

/* Single 40px slot; item art sits inside as a background image */
.bag-slot{
  position: relative;
  width: 40px;
  height: 40px;
  background: var(--slot-bg) center/cover no-repeat;
  border: 1px solid var(--gold-deep);
  border-radius: 4px;
  box-shadow: inset 0 0 6px rgba(0,0,0,.85);
  cursor: pointer;
}
.bag-slot:hover{
  border-color: var(--gold-trim);
  box-shadow: inset 0 0 6px rgba(0,0,0,.7), 0 0 6px rgba(255,209,0,.35);
}

/* Small stack-size number, bottom-right of the slot */
.bag-count{
  position: absolute;
  right: 1px;
  bottom: 0;
  font-family: var(--font-chat), Arial, sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 2px #000, 1px 1px 1px #000;
  pointer-events: none;
}

/* Coin readout: gold / silver / copper amounts */
.gold-amount{
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  font-family: var(--font-chat), Arial, sans-serif;
  font-size: 12px;
  font-weight: 700;
  text-shadow: 0 1px 1px #000;
}
.gold-amount .gold{ color: #ffd100; }
.gold-amount .silver{ color: #d7d7e0; }
.gold-amount .copper{ color: #e08a3c; }
/* Little coin dots after each number */
.gold-amount .gold::after,
.gold-amount .silver::after,
.gold-amount .copper::after{
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  margin-left: 3px;
  border-radius: 50%;
  vertical-align: baseline;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.4);
}
.gold-amount .gold::after{ background: radial-gradient(circle at 35% 30%, #fff2a0, #d9a800); }
.gold-amount .silver::after{ background: radial-gradient(circle at 35% 30%, #ffffff, #9b9bad); }
.gold-amount .copper::after{ background: radial-gradient(circle at 35% 30%, #ffcf9c, #b5591c); }

/* ============================================================
   6. CHARACTER SHEET — paper-doll with stats
   ============================================================ */

.charsheet{
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 10px;
  align-items: start;
}
/* Character name + level header spans the sheet */
.char-title{
  grid-column: 1 / -1;
  text-align: center;
  font-family: var(--font-wow), serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 1px 2px #000;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--gold-deep);
}
.char-title small{ display: block; font-size: 11px; color: var(--cream); opacity: .8; }

/* Left/right equipment columns */
.equip-col{ display: flex; flex-direction: column; gap: 8px; }

/* A labelled equipment slot */
.equip-slot{
  position: relative;
  width: 40px;
  height: 40px;
  background: var(--slot-bg) center/cover no-repeat;
  border: 1px solid var(--gold-dark);
  border-radius: 4px;
  box-shadow: inset 0 0 6px rgba(0,0,0,.85);
  cursor: pointer;
}
.equip-slot:hover{ border-color: var(--gold-trim); }
/* Faint slot label (e.g. "Head") shown when empty via data-label */
.equip-slot[data-label]::after{
  content: attr(data-label);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  pointer-events: none;
}
/* Hide the label once a slot is filled (background image present) */
.equip-slot.filled::after{ content: none; }

/* Center stat list */
.char-stats{
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
}
.char-stats li,
.char-stats .stat-row{
  display: flex;
  justify-content: space-between;
  padding: 2px 4px;
  border-bottom: 1px dotted rgba(106,90,58,.4);
  list-style: none;
}
.char-stats .stat-name{ color: var(--gold); }
.char-stats .stat-val{ color: #fff; font-weight: 700; text-shadow: 0 1px 1px #000; }

/* ============================================================
   7. DIALOG — NPC quest-giver / vendor window (wider panel)
   ============================================================ */

.dialog{ min-width: 380px; max-width: 480px; }

/* NPC name header */
.npc-name{
  font-family: var(--font-wow), serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 1px 2px #000;
  margin-bottom: 8px;
}
/* Flavor / quest body text */
.dialog-text{
  font-family: var(--font-wow), "Palatino Linotype", serif;
  font-size: 13px;
  font-style: italic;
  line-height: 1.5;
  color: var(--cream);
  padding: 8px 10px;
  background: rgba(0,0,0,.28);
  border: 1px solid var(--gold-deep);
  border-radius: 5px;
  margin-bottom: 10px;
}

/* Selectable quest rows keyed by a leading gold glyph */
.quest-avail,
.quest-turnin{
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  font-size: 13px;
  color: var(--cream);
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
}
.quest-avail:hover,
.quest-turnin:hover{ background: rgba(40,32,20,.45); border-color: var(--gold-deep); }
.quest-avail::before{
  content: "!";
  font-family: var(--font-wow), serif;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 1px 2px #000;
}
.quest-turnin::before{
  content: "?";
  font-family: var(--font-wow), serif;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 1px 2px #000;
}

/* Accept / Complete action button — inherits the existing .wow-btn look;
   add .dialog-btn only for dialog-specific spacing */
.dialog-btn{
  margin-top: 12px;
  min-width: 120px;
}

/* Vendor listing */
.vendor-item{
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 5px 6px;
  border: 1px solid var(--gold-deep);
  border-radius: 4px;
  margin-bottom: 4px;
  cursor: pointer;
}
.vendor-item:hover{ border-color: var(--gold-trim); background: rgba(40,32,20,.4); }
.vendor-item .v-icon{
  width: 34px; height: 34px;
  background: var(--slot-bg) center/cover no-repeat;
  border: 1px solid var(--gold-trim);
  border-radius: 4px;
}
.vendor-item .v-name{ font-size: 13px; color: var(--gold); text-shadow: 0 1px 1px #000; }
.vendor-item .v-price{
  font-size: 12px;
  font-weight: 700;
  color: #ffd100;
  text-shadow: 0 1px 1px #000;
  white-space: nowrap;
}

/* ============================================================
   8. MICRO MENU BAR — bottom-right cluster of panel toggles
   ============================================================ */

.micro-bar{
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--panel-bg);
  border: 1px solid var(--gold-dark);
  border-radius: 6px;
  box-shadow: var(--panel-shadow);
  pointer-events: auto;
  z-index: 480;
}

/* Small square hotkey button */
.micro-btn{
  position: relative;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-wow), serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--gold);
  background: linear-gradient(180deg, #2c2416, #14100a);
  border: 1px solid var(--gold-dark);
  border-radius: 4px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
  text-shadow: 0 1px 2px #000;
  cursor: pointer;
}
.micro-btn:hover{
  border-color: var(--gold-trim);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 0 6px rgba(255,209,0,.4);
}
.micro-btn:active{ transform: translateY(1px); }
/* Active/open state — the panel it controls is showing */
.micro-btn.active{
  border-color: var(--gold-trim);
  background: linear-gradient(180deg, #4a3c22, #241c10);
}

/* Small gold readout that lives beside the bag/micro bar */
.gold-tracker{
  position: absolute;
  right: 10px;
  bottom: 46px;
  display: flex;
  gap: 8px;
  padding: 3px 8px;
  font-family: var(--font-chat), Arial, sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: #ffd100;
  background: var(--panel-bg);
  border: 1px solid var(--gold-dark);
  border-radius: 5px;
  box-shadow: var(--panel-shadow);
  text-shadow: 0 1px 1px #000;
  pointer-events: auto;
  z-index: 480;
}

/* ============================================================
   9. TOASTS — XP number, level-up, and ability-learned popups
   ============================================================ */

/* Small floating XP gain number */
.xp-num{
  position: absolute;
  font-family: var(--font-wow), serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 2px 3px #000;
  pointer-events: none;
  animation: xp-float 1.1s ease-out forwards;
}
@keyframes xp-float{
  0%  { opacity: 0; transform: translateY(6px) scale(.9); }
  20% { opacity: 1; }
  100%{ opacity: 0; transform: translateY(-26px) scale(1); }
}

/* Big centered level-up announcement */
.level-toast{
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 6px 24px;
  font-family: var(--font-wow), serif;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: .5px;
  text-align: center;
  color: var(--gold);
  text-shadow: 0 3px 6px #000, 0 0 18px rgba(255,209,0,.55);
  pointer-events: none;
  z-index: 600;
  animation: level-toast 3s ease-out forwards;
}
@keyframes level-toast{
  0%  { opacity: 0; transform: translate(-50%,-50%) scale(.7); }
  15% { opacity: 1; transform: translate(-50%,-50%) scale(1.05); }
  25% { transform: translate(-50%,-50%) scale(1); }
  80% { opacity: 1; }
  100%{ opacity: 0; transform: translate(-50%,-64%) scale(1); }
}

/* Ability-learned toast (slightly smaller, cream subtitle) */
.learn-toast{
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 6px 20px;
  font-family: var(--font-wow), serif;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  color: var(--cream);
  text-shadow: 0 2px 4px #000;
  pointer-events: none;
  z-index: 600;
  animation: learn-toast 2.6s ease-out forwards;
}
.learn-toast b{ color: var(--gold); text-shadow: 0 2px 4px #000, 0 0 12px rgba(255,209,0,.5); }
@keyframes learn-toast{
  0%  { opacity: 0; transform: translate(-50%,-46%); }
  15% { opacity: 1; transform: translate(-50%,-50%); }
  80% { opacity: 1; }
  100%{ opacity: 0; transform: translate(-50%,-54%); }
}