/* Brown DialogueUI edges only; the center remains a smooth, readable surface. */
#wb-ui > #wb-heroes {
  --wb-player-gold: #e9d2a0;
  top: 6px;
  left: 50%;
  right: auto;
  width: min(1800px, calc(100% - 24px));
  transform: translateX(-50%);
  display: flex;
  justify-content: safe center;
  gap: 6px;
  align-items: stretch;
  padding: 0;
  overflow: visible;
}

#wb-heroes button.wb-hero {
  flex: 0 1 calc((100% - 42px) / 8);
  display: grid !important;
  grid-template-columns: 32px minmax(0, 1fr);
  grid-template-rows: 32px 24px;
  gap: 4px 7px !important;
  width: auto !important;
  min-width: 0;
  height: 78px;
  min-height: 78px !important;
  padding: 5px !important;
  box-sizing: border-box;
  border: 4px solid transparent !important;
  border-image: url('./skin/dialogue-ui/brown-panel-frame.png') 80 / 4px stretch !important;
  background: linear-gradient(150deg, #3b2f25, #211c19) !important;
  border-radius: 0;
  color: #eee5d5;
  text-align: left;
  align-items: center;
  box-shadow: 0 3px 10px #0006;
  outline: none;
  isolation: isolate;
}

#wb-heroes button.wb-hero:hover {
  background: linear-gradient(150deg, #4a3b2c, #29221c) !important;
  box-shadow: inset 0 0 0 1px #d9c29150, 0 3px 12px #0007;
  outline: none;
}

#wb-heroes button.wb-hero:focus-visible {
  outline: 2px solid #f0d99d;
  outline-offset: 2px;
}

#wb-heroes button.wb-hero.wb-you {
  box-shadow: inset 0 0 0 1px #e3c89190, 0 3px 12px #0007;
}

#wb-heroes button.wb-hero.wb-opponent {
  box-shadow: inset 0 0 0 1px #b8785c80, 0 3px 10px #0006;
  outline: none;
}

#wb-heroes .wb-hero-icon {
  width: 32px;
  height: 32px;
  box-sizing: border-box;
  object-fit: cover;
  border: 1px solid #b09a72;
  border-radius: 2px;
  background: #15120f;
  box-shadow: 0 1px 3px #0009;
}

#wb-heroes :is(.wb-hero-icon, .wb-hero-identity, .wb-hero-vitals) {
  position: relative;
  z-index: 1;
}

#wb-heroes .wb-hero-identity { min-width: 0; align-self: center; }
#wb-heroes .wb-hero-name {
  display: block;
  font: 400 12px/15px WarbandFriz, Georgia, serif;
  color: var(--wb-player-gold);
  text-shadow: 0 1px 2px #000;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: normal;
}

#wb-heroes .wb-hero-player {
  display: block;
  margin-top: 2px;
  font: 11px/13px Arial, sans-serif !important;
  color: #d3cabe;
  text-shadow: 0 1px #0008;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: normal;
}

/* Player health is a slim bar (hero-health-bar.mjs): a recessed track, a fill with a gentle top-to-bottom gradient whose
   tone follows health (deep green, gold, red), and the number at the bar's end. Hero Level sits underneath. */
#wb-heroes .wb-hero-vitals {
  --wb-hero-bar-height: 7px;
  --wb-hero-number-space: 30px;
  grid-column: 1 / -1;
  height: 24px;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding-top: 13px;
  box-sizing: border-box;
  white-space: nowrap;
}

/* The sanitized inline fraction and tones come from current player health, not decoration. */
#wb-heroes .wb-hero-vitals::before,
#wb-heroes .wb-hero-vitals::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 0;
  height: var(--wb-hero-bar-height);
  box-sizing: border-box;
  border-radius: 4px;
  pointer-events: none;
}

#wb-heroes .wb-hero-vitals::before {
  width: calc(100% - var(--wb-hero-number-space));
  background: linear-gradient(#0c0a08, #1c1814);
  box-shadow: inset 0 1px 2px #000c, 0 0 0 1px #c8aa6e26, 0 1px #ffffff0d;
}

#wb-heroes .wb-hero-vitals::after {
  width: calc((100% - var(--wb-hero-number-space)) * var(--wb-hero-health-fraction, 0));
  background: linear-gradient(180deg, var(--wb-hero-health-light, #419c46) 0%, var(--wb-hero-health-base, #228c28) 55%, var(--wb-hero-health-dark, #145117) 100%);
  box-shadow: inset 0 1px #ffffff33, 0 0 4px #00000080;
}

#wb-heroes .wb-hero-health {
  position: absolute;
  z-index: 1;
  top: 0;
  right: 0;
  width: calc(var(--wb-hero-number-space) - 4px);
  height: 11px;
  font: 400 11px/11px WarbandFriz, Georgia, serif !important;
  color: #f0e6d2;
  text-align: right;
  font-variant-numeric: tabular-nums;
  margin: 0;
  text-shadow: 0 1px 1px #000;
}

#wb-heroes .wb-hero-level { font: 10px/11px Arial, sans-serif !important; color: #c6b79b; }
#wb-heroes .wb-hero-you { display: none; }
#wb-heroes .wb-hero-soulstone { position: absolute; top: 13px; right: 0; width: 11px; height: 11px; }
/* The entire defeated player frame fades, including its border and crest. */
#wb-heroes button.wb-hero.wb-eliminated { filter: grayscale(1); opacity: .48; }
#wb-heroes button.wb-hero.wb-eliminated .wb-hero-icon { grid-column: 1; grid-row: 1; filter: grayscale(1) brightness(.7); }
#wb-heroes button.wb-hero.wb-eliminated :is(.wb-hero-identity, .wb-hero-vitals) { opacity: .85; }
#wb-heroes .wb-hero-grave { grid-column: 1; grid-row: 1; justify-self: end; align-self: end; position: relative; z-index: 2; width: 16px; height: 16px; margin: 0 -4px -4px 0; filter: drop-shadow(0 1px 1px #000); pointer-events: none; }

/* Retain the health-loss pulse, including a visible red surface over the new brown center. */
#wb-heroes button.wb-hero.wb-hero-hit::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: #c3342c;
  animation: wb-dialogue-player-hit 1s ease-out;
  opacity: 0;
}

@keyframes wb-dialogue-player-hit {
  0%, 25% { opacity: .68; }
  60% { opacity: .25; }
  100% { opacity: 0; }
}

@media (max-width: 1250px) {
  #wb-ui > #wb-heroes { width: calc(100% - 16px); gap: 4px; }
  #wb-heroes button.wb-hero { grid-template-columns: 28px minmax(0, 1fr); column-gap: 5px !important; }
  #wb-heroes .wb-hero-icon { width: 28px; height: 28px; }
  #wb-heroes .wb-hero-name { font-size: 11px; }
  #wb-heroes .wb-hero-player { font-size: 10px; }
}

@media (max-width: 940px) {
  #wb-ui > #wb-heroes {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding-bottom: 4px;
    scrollbar-width: thin;
    scrollbar-color: #9a8058 #221b16;
  }
  #wb-heroes button.wb-hero { flex: 0 0 116px; }
}

@media (prefers-reduced-motion: reduce) {
  #wb-heroes button.wb-hero.wb-hero-hit::after { animation: none; opacity: .35; }
}

#wb-ui.wb-campaign-active > #wb-heroes > button.wb-hero { flex: 1 1 0; }

/* View Deck: a book on your hero box, and on a teammate's, opens that player's card pool. client.mjs places it in the
   box's top-right corner; the Ready tick moves left beside it. */
#wb-ui#wb-ui #wb-heroes > .wb-hero-deck{position:absolute;z-index:2;display:block;width:24px;height:24px;min-width:0!important;min-height:0!important;margin:0;padding:0!important;border:1px solid #8a6d3a!important;border-image:none!important;border-radius:2px!important;background:#16120f url('./icons/cards/inv_misc_book_09.png') center/cover no-repeat!important;box-shadow:0 1px 3px #000c!important;pointer-events:auto}
#wb-ui#wb-ui #wb-heroes > .wb-hero-deck:is(:hover,:focus-visible){border-color:#f0d58c!important;filter:brightness(1.2);outline:none}
#wb-ui #wb-heroes .wb-has-deck .wb-hero-ready{right:36px}
