/* Wulin Saga — HUD overlay (client/js/ui/hud.js). Owned by ui-hud. Contract: docs/ARCHITECTURE.md §7.5.
   Zones: player frame top-left · target frame top-centre · buffs + hotbar bottom-centre ·
   menu bottom-right · EXP bar bottom full width · full-screen vignette / death / banners. */

:root {
  /* Reserved space other panels may read (e.g. chat / party frames): */
  --hud-exp-h: 15px;          /* EXP bar height at the very bottom */
  --hud-bottom-reserved: 84px; /* EXP bar + hotbar/menu row */
  --hud-font-callig: 'Charm', 'Kanit', 'Leelawadee UI', Tahoma, serif;
}

/* Full-screen root must not catch the pointer (style.css: `.layer > * { pointer-events: auto }`). */
#ui-root .hud-root,
.hud-root {
  position: fixed;
  inset: 0;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  color: var(--c-text, #f3e6c8);
  font-family: 'Kanit', 'Leelawadee UI', Tahoma, sans-serif;
  overflow: hidden;
}
.hud-root.no-self .hud-player,
.hud-root.no-self .hud-bottom,
.hud-root.no-self .hud-menu,
.hud-root.no-self .hud-exp { visibility: hidden; }

/* ------------------------------------------------------------------ lacquer plate */
.hud-plate {
  position: absolute;
  box-sizing: border-box;
  pointer-events: auto;
  border-radius: 7px;
  border: 1px solid #140904;
  background:
    radial-gradient(120% 130% at 50% 0%, rgba(255, 214, 140, 0.10), rgba(255, 214, 140, 0) 60%),
    linear-gradient(180deg, rgba(62, 34, 20, 0.95), rgba(24, 13, 8, 0.95));
  box-shadow:
    inset 0 0 0 1px rgba(232, 196, 106, 0.55),
    inset 0 0 0 3px rgba(22, 10, 5, 0.92),
    inset 0 0 0 4px rgba(139, 90, 43, 0.6),
    0 6px 18px rgba(0, 0, 0, 0.55);
}
.hud-plate::before {
  content: '';
  position: absolute;
  inset: 5px;
  pointer-events: none;
  border-radius: 3px;
  --o: var(--c-gold, #e8c46a);
  background:
    linear-gradient(var(--o), var(--o)) left top / 9px 2px no-repeat,
    linear-gradient(var(--o), var(--o)) left top / 2px 9px no-repeat,
    linear-gradient(var(--o), var(--o)) right top / 9px 2px no-repeat,
    linear-gradient(var(--o), var(--o)) right top / 2px 9px no-repeat,
    linear-gradient(var(--o), var(--o)) left bottom / 9px 2px no-repeat,
    linear-gradient(var(--o), var(--o)) left bottom / 2px 9px no-repeat,
    linear-gradient(var(--o), var(--o)) right bottom / 9px 2px no-repeat,
    linear-gradient(var(--o), var(--o)) right bottom / 2px 9px no-repeat;
  opacity: 0.8;
}

/* ------------------------------------------------------------------ bars */
.hud-root .hud-bar {
  position: relative;
  width: auto;
  height: 14px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 3px;
  overflow: hidden;
  background: linear-gradient(180deg, #110604, #2a1410);
  box-shadow: 0 0 0 1px #0b0503, inset 0 1px 3px rgba(0, 0, 0, 0.85), 0 1px 0 rgba(255, 220, 160, 0.14);
}
.hud-root .hud-bar .hud-bar-drain,
.hud-root .hud-bar .hud-bar-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  height: auto;
  width: 0;
  margin: 0;
  border-radius: 0;
}
.hud-root .hud-bar .hud-bar-fill::after { display: none; }
.hud-root .hud-bar .hud-bar-drain { background: linear-gradient(180deg, #fff3d0, #f2b25c); opacity: 0.92; }
.hud-root .hud-bar.healing .hud-bar-drain { background: linear-gradient(180deg, #f2ffe0, #93e36e); }
.hud-root .hud-bar-hp .hud-bar-fill,
.hud-root .hud-bar-thp .hud-bar-fill {
  background: linear-gradient(180deg, #ff9180 0%, var(--c-hp, #d8413a) 42%, #9c1d16 100%);
}
.hud-root .hud-bar-mp .hud-bar-fill {
  background: linear-gradient(180deg, #9ccaff 0%, var(--c-mp, #3a7bd8) 45%, #1b4690 100%);
}
.hud-bar-gloss {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 46%;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.30), rgba(255, 255, 255, 0));
}
.hud-bar-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.3px;
  color: #fff;
  white-space: nowrap;
  text-shadow: 0 0 2px #000, 0 1px 1px #000, 0 0 3px rgba(0, 0, 0, 0.8);
}
.hud-root .hud-bar.low .hud-bar-fill { animation: hud-lowbar 0.9s ease-in-out infinite; }

/* ------------------------------------------------------------------ player frame */
.hud-player {
  top: 12px;
  left: 16px;
  width: 296px;
  height: 90px;
  padding: 9px 14px 9px 90px;
  cursor: pointer;
}
.hud-portrait-wrap {
  position: absolute;
  left: -8px;
  top: 50%;
  width: 88px;
  height: 88px;
  transform: translateY(-50%);
}
.hud-portrait-ring {
  width: 88px;
  height: 88px;
  padding: 4px;
  box-sizing: border-box;
  border-radius: 50%;
  background: conic-gradient(from 200deg, #fbe7ac, #a2702c, #f6dc94, #7a4a1a, #fbe7ac);
  box-shadow: 0 0 0 2px #1a0b05, 0 4px 12px rgba(0, 0, 0, 0.65), inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}
.hud-portrait {
  display: block;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #52321f, #170d08 75%);
  box-shadow: inset 0 0 0 2px #2a1206;
}
.hud-level {
  position: absolute;
  left: -2px;
  bottom: -1px;
  min-width: 28px;
  height: 28px;
  padding: 0 5px;
  box-sizing: border-box;
  border-radius: 14px;
  background: radial-gradient(circle at 35% 30%, #fff4cc, #e8c46a 45%, #95621c);
  box-shadow: 0 0 0 2px #2a1206, 0 2px 6px rgba(0, 0, 0, 0.7);
  color: #2a1206;
  font-size: 14px;
  font-weight: 700;
  line-height: 28px;
  text-align: center;
}
.hud-pinfo { position: relative; min-width: 0; }
.hud-pname-row { display: flex; align-items: center; gap: 5px; height: 21px; }
.hud-emblem { flex: 0 0 auto; width: 19px; height: 19px; border-radius: 50%; background: rgba(0, 0, 0, 0.45);
  box-shadow: 0 0 0 1px currentColor, 0 0 6px currentColor; display: inline-flex; align-items: center; justify-content: center; }
.hud-emblem svg { width: 15px; height: 15px; display: block; }
.hud-emblem svg .ln { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.hud-emblem svg .dot { fill: currentColor; }
.hud-emblem svg .cut { fill: #1a0c06; }
.hud-pname {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 16px;
  font-weight: 600;
  color: #fff3d6;
  text-shadow: 0 1px 2px #000, 0 0 8px rgba(232, 196, 106, 0.25);
}
.hud-pjob { display: flex; align-items: center; gap: 5px; height: 17px; font-size: 12px; color: #d9c497; }
.hud-jobdot { width: 7px; height: 7px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), 0 0 5px rgba(255, 255, 255, 0.25); }
.hud-pjob-text { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.hud-player .hud-bar-hp { height: 16px; margin-top: 3px; }
.hud-player .hud-bar-mp { height: 12px; margin-top: 4px; }
.hud-player .hud-bar-mp .hud-bar-text { font-size: 10px; }
.hud-player.hit { animation: hud-hit 0.32s ease-out; }
.hud-player.hit-crit { animation: hud-hit-crit 0.32s ease-out; }
.hud-player.levelup { animation: hud-frame-glow 1.4s ease-out; }

/* ------------------------------------------------------------------ target frame */
.hud-target {
  display: none;
  top: 12px;
  left: 50%;
  width: 336px;
  min-height: 66px;
  padding: 8px 14px 9px 74px;
  transform: translateX(-50%);
}
.hud-target.show { display: block; }
.hud-target.appear { animation: hud-pop 0.26s ease-out; }
.hud-tportrait-wrap {
  position: absolute;
  left: 10px;
  top: 8px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 38%, #56361f, #160c07 72%);
  box-shadow: 0 0 0 2px #c29445, 0 0 0 4px #1a0b05, 0 3px 8px rgba(0, 0, 0, 0.6);
}
.hud-tportrait { display: block; width: 50px; height: 50px; margin: 1px; border-radius: 50%; }
.hud-tinfo { position: relative; min-width: 0; }
.hud-tname-row { display: flex; align-items: baseline; gap: 6px; height: 21px; }
.hud-tname {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 15px;
  font-weight: 600;
  color: #f3e6c8;
  text-shadow: 0 1px 2px #000;
}
.hud-tlevel { margin-left: auto; flex: 0 0 auto; font-size: 12px; font-weight: 600; text-shadow: 0 1px 2px #000; }
.hud-tbadge {
  display: none;
  flex: 0 0 auto;
  align-self: center;
  padding: 0 7px;
  border-radius: 3px;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 16px;
  letter-spacing: 1px;
  color: #fff4d0;
  background: linear-gradient(180deg, #e0402c, #8a140c);
  box-shadow: 0 0 0 1px #ffcf6a, 0 0 8px rgba(255, 70, 40, 0.6);
}
.hud-tsub {
  height: 16px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 11.5px;
  color: var(--c-muted, #a8977a);
  text-shadow: 0 1px 1px #000;
}
.hud-target .hud-bar-thp { height: 15px; margin-top: 4px; }
.hud-target.friendly .hud-bar-thp .hud-bar-fill { background: linear-gradient(180deg, #a8f59a 0%, #4cbf45 45%, #22721f 100%); }
.hud-target.hit .hud-bar-thp { animation: hud-barflash 0.26s ease-out; }
.hud-target.is-dead .hud-tportrait { filter: grayscale(1) brightness(0.6); }
.hud-target.is-dead .hud-tname { color: #9a8f80 !important; }
.hud-ttags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.hud-tag {
  padding: 0 7px;
  border-radius: 8px;
  font-size: 10.5px;
  line-height: 16px;
  color: #efe2c4;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(232, 196, 106, 0.35);
}
.hud-tag.tag-dead { color: #bdb3a4; border-color: rgba(200, 200, 200, 0.3); }
.hud-tag.tag-stun { color: #ffe27a; border-color: rgba(255, 216, 74, 0.55); }
.hud-tag.tag-slow { color: #a6dcff; border-color: rgba(143, 211, 255, 0.55); }
.hud-tag.tag-buff { color: #aef29c; border-color: rgba(120, 220, 100, 0.5); }
.hud-tag.tag-god { color: #fff; border-color: #ffd98a; background: rgba(232, 196, 106, 0.25); }
.hud-tag.tag-aggro { color: #ff9a86; border-color: rgba(255, 110, 90, 0.5); }
.hud-tag.tag-party { color: #9fd0ff; border-color: rgba(111, 183, 255, 0.55); }
.hud-tag.tag-self { color: #ffe7a8; }
.hud-tag.tag-service { color: #ffe3a0; border-color: rgba(232, 196, 106, 0.55); background: rgba(90, 50, 20, 0.55); }
.hud-target.kind-n .hud-tname-row { height: 22px; }
.hud-target.kind-n .hud-tsub { color: #d8c49a; font-style: italic; }

/* boss styling */
.hud-target.is-boss {
  width: 430px;
  min-height: 76px;
  padding: 9px 16px 10px 88px;
  background:
    radial-gradient(120% 140% at 50% 0%, rgba(255, 120, 60, 0.22), rgba(255, 120, 60, 0) 60%),
    linear-gradient(180deg, rgba(96, 18, 12, 0.96), rgba(30, 7, 5, 0.96));
  box-shadow:
    inset 0 0 0 1px #ffcf6a,
    inset 0 0 0 3px rgba(40, 6, 4, 0.95),
    inset 0 0 0 4px #c0392b,
    0 0 22px rgba(255, 60, 30, 0.35),
    0 6px 18px rgba(0, 0, 0, 0.6);
}
.hud-target.is-boss::after {
  content: '';
  position: absolute;
  left: 50%;
  top: -10px;
  width: 64px;
  height: 16px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #fff0b0, #d9a441 60%, #8a5a1a);
  clip-path: polygon(0 100%, 18% 35%, 32% 70%, 50% 0, 68% 70%, 82% 35%, 100% 100%);
  filter: drop-shadow(0 1px 0 #2a0c06);
}
.hud-target.is-boss .hud-tbadge { display: inline-block; }
.hud-target.is-boss .hud-tportrait-wrap {
  left: 12px;
  top: 9px;
  width: 62px;
  height: 62px;
  box-shadow: 0 0 0 2px #ffcf6a, 0 0 0 4px #4a0806, 0 0 16px rgba(255, 80, 40, 0.75);
}
.hud-target.is-boss .hud-tportrait { width: 60px; height: 60px; }
.hud-target.is-boss .hud-tname-row { height: 26px; }
.hud-target.is-boss .hud-tname {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(180deg, #fff6d0, #ffcf6a 50%, #e0782a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 1px 1px #000);
}
.hud-target.is-boss .hud-bar-thp { height: 18px; box-shadow: 0 0 0 1px #0b0503, 0 0 0 2px rgba(255, 207, 106, 0.45), inset 0 1px 3px rgba(0, 0, 0, 0.85); }
.hud-target.is-boss .hud-bar-thp .hud-bar-text { font-size: 12px; }

/* ------------------------------------------------------------------ bottom centre: buffs + hotbar */
.hud-bottom {
  position: absolute;
  left: 50%;
  bottom: calc(var(--hud-exp-h) + 6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transform: translateX(-50%);
  pointer-events: none;
}
.hud-buffs {
  display: flex;
  flex-wrap: wrap-reverse;
  justify-content: center;
  gap: 5px;
  max-width: 540px;
  pointer-events: none;
}
.hud-buff { position: relative; width: 30px; display: flex; flex-direction: column; align-items: center; pointer-events: auto; cursor: default; }
.hud-buff-frame {
  width: 30px;
  height: 30px;
  padding: 2px;
  box-sizing: border-box;
  border-radius: 5px;
  background: linear-gradient(180deg, #e3f7a4, #4f9a2e);
  box-shadow: 0 0 0 1px #0d0703, 0 2px 5px rgba(0, 0, 0, 0.65);
}
.hud-buff.debuff .hud-buff-frame { background: linear-gradient(180deg, #ffb7a0, #a3261c); }
.hud-buff-icon { display: block; width: 100%; height: 100%; border-radius: 3px; background: #1a0f0a; }
.hud-buff-time {
  min-height: 12px;
  margin-top: 1px;
  font-size: 10px;
  font-weight: 500;
  line-height: 12px;
  color: #fff;
  white-space: nowrap;
  text-shadow: 0 0 2px #000, 0 1px 1px #000;
}
.hud-buff.expiring .hud-buff-icon { animation: hud-blink 0.7s ease-in-out infinite; }

.hud-hotbar {
  position: relative;
  display: flex;
  gap: 4px;
  padding: 8px 9px;
}
.hud-hotbar .hud-slot {
  position: relative;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  overflow: hidden;
  border-radius: 6px;
  border: 1px solid #5c3b1c;
  background: radial-gradient(circle at 50% 38%, #3b2517, #140a06 76%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.75), inset 0 2px 7px rgba(0, 0, 0, 0.75);
  cursor: pointer;
  touch-action: none;
  transition: transform 0.08s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.hud-hotbar .hud-slot.empty {
  cursor: default;
  background:
    linear-gradient(45deg, rgba(232, 196, 106, 0) 46%, rgba(232, 196, 106, 0.07) 50%, rgba(232, 196, 106, 0) 54%),
    linear-gradient(-45deg, rgba(232, 196, 106, 0) 46%, rgba(232, 196, 106, 0.07) 50%, rgba(232, 196, 106, 0) 54%),
    radial-gradient(circle at 50% 38%, #2c1b10, #110805 76%);
}
.hud-hotbar .hud-slot:hover { border-color: var(--c-gold, #e8c46a); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.75), 0 0 9px rgba(232, 196, 106, 0.55); }
.hud-hotbar .hud-slot.pressing,
.hud-hotbar .hud-slot.pressed { transform: scale(0.91); border-color: #fff0c0; }
.hud-hotbar .hud-slot.dragging { opacity: 0.4; }
.hud-hotbar .hud-slot.drop-ok { border-color: var(--c-good, #7ddc6a); box-shadow: 0 0 0 1px var(--c-good, #7ddc6a), 0 0 12px rgba(125, 220, 106, 0.65); }
.hud-hotbar .hud-slot.drop-bad { border-color: var(--c-bad, #ff6b5b); box-shadow: 0 0 0 1px var(--c-bad, #ff6b5b); }
.hud-slot-icon {
  position: absolute;
  left: 3px;
  top: 3px;
  width: calc(100% - 6px);
  height: calc(100% - 6px);
  display: block;
  border-radius: 4px;
  object-fit: cover;
  pointer-events: none;
}
.hud-slot.empty .hud-slot-icon { display: none; }
.hud-slot::after {
  content: '';
  position: absolute;
  left: 3px;
  right: 3px;
  top: 3px;
  height: 40%;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0));
  pointer-events: none;
  z-index: 1;
}
.hud-slot.empty::after { display: none; }
.hud-key {
  position: absolute;
  left: 3px;
  top: 2px;
  z-index: 4;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  color: #f7dc98;
  text-shadow: 0 0 2px #000, 0 1px 1px #000;
  pointer-events: none;
}
.hud-root .hud-slot .hud-qty {
  position: absolute;
  right: 3px;
  bottom: 1px;
  left: auto;
  top: auto;
  z-index: 4;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.15;
  color: #fff;
  text-shadow: 0 0 2px #000, 0 0 2px #000, 0 1px 1px #000;
  pointer-events: none;
}
.hud-cd {
  --cd: 0;
  position: absolute;
  left: 3px;
  top: 3px;
  width: calc(100% - 6px);
  height: calc(100% - 6px);
  z-index: 2;
  display: none;
  border-radius: 4px;
  background: conic-gradient(from 0deg, rgba(8, 3, 1, 0) calc((1 - var(--cd)) * 360deg), rgba(8, 3, 1, 0.74) 0);
  pointer-events: none;
}
.hud-slot.on-cd .hud-cd { display: block; }
.hud-cd-text {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 3px #000, 0 0 2px #000, 0 1px 1px #000;
  pointer-events: none;
}
.hud-slot.no-mp .hud-slot-icon { filter: saturate(0.3) brightness(0.62); }
.hud-slot.no-mp .hud-cd { display: block; background: rgba(28, 64, 170, 0.42); }
.hud-slot.no-mp.on-cd .hud-cd { background: conic-gradient(from 0deg, rgba(28, 64, 170, 0.42) calc((1 - var(--cd)) * 360deg), rgba(8, 3, 1, 0.74) 0); }
.hud-slot.unlearned .hud-slot-icon,
.hud-slot.no-item .hud-slot-icon { filter: grayscale(1) brightness(0.5); }
.hud-root .hud-slot.no-item .hud-qty { color: #ff8a78; }
.hud-slot.cd-ready { animation: hud-ready 0.5s ease-out; }
.hud-root.is-dead .hud-hotbar,
.hud-root.is-dead .hud-buffs { filter: grayscale(1) brightness(0.6); }

/* ------------------------------------------------------------------ menu buttons */
.hud-menu {
  right: 10px;
  bottom: calc(var(--hud-exp-h) + 6px);
  display: flex;
  gap: 4px;
  padding: 8px 9px;
}
.hud-menu-btn {
  position: relative;
  width: 44px;
  height: 46px;
  margin: 0;
  padding: 3px 0 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border: 1px solid #4d2c15;
  border-radius: 6px;
  background: linear-gradient(180deg, #4d2c19, #22120a);
  box-shadow: inset 0 1px 0 rgba(255, 220, 160, 0.18), inset 0 -2px 5px rgba(0, 0, 0, 0.45);
  color: var(--c-gold, #e8c46a);
  font-family: inherit;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.08s ease, background 0.15s ease;
}
.hud-menu-btn:hover { border-color: var(--c-gold, #e8c46a); background: linear-gradient(180deg, #6c3d21, #2d170c); box-shadow: inset 0 1px 0 rgba(255, 220, 160, 0.25), 0 0 9px rgba(232, 196, 106, 0.4); }
.hud-menu-btn:active { transform: translateY(1px) scale(0.97); }
.hud-menu-btn.active { border-color: #ffdd92; background: linear-gradient(180deg, #7a4624, #3a1e0f); box-shadow: inset 0 0 10px rgba(255, 214, 130, 0.45), 0 0 8px rgba(232, 196, 106, 0.45); }
.hud-menu-ico { display: block; height: 22px; }
.hud-menu-ico svg {
  display: block;
  width: 22px;
  height: 22px;
  fill: rgba(232, 196, 106, 0.2);
  stroke: #f2d180;
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.7));
}
.hud-menu-ico svg .ln { fill: none; }
.hud-menu-ico svg .dot { fill: #f2d180; stroke: none; }
.hud-menu-label { font-size: 10.5px; line-height: 13px; color: #f1e2c2; text-shadow: 0 1px 1px #000; white-space: nowrap; }
.hud-menu-key {
  position: absolute;
  left: 3px;
  top: 2px;
  font-size: 9px;
  font-weight: 600;
  line-height: 1;
  color: #c0a06a;
  text-shadow: 0 1px 1px #000;
}
.hud-badge {
  position: absolute;
  right: -5px;
  top: -6px;
  display: none;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  box-sizing: border-box;
  border-radius: 9px;
  background: radial-gradient(circle at 35% 30%, #ff9474, #d52a1c 60%, #8a120c);
  box-shadow: 0 0 0 1.5px #2a0c06, 0 0 8px rgba(255, 80, 40, 0.75);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
}
.hud-menu-btn.has-badge .hud-badge { display: block; animation: hud-badge 1.6s ease-in-out infinite; }
.hud-menu-btn.has-badge .hud-menu-ico svg { stroke: #ffe4a0; }

/* ------------------------------------------------------------------ EXP bar */
.hud-exp {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--hud-exp-h);
  overflow: hidden;
  pointer-events: auto;
  background: linear-gradient(180deg, #0b0503, #1f110a);
  border-top: 1px solid #83511f;
  box-shadow: 0 -1px 0 #160a04, 0 -3px 10px rgba(0, 0, 0, 0.45);
}
.hud-exp-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: linear-gradient(180deg, #fff2bf 0%, var(--c-exp, #e8c46a) 42%, #a8701e 100%);
  box-shadow: 0 0 8px rgba(232, 196, 106, 0.55);
  transition: width 0.6s ease-out;
}
.hud-exp.gain .hud-exp-fill { animation: hud-exp-gain 0.7s ease-out; }
.hud-exp-ticks {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0) 55%),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) calc(10% - 1px), rgba(0, 0, 0, 0.65) calc(10% - 1px), rgba(0, 0, 0, 0.65) 10%);
}
.hud-exp-text {
  position: absolute;
  inset: 0;
  font-size: 10px;
  font-weight: 500;
  line-height: var(--hud-exp-h);
  letter-spacing: 0.6px;
  text-align: center;
  color: #fff;
  text-shadow: 0 0 2px #000, 0 1px 1px #000;
}

/* ------------------------------------------------------------------ low-HP vignette */
.hud-vignette {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(170, 0, 0, 0) 40%, rgba(200, 6, 4, 0.5) 68%, rgba(225, 8, 6, 0.92) 100%);
  box-shadow: inset 0 0 120px rgba(215, 0, 0, 0.6);
  transition: opacity 0.4s ease;
}
.hud-vignette.on { animation: hud-vignette 1.4s ease-in-out infinite; }
.hud-vignette.critical { animation-duration: 0.75s; }

/* ------------------------------------------------------------------ death overlay */
.hud-death {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(40, 4, 2, 0.30) 0%, rgba(8, 2, 1, 0.84) 78%);
  -webkit-backdrop-filter: grayscale(0.9) brightness(0.75);
  backdrop-filter: grayscale(0.9) brightness(0.75);
  transition: opacity 0.6s ease, visibility 0s linear 0.6s;
}
.hud-death.show { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity 1.1s ease; }
.hud-death-panel { text-align: center; transform: translateY(14px) scale(0.98); transition: transform 1.2s ease; }
.hud-death.show .hud-death-panel { transform: none; }
.hud-death-title {
  font-family: var(--hud-font-callig);
  font-size: 68px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 3px;
  color: #ec4b3a;
  text-shadow: 0 0 2px #2a0000, 0 3px 0 #3a0906, 0 0 30px rgba(255, 40, 20, 0.55);
}
.hud-death-line { width: 320px; height: 2px; margin: 6px auto 14px; background: linear-gradient(90deg, rgba(201, 162, 74, 0), #c9a24a, rgba(201, 162, 74, 0)); }
.hud-death-sub { font-size: 16px; color: #dccbaa; text-shadow: 0 1px 2px #000; }
.hud-death-killer { margin-top: 6px; font-size: 14px; color: #e6b0a0; text-shadow: 0 1px 2px #000; }
.hud-death-killer b { color: #ff8a70; font-weight: 600; }
.hud-death-where { margin-top: 6px; font-size: 14px; color: var(--c-muted, #a8977a); text-shadow: 0 1px 2px #000; }
.hud-death-where b { color: var(--c-gold, #e8c46a); font-weight: 600; }
.hud-death .hud-respawn {
  margin-top: 26px;
  min-width: 210px;
  height: 48px;
  padding: 0 28px;
  border-radius: 8px;
  border: 1px solid #ffd98a;
  background: linear-gradient(180deg, #d9432f 0%, #9c1f15 55%, #6d120b 100%);
  box-shadow: inset 0 1px 0 rgba(255, 220, 180, 0.45), inset 0 0 0 2px rgba(60, 8, 4, 0.6), 0 0 18px rgba(255, 90, 50, 0.35), 0 6px 14px rgba(0, 0, 0, 0.6);
  color: #fff4dc;
  font-family: inherit;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 1px;
  text-shadow: 0 1px 2px #3a0604;
  cursor: pointer;
  outline: none;
  transition: transform 0.08s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.hud-death .hud-respawn:hover { filter: brightness(1.12); box-shadow: inset 0 1px 0 rgba(255, 220, 180, 0.5), inset 0 0 0 2px rgba(60, 8, 4, 0.6), 0 0 26px rgba(255, 110, 60, 0.55), 0 6px 14px rgba(0, 0, 0, 0.6); }
.hud-death .hud-respawn:active { transform: translateY(1px); }
.hud-death .hud-respawn:disabled { cursor: default; filter: grayscale(0.6) brightness(0.8); }

/* ------------------------------------------------------------------ map-name banner */
/* Upper band, clear of the target frame; the self character is centred on screen below it. */
.hud-mapbanner {
  position: absolute;
  left: 50%;
  top: max(9vh, 84px);
  width: 760px;
  max-width: 94vw;
  padding: 20px 0 18px;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(-50%);
}
.hud-mapbanner.show { visibility: visible; animation: hud-mapbanner 4.2s ease forwards; }
.hud-mapbanner-ink {
  position: absolute;
  inset: -10px 0;
  background:
    radial-gradient(ellipse 48% 42% at 50% 48%, rgba(10, 5, 2, 0.74), rgba(10, 5, 2, 0.5) 55%, rgba(10, 5, 2, 0) 78%);
}
.hud-mapbanner-name {
  position: relative;
  font-family: var(--hud-font-callig);
  font-size: 60px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 4px;
  background: linear-gradient(180deg, #fff7da 0%, #f4d47c 46%, #c4862a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 0 #3a1a08) drop-shadow(0 0 14px rgba(255, 196, 96, 0.35));
}
.hud-mapbanner-orn { position: relative; display: flex; align-items: center; justify-content: center; gap: 10px; margin: 2px 0 6px; }
.hud-mapbanner-orn i { display: block; width: 170px; height: 1px; background: linear-gradient(90deg, rgba(232, 196, 106, 0), #e8c46a); }
.hud-mapbanner-orn i:last-child { background: linear-gradient(90deg, #e8c46a, rgba(232, 196, 106, 0)); }
.hud-mapbanner-orn b { display: block; width: 8px; height: 8px; transform: rotate(45deg); background: #e8c46a; box-shadow: 0 0 8px rgba(232, 196, 106, 0.8); }
.hud-mapbanner-sub {
  position: relative;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 15px;
  color: #eadfc4;
  text-shadow: 0 1px 2px #000, 0 0 6px #000;
}
.hud-mb-safe { color: #97e690; }
.hud-mb-pvp { color: #ff806e; }

/* ------------------------------------------------------------------ level-up / job banner */
/* Lower band, just below the (screen-centred) hero: the world-space "LEVEL UP" floater from art-fx
   rises above the head, toasts sit at 22vh, the map banner owns the upper band. */
.hud-levelup {
  position: absolute;
  left: 50%;
  bottom: calc(var(--hud-bottom-reserved) + 64px);
  width: 480px;
  padding: 18px 0;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(-50%);
}
.hud-levelup.show { visibility: visible; animation: hud-levelup 3.1s ease forwards; }
.hud-levelup-rays {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 380px;
  height: 380px;
  margin: -190px 0 0 -190px;
  background: repeating-conic-gradient(from 0deg, rgba(255, 222, 130, 0.30) 0deg 5deg, rgba(255, 222, 130, 0) 5deg 15deg);
  -webkit-mask-image: radial-gradient(circle, #000 0%, rgba(0, 0, 0, 0.55) 34%, rgba(0, 0, 0, 0) 66%);
  mask-image: radial-gradient(circle, #000 0%, rgba(0, 0, 0, 0.55) 34%, rgba(0, 0, 0, 0) 66%);
  animation: hud-rays 7s linear infinite;
}
.hud-levelup-title {
  position: relative;
  font-size: 50px;
  font-weight: 700;
  font-style: italic;
  line-height: 1.25;
  letter-spacing: 3px;
  background: linear-gradient(180deg, #fffbe6 0%, #ffe08a 38%, #f0a92c 62%, #b8660f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 0 #4a2208) drop-shadow(0 0 2px #2a1204) drop-shadow(0 0 16px rgba(255, 200, 80, 0.65));
}
.hud-levelup.job .hud-levelup-title { background: linear-gradient(180deg, #f4fbff 0%, #9fd8ff 45%, #3f7fd6 100%); -webkit-background-clip: text; background-clip: text; filter: drop-shadow(0 2px 0 #0d2a4a) drop-shadow(0 0 16px rgba(120, 190, 255, 0.6)); }
.hud-levelup.job .hud-levelup-rays { background: repeating-conic-gradient(from 0deg, rgba(150, 210, 255, 0.28) 0deg 5deg, rgba(150, 210, 255, 0) 5deg 15deg); }
.hud-levelup-value { position: relative; font-size: 27px; font-weight: 600; color: #fff5d6; text-shadow: 0 2px 4px #000, 0 0 12px rgba(255, 210, 120, 0.6); }
.hud-levelup-note { position: relative; margin-top: 2px; font-size: 13.5px; color: #ffe6a4; text-shadow: 0 1px 2px #000, 0 0 5px #000; }

/* ------------------------------------------------------------------ tooltip helpers (rendered by ui.js) */
.hud-tip-hint { margin-top: 5px; font-size: 11px; color: #bba57c; }
.hud-kbd {
  display: inline-block;
  min-width: 14px;
  padding: 0 4px;
  border: 1px solid #8b5a2b;
  border-radius: 3px;
  background: #2a1a12;
  color: #f3e6c8;
  font-size: 10px;
  line-height: 14px;
  text-align: center;
}

/* ------------------------------------------------------------------ animations */
@keyframes hud-lowbar { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.45) saturate(1.2); } }
@keyframes hud-vignette { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }
@keyframes hud-hit {
  0% { transform: translate(0, 0); box-shadow: inset 0 0 0 1px rgba(255, 90, 60, 0.9), inset 0 0 18px rgba(255, 40, 20, 0.45), 0 6px 18px rgba(0, 0, 0, 0.55); }
  30% { transform: translate(-2px, 1px); }
  60% { transform: translate(2px, -1px); }
  100% { transform: translate(0, 0); }
}
@keyframes hud-hit-crit {
  0% { transform: translate(0, 0); box-shadow: inset 0 0 0 2px rgba(255, 210, 80, 0.95), inset 0 0 24px rgba(255, 60, 20, 0.6), 0 6px 18px rgba(0, 0, 0, 0.55); }
  25% { transform: translate(-4px, 2px); }
  50% { transform: translate(4px, -2px); }
  75% { transform: translate(-2px, 1px); }
  100% { transform: translate(0, 0); }
}
@keyframes hud-frame-glow {
  0% { box-shadow: inset 0 0 0 1px #fff3c0, inset 0 0 26px rgba(255, 214, 110, 0.7), 0 0 26px rgba(255, 214, 110, 0.75); }
  100% { box-shadow: inset 0 0 0 1px rgba(232, 196, 106, 0.55), inset 0 0 0 3px rgba(22, 10, 5, 0.92), inset 0 0 0 4px rgba(139, 90, 43, 0.6), 0 6px 18px rgba(0, 0, 0, 0.55); }
}
@keyframes hud-pop { 0% { transform: translateX(-50%) scale(0.94); opacity: 0.4; } 100% { transform: translateX(-50%) scale(1); opacity: 1; } }
@keyframes hud-barflash { 0% { filter: brightness(1.8); } 100% { filter: brightness(1); } }
@keyframes hud-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes hud-ready {
  0% { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.75), 0 0 0 0 rgba(255, 236, 170, 0.9); border-color: #fff4c8; }
  100% { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.75), 0 0 0 7px rgba(255, 236, 170, 0); }
}
@keyframes hud-badge { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.14); } }
@keyframes hud-exp-gain { 0% { filter: brightness(1.9); box-shadow: 0 0 14px rgba(255, 230, 150, 0.95); } 100% { filter: brightness(1); } }
@keyframes hud-mapbanner {
  0% { opacity: 0; transform: translateX(-50%) translateY(-10px) scale(1.06); filter: blur(6px); }
  13% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); filter: blur(0); }
  80% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); filter: blur(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(6px) scale(1); filter: blur(3px); }
}
@keyframes hud-levelup {
  0% { opacity: 0; transform: translateX(-50%) scale(0.55); }
  9% { opacity: 1; transform: translateX(-50%) scale(1.12); }
  17% { opacity: 1; transform: translateX(-50%) scale(1); }
  80% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-16px) scale(1); }
}
@keyframes hud-rays { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ responsive
   Widths: hotbar = 10 slots + 9 gaps + 2 × padding (centred); menu = 7 buttons + 6 gaps + 2 × padding (right).
   Every breakpoint keeps a gap between them (checked by tests/ui-hud.test.js at 1280 and 1024). */
@media (max-width: 1260px) {
  .hud-menu-btn { width: 38px; height: 38px; padding: 0; }
  .hud-menu-label { display: none; }
}
@media (max-width: 1100px) {
  .hud-hotbar { gap: 3px; padding: 7px; }
  .hud-hotbar .hud-slot { width: 38px; height: 38px; }
  .hud-cd-text { font-size: 14px; }
  .hud-menu { gap: 3px; padding: 6px; }
  .hud-menu-btn { width: 34px; height: 34px; }
  .hud-menu-ico svg { width: 20px; height: 20px; }
  .hud-target.is-boss { width: 360px; }
}
@media (max-width: 960px) {
  .hud-hotbar .hud-slot { width: 34px; height: 34px; }
  .hud-key { font-size: 9px; }
  .hud-cd-text { font-size: 13px; }
  .hud-menu { gap: 2px; }
  .hud-menu-btn { width: 32px; height: 32px; }
  .hud-menu-ico svg { width: 19px; height: 19px; }
  .hud-player { width: 252px; }
  .hud-target { width: 290px; }
  .hud-target.is-boss { width: 330px; }
  .hud-mapbanner-name { font-size: 46px; }
  .hud-levelup-title { font-size: 44px; }
  .hud-death-title { font-size: 54px; }
}
@media (max-width: 860px) {
  .hud-menu { bottom: calc(var(--hud-exp-h) + 64px); }
}
@media (prefers-reduced-motion: reduce) {
  .hud-vignette.on { animation: none; opacity: 0.7; }
  .hud-levelup-rays { animation: none; }
  .hud-menu-btn.has-badge .hud-badge { animation: none; }
}
