*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1a2e1a;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: #f2f5e9;
}

#game-root {
  position: relative;
  width: 100%;
  height: 100%;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  background: #3d6b3d;
}

.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 12px 16px;
  pointer-events: none;
  z-index: 2;
}

.hud.hidden {
  display: none;
}

.hud-row {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.hp-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.label {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.85;
}

.hp-bar {
  width: 160px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.55);
  background: rgba(0, 0, 0, 0.45);
  border-radius: 3px;
  overflow: hidden;
}

.hp-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #c23b22, #e8a317);
  transition: width 0.12s linear;
}

.hp-text,
.stat span:last-child {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

.stat {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dig-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dig-bar {
  width: 110px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.55);
  background: rgba(0, 0, 0, 0.45);
  border-radius: 3px;
  overflow: hidden;
}

.dig-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #8b5a2b, #d2a45a);
  transition: width 0.08s linear;
}

.dig-fill.is-burrowed {
  background: linear-gradient(90deg, #c23b22, #e8a317);
}

.dig-fill.is-cooling {
  background: linear-gradient(90deg, #4a5a3a, #8aa05a);
}

.dig-text {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  min-width: 3.5rem;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

.soak-badge {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #103048;
  background: linear-gradient(180deg, #bfe8ff, #7ec4ef);
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-radius: 4px;
  padding: 3px 8px;
  text-shadow: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.soak-badge.hidden {
  display: none;
}

.optics-badge {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #0d2812;
  background: linear-gradient(180deg, #9dff8a, #3fbf55);
  border: 2px solid rgba(200, 255, 180, 0.55);
  border-radius: 4px;
  padding: 3px 8px;
  text-shadow: none;
  box-shadow: 0 0 10px rgba(80, 255, 100, 0.35);
}

.optics-badge.hidden {
  display: none;
}

.upgrade-hud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  max-width: min(420px, 70vw);
  pointer-events: none;
}

.upgrade-chip {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #142014;
  background: rgba(244, 247, 228, 0.92);
  border: 2px solid rgba(20, 40, 16, 0.55);
  border-radius: 4px;
  padding: 2px 6px;
  text-shadow: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.upgrade-hud:empty {
  display: none;
}

.announce {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
  padding: 24px;
}

.announce.hidden {
  display: none;
}

.announce-text {
  font-family: "Bungee", Impact, Haettenschweiler, sans-serif;
  font-size: clamp(1.6rem, 6.5vw, 3.6rem);
  line-height: 1.1;
  color: #fff4a8;
  text-shadow:
    0 3px 0 #5a1a10,
    0 6px 0 #3a1008,
    0 10px 24px rgba(0, 0, 0, 0.55),
    0 0 28px rgba(255, 120, 40, 0.45);
  letter-spacing: 0.02em;
  max-width: 92vw;
  transform: scale(0.55);
  opacity: 0;
}

.announce.is-punch .announce-text {
  animation: announce-punch 0.28s cubic-bezier(0.18, 1.4, 0.35, 1) forwards;
}

.announce.is-fading .announce-text {
  /* opacity driven on root; keep readable scale while fading */
  transform: scale(1.05);
}

.announce[data-style="surprise"] .announce-text {
  color: #ffe56a;
}

@keyframes announce-punch {
  0% {
    transform: scale(0.45) rotate(-3deg);
    opacity: 0;
  }
  55% {
    transform: scale(1.12) rotate(1.5deg);
    opacity: 1;
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 22, 10, 0.72);
  z-index: 3;
}

.overlay.hidden {
  display: none;
}

.panel {
  text-align: center;
  max-width: 440px;
  padding: 32px 28px;
  background: rgba(22, 40, 22, 0.92);
  border: 2px solid rgba(180, 210, 120, 0.45);
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.panel h1 {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  margin-bottom: 10px;
  color: #d8e8a0;
}

.tagline {
  margin-bottom: 8px;
  opacity: 0.9;
}

.run-score {
  margin-bottom: 6px;
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffe56a;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.lb-status {
  min-height: 1.2em;
  margin-bottom: 12px;
  font-size: 0.88rem;
  opacity: 0.85;
  color: #d8e8a0;
}

.controls {
  font-size: 0.9rem;
  opacity: 0.75;
  margin-bottom: 22px;
}

.overlay-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

#start-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  padding: 12px 22px;
  font-size: 1rem;
  font-weight: 700;
  color: #1a2e1a;
  background: #c5e06a;
  border-radius: 6px;
  transition: transform 0.12s ease, background 0.12s ease;
}

#start-btn:hover {
  background: #d6ef86;
  transform: translateY(-1px);
}

#start-btn:active {
  transform: translateY(1px);
}

.menu-link {
  color: #d8e8a0;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  opacity: 0.9;
}

.menu-link:hover {
  text-decoration: underline;
  opacity: 1;
}
