/* =========================================================
   Die Leiste im Spiel
   ========================================================= */

.hud {
  position: absolute;
  z-index: 12;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: clamp(6px, 1.7cqh, 18px) clamp(7px, 1.6cqw, 18px);
  pointer-events: none;
  font-family: var(--font-display);
  /* Ein weicher Verlauf statt einer Kante: die Leiste sitzt im Bild,
     ohne es zu zerschneiden. */
  background: linear-gradient(to bottom, rgba(10, 22, 6, 0.28), transparent);
}

.hud[hidden] {
  display: none;
}

.hud-side {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.hud-side-right {
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ---------- Plaettchen ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: clamp(24px, 6.2cqh, 46px);
  padding: 0 clamp(8px, 1.4cqw, 16px);
  border-radius: var(--r-pill);
  background: rgba(255, 253, 246, 0.9);
  color: #1b2a14;
  font-size: clamp(10px, 2.7cqh, 18px);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.7),
    0 2px 8px rgba(12, 24, 8, 0.22);
  backdrop-filter: blur(10px) saturate(1.3);
  -webkit-backdrop-filter: blur(10px) saturate(1.3);
}

.chip b {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.chip small {
  font-size: 0.8em;
  font-weight: 600;
  opacity: 0.62;
}

.chip .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--level-color, #5fbf3d);
  box-shadow: 0 0 0 3px rgba(95, 191, 61, 0.22);
}

.chip-time b {
  letter-spacing: 0.02em;
}

.chip-score i {
  font-style: normal;
  color: #ffb020;
  text-shadow: 0 1px 0 rgba(180, 110, 0, 0.35);
}

/* Zaehlt die Punktzahl hoch, gibt es einen kurzen Stups. */
.chip-score.bump {
  animation: chipBump 0.34s var(--ease-spring);
}

@keyframes chipBump {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.14);
  }
  100% {
    transform: scale(1);
  }
}

/* ---------- Knochenanzeige ---------- */

.chip-bones .meter {
  display: block;
  width: clamp(28px, 6.5cqw, 62px);
  height: 6px;
  border-radius: var(--r-pill);
  background: rgba(27, 42, 20, 0.14);
  overflow: hidden;
}

.chip-bones .meter span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffd469, #ffb020);
  transition: width 0.35s var(--ease-out);
}

.chip-bones.full {
  background: linear-gradient(135deg, #ffd469, #ffb020);
  animation: chipBump 0.4s var(--ease-spring);
}

.chip-bones.full .meter {
  background: rgba(255, 255, 255, 0.5);
}

/* ---------- Leben ---------- */

.chip-lives {
  gap: 3px;
  padding-inline: clamp(7px, 1.2cqw, 14px);
}

.chip-lives i {
  font-style: normal;
  font-size: clamp(11px, 3cqh, 20px);
  line-height: 1;
  filter: drop-shadow(0 1px 1px rgba(160, 30, 30, 0.35));
  animation: heartIn 0.4s var(--ease-spring) backwards;
}

.chip-lives i.lost {
  animation: heartOut 0.5s var(--ease-out) forwards;
}

@keyframes heartIn {
  from {
    transform: scale(0) rotate(-25deg);
  }
}

@keyframes heartOut {
  to {
    transform: scale(0) translateY(-14px);
    opacity: 0;
  }
}

/* ---------- Knoepfe ---------- */

.hud-buttons {
  display: flex;
  gap: 6px;
  pointer-events: auto;
}

.icon-button {
  width: clamp(24px, 6.2cqh, 46px);
  height: clamp(24px, 6.2cqh, 46px);
  display: grid;
  place-items: center;
  border-radius: var(--r-pill);
  background: rgba(255, 253, 246, 0.9);
  color: #1b2a14;
  font-size: clamp(11px, 3cqh, 20px);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.7),
    0 2px 8px rgba(12, 24, 8, 0.22);
  backdrop-filter: blur(10px) saturate(1.3);
  -webkit-backdrop-filter: blur(10px) saturate(1.3);
  transition: transform 0.14s var(--ease-spring), background 0.2s;
}

.icon-button:active {
  transform: scale(0.9);
  background: #ffffff;
}

.icon-button[hidden] {
  display: none;
}

/* ---------- Levelbanner ----------
   Faehrt beim Levelstart kurz durchs Bild und verschwindet von selbst. */

.level-banner {
  position: absolute;
  z-index: 14;
  left: 0;
  right: 0;
  top: 34%;
  display: grid;
  justify-items: center;
  gap: 6px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  font-family: var(--font-display);
  color: #fffdf6;
  text-shadow: 0 3px 18px rgba(10, 22, 6, 0.6);
}

.level-banner.show {
  animation: bannerSweep 2.4s var(--ease-out) forwards;
}

.level-banner .kicker {
  font-size: clamp(10px, 2.4cqh, 17px);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  opacity: 0.85;
}

.level-banner .name {
  font-size: clamp(26px, 10cqh, 78px);
  font-weight: 700;
  line-height: 1;
}

.level-banner .goal {
  margin-top: 4px;
  padding: 5px 14px;
  border-radius: var(--r-pill);
  background: rgba(12, 24, 8, 0.42);
  font-size: clamp(10px, 2.4cqh, 17px);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

@keyframes bannerSweep {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(0.94);
  }
  14% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  76% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-16px) scale(0.98);
  }
}

/* ---------- Treffer ----------
   Ein kurzes rotes Aufleuchten am Bildrand, wenn es Matheser erwischt. */

.hit-flash {
  position: absolute;
  inset: 0;
  z-index: 13;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at center, transparent 42%, rgba(220, 40, 40, 0.55) 100%);
}

.hit-flash.show {
  animation: hitPulse 0.5s var(--ease-out);
}

@keyframes hitPulse {
  0% {
    opacity: 0;
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

/* ---------- Kette ----------
   Zeigt an, wie viele Funde ohne Pause hintereinander kamen. */

.combo-chip {
  position: absolute;
  z-index: 14;
  right: clamp(7px, 1.6cqw, 18px);
  top: clamp(46px, 8cqh, 78px);
  display: grid;
  justify-items: center;
  gap: 1px;
  padding: clamp(5px, 1.2cqh, 10px) clamp(9px, 1.6cqw, 16px);
  border-radius: var(--r-pill);
  background: linear-gradient(160deg, #ffd469, #ffa60f);
  color: #2a1a02;
  font-family: var(--font-display);
  line-height: 1;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.7) translateY(-6px);
  transition: opacity 0.2s var(--ease-out), transform 0.28s var(--ease-spring);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    0 6px 20px rgba(255, 176, 32, 0.5);
}

.combo-chip.show {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.combo-chip b {
  font-size: clamp(15px, 3.4cqh, 26px);
  font-weight: 700;
}

.combo-chip span {
  font-size: clamp(8px, 1.6cqh, 11px);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.72;
}

.combo-chip.pop {
  animation: comboPop 0.4s var(--ease-spring);
}

@keyframes comboPop {
  0% {
    transform: scale(1) rotate(0deg);
  }
  40% {
    transform: scale(1.22) rotate(-4deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
  }
}
