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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0f1117;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #e8eaf0;
  user-select: none;
}

#game {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  cursor: crosshair;
  touch-action: none; /* stop the browser from scrolling/zooming on drag */
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#score {
  position: absolute;
  left: 16px;
  bottom: 16px;
  font-size: 22px;
  font-weight: 700;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

/* ---------- Action buttons (split / feed) ---------- */
#action-buttons {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

#action-buttons button {
  width: auto;
  padding: 10px 16px;
  font-size: 15px;
  background: rgba(20, 24, 33, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  backdrop-filter: blur(6px);
}

#action-buttons button {
  touch-action: manipulation; /* no 300ms tap delay */
}

#action-buttons .key {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 11px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.18);
}

/* ---------- Mobile layout ---------- */
@media (max-width: 640px), (pointer: coarse) {
  #action-buttons {
    right: 14px;
    bottom: 22px;
    gap: 14px;
  }
  #action-buttons button {
    padding: 18px 22px;
    font-size: 17px;
    border-radius: 14px;
  }
  #action-buttons .key {
    display: none; /* keys don't matter on touch */
  }
  #leaderboard {
    min-width: 120px;
    padding: 8px 10px;
    top: 10px;
    right: 10px;
  }
  #leaderboard h3 { font-size: 11px; }
  #leaderboard li { font-size: 12px; }
  #score {
    font-size: 18px;
    left: 12px;
    bottom: 20px;
  }
  #cheat-toggle {
    font-size: 12px;
    padding: 7px 10px;
  }
  #cheat-panel {
    width: 168px;
    top: 54px;
  }
  #cheat-panel input[type="range"] {
    height: 26px; /* fatter touch target */
  }
}

/* ---------- Cheat toggle ---------- */
#cheat-toggle {
  position: absolute;
  left: 16px;
  top: 16px;
  width: auto;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 700;
  background: rgba(20, 24, 33, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  backdrop-filter: blur(6px);
  pointer-events: auto;
  cursor: pointer;
}

#cheat-toggle.on {
  background: linear-gradient(135deg, #ec4899, #f59e0b);
  border-color: transparent;
}

#cheat-toggle .key {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 12px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.18);
}

#cheat-panel {
  position: absolute;
  left: 16px;
  top: 60px;
  width: 200px;
  padding: 12px 14px;
  background: rgba(20, 24, 33, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  backdrop-filter: blur(6px);
  pointer-events: auto;
}

#cheat-panel label {
  display: block;
  font-size: 13px;
  color: #cdd3e0;
  margin-bottom: 10px;
}

#cheat-panel label:last-child {
  margin-bottom: 0;
}

#cheat-panel .row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
}

#cheat-panel .row span:last-child {
  color: #f59e0b;
  font-weight: 700;
}

#cheat-panel input[type="range"] {
  width: 100%;
  accent-color: #ec4899;
  cursor: pointer;
}

#leaderboard {
  position: absolute;
  top: 16px;
  right: 16px;
  min-width: 180px;
  background: rgba(20, 24, 33, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 12px 14px;
  backdrop-filter: blur(6px);
}

#leaderboard h3 {
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9aa3b5;
  margin-bottom: 8px;
}

#leaderboard ol {
  list-style: none;
  counter-reset: rank;
}

#leaderboard li {
  counter-increment: rank;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
  padding: 3px 0;
}

#leaderboard li::before {
  content: counter(rank) ".";
  color: #6b7386;
  margin-right: 6px;
}

#leaderboard li.me {
  color: #ffd54a;
  font-weight: 700;
}

#leaderboard li .lb-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Overlays ---------- */
#start-screen, #death-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 18, 0.82);
  backdrop-filter: blur(3px);
  z-index: 10;
}

.hidden {
  display: none !important;
}

.panel {
  text-align: center;
  padding: 36px 40px;
  background: rgba(24, 28, 38, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  width: min(90vw, 380px);
}

.panel h1 {
  font-size: 40px;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #6ee7b7, #3b82f6);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tagline {
  color: #9aa3b5;
  margin-bottom: 22px;
  font-size: 15px;
}

#name-input {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #0f1117;
  color: #e8eaf0;
  outline: none;
  margin-bottom: 14px;
  text-align: center;
}

#name-input:focus {
  border-color: #3b82f6;
}

button {
  width: 100%;
  padding: 13px;
  font-size: 17px;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: white;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease;
}

button:hover {
  filter: brightness(1.1);
}

button:active {
  transform: scale(0.97);
}

.hint {
  margin-top: 16px;
  font-size: 13px;
  color: #6b7386;
}

#final-score {
  font-size: 20px;
  color: #ffd54a;
  margin-bottom: 22px;
}
