* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1a0a2e;
  touch-action: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1;
}

#ui-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: 'Lilita One', 'Nunito', sans-serif;
}

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

.title-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

@keyframes bounceIn {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.game-title {
  font-size: clamp(42px, 10vw, 80px);
  color: #ff2d55;
  text-shadow: 0 4px 20px rgba(255,45,85,0.6), 0 0 60px rgba(255,45,85,0.3);
  animation: pulse 2s ease-in-out infinite;
  letter-spacing: 2px;
}

.game-tagline {
  font-family: 'Nunito', sans-serif;
  font-size: clamp(14px, 3.5vw, 22px);
  color: #e8b4f8;
  font-weight: 700;
  text-align: center;
  max-width: 90%;
}

.best-time-display {
  font-family: 'Nunito', sans-serif;
  font-size: clamp(14px, 3vw, 18px);
  color: #ffd700;
  font-weight: 900;
  margin-top: 8px;
}

.btn-start {
  margin-top: 20px;
  padding: 18px 60px;
  font-family: 'Lilita One', sans-serif;
  font-size: clamp(22px, 5vw, 32px);
  color: #fff;
  border: none;
  border-radius: 50px;
  background: linear-gradient(135deg, #ff2d55, #e91e63, #c2185b);
  box-shadow: 0 6px 30px rgba(255,45,85,0.5), inset 0 2px 0 rgba(255,255,255,0.3);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
  overflow: hidden;
}

.btn-start::after {
  content: '';
  position: absolute;
  top: 6px;
  left: 20%;
  right: 20%;
  height: 30%;
  background: linear-gradient(180deg, rgba(255,255,255,0.4), transparent);
  border-radius: 50%;
}

.btn-start:active {
  transform: scale(0.95);
  box-shadow: 0 3px 15px rgba(255,45,85,0.5);
}

.btn-leaderboard {
  margin-top: 10px;
  padding: 10px 30px;
  font-family: 'Nunito', sans-serif;
  font-size: clamp(13px, 3vw, 16px);
  font-weight: 900;
  color: #e8b4f8;
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(232,180,248,0.3);
  border-radius: 30px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-leaderboard:active {
  background: rgba(255,255,255,0.15);
}

.countdown-text {
  font-size: clamp(80px, 20vw, 160px);
  color: #fff;
  text-shadow: 0 0 40px rgba(255,45,85,0.8);
  animation: bounceIn 0.4s ease-out;
}

.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  padding: 16px 20px;
  pointer-events: none;
}

.hud-counter {
  font-family: 'Nunito', sans-serif;
  font-size: clamp(16px, 4vw, 24px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.hud-timer {
  font-family: 'Nunito', sans-serif;
  font-size: clamp(18px, 4.5vw, 28px);
  font-weight: 900;
  color: #ffd700;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.results-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  animation: fadeIn 0.5s ease-out;
  max-width: 90%;
  width: 400px;
}

.results-title {
  font-size: clamp(20px, 5vw, 32px);
  color: #4cff8d;
  text-shadow: 0 0 20px rgba(76,255,141,0.5);
  text-align: center;
}

.results-time {
  font-size: clamp(40px, 10vw, 72px);
  color: #fff;
  text-shadow: 0 4px 20px rgba(255,255,255,0.3);
}

.results-stars {
  font-size: clamp(28px, 7vw, 48px);
}

.new-record {
  font-size: clamp(18px, 4vw, 26px);
  color: #ffd700;
  animation: pulse 0.6s ease-in-out infinite;
  text-shadow: 0 0 15px rgba(255,215,0,0.6);
}

.results-input {
  padding: 12px 20px;
  font-family: 'Nunito', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: rgba(255,255,255,0.1);
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 12px;
  text-align: center;
  width: 80%;
  max-width: 250px;
  outline: none;
}

.results-input:focus {
  border-color: #ff2d55;
  box-shadow: 0 0 15px rgba(255,45,85,0.3);
}

.results-input::placeholder {
  color: rgba(255,255,255,0.4);
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-primary {
  padding: 14px 40px;
  font-family: 'Lilita One', sans-serif;
  font-size: clamp(16px, 4vw, 22px);
  color: #fff;
  border: none;
  border-radius: 30px;
  background: linear-gradient(135deg, #ff2d55, #c2185b);
  box-shadow: 0 4px 20px rgba(255,45,85,0.4);
  cursor: pointer;
  transition: transform 0.15s;
}

.btn-primary:active {
  transform: scale(0.95);
}

.btn-secondary {
  padding: 12px 24px;
  font-family: 'Nunito', sans-serif;
  font-size: clamp(13px, 3vw, 16px);
  font-weight: 900;
  color: #e8b4f8;
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(232,180,248,0.3);
  border-radius: 30px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-secondary:active {
  background: rgba(255,255,255,0.15);
}

.leaderboard-panel {
  background: rgba(20,5,40,0.95);
  border: 2px solid rgba(232,180,248,0.2);
  border-radius: 16px;
  padding: 20px;
  width: 90%;
  max-width: 360px;
  max-height: 50vh;
  overflow-y: auto;
}

.leaderboard-title {
  font-size: clamp(18px, 4.5vw, 26px);
  color: #ffd700;
  text-align: center;
  margin-bottom: 12px;
}

.lb-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-radius: 8px;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: clamp(13px, 3vw, 16px);
  color: #e8b4f8;
}

.lb-row:nth-child(odd) {
  background: rgba(255,255,255,0.04);
}

.lb-rank {
  color: #ffd700;
  min-width: 30px;
}

.lb-name {
  flex: 1;
  margin: 0 10px;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-time {
  color: #4cff8d;
  font-weight: 900;
}

.footer-link {
  position: fixed;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Nunito', sans-serif;
  font-size: 12px;
  color: rgba(232,180,248,0.4);
  text-decoration: none;
  z-index: 20;
  pointer-events: auto;
}

.footer-link:hover {
  color: rgba(232,180,248,0.7);
}