/* ===== Reset & Base ===== */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700;800;900&display=swap');

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

:root {
  /* Palette da logo Lu Pizzicarolo */
  --burgundy: #7B1740;
  --burgundy-deep: #4a0e28;
  --burgundy-light: #9c2254;
  --pink: #E8A0B4;
  --pink-light: #F0C4D3;
  --pink-glow: rgba(232, 160, 180, 0.4);
  --bg-dark: #3A0A20;
  --bg-card: rgba(255, 255, 255, 0.08);
  --bg-card-hover: rgba(255, 255, 255, 0.14);
  --border-glass: rgba(255, 255, 255, 0.15);

  --gold: #fbbf24;
  --gold-glow: rgba(251, 191, 36, 0.4);
  --silver: #d1d5db;
  --bronze: #cd7f32;

  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.75);
  --text-muted: rgba(255, 255, 255, 0.5);
  --success: #34d399;
  --error: #f87171;

  --gradient-hero: linear-gradient(160deg, #4a0e28 0%, #7B1740 40%, #3A0A20 100%);
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Poppins', sans-serif;
  background: var(--gradient-hero);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===== Utility ===== */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 20px;
}

.hidden {
  display: none !important;
}

/* Honeypot anti-bot field */
.hp-field {
  position: absolute;
  left: -9999px;
  top: -9999px;
  opacity: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

/* ===== Logo ===== */
.hero-logo {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  margin: 0 auto 20px;
  display: block;
  filter: drop-shadow(0 4px 20px rgba(0, 0, 0, 0.4));
}

/* ===== Hero Section ===== */
.hero {
  padding: 50px 20px 30px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 50% 40%, rgba(232, 160, 180, 0.1) 0%, transparent 55%);
  animation: pulse-bg 8s ease-in-out infinite;
}

@keyframes pulse-bg {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.1); opacity: 1; }
}

.hero h1 {
  font-size: clamp(1.8rem, 5.5vw, 3rem);
  font-weight: 900;
  background: linear-gradient(135deg, #fff 0%, var(--pink-light) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  position: relative;
  margin-bottom: 12px;
}

.hero .subtitle {
  font-size: clamp(0.95rem, 2.5vw, 1.15rem);
  color: var(--text-secondary);
  max-width: 560px;
  margin: 0 auto 24px;
  position: relative;
}

.hero .brand-tagline {
  font-size: clamp(0.85rem, 2vw, 0.95rem);
  color: var(--pink);
  font-weight: 600;
  font-style: italic;
  margin-bottom: 16px;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.7;
  position: relative;
}

/* ===== Live Counter Badge ===== */
.live-counter {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: 50px;
  padding: 10px 24px;
  margin-bottom: 36px;
  font-size: 0.95rem;
  position: relative;
}

.live-counter .pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6); }
  50% { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); }
}

.live-counter .count-number {
  font-weight: 800;
  color: var(--pink-light);
  font-size: 1.15rem;
}

/* ===== Glass Card ===== */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  padding: 36px 32px;
  margin-bottom: 30px;
}

/* ===== Form Styles ===== */
.form-group {
  margin-bottom: 20px;
  position: relative;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input {
  width: 100%;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: 'Poppins', sans-serif;
  font-size: 1rem;
  transition: border-color 0.3s, box-shadow 0.3s;
  outline: none;
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.form-group input:focus {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px var(--pink-glow);
}

.form-group input.input-error {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.3);
}

.form-group .error-text {
  color: var(--error);
  font-size: 0.8rem;
  margin-top: 6px;
  display: none;
}

.form-group .error-text.visible {
  display: block;
}

/* Phone prefix selector */
.phone-input-group {
  display: flex;
  gap: 8px;
}

.phone-prefix {
  width: 110px;
  flex-shrink: 0;
  padding: 14px 12px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: 'Poppins', sans-serif;
  font-size: 0.9rem;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ffffff80' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.phone-prefix:focus {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px var(--pink-glow);
}

.phone-prefix option {
  background: #3a0a20;
  color: #fff;
}

.phone-input-group input {
  flex: 1;
  min-width: 0;
}

/* City autocomplete */
.city-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #4a1530;
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  margin-top: 4px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}

.city-suggestions.active {
  display: block;
}

.city-suggestion-item {
  padding: 12px 18px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: background 0.2s;
}

.city-suggestion-item:hover {
  background: rgba(232, 160, 180, 0.15);
  color: var(--text-primary);
}

/* ===== Submit Button ===== */
.btn-submit {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 14px;
  font-family: 'Poppins', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.3s;
  background: linear-gradient(135deg, var(--burgundy-light) 0%, var(--burgundy) 100%);
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 1px;
  position: relative;
  overflow: hidden;
  border: 2px solid var(--pink);
}

.btn-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px var(--pink-glow);
}

.btn-submit:active {
  transform: translateY(0);
}

.btn-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-submit .spinner {
  display: none;
  width: 22px;
  height: 22px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto;
}

.btn-submit.loading .btn-text {
  display: none;
}

.btn-submit.loading .spinner {
  display: block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Result Reveal ===== */
.result-section {
  text-align: center;
  animation: fadeInUp 0.8s ease-out;
}

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

.result-distance {
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  font-weight: 900;
  color: var(--pink-light);
  text-shadow: 0 0 40px var(--pink-glow);
  margin: 20px 0 5px;
}

.result-unit {
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.result-rank {
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin-bottom: 30px;
}

.result-rank strong {
  color: var(--pink-light);
  font-size: 1.4rem;
}

.result-city {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.result-prize {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 24px;
  font-style: italic;
}

.btn-leaderboard {
  display: inline-block;
  padding: 14px 36px;
  background: transparent;
  border: 2px solid var(--pink);
  color: var(--pink-light);
  border-radius: 14px;
  font-family: 'Poppins', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.3s;
  margin-top: 10px;
}

.btn-leaderboard:hover {
  background: var(--pink);
  color: var(--burgundy-deep);
  box-shadow: 0 0 30px var(--pink-glow);
}

/* ===== Hero Actions (classifica top CTA) ===== */
.hero-actions {
  margin-bottom: 16px;
  position: relative;
}

.hero-actions .btn-cta {
  font-size: 0.95rem;
  padding: 12px 32px;
}

/* ===== Share Buttons ===== */
.share-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
  position: relative;
}

.btn-social {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  border: none;
  border-radius: 12px;
  font-family: 'Poppins', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.3s;
  color: #fff;
}

.btn-social:hover {
  transform: translateY(-2px);
}

.btn-facebook {
  background: #1877F2;
}

.btn-facebook:hover {
  box-shadow: 0 6px 20px rgba(24, 119, 242, 0.4);
}

/* ===== Podium Section ===== */
.podium-section {
  padding: 40px 20px 20px;
}

.podium-section h2 {
  text-align: center;
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  font-weight: 800;
  margin-bottom: 40px;
  background: linear-gradient(135deg, #fff 0%, var(--pink-light) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.podium {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 50px;
}

.podium-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  padding: 24px 20px;
  text-align: center;
  flex: 1;
  max-width: 220px;
  animation: fadeInUp 0.8s ease-out both;
}

.podium-card:nth-child(1) { animation-delay: 0.3s; }
.podium-card:nth-child(2) { animation-delay: 0.1s; }
.podium-card:nth-child(3) { animation-delay: 0.5s; }

.podium-card.gold {
  border-color: rgba(251, 191, 36, 0.4);
  box-shadow: 0 0 40px rgba(251, 191, 36, 0.15);
  order: 2;
  padding-bottom: 40px;
}

.podium-card.silver {
  order: 1;
}

.podium-card.bronze {
  order: 3;
}

.podium-medal {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

.podium-card.gold .podium-medal { font-size: 3.2rem; }

.podium-name {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 4px;
}

.podium-city {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 12px;
}

.podium-distance {
  font-weight: 800;
  font-size: 1.3rem;
}

.podium-card.gold .podium-distance {
  color: var(--gold);
  text-shadow: 0 0 20px var(--gold-glow);
  font-size: 1.6rem;
}

.podium-card.silver .podium-distance {
  color: var(--silver);
}

.podium-card.bronze .podium-distance {
  color: var(--bronze);
}

.podium-km {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* ===== Leaderboard List ===== */
.leaderboard-list {
  margin-bottom: 20px;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  margin-bottom: 10px;
  transition: background 0.2s;
  animation: fadeInUp 0.5s ease-out both;
}

.leaderboard-item:hover {
  background: var(--bg-card-hover);
}

.leaderboard-rank {
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--text-muted);
  min-width: 36px;
  text-align: center;
}

.leaderboard-info {
  flex: 1;
}

.leaderboard-name {
  font-weight: 600;
  font-size: 1rem;
}

.leaderboard-city {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.leaderboard-distance {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--pink-light);
  white-space: nowrap;
}

/* ===== CTA Section ===== */
.cta-section {
  text-align: center;
  padding: 30px 20px 60px;
}

.cta-section h3 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.cta-section p {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.btn-cta {
  display: inline-block;
  padding: 16px 40px;
  background: linear-gradient(135deg, var(--burgundy-light) 0%, var(--burgundy) 100%);
  color: #fff;
  border: 2px solid var(--pink);
  border-radius: 14px;
  font-family: 'Poppins', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: transform 0.2s, box-shadow 0.3s;
}

.btn-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px var(--pink-glow);
}

/* ===== Scroll Loader ===== */
.scroll-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.scroll-spinner {
  width: 20px;
  height: 20px;
  border: 3px solid var(--border-glass);
  border-top-color: var(--pink);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.empty-state p {
  font-size: 1.1rem;
}

/* ===== Confetti Canvas ===== */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 30px 20px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.footer a {
  color: var(--pink);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

/* ===== My Position Banner ===== */
.my-position {
  background: linear-gradient(135deg, rgba(232, 160, 180, 0.15) 0%, rgba(123, 23, 64, 0.25) 100%);
  border: 2px solid var(--pink);
  border-radius: 20px;
  padding: 20px 24px;
  margin-bottom: 40px;
  animation: fadeInUp 0.6s ease-out;
  position: relative;
  overflow: hidden;
}

.my-position::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, var(--pink-glow) 0%, transparent 70%);
  opacity: 0.3;
}

.my-position-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--pink);
  margin-bottom: 12px;
  position: relative;
}

.my-position-content {
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
}

.my-position-rank {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--pink-light);
  text-shadow: 0 0 20px var(--pink-glow);
  min-width: 64px;
  text-align: center;
}

.my-position-info {
  flex: 1;
}

.my-position-name {
  font-weight: 700;
  font-size: 1.05rem;
}

.my-position-city {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.my-position-distance {
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--pink-light);
  white-space: nowrap;
}

.my-position-footer {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 8px;
  text-align: right;
  position: relative;
}

/* ===== My Row Highlight ===== */
.my-row {
  border: 2px solid var(--pink) !important;
  background: linear-gradient(135deg, rgba(232, 160, 180, 0.12) 0%, rgba(123, 23, 64, 0.18) 100%) !important;
  position: relative;
}

.my-row::after {
  content: 'TU';
  position: absolute;
  top: -8px;
  right: 12px;
  background: var(--pink);
  color: var(--burgundy-deep);
  font-size: 0.6rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 6px;
  letter-spacing: 1px;
}

.my-row-visible {
  animation: highlightPulse 1.5s ease-out;
}

@keyframes highlightPulse {
  0% { box-shadow: 0 0 0 0 var(--pink-glow); }
  30% { box-shadow: 0 0 30px 8px var(--pink-glow); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* ===== Countdown ===== */
.countdown-title {
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 10px;
  font-weight: 600;
  position: relative;
}

.countdown-title-small {
  font-size: 0.75rem;
  margin-bottom: 6px;
}

.countdown {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 24px;
  position: relative;
}

.countdown-item {
  text-align: center;
}

.countdown-value {
  display: block;
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 900;
  color: var(--pink-light);
  text-shadow: 0 0 20px var(--pink-glow);
}

.countdown-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.countdown-small {
  gap: 10px;
  margin-bottom: 16px;
}

.countdown-small .countdown-value {
  font-size: 1.1rem;
}

.countdown-small .countdown-label {
  font-size: 0.6rem;
}

.countdown-ended {
  font-size: 1rem;
  color: var(--gold);
  font-weight: 700;
  text-align: center;
  margin-bottom: 24px;
  position: relative;
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 24px 0;
  margin-top: 10px;
}

.pagination button {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  color: var(--pink-light);
  padding: 10px 20px;
  border-radius: 12px;
  font-family: 'Poppins', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.pagination button:hover:not(:disabled) {
  background: var(--bg-card-hover);
  transform: translateY(-1px);
}

.pagination button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.pagination-info {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .glass-card {
    padding: 24px 18px;
  }

  .hero-logo {
    width: 90px;
    height: 90px;
  }

  .podium {
    flex-direction: column;
    align-items: center;
  }

  .podium-card {
    max-width: 100%;
    width: 100%;
    order: unset !important;
  }

  .podium-card.gold {
    padding-bottom: 24px;
  }

  .hero {
    padding: 30px 16px 20px;
  }

  .btn-leaderboard {
    display: block;
    margin: 10px auto 0;
  }
}
