:root {
  /* Telegram theme params (with sensible fallbacks) */
  --bg: var(--tg-theme-bg-color, #ffffff);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #f2f3f5);
  --text: var(--tg-theme-text-color, #16181c);
  --hint: var(--tg-theme-hint-color, #8b95a1);
  --link: var(--tg-theme-link-color, #2f7bf6);
  --accent: var(--tg-theme-button-color, #2f7bf6);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --card-radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--secondary-bg);
  color: var(--text);
  padding: 0 14px 32px;
  -webkit-font-smoothing: antialiased;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--secondary-bg);
  padding: 14px 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.app-header h1 { font-size: 1.25rem; margin: 0; }

#ride-select {
  flex: 1;
  max-width: 60%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--hint);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}

.card {
  background: var(--bg);
  border-radius: var(--card-radius);
  padding: 14px 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.card h2 { font-size: 1rem; margin: 0 0 10px; }

/* Personal "today" card */
.me-card .me-name { font-weight: 600; margin-bottom: 10px; }
.metric-row { display: flex; gap: 10px; }
.metric {
  flex: 1;
  background: var(--secondary-bg);
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
}
.metric .value { font-size: 1.35rem; font-weight: 700; line-height: 1.1; }
.metric .label { font-size: 0.72rem; color: var(--hint); margin-top: 4px; }

.exec-meter { margin: 4px 0 12px; }
.exec-meter .track {
  height: 10px;
  border-radius: 6px;
  background: var(--secondary-bg);
  overflow: hidden;
}
.exec-meter .fill {
  height: 100%;
  background: var(--accent);
  border-radius: 6px;
  transition: width 0.4s ease;
}
.exec-meter .caption {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--hint);
  margin-top: 4px;
}

.ride-title { font-weight: 600; }
.ride-meta { color: var(--hint); font-size: 0.85rem; margin-top: 2px; }
.checkins { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--secondary-bg);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.8rem;
}

.board-grid { display: grid; grid-template-columns: 1fr; gap: 0; }

.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--secondary-bg);
}
.rank-list li:first-child { border-top: none; }
.rank-list .pos {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--secondary-bg);
  font-size: 0.8rem;
  font-weight: 700;
}
.rank-list li.top1 .pos { background: #ffd54a; color: #4a3b00; }
.rank-list li.top2 .pos { background: #cfd6dd; color: #303a45; }
.rank-list li.top3 .pos { background: #e8b07a; color: #4a2c07; }
.rank-list .name { flex: 1; }
.rank-list .val { font-weight: 700; }
.rank-list .unit { color: var(--hint); font-weight: 400; font-size: 0.8rem; margin-left: 2px; }

.rank-list:empty::after {
  content: attr(data-empty);
  color: var(--hint);
  font-size: 0.85rem;
}

.empty { text-align: center; color: var(--hint); margin-top: 40px; }
.hidden { display: none !important; }
code {
  background: var(--secondary-bg);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 0.9em;
}
