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

:root {
  --bg: #0a0a0f;
  --surface: #141420;
  --border: #2a2a3a;
  --text: #e8e8f0;
  --text-dim: #8888a0;
  --accent: #6c5ce7;
  --accent-glow: #a29bfe;
  --gold: #ffd700;
  --silver: #c0c0c0;
  --bronze: #cd7f32;
  --green: #00d4aa;
  --red: #ff6b6b;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

#app {
  max-width: 540px;
  margin: 0 auto;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

/* Header */
header {
  text-align: center;
}

h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--accent-glow), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  margin-top: 8px;
  color: var(--text-dim);
  font-size: 0.95rem;
}

.goal-number {
  color: var(--gold);
  font-weight: 700;
  -webkit-text-fill-color: var(--gold);
}

/* Your Country Hero */
.country-hero {
  text-align: center;
  padding: 20px;
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid var(--border);
}

.flag-display {
  font-size: 4rem;
  line-height: 1;
  margin-bottom: 8px;
}

.clicking-for {
  color: var(--text-dim);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.country-hero h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 4px;
}

/* Click Button */
#click-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.button-container {
  position: relative;
  width: 140px;
  height: 140px;
}

#click-btn {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(145deg, var(--accent), #5a4bd6);
  color: white;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  cursor: pointer;
  position: relative;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  box-shadow: 0 4px 20px rgba(108, 92, 231, 0.4);
  z-index: 1;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#click-btn:not(:disabled):hover {
  transform: scale(1.03);
  box-shadow: 0 6px 30px rgba(108, 92, 231, 0.6);
}

#click-btn:not(:disabled):active {
  transform: scale(0.93);
  box-shadow: 0 2px 10px rgba(108, 92, 231, 0.3);
}

#click-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Rapid click squish animation */
@keyframes squish {
  0% { transform: scale(1); }
  40% { transform: scale(0.90); }
  100% { transform: scale(1); }
}

#click-btn.squish {
  animation: squish 0.15s ease-out;
}

#click-btn.on-cooldown {
  background: linear-gradient(145deg, #3a3a4a, #2a2a3a);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.btn-text {
  position: relative;
  z-index: 2;
}

/* Cooldown Ring */
.cooldown-ring {
  position: absolute;
  top: -6px;
  left: -6px;
  width: calc(100% + 12px);
  height: calc(100% + 12px);
  transform: rotate(-90deg);
  pointer-events: none;
  z-index: 0;
}

.ring-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 3;
}

.ring-progress {
  fill: none;
  stroke: var(--accent-glow);
  stroke-width: 3;
  stroke-dasharray: 339.292;
  stroke-dashoffset: 339.292;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.05s linear;
}

/* Click ripple */
@keyframes ripple {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 0.5; }
  100% { transform: translate(-50%, -50%) scale(4); opacity: 0; }
}

.click-ripple {
  position: fixed;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  animation: ripple 0.7s ease-out forwards;
  pointer-events: none;
  z-index: 50;
}

/* Counter */
.click-counter {
  text-align: center;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.big-number {
  font-size: 2.5rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  transition: color 0.3s;
}

.big-number.incrementing {
  color: var(--green);
}

.counter-label {
  color: var(--text-dim);
  font-size: 1rem;
}

/* Progress Bar */
.progress-bar-container {
  width: 100%;
  max-width: 400px;
  height: 8px;
  background: var(--surface);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--green));
  border-radius: 4px;
  width: 0%;
  transition: width 0.5s ease;
}

/* Turnstile */
.turnstile-wrap {
  display: flex;
  justify-content: center;
}

.turnstile-wrap.hidden {
  display: none;
}

/* Leaderboard */
#leaderboard-section {
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 20px;
}

#leaderboard-section h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
  text-align: center;
}

.leaderboard {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lb-entry {
  display: grid;
  grid-template-columns: 32px 32px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  transition: background 0.2s;
}

.lb-entry:hover {
  background: rgba(255, 255, 255, 0.03);
}

.lb-entry.your-country {
  background: rgba(108, 92, 231, 0.1);
  border: 1px solid rgba(108, 92, 231, 0.3);
}

.lb-rank {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-dim);
  text-align: center;
}

.lb-entry:nth-child(1) .lb-rank { color: var(--gold); }
.lb-entry:nth-child(2) .lb-rank { color: var(--silver); }
.lb-entry:nth-child(3) .lb-rank { color: var(--bronze); }

.lb-flag {
  font-size: 1.4rem;
  text-align: center;
}

.lb-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-clicks {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
  color: var(--accent-glow);
  text-align: right;
}

.lb-entry.winner .lb-name::after {
  content: " \u{1F3C6}";
}

/* Progress mini-bar in leaderboard */
.lb-progress-wrap {
  grid-column: 1 / -1;
  height: 3px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 2px;
  overflow: hidden;
  margin-top: -2px;
}

.lb-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--green));
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* Your rank (if not in top 20) */
.your-rank-separator {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  padding: 8px 0;
}

/* Share */
#share-section {
  text-align: center;
}

#share-section p {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 10px;
}

.share-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.share-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 28px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.share-btn:hover {
  background: var(--border);
  border-color: var(--text-dim);
}

/* Celebration overlay */
.celebration {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  flex-direction: column;
  gap: 16px;
}

.celebration.hidden {
  display: none;
}

.celebration h2 {
  font-size: 2rem;
  text-align: center;
}

.celebration .winner-flag {
  font-size: 6rem;
}

/* Loading */
.loading {
  text-align: center;
  color: var(--text-dim);
  padding: 20px;
}

/* Footer */
footer {
  text-align: center;
  padding: 16px 0;
}

footer p {
  color: var(--text-dim);
  font-size: 0.8rem;
}

/* Confetti canvas */
#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 99;
  display: none;
}

#confetti-canvas.active {
  display: block;
}

/* Milestone flash */
@keyframes milestone-flash {
  0% { background: rgba(255, 215, 0, 0.2); }
  100% { background: transparent; }
}

.milestone-flash {
  animation: milestone-flash 1s ease-out;
}

/* Number roll animation */
@keyframes count-up {
  0% { transform: translateY(100%); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

/* Mobile */
@media (max-width: 480px) {
  h1 { font-size: 1.4rem; }
  .flag-display { font-size: 3rem; }
  .big-number { font-size: 2rem; }
  .button-container, #click-btn { width: 120px; height: 120px; }
  #click-btn { font-size: 1rem; }
}
