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

html, body {
  height: 100%;
  background: radial-gradient(circle at 50% 20%, #1c1c2e 0%, #0e0e18 70%);
  color: #f0f0f5;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#top-bar {
  width: 100%;
  max-width: 560px;
}

#game-title {
  font-family: 'Luckiest Guy', 'Comic Sans MS', 'Chalkboard SE', cursive;
  font-weight: 400;
  font-size: clamp(20px, 5.4vw, 32px);
  letter-spacing: 1.5px;
  text-align: center;
  padding: 8px 8px 0;
  background: linear-gradient(180deg, #ffe27a 20%, #f59f15 90%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 8px rgba(255, 180, 40, 0.35));
}

#hud {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 12px 8px;
  font-variant-numeric: tabular-nums;
}

.hud-item { display: flex; flex-direction: column; align-items: center; min-width: 46px; }
.hud-label {
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #8b8ba6;
}
.hud-value { font-size: 18px; font-weight: 700; color: #ffd24a; }
#lives { font-size: 15px; letter-spacing: 1px; }

.hud-buttons { display: flex; gap: 6px; }

.icon-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  color: inherit;
  font-size: 16px;
  padding: 5px 9px;
  cursor: pointer;
}
.icon-btn.off { opacity: 0.35; filter: grayscale(1); }

#game-area {
  position: relative;
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 0;
}

#game {
  display: block;
  border-radius: 10px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  background: #12121c;
}

#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 18, 0.72);
  backdrop-filter: blur(3px);
  z-index: 10;
}
#overlay.hidden { display: none; }

#overlay-card {
  text-align: center;
  padding: 24px 30px;
  background: rgba(24, 24, 40, 0.94);
  border: 1px solid rgba(255, 210, 74, 0.35);
  border-radius: 16px;
  max-width: 88%;
  max-height: 86%;
  overflow-y: auto;
  box-shadow: 0 12px 50px rgba(0,0,0,0.6);
}

#ov-title {
  font-family: 'Luckiest Guy', 'Comic Sans MS', cursive;
  font-weight: 400;
  font-size: clamp(20px, 6vw, 30px);
  letter-spacing: 1.5px;
  color: #ffd24a;
  margin-bottom: 12px;
  text-shadow: 0 2px 12px rgba(255, 210, 74, 0.35);
}

#ov-msg { font-size: 15px; line-height: 1.5; color: #c9c9dd; margin-bottom: 16px; }

#ov-btn {
  font-size: 18px;
  font-weight: 700;
  padding: 12px 42px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffd24a, #f0a818);
  color: #2a2010;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(255, 210, 74, 0.4);
}
#ov-btn:active { transform: scale(0.96); }

.btn-secondary {
  display: block;
  margin: 10px auto 0;
  font-size: 14px;
  padding: 9px 22px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.22);
  color: #e8e8f5;
  cursor: pointer;
}
.btn-secondary:active { transform: scale(0.96); }

.hint { margin-top: 14px; font-size: 12px; color: #8b8ba6; }

/* ----- name entry ----- */
#name-entry { margin-bottom: 16px; }
.lb-congrats { font-size: 14px; color: #7fd47f; margin-bottom: 10px; }
.name-row { display: flex; gap: 8px; justify-content: center; }
#name-input {
  width: 160px;
  font-size: 15px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 210, 74, 0.45);
  background: #101020;
  color: #fff;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}
#name-save {
  font-size: 14px;
  font-weight: 700;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  background: #7fd47f;
  color: #10240f;
  cursor: pointer;
}

/* ----- leaderboard ----- */
#lb-list {
  list-style: none;
  margin: 0 auto 16px;
  max-width: 280px;
  max-height: 38vh;
  overflow-y: auto;
  text-align: left;
}
#lb-list li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 4px 10px;
  font-size: 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
#lb-list li:nth-child(1) .lb-rank { color: #ffd24a; }
#lb-list li:nth-child(2) .lb-rank { color: #c9cdd8; }
#lb-list li:nth-child(3) .lb-rank { color: #d89a6a; }
.lb-rank { width: 26px; text-align: right; color: #8b8ba6; font-weight: 700; }
.lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-level { width: 42px; text-align: center; color: #9fd4ff; font-variant-numeric: tabular-nums; }
.lb-score { min-width: 52px; text-align: right; color: #ffd24a; font-weight: 700; font-variant-numeric: tabular-nums; }
.lb-empty { justify-content: center; color: #8b8ba6; }
.lb-head {
  font-size: 11px !important;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #8b8ba6;
}
.lb-head .lb-name, .lb-head .lb-level, .lb-head .lb-score {
  color: #8b8ba6;
  font-weight: 600;
}

#joystick {
  position: fixed;
  width: 124px;
  height: 124px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  border: 2px solid rgba(255, 255, 255, 0.22);
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 20;
}
#joystick.hidden { display: none; }

#stick {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(255, 210, 74, 0.85);
  box-shadow: 0 2px 14px rgba(0,0,0,0.45);
  transform: translate(-50%, -50%);
}
