/* Field instruments. All combat layout lives here; see docs/ui-design.md. */
#hud {
  --hud-edge: 12px;
  --hud-top: max(8px, env(safe-area-inset-top));
  --hud-bottom: max(8px, env(safe-area-inset-bottom));
  --hud-left: max(var(--hud-edge), env(safe-area-inset-left));
  --hud-right: max(var(--hud-edge), env(safe-area-inset-right));
  --hud-surface: #102932d9;
  --hud-line: #b9cec040;
  --hud-text: #f2edda;
  --hud-muted: #b7c9be;
  --hud-accent: #f0d895;
  --hud-target: 44px;
  --stick-size: 128px;
  --dock-width: 560px;
  position: fixed;
  inset: 0;
  pointer-events: none;
  color: var(--hud-text);
  font-variant-numeric: tabular-nums;
}
#hud button {
  pointer-events: auto;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
#hud kbd {
  font-size: 11px;
  padding: 1px 3px;
  line-height: 1.1;
  letter-spacing: 0;
}
.hud-icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
#hud .hud-action,
#hud #squadToggle,
#hud .squad-buttons button,
#hud .touch-action {
  width: var(--hud-target);
  min-width: var(--hud-target);
  height: var(--hud-target);
  min-height: var(--hud-target);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border: 1px solid var(--hud-line);
  border-radius: 6px;
  color: var(--hud-text);
  background: var(--hud-surface);
  box-shadow: none;
  font-size: 13px;
}
#hud button:focus-visible {
  outline: 2px solid var(--hud-accent);
  outline-offset: 2px;
}
#hud button:disabled {
  opacity: 0.4;
  cursor: default;
}
#hud button[aria-pressed='true'],
#hud #squadToggle[aria-expanded='true'] {
  border-color: var(--hud-accent);
  color: var(--hud-accent);
}
@media (hover: hover) {
  #hud button:hover:not(:disabled) {
    background: #34514b;
    border-color: var(--hud-accent);
  }
}
#hud .topbar {
  position: absolute;
  inset: var(--hud-top) var(--hud-right) auto var(--hud-left);
  height: 44px;
}
#hud .match {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  padding: 4px 12px;
  background: var(--hud-surface);
  border: 1px solid var(--hud-line);
  border-radius: 6px;
}
#hud .team {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 84px;
}
#hud .team span {
  font-size: 11px;
  letter-spacing: 0.3px;
}
#hud .team b {
  font-size: 22px;
  line-height: 1;
  min-width: 28px;
  text-align: center;
}
#hud .team-progress {
  position: absolute;
  left: 0;
  bottom: -8px;
  height: 2px;
  background: currentColor;
}
#hud .clock {
  padding: 0 12px;
  text-align: center;
  border-inline: 1px solid var(--hud-line);
}
#hud .clock strong {
  font-size: 22px;
  line-height: 1;
  white-space: nowrap;
}
#hud .clock.overtime {
  color: var(--hud-accent);
}
#hud #matchRule {
  position: absolute;
  left: 50%;
  top: 44px;
  transform: translateX(-50%);
  padding: 3px 6px;
  background: var(--hud-surface);
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
}
#hud #matchRule:empty {
  display: none;
}
#hud .hud-actions {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  gap: 4px;
}
#hud .objectives {
  position: absolute;
  top: calc(var(--hud-top) + 46px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
}
#hud .point-chip {
  position: relative;
  width: 30px;
  height: 25px;
  padding: 4px 0;
  font-size: 15px;
  line-height: 1;
  text-align: center;
  font-weight: 700;
  background: var(--hud-surface);
  border: 1px solid var(--hud-line);
  border-radius: 4px;
  overflow: hidden;
}
#hud .point-chip i {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
}
#hud .point-chip.contested {
  border-color: currentColor;
}
#hud .point-chip.locked {
  opacity: 0.5;
}
#hud #operationStatus {
  position: absolute;
  top: calc(var(--hud-top) + 75px);
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100vw - 320px);
  padding: 3px 7px;
  background: var(--hud-surface);
  border-radius: 4px;
  color: var(--hud-accent);
  font-size: 12px;
  line-height: 1.3;
  text-align: center;
}
#hud[data-mode='zombies'] #operationStatus {
  top: calc(var(--hud-top) + 46px);
}
#hud .tactical {
  position: absolute;
  top: calc(var(--hud-top) + 20px);
  left: var(--hud-left);
  width: 140px;
  padding: 0;
  border: 1px solid var(--hud-line);
  border-radius: 5px;
  overflow: hidden;
  background: var(--hud-surface);
}
#hud .tactical canvas {
  width: 100%;
  display: block;
  height: auto;
  aspect-ratio: 3 / 2;
  margin: 0;
}
#hud .tactical .eyebrow,
#hud .map-caption {
  display: none;
}
#hud #garageStatus {
  font-size: 12px;
  line-height: 1.3;
  padding: 6px;
  margin: 0;
  color: var(--hud-accent);
}
#performanceHud {
  position: absolute;
  top: var(--hud-top);
  left: var(--hud-left);
  height: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #c4d3cacc;
  font:
    11px/1 'Segoe UI',
    sans-serif;
  text-shadow:
    0 1px 2px #000,
    0 0 3px #102932;
  pointer-events: none;
  white-space: nowrap;
}
#performanceHud b {
  font-weight: 400;
}
#hud .squad-panel {
  position: absolute;
  top: calc(var(--hud-top) + 48px);
  right: var(--hud-right);
  width: max-content;
  max-width: calc(100vw - 24px);
  margin: 0;
  padding: 0;
  background: none;
  border: 0;
}
#hud .squad-command-row {
  display: flex;
  flex-direction: row-reverse;
  align-items: flex-start;
  gap: 4px;
}
#hud .squad-buttons {
  display: grid;
  grid-template-columns: repeat(2, 90px);
  gap: 4px;
  margin: 0;
}
#hud .squad-buttons button {
  width: 90px;
  gap: 4px;
  font-size: 13px;
  padding: 4px;
}
#hud #squadStatus {
  position: absolute;
  top: 100%;
  right: 0;
  width: 230px;
  margin: 4px 0 0;
  padding: 5px 7px;
  background: var(--hud-surface);
  border-radius: 4px;
  color: var(--hud-accent);
  font-size: 12px;
  line-height: 1.3;
  text-align: right;
}
#hud .killfeed {
  position: absolute;
  top: calc(var(--hud-top) + 98px);
  right: var(--hud-right);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  max-width: 240px;
  font-size: 12px;
}
#hud .killfeed > div {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 5px;
  min-height: 24px;
  background: var(--hud-surface);
  border-left: 2px solid var(--blue);
  border-radius: 3px;
}
#hud .killfeed .enemy {
  border-color: var(--red);
}
#hud .killfeed b,
#hud .kill-victim {
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#hud .killfeed b {
  color: var(--blue);
  font-weight: 600;
}
#hud .killfeed .enemy b {
  color: var(--red);
}
#hud .kill-weapon .weapon-art {
  width: 34px;
  height: 22px;
  margin: 0;
}
#hud .kill-weapon small {
  display: none;
}
#hud:has(#squadToggle[aria-expanded='true']) .killfeed,
#hud:has(#squadStatus:not([hidden])) .killfeed {
  display: none;
}
#hud .bottom-hud {
  position: absolute;
  left: 50%;
  bottom: var(--hud-bottom);
  transform: translateX(-50%);
  width: min(var(--dock-width), calc(100vw - 24px));
  display: grid;
  grid-template-columns: 96px 1fr 96px;
  align-items: end;
  gap: 6px;
}
#hud .vitals,
#hud .ammo {
  position: relative;
  width: auto;
  min-width: 0;
  height: 48px;
  padding: 8px 6px;
  background: var(--hud-surface);
  border: 1px solid var(--hud-line);
  border-radius: 5px;
}
#hud .vitals {
  grid-column: 1;
  grid-row: 1;
}
#hud .ammo {
  grid-column: 3;
  grid-row: 1;
}
#hud #healthLabel,
#hud #weaponType {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
#hud .health-line,
#hud .ammo-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin: 0;
}
#hud .health-line > b,
#hud .ammo b {
  font-size: 22px;
  line-height: 1;
}
#hud .health-line .hud-icon,
#hud .ammo-line .hud-icon {
  width: 16px;
  height: 16px;
  color: var(--hud-muted);
}
#hud .ammo span {
  font-size: 12px;
  color: var(--hud-muted);
  white-space: nowrap;
}
#hud .health-track,
#hud .ammo-track {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 5px;
  height: 3px;
  margin: 0;
  background: #adc8b52b;
  border-radius: 2px;
  overflow: hidden;
}
#hud .health-track i,
#hud .ammo-track i {
  display: block;
  height: 100%;
  background: var(--hud-accent);
}
#hud.low-health .vitals {
  box-shadow: inset 0 0 0 1px var(--red);
  border-color: var(--red);
  color: var(--red);
}
#hud.reloading .ammo {
  border-color: var(--hud-accent);
}
#hud #reloadHint {
  position: absolute;
  bottom: calc(100% + 5px);
  right: 0;
  width: max-content;
  padding: 4px 6px;
  border-radius: 4px;
  background: var(--hud-surface);
  color: var(--hud-accent);
  font-size: 12px;
}
#hud .loadout {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
}
#hud .loadout button {
  position: relative;
  flex: 1;
  min-width: 44px;
  max-width: 68px;
  width: auto;
  height: 48px;
  padding: 2px;
  color: var(--hud-muted);
  background: var(--hud-surface);
  border: 1px solid var(--hud-line);
  border-radius: 5px;
  box-shadow: none;
  transform: none;
}
#hud .loadout button.selected {
  color: var(--hud-accent);
  border-color: var(--hud-accent);
  box-shadow: inset 0 -2px var(--hud-accent);
  background: #35463bdc;
}
#hud .loadout .weapon-art {
  width: 52px;
  max-width: 100%;
  height: 29px;
  margin: 0 auto;
}
#hud .loadout kbd {
  position: absolute;
  top: -7px;
  left: 2px;
  background: #102932;
  color: var(--hud-muted);
  border: 1px solid var(--hud-line);
}
#hud .loadout b {
  display: block;
  margin: 0;
  font-size: 12px;
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
}
#hud .grenade-icon {
  display: flex;
  justify-content: center;
  height: 29px;
  align-items: center;
}
#hud #grenades {
  position: absolute;
  right: 5px;
  bottom: 5px;
  font-size: 12px;
}
#hud #announcement,
#hud #interaction,
#hud #fieldHint {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(460px, calc(100vw - 280px));
  padding: 5px 8px;
  border: 0;
  border-radius: 4px;
  background: var(--hud-surface);
  color: var(--hud-text);
  font-size: 13px;
  line-height: 1.3;
  text-align: center;
  white-space: normal;
  letter-spacing: 0;
}
#hud #announcement {
  top: calc(var(--hud-top) + 102px);
  font-weight: 600;
}
#hud #interaction,
#hud #fieldHint {
  bottom: calc(var(--hud-bottom) + 70px);
}
#hud #announcement:empty,
#hud #interaction:empty {
  display: none;
}
#hud #respawn {
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 12px 18px;
  text-align: center;
  background: var(--hud-surface);
  border-radius: 6px;
  font-size: 13px;
}
#hud #respawn b {
  display: block;
  font-size: 36px;
  margin: 4px;
}
#hud .infection-countdown {
  position: absolute;
  left: 50%;
  top: 45%;
  transform: translate(-50%, -50%);
  padding: 6px 12px;
  text-align: center;
  pointer-events: none;
  color: var(--hud-accent);
  text-shadow: 0 2px 3px #102932;
}
#hud .infection-countdown span {
  display: block;
  font-size: 12px;
}
#hud .infection-countdown b {
  font-size: 40px;
  line-height: 1.1;
}
#hud .infection-countdown.urgent {
  color: var(--red);
}
#hud[data-mode='zombies'] .red,
#hud[data-mode='zombies'] .killfeed .enemy b {
  color: #b4e77c;
}
#hud[data-role='infected'] .vitals {
  border-color: #b4e77c;
}
#hud[data-role='infected'] .ammo b {
  font-size: 18px;
}
/* Thumb space is independent of the visual footprint of each button. */
.touch-controls #hud .bottom-hud {
  left: calc((100vw + var(--hud-left) - var(--hud-right)) / 2);
  --dock-width: 316px;
  width: min(
    var(--dock-width),
    calc(100vw - var(--hud-left) - var(--hud-right) - 2 * var(--stick-size) - 104px)
  );
  grid-template-columns: 1fr 1fr;
  row-gap: 4px;
}
.touch-controls #hud .vitals,
.touch-controls #hud .ammo {
  height: 27px;
  padding: 2px 6px;
  border: 0;
  background: #102932a8;
}
.touch-controls #hud .vitals {
  grid-column: 1;
}
.touch-controls #hud .ammo {
  grid-column: 2;
}
.touch-controls #hud .health-line,
.touch-controls #hud .ammo-line {
  justify-content: flex-start;
}
.touch-controls #hud .health-line > b,
.touch-controls #hud .ammo b {
  font-size: 20px;
}
.touch-controls #hud .health-track {
  position: static;
  flex: 1;
  min-width: 14px;
}
.touch-controls #hud .ammo-track {
  bottom: 0;
  left: 6px;
  right: 6px;
  height: 2px;
}
.touch-controls #hud .loadout {
  grid-column: 1/-1;
  grid-row: 2;
}
.touch-controls #hud .loadout button {
  height: 44px;
}
.touch-controls #hud .loadout .weapon-art {
  height: 32px;
}
.touch-controls #hud .loadout button[data-weapon] b {
  display: none;
}
.touch-controls #hud .grenade-icon {
  height: 32px;
}
.touch-controls #hud .touch-stick {
  touch-action: none;
  width: var(--stick-size);
  height: var(--stick-size);
  bottom: var(--hud-bottom);
  border: 1px solid #e0e4c76b;
  background: #10293226;
  box-shadow: none;
  opacity: 0.6;
}
.touch-controls #hud #aimStick.firing {
  border-color: #ffce83;
  box-shadow: inset 0 0 0 4px #ffc27745;
}
.touch-controls #hud .touch-stick.held {
  opacity: 1;
}
.touch-controls #hud .stick-thumb {
  width: 38px;
  height: 38px;
  background: #18353c55;
}
.touch-controls #hud .stick-label {
  display: none;
}
.touch-controls #hud #moveStick {
  left: var(--hud-left);
}
.touch-controls #hud #aimStick {
  right: var(--hud-right);
}
#hud #touchUse {
  left: calc(var(--hud-left) + var(--stick-size) + 4px);
  bottom: var(--hud-bottom);
  font-size: 12px;
}
#hud #touchReload {
  right: calc(var(--hud-right) + var(--stick-size) + 4px);
  bottom: var(--hud-bottom);
}
.touch-controls #hud #interaction {
  display: none;
}
.touch-controls #hud #fieldHint {
  bottom: calc(var(--hud-bottom) + 94px);
}
@media (max-width: 900px), (max-height: 500px) {
  #hud {
    --hud-edge: 8px;
    --stick-size: 104px;
    --dock-width: 480px;
  }
  #hud .team {
    min-width: 28px;
  }
  #hud .team span {
    display: none;
  }
  #hud .match {
    gap: 6px;
    padding-inline: 8px;
  }
  #hud .clock {
    padding-inline: 8px;
  }
  #hud .tactical,
  #hud .killfeed {
    display: none;
  }
  #hud .bottom-hud {
    grid-template-columns: 82px 1fr 82px;
  }
  #hud .squad-buttons {
    grid-template-columns: repeat(2, 76px);
  }
  #hud .squad-buttons button {
    width: 76px;
    font-size: 12px;
  }
  #hud .squad-buttons kbd {
    display: none;
  }
  #hud #squadStatus {
    width: 190px;
  }
  #hud #operationStatus {
    max-width: calc(100vw - 220px);
  }
  #hud #announcement {
    top: calc(var(--hud-top) + 98px);
  }
  #hud:has(#squadToggle[aria-expanded='true']) #operationStatus {
    visibility: hidden;
  }
  .touch-controls #hud .bottom-hud {
    --dock-width: 284px;
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 600px) {
  #hud .hud-actions {
    gap: 2px;
  }
  #hud .loadout button[data-weapon] b {
    display: none;
  }
  #hud .loadout .weapon-art {
    height: 36px;
  }
}
@media (prefers-reduced-motion: reduce) {
  #hud *,
  #hud *::before,
  #hud *::after {
    animation: none;
    transition: none;
  }
}
