/* ==========================================================================
   ViinderTrackFit - Espectador en Vivo (Tour de France Style)
   Paleta oficial: VIINDERRed #E53935 | Dark #0E0F12 / #17181D
   ========================================================================== */

:root {
  --viinder-red: #E53935;
  --viinder-red-glow: rgba(229, 57, 53, 0.4);
  --viinder-green: #00E676;
  --viinder-green-glow: rgba(0, 230, 118, 0.4);
  --viinder-yellow: #FFB300;
  --bg-dark: #0E0F12;
  --surface-dark: #17181D;
  --surface-elevated: #21232B;
  --surface-glass: rgba(23, 24, 29, 0.88);
  --border-color: rgba(255, 255, 255, 0.08);
  --text-main: #FFFFFF;
  --text-muted: #9E9E9E;
  --text-secondary: #D1D5DB;
}

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

body, html {
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  overflow: hidden;
}

/* ==========================================================================
   BARRA SUPERIOR (HEADER)
   ========================================================================== */
.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 1000;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  height: 32px;
  width: auto;
}

.event-details {
  display: flex;
  flex-direction: column;
}

.event-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.event-title {
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 20px;
  letter-spacing: 0.5px;
}

.status-tag.live {
  background: rgba(229, 57, 53, 0.2);
  color: #FF5252;
  border: 1px solid rgba(229, 57, 53, 0.4);
}

.status-tag.waiting {
  background: rgba(255, 179, 0, 0.18);
  color: #FFB300;
  border: 1px solid rgba(255, 179, 0, 0.4);
}

.status-tag.finished {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid var(--border-color);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  background-color: var(--viinder-red);
  border-radius: 50%;
  animation: pulse-glow 1.5s infinite;
}

@keyframes pulse-glow {
  0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(229, 57, 53, 0.7); }
  70% { transform: scale(1.2); box-shadow: 0 0 0 8px rgba(229, 57, 53, 0); }
  100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(229, 57, 53, 0); }
}

.event-sub-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.sport-badge {
  color: var(--text-secondary);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.timer-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-elevated);
  padding: 6px 12px;
  border-radius: 20px;
  font-family: monospace;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  border: 1px solid var(--border-color);
}

.timer-pill i {
  color: var(--viinder-red);
}

/* ==========================================================================
   CONTENEDOR PRINCIPAL DEL MAPA (TEMA CLARO)
   ========================================================================== */
#map {
  position: absolute;
  top: 64px;
  bottom: 0;
  left: 0;
  right: 0;
  background: #f1f3f6;
  z-index: 1;
}

/* ==========================================================================
   CONTROLES FLOTANTES EN EL MAPA
   ========================================================================== */
.map-floating-controls {
  position: fixed;
  right: 16px;
  top: 80px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 999;
}

.map-control-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--surface-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: all 0.2s ease;
}

.map-control-btn:hover {
  background: var(--surface-elevated);
  transform: translateY(-2px);
}

.map-control-btn.active {
  border-color: var(--viinder-red);
  color: var(--viinder-red);
}

/* ==========================================================================
   TABLERO "TOUR DE FRANCE" (DRAWER / SIDEBAR)
   ========================================================================== */
.leaderboard-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 48vh;
  background: var(--surface-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-color);
  border-radius: 24px 24px 0 0;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.6);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.leaderboard-drawer.collapsed {
  transform: translateY(calc(100% - 56px));
}

.drawer-header {
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.drawer-handle-bar {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
}

.drawer-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.title-mobile {
  display: none;
}

.drawer-stats-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  color: var(--text-secondary);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.stat-item i {
  color: var(--viinder-red);
}

.leaderboard-list {
  padding: 12px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ==========================================================================
   TARJETA DE ATLETA (LEADERBOARD CARD)
   ========================================================================== */
.athlete-card {
  display: flex;
  align-items: center;
  background: var(--surface-dark);
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.athlete-card:hover {
  background: var(--surface-elevated);
  transform: scale(1.01);
}

.athlete-card.leader-card {
  border: 1px solid rgba(255, 179, 0, 0.4);
  background: linear-gradient(90deg, rgba(255, 179, 0, 0.06), var(--surface-dark));
}

.athlete-card.sos-card {
  border: 1px solid var(--viinder-red);
  background: linear-gradient(90deg, rgba(229, 57, 53, 0.15), var(--surface-dark));
  animation: alert-border-pulse 1.2s infinite;
}

@keyframes alert-border-pulse {
  0% { box-shadow: 0 0 0 0 rgba(229, 57, 53, 0.6); }
  70% { box-shadow: 0 0 0 10px rgba(229, 57, 53, 0); }
  100% { box-shadow: 0 0 0 0 rgba(229, 57, 53, 0); }
}

.rank-badge {
  font-size: 13px;
  font-weight: 900;
  width: 28px;
  text-align: center;
  color: var(--text-muted);
}

.rank-badge.podium-1 { color: #FFD700; font-size: 15px; }
.rank-badge.podium-2 { color: #C0C0C0; font-size: 14px; }
.rank-badge.podium-3 { color: #CD7F32; font-size: 14px; }

.athlete-avatar-box {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #2A2D36;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 10px;
  position: relative;
  font-weight: 800;
  font-size: 13px;
  color: #fff;
  border: 2px solid var(--surface-elevated);
  overflow: hidden;
}

.avatar-circle {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.avatar-initials {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  color: #fff;
  text-transform: uppercase;
}

.athlete-main-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.athlete-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.athlete-name {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crown-tag {
  font-size: 11px;
  font-weight: 800;
  color: #FFD700;
  background: rgba(255, 215, 0, 0.15);
  padding: 1px 6px;
  border-radius: 10px;
}

.athlete-sub-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 3px;
  font-size: 11px;
}

.gap-text {
  color: var(--text-secondary);
  font-weight: 600;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
}

.status-pill.active {
  background: rgba(0, 230, 118, 0.15);
  color: var(--viinder-green);
}

.status-pill.paused {
  background: rgba(255, 179, 0, 0.15);
  color: var(--viinder-yellow);
}

.status-pill.sos {
  background: var(--viinder-red);
  color: #fff;
  animation: pulse-glow 1s infinite;
}

.athlete-metrics {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: right;
}

.metric-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.metric-val {
  font-size: 16px;
  font-weight: 900;
  color: #fff;
  font-family: monospace;
}

.metric-val small {
  display: none;
}

.metric-lbl {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* ==========================================================================
   PINS DE ATLETA EN EL MAPA (LEAFLET CUSTOM ICONS)
   ========================================================================== */
.athlete-marker-container {
  background: none;
  border: none;
}

.athlete-pin {
  position: relative;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pin-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #17181D;
  border: 2px solid #fff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  overflow: hidden;
  z-index: 2;
}

.pin-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.athlete-pin.leader .pin-avatar {
  border-color: #FFD700;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.8);
}

.athlete-pin.sos .pin-avatar {
  border-color: var(--viinder-red);
  background: var(--viinder-red);
  animation: pulse-glow 1s infinite;
}

.leader-crown {
  position: absolute;
  top: -10px;
  font-size: 14px;
  z-index: 4;
}

.pin-speed-badge {
  position: absolute;
  bottom: -6px;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 3;
}

.custom-pin .pin-marker {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
  border: 2px solid #fff;
  box-shadow: 0 3px 8px rgba(0,0,0,0.5);
}

.pin-marker.start { background: var(--viinder-green); }
.pin-marker.finish { background: var(--viinder-red); }

/* ==========================================================================
   ALERTA SOS Y MODAL DE FINALIZACIÓN
   ========================================================================== */
.alert-banner {
  position: fixed;
  top: 72px;
  left: 16px;
  right: 16px;
  background: var(--viinder-red);
  color: #fff;
  padding: 12px 18px;
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(229, 57, 53, 0.6);
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slide-down 0.4s ease;
}

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

.alert-banner i { font-size: 20px; }

.finish-banner {
  position: fixed;
  top: 72px;
  left: 16px;
  right: 16px;
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  padding: 14px 20px;
  border-radius: 14px;
  color: #fff;
  z-index: 1500;
  text-align: center;
  font-weight: 700;
  display: none;
}

.error-state {
  position: fixed;
  inset: 0;
  background: var(--bg-dark);
  z-index: 9999;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}

.error-icon {
  font-size: 54px;
  color: var(--viinder-red);
  margin-bottom: 16px;
}

/* ==========================================================================
   MODAL DE INGRESO DE CÓDIGO (CUANDO SE VISITA SIN ?code=)
   ========================================================================== */
.code-entry-modal {
  position: fixed;
  inset: 0;
  background: rgba(14, 15, 18, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.code-entry-card {
  background: var(--surface-dark);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 28px 24px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
  animation: modal-fade-in 0.3s ease;
}

@keyframes modal-fade-in {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.code-entry-icon {
  width: 60px;
  height: 60px;
  background: rgba(229, 57, 53, 0.12);
  border: 1px solid rgba(229, 57, 53, 0.3);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: var(--viinder-red);
  margin-bottom: 16px;
}

.code-entry-title {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 8px;
}

.code-entry-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 22px;
}

.code-input-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.code-input-field {
  width: 100%;
  background: var(--surface-elevated);
  border: 1.5px solid var(--border-color);
  border-radius: 12px;
  padding: 14px 16px;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2px;
  text-align: center;
  text-transform: uppercase;
  outline: none;
  transition: border-color 0.2s;
}

.code-input-field:focus {
  border-color: var(--viinder-red);
}

.code-submit-btn {
  width: 100%;
  background: var(--viinder-red);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity 0.2s, transform 0.2s;
}

.code-submit-btn:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

/* ==========================================================================
   RESPONSIVIDAD (ESCRITORIO / PANTALLAS GRANDES)
   ========================================================================== */
@media (min-width: 768px) {
  .leaderboard-drawer {
    left: auto;
    right: 20px;
    bottom: 20px;
    width: 380px;
    max-height: 80vh;
    border-radius: 20px;
    border: 1px solid var(--border-color);
  }

  .leaderboard-drawer.collapsed {
    transform: translateY(calc(100% - 56px));
  }

  .event-title {
    max-width: 400px;
    font-size: 17px;
  }
}

/* ==========================================================================
   1. BARRA DE PROGRESO DE CARRERA Y ETA (TOUR DE FRANCE)
   ========================================================================== */
body.has-progress #map {
  top: 92px;
}

body.has-progress .map-floating-controls {
  top: 104px;
}

.race-progress-bar-container {
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  height: 28px;
  background: rgba(14, 15, 18, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  z-index: 999;
  overflow: hidden;
}

.race-progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  background: linear-gradient(90deg, rgba(229, 57, 53, 0.4), rgba(229, 57, 53, 0.85));
  transition: width 0.5s ease;
}

.race-progress-content {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 16px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}

.progress-info-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-badge {
  color: #FFB300;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.progress-pct {
  color: #FF5252;
  font-weight: 800;
}

.progress-info-right {
  font-family: monospace;
  color: var(--text-secondary);
  font-size: 11px;
}

/* ==========================================================================
   2. ETIQUETAS DE GRUPO Y PELOTÓN (TOUR DE FRANCE)
   ========================================================================== */
.group-tag {
  font-size: 10px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.group-tag.leader-escape {
  background: rgba(255, 215, 0, 0.2);
  color: #FFD700;
  border: 1px solid rgba(255, 215, 0, 0.4);
}

.group-tag.peloton {
  background: rgba(0, 230, 118, 0.18);
  color: #00E676;
  border: 1px solid rgba(0, 230, 118, 0.35);
}

.group-tag.chaser {
  background: rgba(255, 152, 0, 0.2);
  color: #FFA726;
  border: 1px solid rgba(255, 152, 0, 0.4);
}

/* ==========================================================================
   8. PERFIL ALTIMÉTRICO (ELEVATION DRAWER)
   ========================================================================== */
.elevation-drawer {
  position: fixed;
  bottom: 60px;
  left: 16px;
  right: 16px;
  background: rgba(23, 24, 29, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  z-index: 1002;
  padding: 10px 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  animation: slide-up 0.3s ease;
}

@media (min-width: 768px) {
  .elevation-drawer {
    left: 20px;
    right: auto;
    width: 440px;
    bottom: 20px;
  }
}

.elevation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.elevation-title {
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
}

.elevation-title i { color: #FF9800; }

.elevation-stats {
  font-size: 11px;
  color: var(--text-muted);
}

.elevation-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
}

.elevation-close-btn:hover { color: #fff; }

.elevation-canvas-wrapper {
  width: 100%;
  height: 85px;
  position: relative;
}

.elevation-canvas-wrapper canvas {
  width: 100%;
  height: 85px;
  display: block;
}

/* ==========================================================================
   6. MODAL DE PODIO FINAL DE PREMIACIÓN
   ========================================================================== */
.podium-modal {
  position: fixed;
  inset: 0;
  background: rgba(14, 15, 18, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.podium-card {
  background: var(--surface-dark);
  border: 1px solid rgba(255, 215, 0, 0.4);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(255, 215, 0, 0.15);
  border-radius: 24px;
  padding: 28px 24px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  position: relative;
  animation: modal-fade-in 0.35s ease;
}

.podium-close-btn {
  position: absolute;
  top: 14px;
  right: 18px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 26px;
  cursor: pointer;
}

.podium-close-btn:hover { color: #fff; }

.podium-trophy-icon {
  font-size: 44px;
  margin-bottom: 8px;
}

.podium-header h2 {
  font-size: 22px;
  font-weight: 900;
  color: #fff;
  margin-bottom: 4px;
}

.podium-header p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.podium-ranks {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 22px;
}

.podium-row {
  display: flex;
  align-items: center;
  background: var(--surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 10px 14px;
  gap: 12px;
}

.podium-row.rank-1 {
  border-color: #FFD700;
  background: linear-gradient(90deg, rgba(255, 215, 0, 0.15), var(--surface-elevated));
}

.podium-row.rank-2 {
  border-color: #C0C0C0;
  background: linear-gradient(90deg, rgba(192, 192, 192, 0.1), var(--surface-elevated));
}

.podium-row.rank-3 {
  border-color: #CD7F32;
  background: linear-gradient(90deg, rgba(205, 127, 50, 0.1), var(--surface-elevated));
}

.podium-medal {
  font-size: 22px;
  width: 30px;
  text-align: center;
}

.podium-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #2A2D36;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
}

.podium-avatar img { width: 100%; height: 100%; object-fit: cover; }

.podium-info {
  flex: 1;
  text-align: left;
}

.podium-name {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

.podium-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.podium-time {
  font-family: monospace;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
}

.share-whatsapp-btn {
  width: 100%;
  background: #25D366;
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.2s, opacity 0.2s;
}

.share-whatsapp-btn:hover {
  opacity: 0.92;
  transform: scale(1.02);
}

/* ==========================================================================
   4. SMART APP DOWNLOAD BANNER
   ========================================================================== */
.smart-app-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(23, 24, 29, 0.95);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border-color);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 998;
  transition: transform 0.3s ease;
}

.banner-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.banner-logo {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.banner-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.banner-text strong {
  font-size: 13px;
  color: #fff;
}

.banner-text span {
  font-size: 11px;
  color: var(--text-muted);
}

.banner-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.banner-download-btn {
  background: var(--viinder-red);
  color: #fff;
  text-decoration: none;
  font-size: 12px;
  font-weight: 800;
  padding: 6px 12px;
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: transform 0.2s;
}

.banner-download-btn:hover { transform: scale(1.03); }

.banner-dismiss-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
}

.banner-dismiss-btn:hover { color: #fff; }

@media (min-width: 768px) {
  .smart-app-banner {
    left: 20px;
    right: auto;
    bottom: 20px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    max-width: 360px;
  }
}

/* ==========================================================================
   5. MODO PANTALLA COMPLETA / TV
   ========================================================================== */
:fullscreen .top-nav,
:-webkit-full-screen .top-nav {
  height: 72px;
}

:fullscreen .event-title,
:-webkit-full-screen .event-title {
  font-size: 19px;
  max-width: 600px;
}

:fullscreen .timer-pill,
:-webkit-full-screen .timer-pill {
  font-size: 17px;
  padding: 8px 16px;
}

:fullscreen .map-floating-controls,
:-webkit-full-screen .map-floating-controls {
  top: 90px;
}

:fullscreen .leaderboard-drawer,
:-webkit-full-screen .leaderboard-drawer {
  max-height: 85vh;
}

/* ==========================================================================
   OPTIMIZACIÓN MÓVIL (PANTALLAS <= 600px)
   ========================================================================== */
@media (max-width: 600px) {
  /* 1. Header ultra compacto y limpio */
  .top-nav {
    height: 56px;
    padding: 0 10px;
  }

  .brand-section {
    gap: 8px;
    flex: 1;
    min-width: 0;
  }

  .brand-logo {
    height: 26px;
  }

  .event-details {
    flex: 1;
    min-width: 0;
  }

  .event-title-row {
    gap: 6px;
    align-items: center;
  }

  .event-title {
    font-size: 13.5px;
    max-width: 140px;
    letter-spacing: -0.2px;
  }

  .status-tag {
    font-size: 9px;
    padding: 2px 6px;
    gap: 3px;
    border-radius: 12px;
    flex-shrink: 0;
  }

  .status-tag i {
    font-size: 8.5px;
  }

  .event-sub-row {
    font-size: 10.5px;
    gap: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .code-label {
    display: none;
  }

  .timer-pill {
    padding: 4px 8px;
    font-size: 12px;
    gap: 4px;
    flex-shrink: 0;
    margin-left: 4px;
    border-radius: 14px;
  }

  .timer-pill i {
    font-size: 11px;
  }

  /* 2. Barra de progreso estilizada */
  body.has-progress #map {
    top: 80px;
  }

  body.has-progress .map-floating-controls {
    top: 88px;
  }

  .race-progress-bar-container {
    top: 56px;
    height: 24px;
  }

  .race-progress-content {
    padding: 0 10px;
    font-size: 10px;
  }

  .progress-info-left {
    gap: 4px;
  }

  .progress-badge {
    font-size: 9px;
  }

  .progress-info-right {
    font-size: 9.5px;
  }

  /* 3. Botones flotantes compactos (Dock lateral derecho) */
  .map-floating-controls {
    right: 10px;
    top: 66px;
    gap: 6px;
  }

  .map-control-btn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 13px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
  }

  /* 4. Cajón de clasificación inferior */
  .leaderboard-drawer {
    max-height: 55vh;
    border-radius: 20px 20px 0 0;
  }

  .leaderboard-drawer.collapsed {
    transform: translateY(calc(100% - 46px));
  }

  .drawer-header {
    padding: 8px 12px 10px 12px;
  }

  .drawer-handle-bar {
    top: 5px;
    width: 30px;
    height: 3.5px;
  }

  .drawer-title-group {
    font-size: 12px;
    gap: 5px;
  }

  .drawer-title-group i {
    font-size: 13px;
  }

  .title-desktop {
    display: none;
  }

  .title-mobile {
    display: inline;
  }

  .drawer-stats-summary {
    gap: 8px;
    font-size: 10.5px;
  }

  .stat-item {
    gap: 3px;
  }

  .leaderboard-list {
    padding: 8px 10px;
    gap: 6px;
  }

  /* 5. Tarjeta del Atleta (Rediseñada para móvil) */
  .athlete-card {
    padding: 7px 9px;
    border-radius: 12px;
    gap: 2px;
  }

  .rank-badge {
    width: 18px;
    font-size: 11px;
    flex-shrink: 0;
  }

  .rank-badge.podium-1 { font-size: 12.5px; }

  .athlete-avatar-box {
    width: 32px;
    height: 32px;
    margin: 0 6px 0 2px;
    flex-shrink: 0;
  }

  .athlete-main-info {
    flex: 1;
    min-width: 0;
    margin-right: 6px;
  }

  .athlete-name-row {
    gap: 4px;
  }

  .athlete-name {
    font-size: 12.5px;
    font-weight: 700;
  }

  .crown-tag {
    font-size: 9px;
    padding: 0 3px;
  }

  .athlete-sub-info {
    gap: 4px;
    margin-top: 2px;
    flex-wrap: wrap;
  }

  .group-tag {
    font-size: 8.5px;
    padding: 1px 4px;
    border-radius: 4px;
  }

  .status-pill {
    font-size: 8.5px;
    padding: 1px 4px;
    border-radius: 4px;
  }

  .gap-text {
    font-size: 9px;
  }

  .athlete-metrics {
    gap: 8px;
    flex-shrink: 0;
  }

  .metric-block {
    align-items: flex-end;
  }

  .metric-val {
    font-size: 12.5px;
    font-weight: 800;
    line-height: 1.1;
  }

  .metric-val small {
    display: inline;
    font-size: 8.5px;
    margin-left: 2px;
    color: var(--text-muted);
    font-weight: normal;
  }

  .metric-lbl {
    display: none;
  }

  /* 6. Cajón de altimetría en móvil */
  .elevation-drawer {
    left: 10px;
    right: 10px;
    bottom: 54px;
    padding: 8px 10px;
    border-radius: 12px;
  }

  .elevation-canvas-wrapper,
  .elevation-canvas-wrapper canvas {
    height: 70px;
  }
}
