*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #06060f;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #e0e0e0;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

/* ── UI overlay ─────────────────────────────────────────────────────────── */
#ui-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

#ui-overlay * {
  pointer-events: auto;
}

/* ── Top bar ────────────────────────────────────────────────────────────── */
#top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: linear-gradient(to bottom,
    rgba(6, 6, 15, 0.92) 0%,
    rgba(6, 6, 15, 0.6) 60%,
    transparent 100%);
  gap: 12px;
  flex-wrap: wrap;
}

#top-bar h1 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  white-space: nowrap;
  background: linear-gradient(135deg, #8ab4ff 0%, #c4a0ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
#controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#controls button {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(220, 225, 240, 0.85);
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#controls button:hover {
  background: rgba(130, 170, 255, 0.15);
  border-color: rgba(130, 170, 255, 0.35);
  color: #e0e8ff;
  box-shadow: 0 0 12px rgba(130, 170, 255, 0.1);
}

#controls button:active {
  background: rgba(130, 170, 255, 0.25);
  transform: scale(0.96);
}

/* ── Mass slider ────────────────────────────────────────────────────────── */
#mass-slider-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(6, 6, 15, 0.75);
  padding: 10px 22px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

#mass-slider-container label {
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: rgba(160, 180, 220, 0.6);
  white-space: nowrap;
}

#mass-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 140px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}

#mass-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #bdd4ff, #6699ff);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(102, 153, 255, 0.5);
  border: none;
}

#mass-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #bdd4ff, #6699ff);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(102, 153, 255, 0.5);
  border: none;
}

#mass-value {
  font-size: 0.85rem;
  min-width: 26px;
  text-align: right;
  color: #a0b8e0;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

/* ── Hint & counter ─────────────────────────────────────────────────────── */
#hint {
  position: fixed;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.78rem;
  letter-spacing: 0.5px;
  color: rgba(180, 200, 240, 0.3);
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 0.8s ease;
}

#body-count {
  position: fixed;
  bottom: 30px;
  right: 18px;
  font-size: 0.72rem;
  letter-spacing: 0.3px;
  color: rgba(160, 180, 220, 0.25);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

/* ── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  #top-bar {
    padding: 10px 12px;
  }

  #top-bar h1 {
    font-size: 0.9rem;
  }

  #controls button {
    padding: 8px 13px;
    font-size: 0.78rem;
    border-radius: 7px;
  }

  #mass-slider-container {
    bottom: 16px;
    padding: 9px 16px;
    gap: 10px;
  }

  #mass-slider {
    width: 110px;
  }

  #hint {
    bottom: 58px;
    font-size: 0.72rem;
  }
}

@media (max-width: 380px) {
  #controls button {
    padding: 7px 10px;
    font-size: 0.74rem;
  }

  #mass-slider {
    width: 90px;
  }
}
