/* ============================================================
   hud.css — In-Game HUD, styled to match the landing page.
   Loaded AFTER style.css so it supersedes the original HUD rules.

   Shared vocabulary with the landing page:
     • Orbitron (--font-wordmark) for numerals, Space Grotesk
       (--font-crypto) for captions
     • glass panels: dark translucent fill + backdrop blur
     • green-tinted hairline borders, pill radii
     • uppercase micro-captions in --color-text-dim
     • gradient + glow reserved for the primary action
   ============================================================ */

/* ── Top bar: brand + system controls (mirrors the landing navbar) ── */
.hud-topbar {
  position: absolute;
  top: calc(var(--sp-3) + var(--safe-top));
  left: var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-3);
  border-radius: var(--radius-pill);
  background: rgba(13, 17, 23, 0.68);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid rgba(63, 185, 80, 0.18);
  pointer-events: auto;
}

.hud-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding-right: var(--sp-3);
  margin-right: var(--sp-1);
  border-right: 1px solid var(--color-border);
}

.hud-brand-mark {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--color-primary), #1f7a33);
  font-size: 13px;
  line-height: 1;
  box-shadow: 0 0 12px rgba(63, 185, 80, 0.40);
}

.hud-brand-word {
  font-family: var(--font-wordmark);
  font-size: var(--fs-sm);
  font-weight: 800;
  letter-spacing: 0.08em;
  background: linear-gradient(180deg, #eafff0, var(--color-primary));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hud-sys-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-circle);
  border: 1px solid var(--color-border);
  background: rgba(28, 33, 40, 0.9);
  color: var(--color-text-muted);
  font-family: var(--font-crypto);
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast),
              transform var(--transition-fast);
}

.hud-sys-btn:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
  transform: translateY(-1px);
}

.hud-sys-btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* ── Stat chips (top right) — landing's .landing-stat, condensed ── */
.hud-stats {
  position: absolute;
  top: calc(var(--sp-3) + var(--safe-top));
  right: var(--sp-4);
  left: auto;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: var(--sp-2);
}

.hud-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 62px;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-lg);
  background: rgba(13, 17, 23, 0.68);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border: 1px solid rgba(63, 185, 80, 0.18);
  box-shadow: none;
  letter-spacing: normal;
}

.hud-stat-value {
  font-family: var(--font-wordmark);
  font-size: var(--fs-lg);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.03em;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 14px rgba(63, 185, 80, 0.35);
}

.hud-stat-label {
  margin-top: 2px;
  font-family: var(--font-crypto);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--color-text-dim);
}

.hud-stat.is-muted { opacity: 0.7; }
.hud-stat.is-muted .hud-stat-value {
  color: var(--color-text-muted);
  font-size: var(--fs-md);
  text-shadow: none;
}

/* ── HP / Mana bars ── */
.hud-bars {
  position: absolute;
  bottom: calc(var(--sp-6) + var(--touch-btn-size) + var(--sp-5));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  /* MUST override style.css's align-items:center. Centred column items size
     to their content, and .hud-bar-fill is a percentage width — against a
     content-sized parent that resolves to zero and the bar vanishes. */
  align-items: stretch;
  gap: var(--sp-2);
  width: clamp(230px, 32vw, 340px);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-lg);
  background: rgba(13, 17, 23, 0.60);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border: 1px solid rgba(63, 185, 80, 0.16);
}

.hud-bar-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.hud-bar-caption {
  flex: none;
  width: 34px;
  font-family: var(--font-crypto);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--color-text-dim);
}

.hud-bar-container {
  position: relative;
  /* Zero basis + grow: the track claims all remaining row width regardless
     of its (percentage-width, therefore content-less) children. */
  flex: 1 1 0%;
  width: auto;
  min-width: 0;
  height: 14px;
  background: rgba(5, 8, 11, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-pill);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6);
  backdrop-filter: none;
  overflow: hidden;
}

.hud-bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width var(--transition-normal);
}

.hud-bar-fill.hp {
  background: linear-gradient(90deg, #2ea043, #56d364);
  box-shadow: 0 0 12px rgba(63, 185, 80, 0.55);
}

.hud-bar-fill.mana {
  background: linear-gradient(90deg, #1f6feb, #58a6ff);
  box-shadow: 0 0 12px rgba(88, 166, 255, 0.55);
}

.hud-bar-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-wordmark);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--color-white);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95);
  line-height: 1;
}

/* ── Skill buttons ── */
.hud-skills {
  position: absolute;
  bottom: calc(var(--sp-5) + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: var(--sp-3);
  align-items: flex-end;
  padding: var(--sp-3);
  border-radius: var(--radius-xl);
  background: rgba(13, 17, 23, 0.55);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border: 1px solid rgba(63, 185, 80, 0.14);
}

.skill-btn {
  position: relative;
  width: var(--touch-btn-size);
  height: var(--touch-btn-size);
  min-width: 44px;
  min-height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  background: linear-gradient(180deg, rgba(38, 44, 54, 0.95), rgba(22, 27, 34, 0.95));
  color: var(--color-text);
  cursor: pointer;
  overflow: hidden;
  transition: transform var(--transition-fast), border-color var(--transition-fast),
              box-shadow var(--transition-fast);
  -webkit-touch-callout: none;
}

.skill-icon {
  font-size: 26px;
  line-height: 1;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.6));
}

.skill-btn:hover {
  border-color: var(--color-primary);
  box-shadow: 0 0 16px rgba(63, 185, 80, 0.30);
  transform: translateY(-2px);
}

.skill-btn:active, .skill-btn.pressed {
  transform: translateY(0) scale(0.94);
  border-color: var(--color-primary-active);
  box-shadow: inset 0 0 18px rgba(63, 185, 80, 0.25);
}

.skill-btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.skill-btn:disabled, .skill-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: var(--color-text-dim);
}

/* Primary attack carries the landing page's gradient. */
#skill-1 {
  border-color: rgba(63, 185, 80, 0.55);
  background: linear-gradient(180deg, rgba(63, 185, 80, 0.22), rgba(63, 185, 80, 0.06));
}

/* Ultimate is the one gold element, same role as the landing accent. */
.skill-btn.ultimate {
  width: calc(var(--touch-btn-size) + 8px);
  height: calc(var(--touch-btn-size) + 8px);
  border-color: rgba(212, 160, 37, 0.6);
  background: linear-gradient(180deg, rgba(212, 160, 37, 0.24), rgba(212, 160, 37, 0.06));
  box-shadow: 0 0 18px rgba(212, 160, 37, 0.25);
}

.skill-btn.ultimate:hover {
  border-color: var(--color-accent);
  box-shadow: 0 0 26px rgba(212, 160, 37, 0.45);
}

.skill-btn.on-cooldown {
  border-color: var(--color-border);
  box-shadow: none;
}

.skill-btn.no-mana {
  border-color: var(--color-danger);
  box-shadow: 0 0 14px rgba(248, 81, 73, 0.35);
  animation: shake-subtle 0.3s ease;
}

.skill-hotkey {
  position: absolute;
  top: 3px;
  right: 3px;
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  background: rgba(5, 8, 11, 0.9);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-family: var(--font-crypto);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.4;
  z-index: 2;
}

.skill-cooldown-overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 8, 11, 0.72);
  clip-path: polygon(50% 50%, 50% 0%, 50% 0%);
  pointer-events: none;
  border-radius: inherit;
}

.skill-cooldown-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-wordmark);
  font-size: var(--fs-lg);
  font-weight: 800;
  color: var(--color-white);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.95);
  pointer-events: none;
  z-index: 3;
}

/* ── Touch controls ── */
.touch-dpad-btn {
  border: 1px solid rgba(63, 185, 80, 0.25);
  background: rgba(13, 17, 23, 0.62);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--color-text-muted);
  transition: border-color var(--transition-fast), color var(--transition-fast);
}

.touch-dpad-btn:active, .touch-dpad-btn.pressed {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: rgba(63, 185, 80, 0.18);
}

/* ── Nametags ── */
.nametag {
  font-family: var(--font-crypto);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--color-text);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95);
}



.player-nametag {
  color: var(--color-primary);
  text-shadow: 0 0 10px rgba(63, 185, 80, 0.5), 0 1px 3px rgba(0, 0, 0, 0.95);
}

/* ── Boss health banner ── */
.boss-health-container {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-lg);
  background: rgba(13, 17, 23, 0.72);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border: 1px solid rgba(212, 160, 37, 0.35);
  box-shadow: 0 0 28px rgba(212, 160, 37, 0.18);
}

.boss-name {
  font-family: var(--font-wordmark);
  font-size: var(--fs-md);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-accent);
  text-shadow: 0 0 14px rgba(212, 160, 37, 0.45);
  text-align: center;
}

.boss-health-bar {
  background: rgba(5, 8, 11, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.boss-health-fill {
  background: linear-gradient(90deg, #c9302c, #f85149);
  box-shadow: 0 0 14px rgba(248, 81, 73, 0.5);
  border-radius: var(--radius-pill);
}

/* ── Damage numbers: match the HUD's numeral face ── */
.dmg-number { font-family: var(--font-wordmark); font-weight: 800; }

/* ── Narrow screens ── */
@media (max-width: 720px) {
  .hud-brand { display: none; }   /* controls stay, wordmark goes */

  .hud-stat {
    min-width: 52px;
    padding: var(--sp-1) var(--sp-2);
  }

  .hud-stat-value { font-size: var(--fs-md); }

  .hud-bars {
    width: min(76vw, 300px);
    padding: var(--sp-2) var(--sp-3);
  }

  .hud-skills {
    gap: var(--sp-2);
    padding: var(--sp-2);
  }
}

/* ── Pickup popups (share the damage-number pool) ── */
.dmg-number.is-points {
  font-size: 22px;
  color: var(--color-accent);
  letter-spacing: 0.02em;
}

.dmg-number.is-mana {
  font-size: 20px;
  color: var(--color-mana);
}

.dmg-number.is-item {
  font-size: 20px;
  color: var(--color-primary);
}

/* ── Level-up: pulse the level chip instead of a corner toast ── */
.hud-stat { position: relative; }

.hud-stat.is-levelup {
  animation: levelup-pulse 0.7s ease;
}
.hud-stat.is-levelup .hud-stat-value {
  animation: levelup-value 0.7s ease;
}

@keyframes levelup-pulse {
  0%   { transform: scale(1);    border-color: rgba(63, 185, 80, 0.18); box-shadow: none; }
  35%  { transform: scale(1.18); border-color: var(--color-accent);
         box-shadow: 0 0 22px rgba(212, 160, 37, 0.6); }
  100% { transform: scale(1);    border-color: rgba(63, 185, 80, 0.18); box-shadow: none; }
}

@keyframes levelup-value {
  0%   { color: var(--color-primary); }
  35%  { color: var(--color-accent); text-shadow: 0 0 18px rgba(212, 160, 37, 0.8); }
  100% { color: var(--color-primary); }
}

.hud-levelup-burst {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--color-accent);
  color: #1a1205;
  font-family: var(--font-wordmark);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  box-shadow: 0 0 16px rgba(212, 160, 37, 0.5);
}

.hud-levelup-burst.is-show {
  animation: levelup-burst 1.4s ease forwards;
}

@keyframes levelup-burst {
  0%   { opacity: 0; transform: translateX(-50%) translateY(-6px) scale(0.7); }
  18%  { opacity: 1; transform: translateX(-50%) translateY(2px)  scale(1.05); }
  70%  { opacity: 1; transform: translateX(-50%) translateY(4px)  scale(1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(14px) scale(1); }
}

/* ── Boss compass (under the boss health bar) ── */
.boss-compass {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
  transition: opacity var(--transition-normal);
}

.boss-compass-arrow {
  font-size: var(--fs-lg);
  line-height: 1;
  color: var(--color-danger);
  text-shadow: 0 0 10px rgba(248, 81, 73, 0.6);
  will-change: transform;
  animation: boss-compass-throb 1.2s ease-in-out infinite;
}

@keyframes boss-compass-throb {
  0%, 100% { filter: drop-shadow(0 0 2px rgba(248, 81, 73, 0.4)); }
  50%      { filter: drop-shadow(0 0 8px rgba(248, 81, 73, 0.9)); }
}

.boss-compass-dist {
  font-family: var(--font-wordmark);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--color-accent);
  font-variant-numeric: tabular-nums;
  min-width: 3ch;
  text-align: left;
}

/* ── Enemies-left counter (top-right stat row) ── */
#hud-enemies { min-width: 74px; }

#hud-enemies .hud-stat-value {
  font-size: var(--fs-md);          /* "17/20" is wider than a bare number */
  color: var(--color-text);
  text-shadow: none;
  font-variant-numeric: tabular-nums;
}

/* Down to the last few — amber, matching the low-HP language. */
#hud-enemies.is-almost {
  border-color: rgba(212, 160, 37, 0.6);
}
#hud-enemies.is-almost .hud-stat-value {
  color: var(--color-accent);
  text-shadow: 0 0 12px rgba(212, 160, 37, 0.45);
}

/* Stage cleared — green flush. */
#hud-enemies.is-clear .hud-stat-value {
  color: var(--color-primary);
}

/* ── Low-HP blood vignette ──
   Full-screen red edge glow that intensifies as HP drops below 30%.
   On <body> with pointer-events:none so it never blocks input. z-index
   below the HUD controls (z-hud) so buttons stay crisp over the tint. */
.hud-lowhp-vignette {
  position: fixed;
  inset: 0;
  z-index: 22;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.hud-lowhp-pulse {
  position: absolute;
  inset: 0;
  /* Transparent core, deep red toward the edges — a soft blood vignette. */
  background:
    radial-gradient(ellipse 78% 78% at 50% 50%,
      rgba(0, 0, 0, 0) 40%,
      rgba(150, 8, 8, 0) 52%,
      rgba(158, 10, 10, 0.55) 82%,
      rgba(96, 0, 0, 0.88) 100%);
}

/* Heartbeat pulse. The container's inline opacity encodes severity; this
   only breathes the inner layer, so the two never fight. Duration comes from
   --lowhp-pulse (set per frame in JS) — faster as death nears. */
.hud-lowhp-vignette.is-active .hud-lowhp-pulse {
  animation: lowhp-heartbeat var(--lowhp-pulse, 1.2s) ease-in-out infinite;
}

@keyframes lowhp-heartbeat {
  0%, 100% { opacity: 0.6; }
  50%      { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .hud-lowhp-vignette.is-active .hud-lowhp-pulse { animation: none; }
}

/* ============================================================
   Death screen & leaderboard modal
   ============================================================ */
.death-panel {
  position: relative;
  z-index: 1;
  width: min(460px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  padding: var(--sp-8) var(--sp-6);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(28, 20, 22, 0.96), rgba(16, 12, 14, 0.96));
  border: 1px solid rgba(248, 81, 73, 0.28);
  box-shadow: var(--shadow-lg), 0 0 70px rgba(150, 10, 10, 0.25);
}

.death-title {
  font-family: var(--font-wordmark);
  font-size: var(--fs-3xl);
  font-weight: 900;
  letter-spacing: 0.06em;
  text-align: center;
  color: var(--color-danger);
  text-shadow: 0 0 24px rgba(248, 81, 73, 0.5);
  margin: 0;
}

.death-stats {
  text-align: center;
  font-family: var(--font-crypto);
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
}

.death-board-label {
  font-family: var(--font-crypto);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--color-text-dim);
  text-align: center;
}

/* The board reuses .landing-board row styles; just cap its height here. */
.death-board {
  max-height: 44vh;
  overflow-y: auto;
}

.death-actions {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}

.leaderboard-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

/* ── World labels (camp) ── */
/* The player's level chip rides inside the nametag. */
.nametag-level {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(63, 185, 80, 0.22);
  border: 1px solid rgba(63, 185, 80, 0.45);
  color: #56d364;
  font-size: 10px;
  font-weight: 700;
}

/* NPC: gold, so the quest-giver pops against every place label. */
.nametag--npc span:first-child { color: #e8b63a; }
.nametag--npc {
  border-color: rgba(212, 160, 37, 0.5);
  background: rgba(13, 17, 23, 0.82);
}

/* Places: quiet caps — signage, not combatants. */
.nametag--place {
  background: rgba(13, 17, 23, 0.6);
  border-color: rgba(139, 148, 158, 0.28);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #b6bec8;
  opacity: 0.9;
}
