/* ===== KG Running Club - Spring Festival Map 2026 ===== */

/* Reset & Base */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --red: #E63946;
  --red-deep: #C41E2A;
  --red-glow: rgba(230, 57, 70, 0.4);
  --gold: #F0C050;
  --gold-bright: #FFD700;
  --gold-glow: rgba(240, 192, 80, 0.3);
  --bg-dark: #0B0B1A;
  --bg-card: #12122A;
  --bg-elevated: #1A1A36;
  --text-primary: #F5F0EB;
  --text-secondary: #9E9EB0;
  --text-muted: #6B6B80;
  --border: rgba(240, 192, 80, 0.12);
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.page-container {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
}

/* ===== Header ===== */
.spring-header {
  position: relative;
  padding: 56px 24px 40px;
  background: linear-gradient(165deg, var(--red) 0%, var(--red-deep) 60%, #8B1020 100%);
  overflow: hidden;
}

.spring-header::before {
  content: '';
  position: absolute;
  top: -30%;
  right: -20%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, var(--gold-glow) 0%, transparent 70%);
  opacity: 0.6;
  animation: pulse-slow 4s ease-in-out infinite;
}

.spring-header::after {
  content: '';
  position: absolute;
  bottom: -20%;
  left: -10%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(255, 215, 0, 0.15) 0%, transparent 70%);
  animation: pulse-slow 5s ease-in-out infinite reverse;
}

.header-particles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.header-content {
  position: relative;
  z-index: 1;
  text-align: center;
}

.header-badge {
  display: inline-block;
  padding: 4px 16px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--gold);
  border: 1px solid rgba(240, 192, 80, 0.4);
  border-radius: 20px;
  margin-bottom: 20px;
}

.header-title {
  font-size: 44px;
  font-weight: 900;
  letter-spacing: 3px;
  color: #fff;
  line-height: 1;
  margin-bottom: 8px;
}

.title-dot {
  color: var(--gold);
}

.header-subtitle {
  font-size: 22px;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 6px;
  margin-bottom: 16px;
}

.header-blessing {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 1px;
}

/* Floating particles in header */
.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--gold-bright);
  opacity: 0;
  animation: float-up 3s ease-out infinite;
}

@keyframes float-up {
  0% { opacity: 0; transform: translateY(0) scale(0); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-120px) scale(1); }
}

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

/* ===== Stats Section ===== */
.stats-section {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 20px 16px;
  margin-top: -20px;
  position: relative;
  z-index: 2;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 8px;
  text-align: center;
}

.stat-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--gold);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  letter-spacing: 0.5px;
}

/* ===== Map Section ===== */
.map-section {
  padding: 0 16px;
  margin-top: 8px;
}

.map-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-card);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 12px;
}

.tab-btn {
  flex: 1;
  padding: 10px 0;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  background: transparent;
  color: var(--text-secondary);
}

.tab-btn.active {
  background: var(--red);
  color: #fff;
  box-shadow: 0 2px 8px var(--red-glow);
}

.map-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--bg-card);
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.map-wrapper canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

#particleCanvas {
  pointer-events: none;
}

.map-loading {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 14px;
  z-index: 10;
  transition: opacity 0.5s ease;
}

.map-loading.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--bg-elevated);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* City Legend */
.city-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding: 0 4px;
}

.city-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-primary);
}

.city-tag .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 6px var(--red-glow);
}

.city-tag .count {
  color: var(--gold);
  font-weight: 700;
}

/* ===== Leaderboard Section ===== */
.leaderboard-section {
  padding: 24px 16px;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::before {
  content: '';
  width: 3px;
  height: 18px;
  background: var(--red);
  border-radius: 2px;
}

.runner-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.runner-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: transform 0.2s;
}

.runner-item:active {
  transform: scale(0.98);
}

.runner-rank {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
}

.runner-rank.top1 {
  background: linear-gradient(135deg, #FFD700, #FFA500);
  color: #000;
}

.runner-rank.top2 {
  background: linear-gradient(135deg, #C0C0C0, #A0A0A0);
  color: #000;
}

.runner-rank.top3 {
  background: linear-gradient(135deg, #CD7F32, #B5651D);
  color: #fff;
}

.runner-rank.normal {
  background: var(--bg-elevated);
  color: var(--text-muted);
}

.runner-info {
  flex: 1;
  min-width: 0;
}

.runner-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.runner-cities {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.runner-distance {
  font-size: 16px;
  font-weight: 800;
  color: var(--gold);
  flex-shrink: 0;
}

.runner-distance span {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

/* ===== Date Range ===== */
.date-range {
  text-align: center;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== Download Button ===== */
.download-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: calc(100% - 32px);
  margin: 8px 16px 24px;
  padding: 16px;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, var(--red) 0%, var(--red-deep) 100%);
  box-shadow: 0 4px 16px var(--red-glow);
  transition: all 0.3s ease;
}

.download-btn:active {
  transform: scale(0.97);
  box-shadow: 0 2px 8px var(--red-glow);
}

/* ===== Footer ===== */
.spring-footer {
  padding: 16px 24px 32px;
  text-align: center;
}

.footer-line {
  width: 40px;
  height: 2px;
  background: var(--border);
  margin: 0 auto 12px;
}

.spring-footer p {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 1px;
}

/* ===== Offscreen Export Canvas (hidden) ===== */
.export-canvas {
  display: none;
}

/* ===== Responsive ===== */
@media (max-width: 360px) {
  .header-title { font-size: 42px; }
  .header-subtitle { font-size: 18px; letter-spacing: 4px; }
  .stat-value { font-size: 20px; }
  .stats-section { gap: 6px; padding: 16px 12px; }
}

@media (min-width: 481px) {
  .page-container {
    max-width: 480px;
  }
  body {
    background: #050510;
  }
}
