/* Лидерборд гонки — тёмная тема бробролаба. Мобайл-first, тайпографика под проектор. */

@font-face {
  font-family: "Inter";
  src: url("/static/fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Excalifont";
  src: url("/static/fonts/Excalifont-Regular-cyrillic.woff2") format("woff2");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "Excalifont";
  src: url("/static/fonts/Excalifont-Regular-latin.woff2") format("woff2");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
    U+FEFF, U+FFFD;
}

:root {
  --bg: #1A1A1A;
  --surface: #212121;
  --text: #FFFFFF;
  --muted: #B0B0B0;
  --line: #2E2E2E;
  --accent: #1B4DFF;
  /* место: светлее акцента — контраст на тёмном фоне >= 4,5:1, синий оставлен рамкам/бейджам/шапкам */
  --place: #7C9AFF;
  --gold: #FFB800;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Excalifont", "Inter", sans-serif; /* вся страница — шрифтом заголовка (решение 33) */
  -webkit-font-smoothing: antialiased;
}

/* safe-area для Mini App: футер не уходит под «жест-бар» iPhone */
body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.header {
  padding: 14px 16px 12px;
  text-align: center;
}



.title {
  font-family: "Excalifont", "Inter", sans-serif;
  font-size: clamp(30px, 6.5vw, 76px);
  line-height: 1.08;
  margin: 0;
}

.subtitle {
  font-family: "Excalifont", "Inter", sans-serif; /* тексты — игриво */
  color: var(--muted);
  font-size: clamp(13px, 2.2vw, 22px);
  margin: 6px 0 0;
}

.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 8px 16px 36px;
}

/* топ-3 крупно — читаемость с проектора */
.podium {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 24px 0 8px;
}

.card {
  position: relative; /* якорь для glow-слоя новой карточки */
  overflow: hidden;
  border: 2px solid #ffffff; /* обводка ребят — белая (решение 34) */
  border-radius: 18px;
  background: var(--surface);
  padding: 18px 22px;
}

.card-place {
  font-size: 18px;
  font-weight: 600;
  color: #ffffff; /* номер места белым (решение 35) */
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.card-name {
  font-size: clamp(24px, 4.4vw, 44px);
  font-weight: 700;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.card-time {
  font-size: clamp(34px, 6.4vw, 72px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  color: var(--text); /* главное число — белым, контраст >= 4,5:1 */
}

.card.place-1 {
  border-color: #ffffff; /* рамка лидера тоже белая (решение 34) */
}

.card.me {
  background: rgba(27, 77, 255, 0.12);
}

@media (min-width: 700px) {
  .podium {
    flex-direction: row;
    align-items: stretch;
  }
  .podium .card {
    flex: 1;
  }
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: clamp(16px, 2.6vw, 28px);
  font-family: "Excalifont", "Inter", sans-serif; /* таблица — игриво */
}

.table th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

.table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

.table td.name {
  overflow-wrap: anywhere;
}

.table td.time {
  font-weight: 700;
  color: var(--text); /* время — белым, не синим */
}

tr.me td {
  background: rgba(27, 77, 255, 0.14);
}

/* новая строка/карточка: slide + glow, анимируются только transform/opacity */
@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes glow-out {
  from {
    opacity: 0.35;
  }
  to {
    opacity: 0;
  }
}

.card.new,
tr.new {
  animation: slide-in 0.5s ease-out 1;
}

tr.new {
  position: relative;
}

.card.new::after,
tr.new::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent);
  opacity: 0; /* база прозрачна: при reduced-motion слой не остаётся на экране */
  pointer-events: none;
  animation: glow-out 1.1s ease-out 1 forwards;
}

/* заставка-маскот под шапкой */
.hero {
  display: block;
  width: 100%;
  max-height: clamp(180px, 30vw, 320px);
  object-fit: cover;
  object-position: center 30%;
  border-radius: 18px;
  margin-top: 16px;
  border: 2px solid #ffffff;
}

/* пустое состояние «ждём» — пульс чистым CSS */
.empty {
  margin: 48px 0;
  text-align: center;
  font-size: clamp(22px, 4vw, 44px);
  color: var(--muted);
  animation: soft-pulse 2.4s ease-in-out infinite;
}

@keyframes soft-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

.last {
  margin: 22px 0 8px;
  font-size: clamp(16px, 2.8vw, 26px);
  color: var(--muted);
}

.last b {
  color: var(--text);
}

/* «ты N-й» — плашка над таблицей */
.me-badge {
  display: inline-block;
  margin: 14px 0 4px;
  padding: 6px 14px;
  border: 2px solid var(--accent);
  border-radius: 999px;
  background: rgba(27, 77, 255, 0.12);
  font-weight: 600;
  font-size: clamp(14px, 2.4vw, 20px);
}

/* «данные устарели» — заметно, но без паники */
.stale-notice {
  display: inline-block;
  margin: 10px 0 0;
  padding: 6px 12px;
  border: 1px solid var(--gold);
  border-radius: 10px;
  color: var(--gold);
  font-size: clamp(16px, 2.6vw, 20px);
}

/* конфетти: слой поверх страницы, частицы двигает Web Animations (transform/opacity) */
#confetti {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 50;
}

.confetti-piece {
  position: absolute;
  top: 0;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  will-change: transform, opacity;
}

.meta {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 28px;
  color: var(--muted);
  font-size: 14px;
}

/* лого бробролаба — маленькое, ненавязчивое, слева внизу */
.meta .brand-logo {
  height: 20px;
  width: auto;
  opacity: 0.85;
  align-self: center;
}

.hidden {
  display: none;
}

/* анимационная гигиена: убираем всё, конфетти не показываем */
@media (prefers-reduced-motion: reduce) {
  .card.new,
  tr.new,
  .card.new::after,
  tr.new::after,
  .empty {
    animation: none;
  }
  #confetti {
    display: none;
  }
}
