/* Save the Ducky — Styles v2 (Wave System) */

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #4aa3df;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none;
}

/* Canvas */
#game-canvas {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  touch-action: manipulation;
  will-change: transform;
}

/* === HUD === */
#hud {
  position: absolute; top: 0; left: 0; width: 100%;
  padding: 10px 14px;
  display: flex; justify-content: space-between; align-items: flex-start;
  pointer-events: none; z-index: 10;
  opacity: 0; transition: opacity 0.3s;
}
#hud.visible { opacity: 1; }
#hud > * { pointer-events: auto; }

#hud-left { display: flex; flex-direction: column; gap: 2px; }
#hud-score { display: flex; align-items: baseline; gap: 6px; }
#score-count {
  font-size: 40px; font-weight: 900; color: #fff;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.2); line-height: 1;
}
#score-label { font-size: 11px; color: rgba(255,255,255,0.7); text-transform: uppercase; letter-spacing: 1px; }
#hud-lives { font-size: 20px; line-height: 1; }

#hud-center { text-align: center; flex: 1; }
#hud-wave {
  font-size: 14px; font-weight: 700; color: rgba(255,255,255,0.8);
  text-transform: uppercase; letter-spacing: 2px;
}
#hud-combo {
  font-size: 18px; font-weight: 900; color: #FFE66D;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
  min-height: 24px;
}

#hud-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
#timer-count {
  font-size: 32px; font-weight: 900; color: #fff;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.2);
}
#timer-count.urgent { color: #ff6b6b; animation: pulse 0.5s ease-in-out infinite; }

#btn-mute {
  background: rgba(0,0,0,0.2); border: none; border-radius: 50%;
  width: 32px; height: 32px; font-size: 16px; line-height: 32px;
  text-align: center; cursor: pointer; padding: 0;
  pointer-events: auto; touch-action: manipulation;
}

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

/* === Screens === */
.screen {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 20; opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
}
.screen.active { opacity: 1; pointer-events: auto; }

/* Title */
#screen-title {
  justify-content: space-between;
  padding: 16px 16px env(safe-area-inset-bottom, 24px);
}
#title-top { width: 100%; text-align: center; }
#title-live-badge {
  display: inline-block;
  font-size: 12px; font-weight: 700; color: #fff;
  background: rgba(0,0,0,0.25); border-radius: 20px;
  padding: 4px 14px; margin-bottom: 12px;
  letter-spacing: 1px; text-transform: uppercase;
}
#title-rankings {
  width: 90%; max-width: 340px; margin: 0 auto;
  text-align: left;
}
.rank-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 12px; margin-bottom: 3px; border-radius: 10px;
  background: rgba(255,255,255,0.12); color: #fff; font-size: 14px;
}
.rank-row:first-child { background: rgba(255,230,109,0.2); }
.rank-row .rank-pos { font-weight: 900; width: 28px; }
.rank-row .rank-name { flex: 1; margin-left: 4px; }
.rank-row .rank-score { font-weight: 700; font-variant-numeric: tabular-nums; }
.rank-row.you { border: 1px solid rgba(255,230,109,0.5); background: rgba(255,230,109,0.15); }

#title-center { text-align: center; }
#screen-title h1 {
  font-size: 42px; font-weight: 900; color: #fff;
  text-shadow: 3px 3px 0 rgba(0,0,0,0.15);
  animation: bounce 1.5s ease-in-out infinite;
  margin: 0;
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
#title-subtitle {
  font-size: 16px; color: rgba(255,255,255,0.8);
  margin-top: 6px;
}

#title-bottom { text-align: center; width: 100%; }
#title-your-country {
  font-size: 18px; font-weight: 700; color: #ffe66d;
  margin-bottom: 8px;
}
#title-cta {
  font-size: 14px; color: rgba(255,255,255,0.5);
  animation: pulse 2s ease-in-out infinite;
}

/* Result / Game Over */
#screen-result {
  background: rgba(0,0,0,0.5); backdrop-filter: blur(8px);
  gap: 6px;
}
#result-title {
  font-size: 16px; color: rgba(255,255,255,0.6);
  text-transform: uppercase; letter-spacing: 3px; font-weight: 700;
}
#result-ducks { font-size: 24px; margin: 4px 0; line-height: 1.4; padding: 0 20px; }
#result-score {
  font-size: 42px; font-weight: 900; color: #ffe66d;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.2);
}
#result-wave { font-size: 16px; color: rgba(255,255,255,0.7); }
#result-country { font-size: 18px; color: rgba(255,255,255,0.85); }
#result-best { font-size: 14px; color: rgba(255,255,255,0.6); }
#result-best.new-best {
  color: #ffe66d; font-weight: 900; font-size: 18px;
  animation: pulse 0.6s ease-in-out 3;
}
#result-actions {
  display: flex; flex-direction: column; gap: 10px;
  width: 80%; max-width: 280px; margin-top: 12px;
}

/* Buttons */
button {
  padding: 14px 24px; border: none; border-radius: 50px;
  font-size: 18px; font-weight: 700; cursor: pointer;
  touch-action: manipulation; transition: transform 0.1s;
}
button:active { transform: scale(0.95); }
#btn-play-again { background: #ffe66d; color: #333; }
#btn-share { background: #fff; color: #333; }
#btn-leaderboard, #btn-back {
  background: transparent; color: #fff;
  border: 2px solid rgba(255,255,255,0.5);
}

/* Name Screen */
#screen-name { background: rgba(0,0,0,0.5); backdrop-filter: blur(8px); }
#screen-name p { font-size: 24px; color: #fff; margin-bottom: 16px; }
#input-duck-name {
  padding: 12px 20px; font-size: 20px; border: none; border-radius: 50px;
  text-align: center; width: 80%; max-width: 280px; outline: none;
}
#btn-save-name { margin-top: 12px; background: #ffe66d; color: #333; }

/* Leaderboard */
#screen-leaderboard { background: rgba(0,0,0,0.6); backdrop-filter: blur(8px); }
#screen-leaderboard h2 { font-size: 28px; color: #fff; margin-bottom: 16px; }
#leaderboard-list { width: 90%; max-width: 360px; max-height: 60vh; overflow-y: auto; }
.lb-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; margin-bottom: 4px; border-radius: 12px;
  background: rgba(255,255,255,0.1); color: #fff; font-size: 16px;
}
.lb-row.highlight { background: rgba(255,230,109,0.2); border: 1px solid rgba(255,230,109,0.4); }

/* Score pop animation */
.score-pop {
  position: absolute; font-size: 22px; font-weight: 900;
  color: #ffe66d; text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
  pointer-events: none; z-index: 15;
  animation: scorePop 0.7s ease-out forwards;
}
.score-pop.negative { color: #ff6b6b; }
@keyframes scorePop {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-50px) scale(1.4); }
}
