/* ── Messages & combat (above XP / bottom HUD) ── */
#action-panel {
  padding: 8px 12px 10px;
  background: linear-gradient(180deg, rgba(8,8,16,0.95) 0%, #080810 100%);
  flex-shrink: 0;
  border-top: 1px solid rgba(255,255,255,0.04);
}

/* ── Message log wrap ── */
#message-log-wrap {
  position: relative;
}

#message-box {
  font-size: 0.78rem;
  color: var(--text-dim);
  text-align: center;
  font-style: italic;
  line-height: 1.45;
  min-height: 1.45em;
  transition: color 0.2s;
  cursor: pointer;
  user-select: none;
}

#message-box::after {
  content: '▲';
  font-size: 0.5rem;
  opacity: 0.35;
  margin-left: 6px;
  vertical-align: middle;
}

#message-box.alert {
  color: #ff8888;
  font-style: normal;
}

/* ── Expanded scroll log ── */
#message-log-expanded {
  position: absolute;
  bottom: calc(100% + 4px);
  left: -12px;
  right: -12px;
  height: 300px;
  z-index: 200;
  border-radius: 10px 10px 4px 4px;
  overflow: hidden;
  display: flex;
  flex-direction: column;

  /* Scroll/parchment look */
  background:
    linear-gradient(180deg, rgba(30,20,10,0.97) 0%, rgba(18,12,6,0.99) 100%);
  border: 1px solid rgba(180,130,60,0.4);
  border-bottom: none;
  box-shadow:
    0 -6px 24px rgba(0,0,0,0.7),
    inset 0 1px 0 rgba(200,160,80,0.15),
    inset 0 0 40px rgba(0,0,0,0.4);
}

#message-log-expanded::before {
  content: '— Event Log —';
  display: block;
  text-align: center;
  font-size: 0.6rem;
  letter-spacing: 2px;
  color: rgba(180,140,70,0.6);
  padding: 6px 0 4px;
  border-bottom: 1px solid rgba(180,130,60,0.2);
  flex-shrink: 0;
}

#message-log-expanded.hidden {
  display: none;
}

#message-log-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 6px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(180,130,60,0.3) transparent;
}

.log-entry {
  font-size: 0.72rem;
  color: rgba(180,165,140,0.75);
  font-style: italic;
  line-height: 1.4;
  padding: 4px 6px;
  border-bottom: 1px solid rgba(180,130,60,0.08);
}

.log-entry.log-latest {
  color: var(--text-primary, #e8d5a8);
  font-style: normal;
  font-weight: 600;
}

.log-entry.log-alert {
  color: #ff9999;
  font-style: normal;
}

#action-buttons {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  visibility: visible;
  opacity: 1;
  transition: opacity 0.15s;
}

#action-buttons.hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

/* ── Retreat button — header top-right ── */
#retreat-btn {
  flex-shrink: 0;
  background: rgba(10,6,4,0.82);
  border: 1px solid rgba(180,60,40,0.5);
  border-radius: 8px;
  color: #e88;
  font-size: 1.2rem;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.6);
  transition: background 0.15s, border-color 0.15s;
}

#retreat-btn:active {
  background: rgba(120,30,20,0.7);
}

#retreat-btn.hidden {
  display: none;
}

/* ── Retreat confirmation popup ── */
#retreat-confirm {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: auto;
  z-index: 25;
  background: linear-gradient(160deg, rgba(20,10,8,0.97), rgba(10,6,4,0.99));
  border: 1px solid rgba(180,60,40,0.55);
  border-radius: 10px;
  padding: 12px 14px;
  width: 200px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.75);
  color: var(--text-primary, #e8d5a8);
  font-size: 0.8rem;
  text-align: center;
}

#retreat-confirm p {
  margin: 0 0 10px;
  line-height: 1.5;
}

#retreat-confirm p span {
  font-size: 0.7rem;
  color: rgba(220,180,100,0.7);
  font-style: italic;
}

#retreat-confirm.hidden {
  display: none;
}

.retreat-confirm-btns {
  display: flex;
  gap: 8px;
}

.retreat-confirm-btns button {
  flex: 1;
  padding: 7px 4px;
  border-radius: 7px;
  border: none;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}

#retreat-confirm-yes {
  background: rgba(160,40,30,0.9);
  color: #fff;
  border: 1px solid rgba(220,80,60,0.5);
}

#retreat-confirm-no {
  background: rgba(40,50,60,0.9);
  color: #ccc;
  border: 1px solid rgba(100,120,140,0.4);
}

/* ── XP strip ── */
#xp-bar-container {
  height: 4px;
  background: rgba(0,0,0,0.55);
  flex-shrink: 0;
  border-top: 1px solid rgba(255,255,255,0.05);
}

#xp-bar {
  height: 100%;
  background: linear-gradient(90deg, #4040c0, #7070ff);
  width: 0%;
  transition: width 0.4s ease;
  box-shadow: 0 0 6px rgba(100,100,255,0.45);
}

/* Cheat: Increase stats — tap targets on HUD */
body.cheat-increase-stats [data-hud-cheat-target] {
  cursor: pointer;
  pointer-events: auto;
  position: relative;
  z-index: 1;
}

/* Disabled ability slots still capture clicks; let taps pass through to stats (mana row, etc.) */
body.cheat-increase-stats .hud-actions .hud-action-slot:disabled {
  pointer-events: none;
}

body.cheat-increase-stats #xp-bar-container {
  display: flex;
  align-items: center;
  min-height: 16px;
  padding: 6px 0;
  box-sizing: border-box;
}

/* flex-grow must stay 0 or JS width % is ignored and the bar always looks full */
body.cheat-increase-stats #xp-bar-container #xp-bar {
  flex: 0 0 auto;
  flex-grow: 0;
  height: 4px;
  min-height: 4px;
  max-width: 100%;
}

/* ── Bottom rectangle HUD ── */
#hud-bar {
  position: relative;
  z-index: 60;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 8px;
  padding: 10px 10px 12px;
  flex-shrink: 0;
  overflow: visible;
  background: var(--hud-bar-bg);
  border-top: 1px solid rgba(255,255,255,0.07);
  box-shadow: 0 -4px 24px rgba(0,0,0,0.45);
}

/* Character portrait */
#hud-portrait-wrap {
  flex-shrink: 0;
  align-self: stretch;
  display: flex;
  align-items: stretch;
  overflow: visible;
  z-index: 10;
  position: relative;
}

/* ── Freezing Hit screen border ── */
.freeze-overlay {
  position: fixed;
  /* Cover from top of screen down to just above the HUD — pointer-events: none so taps pass through */
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 55;
  pointer-events: none;
  background-image: url('../assets/ui/freeze-effect.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.freeze-overlay.hidden { display: none; }
.freeze-overlay.stacks-1 { opacity: 0.75; }
.freeze-overlay.stacks-2 { opacity: 0.82; }
.freeze-overlay.stacks-3 { opacity: 0.88; }
.freeze-overlay.stacks-4 { opacity: 0.93; }
.freeze-overlay.stacks-5 { opacity: 1.00; }

/* ── Low health blood border ── */
.blood-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 54;
  pointer-events: none;
  background-image: url('../assets/ui/blood-border.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 0.5s ease;
  animation: blood-pulse 1.8s ease-in-out infinite;
}
.blood-overlay.hidden { display: none; }
.blood-overlay.active { opacity: 1; }

@keyframes blood-pulse {
  0%, 100% { opacity: 0; }
  50%       { opacity: 0.5; }
}

/* ── Burn screen border overlay ── */
.burn-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 53;
  pointer-events: none;
  /* Fiery vignette using radial gradient — no extra asset needed */
  background:
    radial-gradient(ellipse at top left,    rgba(255, 80,  0, 0.55) 0%, transparent 55%),
    radial-gradient(ellipse at top right,   rgba(255, 120, 0, 0.45) 0%, transparent 55%),
    radial-gradient(ellipse at bottom left, rgba(255, 60,  0, 0.50) 0%, transparent 55%),
    radial-gradient(ellipse at bottom right,rgba(255, 100, 0, 0.45) 0%, transparent 55%);
  opacity: 0;
  transition: opacity 0.4s ease;
  animation: burn-flicker 1.2s ease-in-out infinite;
}
.burn-overlay.hidden { display: none; }
.burn-overlay.stacks-1 { opacity: 0.55; }
.burn-overlay.stacks-2 { opacity: 0.75; }
.burn-overlay.stacks-3 { opacity: 1.00; }

@keyframes burn-flicker {
  0%, 100% { opacity: var(--burn-base, 0.75); filter: brightness(1.0); }
  30%       { opacity: calc(var(--burn-base, 0.75) * 0.85); filter: brightness(1.1); }
  65%       { opacity: calc(var(--burn-base, 0.75) * 1.10); filter: brightness(0.95); }
}

/* ── Player Poison screen overlay ── */
.player-poison-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 51;
  pointer-events: none;
  background:
    radial-gradient(ellipse at top left,    rgba(30, 160, 20, 0.55) 0%, transparent 55%),
    radial-gradient(ellipse at top right,   rgba(50, 180, 10, 0.45) 0%, transparent 55%),
    radial-gradient(ellipse at bottom left, rgba(20, 140, 10, 0.50) 0%, transparent 55%),
    radial-gradient(ellipse at bottom right,rgba(40, 160, 15, 0.45) 0%, transparent 55%);
  opacity: 0;
  transition: opacity 0.4s ease;
  animation: poison-seep 2.0s ease-in-out infinite;
}
.player-poison-overlay.hidden  { display: none; }
.player-poison-overlay.stacks-1 { opacity: 0.35; }
.player-poison-overlay.stacks-2 { opacity: 0.50; }
.player-poison-overlay.stacks-3 { opacity: 0.65; }
.player-poison-overlay.stacks-4 { opacity: 0.80; }
.player-poison-overlay.stacks-5 { opacity: 1.00; }

@keyframes poison-seep {
  0%, 100% { filter: brightness(1.0) saturate(1.0); }
  50%       { filter: brightness(0.88) saturate(1.3); }
}

/* ── Corruption screen overlay ── */
.corruption-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 52;
  pointer-events: none;
  /* Sickly purple-green vignette */
  background:
    radial-gradient(ellipse at top left,    rgba(100, 0, 180, 0.50) 0%, transparent 55%),
    radial-gradient(ellipse at top right,   rgba(60,  120, 0, 0.45) 0%, transparent 55%),
    radial-gradient(ellipse at bottom left, rgba(80,  0,  160, 0.45) 0%, transparent 55%),
    radial-gradient(ellipse at bottom right,rgba(40,  100, 0, 0.50) 0%, transparent 55%);
  opacity: 0;
  transition: opacity 0.4s ease;
  animation: corruption-pulse 2.4s ease-in-out infinite;
}
.corruption-overlay.hidden  { display: none; }
.corruption-overlay.stacks-1 { opacity: 0.40; }
.corruption-overlay.stacks-2 { opacity: 0.55; }
.corruption-overlay.stacks-3 { opacity: 0.68; }
.corruption-overlay.stacks-4 { opacity: 0.82; }
.corruption-overlay.stacks-5 { opacity: 1.00; }

@keyframes corruption-pulse {
  0%, 100% { filter: hue-rotate(0deg)   brightness(1.0); }
  50%       { filter: hue-rotate(20deg)  brightness(0.9); }
}

/* Teary Eyes debuff badge — sits top-right of the portrait */
/* No global `.hidden` in this project — must be explicit (see main.css comment). */
#hud-teary-eyes.hidden,
#hud-freezing-hit.hidden,
#hud-burn.hidden,
#hud-corruption.hidden,
#hud-player-poison.hidden {
  display: none !important;
}

.hud-debuff-btn {
  position: absolute;
  top: -6px;
  right: -8px;
  z-index: 20;
  background: linear-gradient(135deg, #1a2a3a, #0d1a26);
  border: 1.5px solid #4ab0e8;
  border-radius: 10px;
  color: #7fd4ff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 5px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 0 6px rgba(74,176,232,0.5);
  animation: teary-pulse 1.8s ease-in-out infinite;
}
.hud-debuff-btn:active { transform: scale(0.93); }

@keyframes teary-pulse {
  0%, 100% { box-shadow: 0 0 5px rgba(74,176,232,0.4); }
  50%       { box-shadow: 0 0 11px rgba(74,176,232,0.85); }
}

.hud-portrait {
  width: 72px;
  align-self: stretch;
  position: relative;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(255,255,255,0.12) 0%, transparent 42%),
    linear-gradient(180deg, #3a3848 0%, #252530 100%);
  border: 2px solid rgba(90,85,110,0.85);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.15),
    inset 0 -2px 0 rgba(0,0,0,0.35),
    0 3px 10px rgba(0,0,0,0.5);
}

#hud-portrait-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  object-fit: contain;
  object-position: center center;
  image-rendering: pixelated;
  pointer-events: none;
  z-index: 20;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.9));
}

#hud-portrait-wrap.is-ranger .hud-portrait {
  border-color: rgba(80, 140, 90, 0.85);
  background:
    linear-gradient(145deg, rgba(120,200,140,0.15) 0%, transparent 45%),
    linear-gradient(180deg, #283828 0%, #1a241c 100%);
}

/* Stats column — pill / bar feel (shrinks first; keeps readable minimum) */
#hud-stats {
  flex: 1;
  min-width: 50px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  justify-content: center;
}

.hud-stat-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  min-height: 22px;
  min-width: 0;
  /* Socket / inset look */
  background: rgba(0,0,0,0.48);
  border-radius: 7px;
  padding: 3px 7px;
  border: 1px solid rgba(0,0,0,0.7);
  box-shadow:
    inset 0 2px 4px rgba(0,0,0,0.55),
    inset 0 1px 0 rgba(0,0,0,0.4),
    0 1px 0 rgba(255,255,255,0.07);
}

.hud-stat-row.hud-stat-dmg {
  background: rgba(0,0,0,0.48);
  border-radius: 7px;
  padding: 3px 7px;
  border: 1px solid rgba(0,0,0,0.7);
  box-shadow:
    inset 0 2px 4px rgba(0,0,0,0.55),
    inset 0 1px 0 rgba(0,0,0,0.4),
    0 1px 0 rgba(255,255,255,0.07);
}

.hud-stat-ic {
  flex-shrink: 0;
  font-size: 0.85rem;
  line-height: 1;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.6));
}

.hud-micro-bar {
  flex: 1;
  min-width: 0;
  height: 8px;
  border-radius: 5px;
}

.hud-stat-num {
  flex-shrink: 1;
  font-size: clamp(0.52rem, 0.9vw + 0.42rem, 0.62rem);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-weight: 600;
  color: rgba(235, 228, 215, 0.92);
  letter-spacing: 0.3px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.85);
  min-width: 0;
  text-align: right;
}

.hud-dmg-num {
  font-size: 0.68rem;
  text-align: left;
  flex: 1;
  min-width: 0;
}

.hud-meta {
  display: flex;
  align-items: center;
  margin-top: 1px;
}

/* Gold gets its own socket row matching HP/mana */
.hud-gold-inline {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  font-size: 0.62rem;
  color: var(--gold);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-weight: 700;
  text-shadow: 0 0 10px rgba(255,200,0,0.35);
  background: rgba(0,0,0,0.48);
  border-radius: 7px;
  padding: 3px 7px;
  border: 1px solid rgba(0,0,0,0.7);
  box-shadow:
    inset 0 2px 4px rgba(0,0,0,0.55),
    inset 0 1px 0 rgba(0,0,0,0.4),
    0 1px 0 rgba(255,255,255,0.07);
}

.hud-gold-inline .gold-icon {
  font-size: 0.75rem;
}

/* Golden keys — middle HUD slot when count > 0 */
.hud-key-golden-slot {
  position: relative;
}

#hud-key-slot-placeholder.hidden {
  display: none !important;
}

.hud-key-display.hud-key-display--slot {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  margin: 0;
  padding: 2px;
  font-size: 0.58rem;
  font-weight: 800;
  font-family: ui-sans-serif, system-ui, sans-serif;
  color: #ffe066;
  text-shadow:
    0 0 10px rgba(255, 200, 60, 0.85),
    0 1px 2px rgba(0, 0, 0, 0.9);
  line-height: 1.05;
}

.hud-key-display.hud-key-display--slot .key-icon {
  font-size: clamp(0.95rem, 2.8vw, 1.15rem);
  line-height: 1;
  filter: drop-shadow(0 0 4px rgba(255, 210, 80, 0.75));
}

.hud-key-display.hidden {
  display: none !important;
}

/* Stat bars (shared with legacy class names) */
.stat-bar {
  background: rgba(0,0,0,0.65);
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.8);
  box-shadow:
    inset 0 2px 3px rgba(0,0,0,0.6),
    0 1px 0 rgba(255,255,255,0.06);
}

.stat-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.35s ease;
}

.hp-fill {
  width: 100%;
  background: linear-gradient(90deg, var(--hp-red), var(--hp-bright));
  box-shadow: 0 0 8px rgba(231,76,60,0.35);
}

.hp-fill.critical {
  background: linear-gradient(90deg, #700000, #cc0000);
  animation: pulse-danger 0.7s ease-in-out infinite;
}

.mana-fill {
  width: 100%;
  background: linear-gradient(90deg, var(--mana-blue), var(--mana-bright));
  box-shadow: 0 0 8px rgba(46,134,193,0.35);
}

/* Key items — same row height as ability column; squares grow to match ability cell height when space allows */
.hud-keys {
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: center;
  align-items: center;
  align-self: stretch;
  flex-shrink: 0;
  width: min-content;
}

.hud-key-slot {
  box-sizing: border-box;
  flex: 0 0 auto;
  /* One row of the 3×2 ability grid: same vertical slice as a single ability row */
  height: max(30px, calc((100% - 8px) / 3));
  width: auto;
  max-width: 100%;
  aspect-ratio: 1;
  min-width: 30px;
  min-height: 30px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.4);
}

.hud-key-slot-img {
  max-height: 82%;
  width: auto;
  max-width: 92%;
  object-fit: contain;
  image-rendering: pixelated;
  pointer-events: none;
}

.hud-key-ghost {
  font-size: 0.85rem;
  opacity: 0.28;
  filter: grayscale(0.4);
}

.hud-key-backpack {
  font-size: 0.9rem;
  cursor: pointer;
  border-color: rgba(245,197,24,0.35);
  transition: border-color 0.15s, transform 0.1s;
}

.hud-key-backpack:active {
  transform: scale(0.9);
  border-color: rgba(245,197,24,0.7);
}

/* 2×3 action slots */
.hud-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(3, 1fr);
  gap: 4px;
  align-self: stretch;
  flex-shrink: 0;
}

.hud-action-slot {
  touch-action: none;
  aspect-ratio: 1;
  border-radius: 8px;
  border: 2px solid rgba(245, 197, 24, 0.38);
  background: linear-gradient(165deg, rgba(40,38,52,0.95) 0%, rgba(18,18,28,0.98) 100%);
  font-size: 1.15rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--text-primary);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.1),
    0 2px 6px rgba(0,0,0,0.45);
  transition: transform 0.1s ease, opacity 0.15s ease;
}

.hud-action-slot:not(:disabled):active {
  transform: scale(0.94);
}

.hud-action-slot.is-backpack:not(:disabled) {
  border-color: rgba(245, 197, 24, 0.55);
}

.hud-action-slot:disabled {
  opacity: 0.45;
  cursor: default;
}

.hud-action-slot.is-slam {
  border-color: rgba(255, 120, 20, 0.6);
  padding: 2px;
  overflow: hidden;
  width: 44px;
  height: 44px;
}

.hud-action-slot.is-slam-active {
  border-color: #ff7014;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.1),
    0 0 10px rgba(255,100,0,0.6),
    0 2px 6px rgba(0,0,0,0.45);
  animation: pulse-slam 0.9s ease-in-out infinite;
}

@keyframes pulse-slam {
  0%, 100% { box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 0 8px rgba(255,100,0,0.5), 0 2px 6px rgba(0,0,0,0.45); }
  50%       { box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 0 18px rgba(255,140,0,0.85), 0 2px 6px rgba(0,0,0,0.45); }
}

.hud-action-slot.is-ricochet {
  border-color: rgba(60, 200, 255, 0.55);
  padding: 2px;
  overflow: hidden;
  width: 44px;
  height: 44px;
}

.hud-action-slot.is-ricochet-active {
  border-color: #38c8ff;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.1),
    0 0 10px rgba(56, 200, 255, 0.55),
    0 2px 6px rgba(0, 0, 0, 0.45);
  animation: pulse-ricochet 0.9s ease-in-out infinite;
}

@keyframes pulse-ricochet {
  0%, 100% { box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 0 8px rgba(56, 200, 255, 0.45), 0 2px 6px rgba(0,0,0,0.45); }
  50%       { box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 0 18px rgba(80, 220, 255, 0.85), 0 2px 6px rgba(0,0,0,0.45); }
}

.hud-action-slot.is-arrow-barrage {
  border-color: rgba(255, 170, 80, 0.55);
  padding: 2px;
  overflow: hidden;
  width: 44px;
  height: 44px;
}

.hud-action-slot.is-arrow-barrage-active {
  border-color: #ffb04a;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.1),
    0 0 10px rgba(255, 160, 70, 0.5),
    0 2px 6px rgba(0, 0, 0, 0.45);
  animation: pulse-arrow-barrage 0.9s ease-in-out infinite;
}

@keyframes pulse-arrow-barrage {
  0%, 100% { box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 0 8px rgba(255, 150, 60, 0.4), 0 2px 6px rgba(0,0,0,0.45); }
  50%       { box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 0 18px rgba(255, 190, 90, 0.85), 0 2px 6px rgba(0,0,0,0.45); }
}

.hud-action-slot.is-poison-arrow-shot {
  border-color: rgba(120, 220, 100, 0.55);
  padding: 2px;
  overflow: hidden;
  width: 44px;
  height: 44px;
}

.hud-action-slot.is-poison-arrow-shot-active {
  border-color: #6ecf6e;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.1),
    0 0 10px rgba(100, 200, 90, 0.5),
    0 2px 6px rgba(0, 0, 0, 0.45);
  animation: pulse-poison-arrow 0.9s ease-in-out infinite;
}

@keyframes pulse-poison-arrow {
  0%, 100% { box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 0 8px rgba(90, 180, 80, 0.4), 0 2px 6px rgba(0,0,0,0.45); }
  50%       { box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 0 18px rgba(120, 220, 100, 0.75), 0 2px 6px rgba(0,0,0,0.45); }
}

.hud-action-slot.is-placeholder {
  font-size: 0.85rem;
  font-weight: 700;
  color: rgba(120,115,105,0.7);
  letter-spacing: 1px;
}

.ability-btn-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.ability-btn-emoji {
  font-size: 1.75rem;
  line-height: 1;
}

.ability-btn-img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
  flex-shrink: 0;
}

.ability-btn-wrap--ricochet .ability-btn-bg,
.ability-btn-wrap--arrow-barrage .ability-btn-bg,
.ability-btn-wrap--poison-arrow-shot .ability-btn-bg,
.ability-btn-wrap--divine-light .ability-btn-bg {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
  flex-shrink: 0;
}

.ability-btn-wrap--ricochet .ability-btn-badge,
.ability-btn-wrap--arrow-barrage .ability-btn-badge,
.ability-btn-wrap--poison-arrow-shot .ability-btn-badge,
.ability-btn-wrap--divine-light .ability-btn-badge {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  object-fit: contain;
  pointer-events: none;
  z-index: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

/* Mana cost bottom-right — Ricochet / Triple Volley / Poison badge stays centered; Slam / Blinding use same corner layout */
.ability-btn-wrap--ricochet .ability-btn-cost,
.ability-btn-wrap--arrow-barrage .ability-btn-cost,
.ability-btn-wrap--poison-arrow-shot .ability-btn-cost,
.ability-btn-wrap--divine-light .ability-btn-cost,
.ability-btn-wrap--mana-corner .ability-btn-cost {
  top: auto;
  left: auto;
  right: 1px;
  bottom: 0;
  transform: none;
  font-size: 0.62rem;
  z-index: 2;
}

.ability-btn-cost {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.95rem;
  font-weight: 800;
  color: #82b4e7;
  -webkit-text-stroke: 1px #2a3fa3;
  text-shadow: 0 0 4px #000, 0 0 8px #000, 0 1px 2px #000;
  pointer-events: none;
  line-height: 1;
}

.hud-action-slot.is-blinding-light {
  border-color: rgba(100, 180, 255, 0.6);
  padding: 2px;
  overflow: hidden;
  width: 44px;
  height: 44px;
}

.hud-action-slot.is-blinding-light-active {
  border-color: #64b4ff;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.1),
    0 0 14px rgba(100,180,255,0.7),
    0 2px 6px rgba(0,0,0,0.45);
  animation: pulse-blinding 1s ease-in-out infinite;
}

@keyframes pulse-blinding {
  0%, 100% { box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 0 10px rgba(100,180,255,0.5), 0 2px 6px rgba(0,0,0,0.45); }
  50%       { box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 0 20px rgba(100,180,255,0.9), 0 2px 6px rgba(0,0,0,0.45); }
}

/* ── Divine Light ── */
.hud-action-slot.is-divine-light {
  border-color: rgba(255, 220, 80, 0.6);
  padding: 2px;
  overflow: hidden;
  width: 44px;
  height: 44px;
}

.hud-action-slot.is-divine-light-active {
  border-color: #ffd84a;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.1),
    0 0 14px rgba(255,220,80,0.7),
    0 2px 6px rgba(0,0,0,0.45);
  animation: pulse-divine 1s ease-in-out infinite;
}

@keyframes pulse-divine {
  0%, 100% { box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 0 10px rgba(255,220,80,0.5), 0 2px 6px rgba(0,0,0,0.45); }
  50%       { box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 0 20px rgba(255,220,80,0.9), 0 2px 6px rgba(0,0,0,0.45); }
}

.ability-btn-divine-icon {
  font-size: 1.6rem;
  line-height: 1;
  display: block;
}

/* Portrait glows gold when Divine Light heal is ready */
#hud-portrait-wrap.divine-light-target .hud-portrait {
  box-shadow: 0 0 16px 4px rgba(255, 220, 80, 0.75);
  cursor: pointer;
  animation: pulse-divine 1s ease-in-out infinite;
}

/* ── Combat / retreat buttons (below message) ── */
.action-btn {
  flex: 1;
  padding: 9px 6px;
  border-radius: 0.5em;
  font-size: 0.75rem;
  font-family: Georgia, serif;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  user-select: none;
  letter-spacing: 0.3px;
  line-height: 1.2;
  background: var(--color-back);
  border: solid 2px #030f14;
  color: var(--btn-text);
  box-shadow:
    inset 0px -6px 18px -6px rgba(3, 15, 20, 0),
    inset rgba(54, 69, 75, 1) -1px -1px 6px 0px,
    inset 12px 0px 12px -6px rgba(3, 15, 20, 0),
    inset -12px 0px 12px -6px rgba(3, 15, 20, 0),
    rgba(54, 69, 75, 1) -1px -1px 6px 0px;
  transition: all 0.3s;
}
.action-btn:hover {
  box-shadow:
    inset 0px -6px 18px -6px rgba(3, 15, 20, 1),
    inset 0px 6px 18px -6px rgba(3, 15, 20, 1),
    inset 12px 0px 12px -6px rgba(3, 15, 20, 0),
    inset -12px 0px 12px -6px rgba(3, 15, 20, 0),
    -1px -1px 6px 0px rgba(54, 69, 75, 1);
}
.action-btn:active {
  box-shadow:
    inset 0px -12px 12px -6px rgba(3, 15, 20, 1),
    inset 0px 12px 12px -6px rgba(3, 15, 20, 1),
    inset 12px 0px 12px -6px rgba(3, 15, 20, 1),
    inset -12px 0px 12px -6px rgba(3, 15, 20, 1),
    -1px -1px 6px 0px rgba(54, 69, 75, 1);
  transform: scale(0.95);
}
.action-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.spell-btn { color: #8ab4ff; }
.spell-btn.targeting {
  color: #c0d8ff;
  animation: pulse-spell 1s ease-in-out infinite;
}

@keyframes pulse-spell {
  0%, 100% { box-shadow:
    inset 0px -6px 18px -6px rgba(3, 15, 20, 0),
    inset rgba(54, 69, 75, 1) -1px -1px 6px 0px,
    inset 12px 0px 12px -6px rgba(3, 15, 20, 0),
    inset -12px 0px 12px -6px rgba(3, 15, 20, 0),
    rgba(54, 69, 75, 1) -1px -1px 6px 0px,
    0 0 8px rgba(80,120,255,0.4); }
  50%       { box-shadow:
    inset 0px -6px 18px -6px rgba(3, 15, 20, 0),
    inset rgba(54, 69, 75, 1) -1px -1px 6px 0px,
    inset 12px 0px 12px -6px rgba(3, 15, 20, 0),
    inset -12px 0px 12px -6px rgba(3, 15, 20, 0),
    rgba(54, 69, 75, 1) -1px -1px 6px 0px,
    0 0 18px rgba(100,150,255,0.75); }
}

.flee-btn { color: #90d890; }

.retreat-btn {
  width: 100%;
  background: var(--color-back);
  border: solid 2px #030f14;
  color: var(--btn-text);
  font-size: 0.72rem;
  font-weight: 700;
  font-family: Georgia, serif;
  padding: 8px;
  border-radius: 0.5em;
  cursor: pointer;
  outline: none;
  user-select: none;
  box-shadow:
    inset 0px -6px 18px -6px rgba(3, 15, 20, 0),
    inset rgba(54, 69, 75, 1) -1px -1px 6px 0px,
    inset 12px 0px 12px -6px rgba(3, 15, 20, 0),
    inset -12px 0px 12px -6px rgba(3, 15, 20, 0),
    rgba(54, 69, 75, 1) -1px -1px 6px 0px;
  transition: all 0.3s;
}
.retreat-btn:hover {
  box-shadow:
    inset 0px -6px 18px -6px rgba(3, 15, 20, 1),
    inset 0px 6px 18px -6px rgba(3, 15, 20, 1),
    inset 12px 0px 12px -6px rgba(3, 15, 20, 0),
    inset -12px 0px 12px -6px rgba(3, 15, 20, 0),
    -1px -1px 6px 0px rgba(54, 69, 75, 1);
}
.retreat-btn:active {
  box-shadow:
    inset 0px -12px 12px -6px rgba(3, 15, 20, 1),
    inset 0px 12px 12px -6px rgba(3, 15, 20, 1),
    inset 12px 0px 12px -6px rgba(3, 15, 20, 1),
    inset -12px 0px 12px -6px rgba(3, 15, 20, 1),
    -1px -1px 6px 0px rgba(54, 69, 75, 1);
  transform: scale(0.97);
}

