* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, #1f2b1f, #0b0f0b 70%);
  color: #e8f5e9;
  font-family: "Segoe UI", Roboto, sans-serif;
}

.wrap {
  text-align: center;
  padding: 20px;
}

h1 {
  margin: 0 0 10px;
  letter-spacing: 2px;
}

.hud {
  display: flex;
  justify-content: center;
  gap: 24px;
  font-size: 1.1rem;
  margin-bottom: 10px;
}

.canvas-wrap {
  position: relative;
  display: inline-block;
}

canvas {
  background: #10160f;
  border: 4px solid #4caf50;
  border-radius: 8px;
  box-shadow: 0 0 25px rgba(76, 175, 80, 0.4);
  image-rendering: pixelated;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 8px;
  transition: opacity 0.2s ease;
}

.overlay.hidden {
  display: none;
}

#overlay-text {
  font-size: 1.2rem;
  max-width: 280px;
  margin: 0;
}

#restart-btn {
  padding: 8px 18px;
  font-size: 1rem;
  border: none;
  border-radius: 6px;
  background: #4caf50;
  color: #0b0f0b;
  cursor: pointer;
  font-weight: bold;
}

#restart-btn:hover {
  background: #66bb6a;
}

#restart-btn.hidden {
  display: none;
}

.help {
  margin-top: 12px;
  opacity: 0.7;
  font-size: 0.9rem;
}

.touch-controls {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
}

.touch-controls .row {
  display: flex;
  gap: 6px;
}

.touch-controls button {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  border: 1px solid #4caf50;
  background: #16210f;
  color: #e8f5e9;
  font-size: 1.2rem;
}

@media (max-width: 480px) {
  canvas {
    width: 90vw;
    height: 90vw;
  }
  .touch-controls {
    display: flex;
  }
}
