/* Cut-metal silhouettes are decorative layers so text and focus remain free. */
#hud {
  --hud-lime: #e4fb8f;
  --hud-health: #ffa78f;
  --hud-clock: #a9e2ee;
  --hud-money: #f4d281;
  --hud-metal: #59717a;
  --hud-fill: linear-gradient(128deg, #20313cf7, #0c1720fa 76%);
}
#hud .hud-top {
  inset: max(17px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right))
    auto max(18px, env(safe-area-inset-left));
  grid-template-columns: minmax(0,1fr) auto minmax(0,1fr);
  gap: 6px;
}
#hud .readout, #hud .boss-hud, #hud .loadout, #hud .slot, #hud #pause {
  --plate-accent: var(--hud-metal);
  --plate-cut: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
  isolation: isolate;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
#hud .readout, #hud .loadout, #hud .slot, #hud #pause { position: relative; }
#hud :where(.readout, .boss-hud, .loadout, .slot, #pause)::before,
#hud :where(.readout, .boss-hud, .loadout, .slot, #pause)::after {
  content: "";
  position: absolute;
  z-index: -1;
  clip-path: var(--plate-cut);
  pointer-events: none;
}
#hud :where(.readout, .boss-hud, .loadout, .slot, #pause)::before {
  inset: 0;
  background: linear-gradient(142deg, var(--plate-accent), #50626a 48%, #182c37);
}
#hud :where(.readout, .boss-hud, .loadout, .slot, #pause)::after {
  inset: 1px;
  background:
    linear-gradient(90deg, var(--plate-accent), transparent) left top / 44% 2px no-repeat,
    var(--plate-fill, var(--hud-fill));
}
#hud .readout, #hud .boss-hud {
  min-width: 0;
  padding: 8px 11px 9px;
}
#hud .hud-label {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--plate-accent);
  text-transform: uppercase;
}
.hud-label svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#hud .health {
  --plate-accent: var(--hud-health);
  --plate-cut: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%);
  width: min(100%, 168px);
  gap: 4px;
  padding: 6px 7px;
}
#hud .health[data-critical] {
  --plate-accent: #ffc2a8;
  --plate-fill: linear-gradient(128deg, #48303a, #221e2b 76%);
}
#hud .vital-meter {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  width: 100%;
  min-height: 16px;
  padding: 0 5px;
  border: 1px solid #6b806a;
  border-radius: 2px;
  color: #fff6dc;
  text-shadow: 0 1px 2px #130f13, 0 0 4px #0f1214;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
#hud .vital-meter .meter {
  position: absolute;
  inset: 0;
  z-index: -1;
  height: 100%;
  margin: 0;
  border-radius: 1px;
  background: #111a1b;
}
#hud .vital-meter .meter span { background: linear-gradient(#467849, #3e7442); }
#hud .vital-meter--hp { min-height: 25px; border-color: #a36669; }
#hud .vital-meter--hp .meter { background: #251820; }
#hud .vital-meter--hp .meter span { background: linear-gradient(#b64648, #a73842); }
#hud .vital-meter .micro { color: inherit; font-size: 9px; letter-spacing: .04em; }
#hud #health-text { margin: 0; font-size: clamp(13px, 3.8vw, 16px); line-height: 1.1; }
#hud #health-warning { color: #ffc2a8; font-size: 8px; letter-spacing: .045em; }
#hud .boss-hud .meter {
  position: relative;
  height: 6px;
  border-radius: 0;
  transform: skewX(-13deg);
}
#hud .boss-hud .meter::after {
  position: absolute;
  inset: 0;
  content: "";
  background: repeating-linear-gradient(90deg, transparent 0 11px, #101921b3 11px 13px);
}
#hud .wave-readout {
  --plate-accent: var(--hud-clock);
  --plate-cut: polygon(10px 0, calc(100% - 10px) 0, 100% 10px, 100% calc(100% - 10px), calc(100% - 10px) 100%, 10px 100%, 0 calc(100% - 10px), 0 10px);
  min-width: 122px;
  padding-inline: 13px;
  text-align: center;
}
#hud .wave-readout::after {
  background:
    linear-gradient(90deg, transparent, var(--plate-accent), transparent) center top / 76% 2px no-repeat,
    var(--hud-fill);
}
#hud .wave-readout strong { font-size: clamp(20px, 3vw, 27px); color: var(--plate-accent); }
#hud .wave-readout[data-urgent] { --plate-accent: #ffd7a5; }
#hud .wave-readout[data-urgent] .meter span { background: #ffc591; }
#hud .wave-readout #time-text { font-variant-numeric: tabular-nums; }
#hud #enemy-readout { display: grid; justify-items: center; }
#hud .cash {
  --plate-accent: var(--hud-money);
  --plate-cut: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
  min-width: 78px;
}
#hud .cash strong { color: var(--hud-money); }
#hud #cash-pickup { color: var(--hud-lime); margin-top: 2px; letter-spacing: .03em; font-size: 10px; }
#hud .hud-right { min-width: 0; gap: 6px; }
#hud #pause {
  --plate-accent: #a1b9ba;
  --plate-cut: polygon(8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px), 0 8px);
  width: 46px;
  flex-basis: 46px;
  min-height: 46px;
}
#hud #pause:hover, #hud #pause:focus-visible { --plate-accent: var(--hud-lime); --plate-fill: #263d42; }
#hud .hud-bottom { inset-inline: max(17px, env(safe-area-inset-left)) max(17px, env(safe-area-inset-right)); }
#hud #build-rule-readout { display: block; max-width: 185px; margin-top: 5px; color: #deefab; letter-spacing: .02em; font-size: 10px; line-height: 1.25; }
#hud #build-rule-readout[hidden] { display: none; }
#hud .loadout {
  --plate-accent: #879a95;
  --plate-cut: polygon(10px 0, calc(100% - 10px) 0, 100% 10px, 100% calc(100% - 5px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 5px), 0 10px);
  --plate-fill: linear-gradient(180deg, #20313b, #0b151e);
  padding: 5px 7px;
  gap: 4px;
}
#hud .loadout::after {
  background:
    repeating-linear-gradient(90deg, #a0b0ab 0 3px, transparent 3px 6px) center top / 31px 2px no-repeat,
    var(--plate-fill);
}
#hud .slot {
  --plate-accent: var(--tier-color, #485f6a);
  --plate-cut: polygon(5px 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 0 100%, 0 5px);
  --plate-fill: linear-gradient(148deg, #273943, #14212d 76%);
}
#hud .slot::after {
  background:
    linear-gradient(90deg, var(--plate-accent), transparent) left bottom / 70% 2px no-repeat,
    var(--plate-fill);
}
#hud .slot.empty { opacity: .64; }
#hud .slot.empty::after { background: #101b26; }
#hud .hud-kills {
  display: block;
  margin-top: 3px;
  color: #dae6df;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.hud-kills strong { color: var(--hud-lime); }
#hud .boss-hud {
  --plate-accent: #e890a0;
  --plate-cut: polygon(12px 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 12px 100%, 0 50%);
  top: max(121px, calc(env(safe-area-inset-top) + 105px));
  width: min(360px, calc(100% - 38px));
  padding: 7px 16px 8px;
  text-shadow: none;
}
.boss-hud-label { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; }
.boss-designation {
  padding: 3px 7px;
  clip-path: polygon(0 0, calc(100% - 4px) 0, 100% 50%, calc(100% - 4px) 100%, 0 100%);
  color: #ffb9cc;
  background: #642d46;
}
#boss-percent { color: #ffb9cc; font-variant-numeric: tabular-nums; }
#hud .boss-hud .meter { border: 0; background: #fbb2c62b; }
#hud .boss-hud .meter span { background: linear-gradient(90deg, #dd6d9e, #ffc191); }
#hud .boss-hud[data-finale] {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
#hud [data-finale] .boss-meter-card { display: grid; grid-template-rows: 1fr auto; min-width: 0; }
#hud [data-finale] .boss-hud-label { grid-template-columns: minmax(0, 1fr) auto; gap: 4px; text-align: left; }
#hud [data-finale] .boss-hud-label .micro { font-size: 9px; overflow-wrap: anywhere; }
#hud [data-finale] .boss-designation { display: none; }
#hud [data-finale] #encore-hud .meter span { background: linear-gradient(90deg, #9b6dcc, #efd1ff); }
#hud [data-finale] #encore-percent { color: #edd0ff; white-space: nowrap; }
#hud [data-finale] [data-status="scheduled"] .meter { opacity: .35; }
#hud [data-finale] [data-status="incoming"] .meter { background: repeating-linear-gradient(90deg, #bd8dd4 0 3px, #52395e 3px 7px); }
#hud [data-finale] [data-status="defeated"] { opacity: .65; }
#hud:has(.boss-hud:not([hidden])) #wave-call { top: clamp(180px, 31%, 260px); }
@media (max-width: 650px) {
  #hud #build-rule-readout { font-size: 8px; margin-top: 3px; }
  #hud .hud-top {
    inset-inline: max(9px, env(safe-area-inset-left)) max(9px, env(safe-area-inset-right));
    grid-template-columns: minmax(0,1fr) auto minmax(99px,1fr);
  }
  #hud .readout { padding: 6px 7px; }
  #hud .wave-readout { min-width: 83px; max-width: 116px; padding-inline: 6px; }
  #hud .cash { min-width: 51px; }
  #hud .hud-right { gap: 4px; }
  #hud #pause { width: 44px; min-height: 44px; flex-basis: 44px; }
  #hud .hud-label svg { width: 11px; height: 11px; }
  #hud .boss-hud { top: max(115px, calc(env(safe-area-inset-top) + 101px)); }
  #hud .hud-kills { display: inline; margin-left: 5px; font-size: 9px; }
}
@media (max-width: 360px) {
  #hud .hud-top { gap: 4px; }
  #hud .cash strong { font-size: 16px; }
  #hud .wave-readout[data-urgent] #time-text { font-size: 18px; }
  #hud .readout .micro { font-size: 8px; letter-spacing: .045em; }
  #hud .hud-kills { font-size: 8px; }
}
@media (max-width: 650px) and (orientation: portrait) {
  #hud #wave-call {
    top: max(101px, calc(env(safe-area-inset-top) + 88px));
    width: min(330px, calc(100% - 30px));
  }
  #hud:has(.boss-hud:not([hidden])) #wave-call {
    top: max(159px, calc(env(safe-area-inset-top) + 145px));
  }
}
@media (max-height: 460px) and (orientation: landscape) {
  #hud .boss-hud { top: 108px; }
  #hud:has(.boss-hud:not([hidden])) #wave-call { top: 157px; }
}
