body {
  background-color: black;
  color: #59cf59;
  font-family: Arial, Helvetica, sans-serif;
}

#gamefield {
  width: 800px;
  height: 600px;
  border: 1px solid yellow;
  position: relative;
  overflow: hidden;
}

#ground {
  position: absolute;
  width: 1000px;
  border-radius: 100%;
  height: 200px;
  bottom: -100px;
  left: -100px;
  background-color: #c7733b;
}

.enemy {
  position: absolute;
  top: 0;
  font-size: 64px;
  cursor: crosshair;
  transform: translate(calc(var(--x) * 1px), calc(var(--y) * 1px));
}

#healthbar {
  position: absolute;
  bottom: 8px;
  width: 100%;
  display: flex;
  justify-content: center;
  --health: 100;
}

#healthbar #bar {
  width: 50%;
  height: 16px;
  border: 4px groove #aaa;
  background-color: black;
  overflow: hidden;
}

#healthbar #health {
  background-color: rgb(88, 229, 63);
  height: 100%;
  width: 100%;
  translate: calc((100 - var(--health)) * -1%) 0;
}

/* Effects */
.shake {
  animation: shake 0.3s linear 2;
}

@keyframes shake {
  0% {
    rotate: 0deg;
  }
  25% {
    rotate: -1.5deg;
  }
  50% {
    rotate: 0deg;
  }
  75% {
    rotate: 2deg;
  }
  100% {
    rotate: 0deg;
  }
}

.crash {
  animation: flash 0.5s ease-in alternate 4;
}

.crash::before {
  position: absolute;
  content: "⚡";
  animation: flash 0.5s ease-in alternate 4;
}

@keyframes flash {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

.explode::before {
  position: absolute;
  content: "💥";
  left: -0.15em;
  top: -0.12em;
  font-size: 130%;
  animation: flash 0.25s ease-in alternate 3;
}

.explode {
  animation: flash 2s 0.5s ease-in reverse 1 forwards;
}

#hud {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  gap: 20px;
  font-family: monospace;
  font-size: 20px;
  color: white;
  background: rgba(0, 0, 0, 0.5);
  padding: 8px 12px;
  border-radius: 12px;
  z-index: 10;
}

#controls {
  margin-top: 20px;
}

#resetButton {
  font-size: 18px;
  padding: 10px 20px;
  background-color: #4caf50;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

#resetButton:hover {
  background-color: #45a049;
}

body {
  background-color: black;
  color: #59cf59;
  font-family: Arial, Helvetica, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
}

/* -----------------------------
   Responsive for mobile
------------------------------ */
@media (max-width: 480px) {
  /* Shrink enemies */
  .enemy {
    font-size: 32px;
  }

  /* Shrink HUD */
  #hud {
    font-size: 16px;
    padding: 4px 8px;
  }

  /* Wider health bar on mobile */
  #healthbar #bar {
    width: 70%;
  }

  #ground {
    /* slightly lower and narrower for tiny phones */
    bottom: -20%;
    width: 130%;
    left: -15%;
  }
}

/* -----------------------------
   Gamefield responsive width
------------------------------ */
#gamefield {
  /* maintain 4:3 aspect ratio */
  aspect-ratio: 4 / 3;

  /* scale with screen size */
  width: min(90vw, 800px); /* max 800px, shrink on smaller screens */
  height: auto;

  margin: 0 auto;
}
