/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%; width: 100%;
  overflow: hidden; touch-action: none; user-select: none;
  -webkit-user-select: none; -webkit-touch-callout: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: #0a0f1f; color: #fff;
}
body { position: relative; }

/* ── Screens ────────────────────────────────────────────────── */
.screen {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  align-items: center; justify-content: center;
}
.screen.active { display: flex; }

/* ── Splash ─────────────────────────────────────────────────── */
#splash {
  background: linear-gradient(180deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
  text-align: center;
}
.splash-content { max-width: 400px; padding: 24px; }
.logo { font-size: 80px; line-height: 1; margin-bottom: 8px; animation: float 3s ease-in-out infinite; }
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}
.splash-content h1 {
  font-size: 48px; font-weight: 800;
  background: linear-gradient(135deg, #ff6b6b, #ffd93d, #6bcb77);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}
.subtitle { font-size: 16px; color: rgba(255,255,255,0.6); margin-bottom: 32px; }
.btn-primary {
  display: inline-block;
  padding: 16px 48px;
  font-size: 20px; font-weight: 700;
  border: none; border-radius: 50px;
  cursor: pointer;
  background: linear-gradient(135deg, #ff6b6b, #ee5a24);
  color: #fff;
  box-shadow: 0 4px 20px rgba(238,90,36,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-primary:hover { transform: scale(1.05); box-shadow: 0 6px 30px rgba(238,90,36,0.6); }
.btn-primary:active { transform: scale(0.97); }
.status-text { margin-top: 16px; font-size: 13px; color: rgba(255,255,255,0.4); }

/* ── Game Canvas ────────────────────────────────────────────── */
#gameCanvas {
  display: block;
  width: 100%; height: 100%;
  cursor: crosshair;
  background: linear-gradient(180deg, #87CEEB 0%, #E0F0FF 30%, #F0F8FF 60%, #98D8C8 85%, #7BC8A4 100%);
}

/* ── HUD ─────────────────────────────────────────────────────── */
#hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,0.3) 0%, transparent 100%);
}
.hud-left { display: flex; align-items: baseline; gap: 6px; }
#scoreDisplay { font-size: 32px; font-weight: 800; color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,0.5); }
.hud-label { font-size: 14px; font-weight: 600; color: rgba(255,255,255,0.6); text-transform: uppercase; letter-spacing: 1px; }
.hud-center { position: absolute; left: 50%; transform: translateX(-50%); }
#comboDisplay {
  font-size: 20px; font-weight: 700;
  color: #ffd93d;
  text-shadow: 0 0 20px rgba(255,217,61,0.5);
  animation: pulse 0.3s ease-out;
}
@keyframes pulse { 0% { transform: scale(1.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.hud-right { display: flex; align-items: center; gap: 8px; }
#timerDisplay { font-size: 18px; font-weight: 600; color: rgba(255,255,255,0.8); text-shadow: 0 2px 4px rgba(0,0,0,0.4); }
.hidden { display: none !important; }

/* ── Scoreboard ─────────────────────────────────────────────── */
#scoreboard {
  position: absolute; top: 60px; right: 8px;
  width: 180px; max-height: 50vh;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-radius: 12px;
  padding: 10px 12px;
  pointer-events: none;
  overflow-y: auto;
  border: 1px solid rgba(255,255,255,0.08);
}
.sb-header {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 700;
  padding-bottom: 6px; margin-bottom: 4px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.9);
}
.player-count {
  background: rgba(255,255,255,0.15);
  padding: 1px 8px; border-radius: 10px;
  font-size: 11px;
}
#sbList { font-size: 13px; }
.sb-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 0; gap: 4px;
}
.sb-rank { width: 18px; text-align: right; font-weight: 700; color: rgba(255,255,255,0.5); }
.sb-rank.gold { color: #ffd93d; }
.sb-rank.silver { color: #c0c0c0; }
.sb-rank.bronze { color: #cd7f32; }
.sb-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-you { color: #ffd93d; font-size: 10px; margin-left: 2px; }
.sb-score { font-weight: 600; color: rgba(255,255,255,0.9); }

/* ── Tap hint (mobile first-time) ───────────────────────────── */
.tap-hint {
  position: absolute; bottom: 40px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.5); backdrop-filter: blur(8px);
  padding: 10px 24px; border-radius: 20px;
  font-size: 14px; pointer-events: none;
  animation: hintBounce 2s ease-in-out infinite;
}
@keyframes hintBounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-6px); }
}

/* ── Pop animation text ─────────────────────────────────────── */
.pop-text {
  position: absolute; pointer-events: none;
  font-weight: 800; font-size: 24px;
  animation: popText 0.8s ease-out forwards;
}
@keyframes popText {
  0% { transform: scale(0.5); opacity: 1; }
  100% { transform: scale(2) translateY(-60px); opacity: 0; }
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 500px) {
  .splash-content h1 { font-size: 36px; }
  .logo { font-size: 60px; }
  .btn-primary { padding: 14px 36px; font-size: 18px; }
  #scoreboard { width: 140px; right: 4px; top: 54px; font-size: 12px; }
  .sb-header { font-size: 12px; }
  #sbList { font-size: 11px; }
  #scoreDisplay { font-size: 24px; }
}
