* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #3c3d41;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  touch-action: none;
}

:root {
  --ad-banner-height: 50px;
}

#game-container {
  position: relative;
  width: 100vw;
  height: calc(100dvh - var(--ad-banner-height) - env(safe-area-inset-bottom));
  overflow: hidden;
}

#ad-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--ad-banner-height);
  padding-bottom: env(safe-area-inset-bottom);
  background: #202124;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

#ad-banner span {
  color: rgba(255, 255, 255, 0.35);
  font-size: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #3c3d41;
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: max(12px, env(safe-area-inset-top)) 16px 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: none;
  z-index: 5;
}

#health-wrap {
  flex: 1;
}

#health-bar {
  width: 100%;
  height: 22px;
  background: rgba(0,0,0,0.4);
  border: 2px solid #fff3;
  border-radius: 11px;
  overflow: hidden;
}

#health-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #4caf50, #8bc34a);
  transition: width 0.15s ease-out, background-color 0.3s;
}

#wave-indicator {
  color: #ffcf7a;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  background: rgba(20, 20, 25, 0.55);
  padding: 5px 12px;
  border-radius: 999px;
}

#score {
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  min-width: 40px;
  text-align: center;
  background: rgba(20, 20, 25, 0.55);
  padding: 5px 14px;
  border-radius: 999px;
}

#wave-banner {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1);
  color: #fff;
  font-size: 40px;
  font-weight: 800;
  z-index: 8;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.4s ease, transform 0.4s ease;
  text-align: center;
  background: rgba(20, 20, 25, 0.55);
  padding: 16px 32px;
  border-radius: 20px;
}

#wave-banner.hidden {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.8);
}

#wave-banner .sub {
  display: block;
  font-size: 16px;
  font-weight: 500;
  margin-top: 6px;
  opacity: 0.85;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(0,0,0,0.55);
  color: #fff;
  padding: 24px;
  z-index: 10;
}

.overlay.hidden {
  display: none;
}

.overlay h1 {
  font-size: 50px;
  margin: 0 0 20px;
  color: #fff;
}

.overlay p {
  font-size: 35px;
  line-height: 1.5;
  opacity: 1;
  margin: 0 0 24px;
  color: #FF0000;
}

.overlay button {
  font-size: 20px;
  font-weight: 700;
  padding: 14px 36px;
  border: none;
  border-radius: 999px;
  background: #ff9800;
  color: #2b1d14;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}

.overlay button:active {
  transform: scale(0.96);
}
