#hud {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  user-select: none;
}

/* ---------------------------------------------------------------- crosshair */
#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  translate: -50% -50%;
  opacity: .9;
  transition: scale var(--t-fast) var(--ease-out), opacity var(--t-fast) ease;
}

#crosshair.is-hit { scale: .82; opacity: 1; }
#crosshair.is-aimed .cross__h, #crosshair.is-aimed .cross__v { background: #fff8e6; }

.cross__h, .cross__v {
  position: absolute;
  background: #e9e4d8;
  mix-blend-mode: exclusion;
  box-shadow: 0 0 2px rgba(0, 0, 0, .45);
}

.cross__h { left: 0; top: 50%; width: 100%; height: 2px; translate: 0 -50%; }
.cross__v { top: 0; left: 50%; width: 2px; height: 100%; translate: -50% 0; }

/* ---------------------------------------------------------------- vitals */
#vitals {
  position: absolute;
  left: 50%;
  bottom: calc(var(--slot) + 30px);
  /* nine slots plus gaps and padding, so hearts and hunger sit on the hotbar's edges */
  width: calc(9 * var(--slot) + 8 * 3px + 8px);
  translate: -50% 0;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  transition: opacity var(--t) ease;
}

#vitals.is-hidden { opacity: 0; }

.vitals__row { display: flex; gap: 1px; }
.vitals__row--right { flex-direction: row-reverse; }

.pip {
  width: 18px;
  height: 18px;
  background-size: contain;
  background-repeat: no-repeat;
  filter: drop-shadow(1px 1px 0 rgba(0, 0, 0, .55));
}

.pip.is-low { animation: pip-pulse 900ms var(--ease-in-out) infinite; }

@keyframes pip-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.16); }
}

@media (prefers-reduced-motion: reduce) {
  .pip.is-low { animation: none; opacity: .8; }
}

/* ---------------------------------------------------------------- hotbar */
#hotbar {
  position: absolute;
  left: 50%;
  bottom: 18px;
  translate: -50% 0;
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid rgba(0, 0, 0, .55);
  border-radius: var(--r);
  background: rgba(14, 11, 7, .5);
  box-shadow: inset 0 1px 0 rgba(255, 244, 222, .08), 0 8px 26px -12px rgba(0, 0, 0, .9);
  pointer-events: auto;
}

.slot {
  position: relative;
  width: var(--slot);
  height: var(--slot);
  border: 1px solid rgba(255, 245, 225, .1);
  border-radius: var(--r);
  background: rgba(30, 26, 20, .62);
  box-shadow: inset 0 1px 0 rgba(0, 0, 0, .35);
  cursor: pointer;
  transition: border-color var(--t-fast) ease, background var(--t-fast) ease;
}

.slot__icon {
  position: absolute;
  inset: 5px;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  filter: drop-shadow(2px 3px 2px rgba(0, 0, 0, .45));
  pointer-events: none;
}

.slot__count {
  position: absolute;
  right: 3px;
  bottom: 1px;
  font-family: var(--font-mono);
  font-size: .78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #fff6e4;
  text-shadow: var(--hud-shadow);
  pointer-events: none;
}

.slot__dura {
  position: absolute;
  left: 5px;
  right: 5px;
  bottom: 4px;
  height: 3px;
  border-radius: 1px;
  background: rgba(0, 0, 0, .7);
  overflow: hidden;
  pointer-events: none;
}

.slot__dura i {
  display: block;
  height: 100%;
  background: var(--ok);
}

#hotbar .slot.is-active {
  border-color: #fff4dc;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .7), 0 0 14px -2px rgba(255, 226, 160, .55);
  background: rgba(58, 50, 38, .7);
}

/* ---------------------------------------------------------------- held item name */
#held-name {
  position: absolute;
  left: 50%;
  bottom: calc(var(--slot) + 62px);
  margin: 0;
  translate: -50% 0;
  font-size: .95rem;
  font-weight: 600;
  letter-spacing: .02em;
  color: #fdf6e7;
  text-shadow: var(--hud-shadow);
  opacity: 0;
  transition: opacity 260ms ease;
}

#held-name.is-shown { opacity: 1; }

/* ---------------------------------------------------------------- toasts */
#toasts {
  position: absolute;
  right: 16px;
  top: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
  max-width: 320px;
}

.toast {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .45rem .7rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--r);
  background: rgba(18, 15, 10, .85);
  font-size: .82rem;
  color: var(--text);
  text-shadow: var(--shadow-1);
  box-shadow: var(--shadow-2);
  transition: opacity 220ms ease, transform 220ms var(--ease-out);
}

.toast__icon {
  width: 22px;
  height: 22px;
  background-size: contain;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  flex: none;
}

.toast.is-out { opacity: 0; transform: translate3d(8px, 0, 0); }
.toast--warn { border-left-color: var(--danger); }

/* ---------------------------------------------------------------- debug */
#debug {
  position: absolute;
  left: 10px;
  top: 10px;
  padding: .55rem .7rem;
  max-width: 44ch;
  border-radius: var(--r);
  background: rgba(10, 8, 5, .62);
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.5;
  color: #e7ffd9;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, .6);
  white-space: pre;
}

/* ---------------------------------------------------------------- full screen effects */
#damage-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(90% 80% at 50% 50%, transparent 35%, rgba(150, 26, 12, .62) 100%);
  opacity: 0;
  transition: opacity 320ms ease;
}

#damage-flash.is-on { opacity: 1; transition-duration: 60ms; }

#water-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(24, 92, 140, .42), rgba(10, 48, 86, .58));
  opacity: 0;
  transition: opacity 200ms ease;
}

#water-overlay.is-on { opacity: 1; }

#vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(78% 68% at 50% 50%, transparent 55%, rgba(0, 0, 0, .42) 100%);
}
