/* ===========================
   RANKING ANIMADO - BLACKRUNNING
   =========================== */

:root {
  --bar-height: 22px;
  --bar-gap: 10px;
  --row-height: calc(var(--bar-height) + 18px);
  --transition-duration: 900ms;
}

* {
  box-sizing: border-box;
}

/* Fundo escuro, compatível com o site */
body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, rgba(66, 253, 43, 0.08), transparent 55%),
    radial-gradient(circle at bottom right, rgba(249, 255, 66, 0.06), transparent 60%),
    #0E0A17;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* Container principal */
.app {
  width: 100%;
  max-width: 960px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background:
    radial-gradient(circle at top left, rgba(66, 253, 43, 0.08), transparent 55%),
    radial-gradient(circle at bottom right, rgba(249, 255, 66, 0.05), transparent 60%),
    linear-gradient(135deg, #18121F 0%, #0E0A17 50%, #050308 100%);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.8),
    0 0 0 1px rgba(0, 0, 0, 0.5);
  padding: 24px 24px 28px;
  backdrop-filter: blur(10px);
}

/* HEADER / TÍTULO */

.app-header {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
}

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

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

.pill {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(249, 255, 66, 0.7);
  color: #F9FF42;
  background: radial-gradient(circle at top, rgba(249, 255, 66, 0.18), transparent 60%);
}

h1 {
  font-size: 22px;
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.02em;
  display: flex;
  align-items: baseline;
  gap: 4px;
}

h1 span.highlight {
  background: linear-gradient(120deg, #42FD2B, #F9FF42);
  -webkit-background-clip: text;
  color: transparent;
}

.subtitle {
  font-size: 13px;
  color: #A8A8AB;
  max-width: 520px;
}

/* HEADER RIGHT: logo + controles */

.header-right {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
}

/* Slot da logo */

.logo-slot {
  min-height: 40px;
  min-width: 120px;
  max-width: 220px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 16px;
  background: rgba(14, 10, 23, 0.9);
}

.logo-slot img {
  max-height: 32px;
  max-width: 100%;
  object-fit: contain;
}

/* CONTROLES (CATEGORIA, VELOCIDADE, BOTÕES) */

.controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
  justify-content: flex-end;
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 160px;
}

.field label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #A8A8AB;
}

.field-speed {
  max-width: 130px;
}

.select-wrapper {
  position: relative;
}

.select-wrapper::after {
  content: "▾";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: #A8A8AB;
  pointer-events: none;
}

select {
  appearance: none;
  width: 100%;
  padding: 7px 26px 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background-color: #0E0A17;
  color: #FFFFFF;
  font-size: 13px;
  outline: none;
}

select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* BOTÕES PADRÃO */

button {
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(90deg, #42FD2B, #F9FF42);
  color: #000000;
  box-shadow:
    0 10px 30px rgba(66, 253, 43, 0.4),
    0 0 0 1px rgba(0, 0, 0, 0.4);
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
  white-space: nowrap;
}

button span.icon {
  font-size: 14px;
}

button:disabled {
  opacity: 0.45;
  cursor: default;
  box-shadow: none;
  transform: none;
}

button:not(:disabled):hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
  box-shadow:
    0 16px 40px rgba(249, 255, 66, 0.55),
    0 0 0 1px rgba(0, 0, 0, 0.6);
}

/* BOTÕES-LINK (Ranking completo, Minha jornada) */

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 12px;
  font-weight: 500;
  color: #FFFFFF;
  text-decoration: none;
  background: rgba(14, 10, 23, 0.9);
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease, color 120ms ease;
  white-space: nowrap;
}

.link-button:hover {
  background: rgba(24, 18, 37, 0.95);
  border-color: rgba(249, 255, 66, 0.9);
  color: #F9FF42;
  transform: translateY(-1px);
}

/* CARD PRINCIPAL */

.main-card {
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background:
    radial-gradient(circle at top left, rgba(66, 253, 43, 0.12), transparent 55%),
    radial-gradient(circle at bottom right, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0.95));
  padding: 16px 16px 18px;
}

/* TOPO DO CARD – ETAPA + META + BOTÕES-LINK */

.top-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 4px;
}

.top-row-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.race-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
}

.race-label-main {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #A8A8AB;
}

.race-label-value {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #42FD2B;
}

.race-label-sub {
  font-size: 12px;
  color: #A8A8AB;
}

.race-label.flash::before {
  content: "";
  position: absolute;
  inset: -6px -10px;
  border-radius: 16px;
  background: radial-gradient(circle, rgba(66, 253, 43, 0.5), transparent 65%);
  opacity: 0;
  animation: raceFlash 650ms ease-out;
  pointer-events: none;
  z-index: -1;
}

@keyframes raceFlash {
  0%   { opacity: 0; transform: scale(0.95); }
  40%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.05); }
}

.meta {
  display: flex;
  gap: 14px;
  align-items: center;
  font-size: 11px;
  color: #A8A8AB;
}

.meta span.dot {
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
}

.meta strong {
  color: #F9FF42;
  font-weight: 500;
}

/* CARD DO GRÁFICO */

.chart-card {
  margin-top: 12px;
  border-radius: 16px;
  border: 1px solid rgba(24, 20, 29, 0.31);
  background:
    radial-gradient(circle at top, rgba(24, 20, 37, 0.9), rgba(14, 10, 23, 0.98));
  padding: 14px 14px 16px;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 12px;
  color: #A8A8AB;
}

.chart-header-left {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.chart-header-left span.badge {
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  padding: 2px 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #A8A8AB;
}

.chart-header-left span.info {
  font-size: 11px;
  color: #A8A8AB;
}

.chart-header-right {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
}

.chart-header-right strong {
  color: #F9FF42;
  font-weight: 500;
}

.chart-header-right .bullet {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1px solid rgba(66, 253, 43, 0.8);
  box-shadow: 0 0 0 3px rgba(66, 253, 43, 0.3);
  background: radial-gradient(circle, #42FD2B, #2ED51D);
}

.chart-wrapper {
  position: relative;
  margin-top: 4px;
}

/* ÁREA DAS BARRAS */

.bars-wrapper {
  position: relative;
  height: calc(
    var(--row-height) * 10 +
    var(--bar-gap) * 11
  );
  padding-top: 2px;
  padding-bottom: 8px;
  overflow: visible; /* não cortar as barras/atletas no fim */
}

.bar-row {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transform: translateY(
    calc(
      var(--rank, 0) * (var(--row-height) + var(--bar-gap))
    )
  );
  transition: transform var(--transition-duration) cubic-bezier(0.23, 0.7, 0.21, 1);
}

/* linha com posição + barra */
.bar-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bar {
  display: flex;
  align-items: center;
  height: var(--bar-height);
  border-radius: 999px;
  background: linear-gradient(90deg, #1B1329, #251938);
  border: 1px solid rgba(24, 20, 29, 0.31);
  padding-right: 8px;
  overflow: visible;
  width: 0%;
  max-width: 100%;
  transition: width 300ms linear;
}

.bar-row.top5 .bar {
  background: linear-gradient(90deg, #42FD2B, #F9FF42);
  border-color: #42FD2B;
  box-shadow:
    0 0 0 1px rgba(66, 253, 43, 0.6),
    0 0 18px rgba(66, 253, 43, 0.5);
}

.bar-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 12px;
  width: 100%;
}

.bar-values {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-variant-numeric: tabular-nums;
}

.bar-current {
  font-size: 13px;
  font-weight: 600;
  color: #000000;
}

/* PÍLULA DE POSIÇÃO */

.bar-rank-pill {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.7);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #000000;
  background:
    radial-gradient(circle at top, #FFFFFF, #E4E4E7);
}

.bar-row.top5 .bar-rank-pill {
  background: radial-gradient(circle at top, #F9FF42, #FFE46A);
}

.bar-row.top5 .bar-rank-pill.gold {
  box-shadow:
    0 0 0 1px rgba(161, 98, 7, 0.5),
    0 0 18px rgba(250, 204, 21, 0.35);
}

/* RÓTULO DO NOME */

.bar-label {
  padding-left: 30px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.bar-label-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

/* (Para futura "minha jornada") – destaque do atleta */
.bar-row.self-athlete .bar {
  box-shadow:
    0 0 0 2px rgba(249, 255, 66, 0.8),
    0 0 20px rgba(249, 255, 66, 0.7);
}

.bar-row.self-athlete .bar-rank-pill {
  transform: scale(1.1);
  box-shadow:
    0 0 0 2px rgba(249, 255, 66, 0.9),
    0 0 16px rgba(249, 255, 66, 0.7);
}

.bar-row.self-athlete .bar-label-name {
  color: #F9FF42;
  font-weight: 600;
}

/* PROGRESSO DAS ETAPAS */

.stage-progress {
  margin-top: 10px;
  font-size: 11px;
  color: #A8A8AB;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.stage-dots {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}

.stage-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #18121F;
  border: 1px solid rgba(255, 255, 255, 0.12);
  opacity: 0.55;
}

.stage-dot.active {
  background: radial-gradient(circle, #42FD2B, #2ED51D);
  border-color: rgba(66, 253, 43, 0.9);
  opacity: 1;
  box-shadow:
    0 0 0 4px rgba(66, 253, 43, 0.26),
    0 0 12px rgba(66, 253, 43, 0.7);
}

.stage-progress-text {
  text-align: right;
}

.stage-progress-text strong {
  color: #F9FF42;
  font-weight: 500;
}

/* STATUS */

.status-line {
  margin-top: 10px;
  font-size: 11px;
  color: #A8A8AB;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.status-left {
  display: flex;
  gap: 10px;
  align-items: center;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #42FD2B;
  box-shadow:
    0 0 0 4px rgba(66, 253, 43, 0.25),
    0 0 16px rgba(66, 253, 43, 0.7);
}

.status-left span {
  color: #A8A8AB;
}

.status-right {
  font-size: 11px;
  color: #A8A8AB;
}

.status-right strong {
  color: #F9FF42;
  font-weight: 500;
}

.status-error {
  color: #ff9ea0;
}

/* ====== RESPONSIVO ====== */

@media (max-width: 720px) {
  body {
    padding: 0;
    background: #0E0A17;
    display: block;
  }

  .app {
    max-width: 100%;
    width: 100%;
    min-height: 100vh;
    border-radius: 0;
    box-shadow: none;
    padding: 16px 12px 18px;
    display: flex;
    flex-direction: column;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
  }

  .header-right {
    width: 100%;
    align-items: stretch;
    gap: 12px;
  }

  .logo-slot {
    align-self: flex-end;
  }

  .controls {
    width: 100%;
    align-items: stretch;
  }

  .controls-row {
    justify-content: flex-start;
  }

  .field {
    min-width: 0;
    flex: 1;
  }

  .main-card {
    margin-top: 4px;
    flex: 1;
    display: flex;
    flex-direction: column;
  }

  .chart-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 10px 10px 12px;
  }

  .chart-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
  }

  .bars-wrapper {
    flex: 0 0 auto;
    height: calc(
      var(--row-height) * 10 +
      var(--bar-gap) * 12
    );
    overflow: visible;
  }

  .top-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .top-row-right {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 8px;
  }

  .link-button {
    font-size: 12px;
    padding: 6px 10px;
    align-items: center;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  :root {
    --bar-height: 20px;
    --bar-gap: 7px;
    --row-height: calc(var(--bar-height) + 16px);
  }

  .app {
    padding: 12px 8px 14px;
  }

  h1 {
    font-size: 18px;
  }

  .subtitle {
    font-size: 12px;
  }

  .bar-label-name {
    font-size: 12px;
  }

  .bar-current {
    font-size: 12px;
  }

  .chart-card {
    padding: 10px 8px 12px;
  }
}
/* ===========================
   TELA INICIAL / WELCOME OVERLAY
   =========================== */

.welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background:
    radial-gradient(circle at top, rgba(66, 253, 43, 0.18), transparent 60%),
    radial-gradient(circle at bottom, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.95));
  backdrop-filter: blur(12px);
  transition: opacity 220ms ease, transform 220ms ease;
}

.welcome-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(1.02);
}

.welcome-card {
  width: 100%;
  max-width: 520px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background:
    radial-gradient(circle at top left, rgba(66, 253, 43, 0.16), transparent 60%),
    #0E0A17;
  padding: 20px 18px 18px;
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.8),
    0 0 0 1px rgba(0, 0, 0, 0.6);
}

.welcome-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.welcome-logo {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 12px;
}

.welcome-logo img {
  max-height: 56px;
  width: auto;
}
@media (max-width: 480px) {
  .welcome-logo img {
    max-height: 44px;
  }
}

.welcome-pill {
  align-self: flex-start;
  text-align: center;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(249, 255, 66, 0.7);
  color: #F9FF42;
  background: radial-gradient(circle at top, rgba(249, 255, 66, 0.18), transparent 60%);
}

.welcome-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.welcome-header p {
  margin: 0;
  font-size: 13px;
  color: #A8A8AB;
}

.welcome-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.welcome-field {
  min-width: 0;
}

.welcome-footer-text {
  margin: 16px 0 0;
  font-size: 11px;
  color: #A8A8AB;
}

@media (max-width: 720px) {
  .welcome-card {
    max-width: 380px;
    padding: 18px 14px 16px;
  }

  .welcome-header h2 {
    font-size: 18px;
  }
}

@media (max-width: 480px) {
  .welcome-card {
    max-width: 340px;
  }
}
.bar-label-details {
  font-size: 11px;
  color: #A8A8AB;
}
