/* Stage label, stat row, lives and the countdown bar. */

.hud {
  width: min(94vw, 860px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: clamp(10px, 2vmin, 18px) clamp(12px, 3vmin, 24px);
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hud-stage {
  margin: 0;
  text-align: center;
  font-weight: 700;
  font-size: clamp(0.85rem, 2.6vw, 1.05rem);
  color: var(--ink-soft);
  letter-spacing: 0.4px;
}

.hud-stats {
  display: grid;
  /* Wraps to two rows on a phone instead of squeezing, which is what broke the
     old layout at narrow widths. */
  grid-template-columns: repeat(auto-fit, minmax(78px, 1fr));
  gap: clamp(6px, 2vw, 18px);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ink-soft);
}

.stat-value {
  font-size: clamp(1.3rem, 5vw, 2rem);
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-value--score {
  color: var(--accent-dark);
}

.stat-value--target {
  color: var(--grass-deep);
}

.stat-value--time {
  color: var(--ink);
}

.lives {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: clamp(1.3rem, 5vw, 2rem);
}

.life {
  width: clamp(18px, 4.5vw, 26px);
  height: clamp(18px, 4.5vw, 26px);
  color: var(--danger);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.life--spent {
  color: var(--ink-soft);
  opacity: 0.25;
  transform: scale(0.85);
}

.timer {
  height: 12px;
  border-radius: 999px;
  background: rgba(43, 27, 18, 0.12);
  overflow: hidden;
}

.timer-fill {
  --fill: 1;

  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--grass), var(--grass-dark));
  transform-origin: left center;
  /* Scaling rather than animating width keeps the bar off the layout path. */
  transform: scaleX(var(--fill));
  transition: transform 0.1s linear, background 0.3s ease;
}

.timer-fill.is-urgent {
  background: linear-gradient(90deg, #f0a02f, var(--danger));
  animation: pulse 0.6s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.6;
  }
}
