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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #10151c;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: none;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.6);
}

#hud-top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#hud-crowd {
  font-size: 40px;
  font-weight: 800;
}

#hud-topright {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

#hud-stage {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  opacity: 0.9;
}

#hud-score-row {
  font-size: 15px;
  font-weight: 700;
  opacity: 0.95;
}

#hud-score {
  color: #ffd93d;
}

#hud-distance-bar {
  width: min(400px, 80%);
  height: 14px;
  background: rgba(255,255,255,0.25);
  border-radius: 7px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.4);
}

#hud-distance-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ffd93d, #ff9f1c);
  transition: width 0.1s linear;
}

#hud-boss-bar {
  width: min(500px, 90%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

#hud-boss-label {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
}

#hud-boss-hp-track {
  width: 100%;
  height: 16px;
  background: rgba(255,255,255,0.2);
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.4);
}

#hud-boss-hp-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff4d4d, #c81d25);
  transition: width 0.15s linear;
}

.hidden {
  display: none !important;
}

.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  color: #fff;
}

.overlay-title {
  font-size: 56px;
  font-weight: 900;
  letter-spacing: 4px;
  text-shadow: 0 4px 8px rgba(0,0,0,0.5);
}

.retry-btn {
  font-size: 22px;
  font-weight: 700;
  padding: 14px 40px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  background: #ffd93d;
  color: #10151c;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.retry-btn:active {
  transform: translateY(2px);
}

/* --- Result overlay (score + leaderboard) --- */
#overlay-result {
  gap: 14px;
  padding: 20px;
  justify-content: center;
}

#overlay-result .overlay-title {
  font-size: 44px;
}

.result-score {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
}

.result-score span {
  font-size: 30px;
  font-weight: 900;
  color: #ffd93d;
}

.name-row {
  display: flex;
  gap: 8px;
  width: min(360px, 90%);
}

#player-name {
  flex: 1;
  min-width: 0;
  font-size: 18px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.12);
  color: #fff;
  outline: none;
}

#player-name::placeholder {
  color: rgba(255,255,255,0.55);
}

.submit-btn {
  font-size: 15px;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  background: #3fa7ff;
  color: #fff;
  white-space: nowrap;
}

.submit-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

#leaderboard-list {
  list-style: none;
  padding: 0;
  margin: 0;
  width: min(360px, 90%);
  max-height: 34vh;
  overflow-y: auto;
  counter-reset: rank;
}

#leaderboard-list li {
  counter-increment: rank;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  font-size: 16px;
}

#leaderboard-list li::before {
  content: counter(rank);
  width: 26px;
  text-align: right;
  opacity: 0.7;
  font-weight: 700;
}

#leaderboard-list .lb-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#leaderboard-list .lb-score {
  font-weight: 800;
  color: #ffd93d;
}

#leaderboard-note {
  font-size: 12px;
  opacity: 0.7;
}

#name-warning {
  font-size: 13px;
  font-weight: 700;
  color: #ff8080;
  margin-top: -6px;
}
