#health-hud {
  /* Safe insets and viewport sizes are physical CSS px; zoom scales HUD lengths. */
  --health-safe-top: calc(env(safe-area-inset-top) / var(--jiggy-ui-scale, 1));
  --health-safe-right: calc(env(safe-area-inset-right) / var(--jiggy-ui-scale, 1));
  --health-safe-bottom: calc(env(safe-area-inset-bottom) / var(--jiggy-ui-scale, 1));
  --health-safe-left: calc(env(safe-area-inset-left) / var(--jiggy-ui-scale, 1));
  --health-width: calc((100vw - env(safe-area-inset-left) - env(safe-area-inset-right)) / var(--jiggy-ui-scale, 1) - 24px);
  --health-height: calc((100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom)) / var(--jiggy-ui-scale, 1));
  position: fixed; top: calc(72px + var(--health-safe-top)); right: calc(12px + var(--health-safe-right)); z-index: 15;
  width: min(340px, var(--health-width)); max-height: calc(var(--health-height) - 150px);
  overflow: auto; overscroll-behavior: contain; scrollbar-width: thin;
  color: #f3eed9; font: 14px/1.4 "Fira Sans", system-ui, sans-serif;
  text-align: left; pointer-events: auto;
  zoom: var(--jiggy-ui-scale, 1);
}
#health-hud[hidden] { display: none; }
#health-hud details { margin: 0 0 5px; background: #191910f2; border-left: 3px solid #e8b64a; border-radius: 3px; }
#health-hud details[data-severity="severe"] { border-color: #e25a3c; }
#health-hud summary { display: flex; align-items: center; gap: 8px; padding: 7px 9px; cursor: pointer; color: #e8b64a; }
#health-hud [data-severity="severe"] summary { color: #e25a3c; }
#health-hud summary:focus-visible { outline: 2px solid #fff9e5; outline-offset: -2px; }
#health-hud details p { margin: 0; padding: 0 10px 10px; }
#health-hud .health-icon { display: inline-block; flex: 0 0 20px; height: 20px; background: currentColor; mask: var(--health-icon) center / contain no-repeat; }
#health-hud .health-help { margin: 0; padding: 5px 8px; background: #191910f2; color: #d9ceab; font-size: 12px; }
#health-hud .health-announcement { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
@media (max-width: 480px) { #health-hud { top: calc(64px + var(--health-safe-top)); right: calc(8px + var(--health-safe-right)); width: min(310px, calc(var(--health-width) + 8px)); font-size: 13px; } }
@media (orientation: portrait) and (max-width: 860px) {
  #health-hud { top: auto; bottom: calc(32px + var(--health-safe-bottom)); right: calc(8px + var(--health-safe-right)); max-height: calc(var(--health-height) * 0.4); pointer-events: none; }
  #health-hud details { pointer-events: auto; }
}
/* The HUD observes the usable game size, matching fit_lobby after safe-area insets. */
@media (orientation: landscape) {
  html:not([data-in-match]) #health-hud[data-menu-clearance="true"] {
    top: calc(12px + var(--health-safe-top)); right: calc(12px + var(--health-safe-right));
    width: min(340px, calc(var(--health-width) - var(--jiggy-menu-right) / var(--jiggy-ui-scale, 1)));
    max-height: calc(var(--health-height) - 44px);
  }
  html:not([data-in-match]) #health-hud[data-menu-clearance="true"][data-narrow="true"] { font-size: 12px; overflow-wrap: anywhere; }
  html:not([data-in-match]) #health-hud[data-menu-clearance="true"][data-narrow="true"] summary { padding: 7px 4px; }
  html:not([data-in-match]) #health-hud[data-menu-clearance="true"][data-narrow="true"] .health-icon { display: none; }
  html:not([data-in-match]) #health-hud[data-menu-clearance="true"][data-narrow="true"] details p { padding: 0 4px 10px; }
  html:not([data-in-match]) #health-hud[data-menu-clearance="true"][data-narrow="true"] .health-help { padding: 5px 4px; }
}
@media (pointer: coarse) {
  html[data-in-match] #health-hud, html[data-in-match] #health-hud details { pointer-events: none; }
  html[data-in-match] #health-hud { opacity: 0.6; }
  html[data-in-match] #health-hud .health-help { display: none; }
}

#health-hud .health-performance[hidden] { display: none; }
#health-hud .health-performance { border: 1px solid #b9ae8c60; }
#health-hud .health-performance > summary { font-weight: 600; }
#health-hud .health-performance details { margin: 0 8px 8px; border-left-width: 2px; }
#health-hud[data-performance-only="true"] { top: auto; bottom: calc(16px + var(--health-safe-bottom)); width: max-content; max-width: var(--health-width); }
#health-hud[data-performance-only="true"] .health-help { display: none; }
html:not([data-in-match]) #health-hud[data-performance-only="true"] {
  top: auto; bottom: calc(12px + var(--health-safe-bottom)); left: calc(12px + var(--health-safe-left)); right: auto; width: max-content; max-width: var(--health-width);
}
#health-hud[data-performance-only="true"]:has(.health-performance[open]) { width: min(340px, var(--health-width)); bottom: calc(88px + var(--health-safe-bottom)); }

/* Keep touch warnings between the top HUD and the movement stick. The half-width
   column also clears the taller action cluster. Zoom multiplies CSS lengths. */
html[data-touch-controls] #health-hud,
html[data-touch-controls] #health-hud[data-performance-only="true"],
html[data-touch-controls] #health-hud[data-performance-only="true"]:has(.health-performance[open]) {
  top: auto;
  left: calc((12px + env(safe-area-inset-left)) / var(--jiggy-ui-scale, 1));
  right: auto;
  bottom: calc((var(--jiggy-touch-move-height, 0px) + 8px + env(safe-area-inset-bottom)) / var(--jiggy-ui-scale, 1));
  max-width: calc((100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)) / 2 / var(--jiggy-ui-scale, 1));
  max-height: calc((100dvh - var(--jiggy-touch-move-height, 0px) - 20px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) / var(--jiggy-ui-scale, 1) - 150px);
}

/* A left-handed layout has the stick on the right; the warnings follow it. */
html[data-touch-controls][data-touch-hand="left"] #health-hud,
html[data-touch-controls][data-touch-hand="left"] #health-hud[data-performance-only="true"],
html[data-touch-controls][data-touch-hand="left"] #health-hud[data-performance-only="true"]:has(.health-performance[open]) {
  left: auto;
  right: calc((12px + env(safe-area-inset-right)) / var(--jiggy-ui-scale, 1));
}

html:not([data-in-match]) #health-hud[data-performance-only="true"] {
  bottom: calc(4px + var(--health-safe-bottom));
  left: calc(80px + var(--health-safe-left));
  max-width: calc(var(--health-width) - 68px);
  font-size: 12px;
}
html:not([data-in-match]) #health-hud[data-performance-only="true"] > details { margin: 0; }
html:not([data-in-match]) #health-hud[data-performance-only="true"] > details > summary { padding: 2px 6px; }
html:not([data-in-match]) #health-hud[data-performance-only="true"]:has(.health-performance[open]) {
  left: calc(12px + var(--health-safe-left));
  bottom: calc(40px + var(--health-safe-bottom));
  max-width: var(--health-width);
}
