/* ==========================================================================
   PitWall Mini App — гоночная стилистика, авто-тема Telegram
   Переменные --tg-* приходят из Telegram.WebApp.themeParams (см. app.js).
   Значения по умолчанию — тёмная тема.
   ========================================================================== */

:root {
    /* Telegram theme params (fallback — тёмная тема) */
    --tg-bg: #0d1117;
    --tg-secondary-bg: #161b22;
    --tg-text: #e6edf3;
    --tg-hint: #8b949e;
    --tg-link: #58a6ff;
    --tg-button: #e10600;
    --tg-button-text: #ffffff;
    --tg-accent: #e10600;

    /* Производные */
    --surface: var(--tg-secondary-bg);
    --surface-2: color-mix(in srgb, var(--tg-secondary-bg) 70%, var(--tg-bg));
    --border: color-mix(in srgb, var(--tg-hint) 28%, transparent);
    --accent: var(--tg-accent);
    --accent-soft: color-mix(in srgb, var(--tg-accent) 18%, transparent);
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    background: var(--tg-bg);
    color: var(--tg-text);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.45;
    overscroll-behavior-y: none;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    max-width: 640px;
    margin: 0 auto;
    position: relative;
}

/* ------------------------------- Шапка ---------------------------------- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px 10px;
    position: sticky;
    top: 0;
    z-index: 20;
    background: color-mix(in srgb, var(--tg-bg) 88%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
}

.topbar__brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    letter-spacing: 0.4px;
    font-size: 17px;
}

.topbar__logo {
    font-size: 20px;
    filter: drop-shadow(0 0 8px var(--accent-soft));
}

.topbar__title {
    background: linear-gradient(92deg, var(--tg-text), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.topbar__user {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    min-width: 0;
}

.topbar__name {
    font-weight: 600;
    font-size: 14px;
    max-width: 46vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar__tz {
    font-size: 11px;
    color: var(--tg-hint);
}

/* ------------------------------ Контент --------------------------------- */

.content {
    flex: 1;
    padding: 14px 16px calc(84px + var(--safe-bottom));
}

.tab-panel {
    display: none;
}

.tab-panel.is-active {
    display: block;
    /* Плавное переключение вкладок */
    animation: tab-in 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes tab-in {
    from { opacity: 0; transform: translateY(8px) scale(0.995); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* --------------------------- Карточка сессии ---------------------------- */

.hero-card {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius);
    padding: 18px 18px 16px;
    background:
        radial-gradient(120% 140% at 100% 0%, var(--accent-soft) 0%, transparent 58%),
        linear-gradient(160deg, var(--surface) 0%, var(--surface-2) 100%);
    border: 1px solid var(--border);
    /* Верхняя цветовая полоса серии + мягкая тень */
    box-shadow: var(--shadow), inset 0 2px 0 var(--series-color, var(--accent));
}

/* Тонкая гоночная сетка-телеметрия поверх карточки */
.hero-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(to right, color-mix(in srgb, var(--tg-text) 5%, transparent) 1px, transparent 1px),
        linear-gradient(to bottom, color-mix(in srgb, var(--tg-text) 5%, transparent) 1px, transparent 1px);
    background-size: 26px 26px;
    mask-image: radial-gradient(120% 100% at 0% 0%, #000 0%, transparent 72%);
    -webkit-mask-image: radial-gradient(120% 100% at 0% 0%, #000 0%, transparent 72%);
    pointer-events: none;
}

/* Диагональные «гоночные» полосы */
.hero-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: repeating-linear-gradient(
        115deg,
        transparent 0 22px,
        color-mix(in srgb, var(--tg-text) 4%, transparent) 22px 24px
    );
    pointer-events: none;
}

.hero-card__label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    color: var(--tg-hint);
    font-weight: 700;
}

.hero-card__series {
    margin-top: 6px;
    font-size: 12px;
    font-weight: 700;
    color: var(--series-color, var(--accent));
    letter-spacing: 0.6px;
    position: relative;
    z-index: 1;
}

.hero-card__title {
    margin-top: 4px;
    font-size: 19px;
    font-weight: 800;
    line-height: 1.25;
    position: relative;
    z-index: 1;
}

.hero-card__time {
    margin-top: 4px;
    font-size: 13px;
    color: var(--tg-hint);
    position: relative;
    z-index: 1;
}

.countdown {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 4px;
    margin-top: 16px;
    position: relative;
    z-index: 1;
}

.countdown__cell {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 9px 4px;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--tg-bg) 55%, transparent);
    border: 1px solid var(--border);
}

.countdown__num {
    font-variant-numeric: tabular-nums;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: var(--tg-text);
}

.countdown__cap {
    font-size: 9.5px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--tg-hint);
}

.countdown__sep {
    align-self: center;
    font-size: 20px;
    font-weight: 800;
    color: var(--tg-hint);
    opacity: 0.6;
    padding-bottom: 14px;
}

/* ------------------------------- Кнопки --------------------------------- */

.btn {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 13px 16px;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.12s ease, opacity 0.15s ease, background-color 0.15s ease;
    color: var(--tg-text);
    background: var(--surface);
}

.btn:active {
    transform: scale(0.975);
}

.btn--wide {
    width: 100%;
    margin-top: 12px;
}

.btn--primary {
    background: var(--tg-button);
    color: var(--tg-button-text);
    box-shadow: 0 6px 18px color-mix(in srgb, var(--tg-button) 35%, transparent);
}

.btn--primary:disabled {
    opacity: 0.45;
    box-shadow: none;
    cursor: not-allowed;
}

.btn--ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--tg-text);
}

.btn--ghost:active {
    background: var(--surface);
}

/* --------------------------- Заголовки секций --------------------------- */

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin: 22px 2px 10px;
}

.section-head__title {
    margin: 0;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.3px;
}

.section-head__hint {
    font-size: 11.5px;
    color: var(--tg-hint);
}

.badge {
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--tg-hint);
    white-space: nowrap;
}

.badge--open {
    color: #2ecc71;
    border-color: color-mix(in srgb, #2ecc71 45%, transparent);
    background: color-mix(in srgb, #2ecc71 14%, transparent);
}

.badge--closed {
    color: #ff6b6b;
    border-color: color-mix(in srgb, #ff6b6b 45%, transparent);
    background: color-mix(in srgb, #ff6b6b 14%, transparent);
}

/* ---------------------------- Список заездов ---------------------------- */

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

.event-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px 12px 16px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    overflow: hidden;
}

/* Цветовой индикатор серии слева (гоночная телеметрия) */
.event-row::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--series-color, var(--accent));
    box-shadow: 0 0 10px var(--series-color, var(--accent));
}

.event-row__series {
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 800;
    padding: 4px 8px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--series-color, var(--accent)) 16%, transparent);
    color: var(--series-color, var(--accent));
    border: 1px solid color-mix(in srgb, var(--series-color, var(--accent)) 38%, transparent);
    white-space: nowrap;
}

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

.event-row__title {
    font-size: 13.5px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.event-row__time {
    font-size: 11.5px;
    color: var(--tg-hint);
    margin-top: 2px;
}

.event-row__left {
    flex: 0 0 auto;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--tg-hint);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/* --------------------- Лента чипов-фильтров серий ----------------------- */

.chip-strip {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    padding: 2px 2px 8px;
    margin: 0 -2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.chip-strip::-webkit-scrollbar {
    display: none;
}

.chip {
    flex: 0 0 auto;
    appearance: none;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--tg-hint);
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.2px;
    padding: 7px 13px;
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.chip:active {
    transform: scale(0.96);
}

.chip.is-active {
    color: #fff;
    background: var(--chip-color, var(--accent));
    border-color: var(--chip-color, var(--accent));
    box-shadow: 0 4px 14px color-mix(in srgb, var(--chip-color, var(--accent)) 40%, transparent);
}

/* ------------------------------ Прогноз --------------------------------- */

.gp-card {
    padding: 14px 16px;
    border-radius: var(--radius);
    background: linear-gradient(150deg, var(--surface) 0%, var(--surface-2) 100%);
    border: 1px solid var(--border);
}

.gp-card__name {
    font-size: 16px;
    font-weight: 800;
}

.gp-card__deadline {
    margin-top: 4px;
    font-size: 12.5px;
    color: var(--tg-hint);
}

.segmented {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    padding: 4px;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
}

.segmented__btn {
    flex: 1;
    appearance: none;
    border: none;
    background: transparent;
    color: var(--tg-hint);
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    padding: 9px 6px;
    border-radius: 9px;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.segmented__btn.is-active {
    background: var(--accent);
    color: #fff;
}

.segmented__btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.podium {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 14px;
}

.podium__slot {
    padding: 12px 8px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1.5px solid var(--border);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.12s ease;
}

.podium__slot:active {
    transform: scale(0.97);
}

.podium__slot.is-active {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.podium__slot.is-filled .podium__value {
    color: var(--tg-text);
    font-weight: 700;
}

.podium__medal {
    font-size: 20px;
    line-height: 1;
}

.podium__label {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--tg-hint);
    margin-top: 4px;
}

.podium__value {
    margin-top: 3px;
    font-size: 12.5px;
    color: var(--tg-hint);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.driver-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 7px;
    margin-top: 14px;
}

.driver-chip {
    appearance: none;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--tg-text);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    padding: 10px 6px;
    border-radius: 10px;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.driver-chip:active {
    transform: scale(0.96);
}

.driver-chip.is-used {
    opacity: 0.35;
    pointer-events: none;
}

.driver-chip.is-picked {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
}

.actions {
    margin-top: 16px;
}

.notice {
    margin-top: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    border: 1px solid var(--border);
    background: var(--surface);
}

.notice--ok {
    color: #2ecc71;
    border-color: color-mix(in srgb, #2ecc71 45%, transparent);
    background: color-mix(in srgb, #2ecc71 12%, transparent);
}

.notice--err {
    color: #ff6b6b;
    border-color: color-mix(in srgb, #ff6b6b 45%, transparent);
    background: color-mix(in srgb, #ff6b6b 12%, transparent);
}

/* -------------------------- История прогнозов --------------------------- */

.history-list {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.hist-card {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
}

.hist-card__head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hist-card__title {
    flex: 1;
    min-width: 0;
    font-size: 13.5px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hist-card__type {
    flex: 0 0 auto;
    font-size: 10.5px;
    font-weight: 700;
    color: var(--tg-hint);
    padding: 2px 7px;
    border-radius: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.hist-card__points {
    flex: 0 0 auto;
    font-size: 14px;
    font-weight: 900;
    color: #2ecc71;
    font-variant-numeric: tabular-nums;
    min-width: 34px;
    text-align: right;
}

.hist-card__points--pending {
    color: var(--tg-hint);
}

.hist-card__actual {
    margin-top: 6px;
    font-size: 11.5px;
    color: var(--tg-hint);
    font-variant-numeric: tabular-nums;
}

.hist-card__actual--pending {
    font-style: italic;
    opacity: 0.8;
}

.hist-card__picks {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
}

.hist-slot {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12.5px;
}

.hist-slot__medal {
    flex: 0 0 auto;
    font-size: 13px;
}

.hist-slot__driver {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hit-badge {
    flex: 0 0 auto;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 999px;
    border: 1px solid var(--border);
    white-space: nowrap;
}

.hit-badge--exact {
    color: #2ecc71;
    border-color: color-mix(in srgb, #2ecc71 45%, transparent);
    background: color-mix(in srgb, #2ecc71 14%, transparent);
}

.hit-badge--podium {
    color: #f5a623;
    border-color: color-mix(in srgb, #f5a623 45%, transparent);
    background: color-mix(in srgb, #f5a623 14%, transparent);
}

.hit-badge--miss {
    color: #ff6b6b;
    border-color: color-mix(in srgb, #ff6b6b 40%, transparent);
    background: color-mix(in srgb, #ff6b6b 12%, transparent);
}

.hit-badge--pending {
    color: var(--tg-hint);
}

/* -------------------------------- Гараж --------------------------------- */

.garage-profile {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 14px 16px;
    border-radius: var(--radius);
    background: linear-gradient(150deg, var(--accent-soft), var(--surface));
    border: 1px solid color-mix(in srgb, var(--accent) 38%, transparent);
}

.garage-profile__avatar {
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    border-radius: 14px;
    background: color-mix(in srgb, var(--tg-bg) 55%, transparent);
    border: 1px solid var(--border);
}

.garage-profile__meta {
    min-width: 0;
}

.garage-profile__name {
    font-size: 16px;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.garage-profile__sub {
    font-size: 12px;
    color: var(--tg-hint);
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}

.garage-block {
    margin-top: 18px;
    padding: 14px 16px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
}

.garage-block__title {
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.2px;
}

.garage-block__hint {
    font-size: 11.5px;
    color: var(--tg-hint);
    margin-top: 2px;
}

.toggle-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 10px;
}

.toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 2px;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}

.toggle-row:last-child {
    border-bottom: none;
}

.toggle-row__dot {
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--series-color, var(--accent));
    box-shadow: 0 0 8px var(--series-color, var(--accent));
}

.toggle-row__label {
    flex: 1;
    min-width: 0;
    font-size: 13.5px;
    font-weight: 600;
}

/* Тумблер */
.switch {
    flex: 0 0 auto;
    position: relative;
    width: 46px;
    height: 27px;
    padding: 0;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    cursor: pointer;
    transition: background-color 0.18s ease, border-color 0.18s ease;
}

.switch__knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 21px;
    height: 21px;
    border-radius: 50%;
    background: var(--tg-hint);
    transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.18s ease;
}

.switch.is-on {
    background: color-mix(in srgb, var(--accent) 30%, transparent);
    border-color: var(--accent);
}

.switch.is-on .switch__knob {
    transform: translateX(19px);
    background: var(--accent);
}

.tz-select-wrap {
    margin-top: 10px;
}

.tz-select {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    color: var(--tg-text);
    background-color: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 11px;
    padding: 12px 38px 12px 14px;
    cursor: pointer;
    background-image: linear-gradient(45deg, transparent 50%, var(--tg-hint) 50%),
                      linear-gradient(135deg, var(--tg-hint) 50%, transparent 50%);
    background-position: calc(100% - 19px) 50%, calc(100% - 13px) 50%;
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
}

.tz-select:focus {
    outline: none;
    border-color: var(--accent);
}

/* -------------------------------- Toast --------------------------------- */

.toast-stack {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(84px + var(--safe-bottom));
    z-index: 80;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: calc(100% - 32px);
    max-width: 420px;
    pointer-events: none;
}

.toast {
    padding: 11px 15px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.24s ease, transform 0.24s ease;
}

.toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.toast--ok {
    color: #2ecc71;
    border-color: color-mix(in srgb, #2ecc71 45%, transparent);
    background: color-mix(in srgb, #2ecc71 14%, var(--surface));
}

.toast--err {
    color: #ff6b6b;
    border-color: color-mix(in srgb, #ff6b6b 45%, transparent);
    background: color-mix(in srgb, #ff6b6b 14%, var(--surface));
}

.toast--info {
    color: var(--tg-text);
}

/* -------------------------------- Лига ---------------------------------- */

.my-rank-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: var(--radius);
    background: linear-gradient(150deg, var(--accent-soft), var(--surface));
    border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
}

.my-rank-card__pos {
    font-size: 26px;
    font-weight: 900;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    min-width: 62px;
}

.my-rank-card__points {
    font-size: 15px;
    font-weight: 800;
}

.my-rank-card__hits {
    font-size: 12px;
    color: var(--tg-hint);
    margin-top: 2px;
}

.leaderboard {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 12px;
}

.lb-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
}

.lb-row.is-me {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.lb-row__rank {
    flex: 0 0 34px;
    font-size: 14px;
    font-weight: 800;
    color: var(--tg-hint);
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.lb-row__rank--medal {
    font-size: 18px;
}

.lb-row__name {
    flex: 1;
    min-width: 0;
    font-size: 13.5px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-row__points {
    flex: 0 0 auto;
    font-size: 13px;
    font-weight: 800;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

/* ------------------------------ Скелетоны ------------------------------- */

.skeleton-row {
    height: 46px;
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.3s infinite linear;
}

@keyframes shimmer {
    from { background-position: 200% 0; }
    to   { background-position: -200% 0; }
}

/* ---------------------------- Нижняя навигация -------------------------- */

.tabbar {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 0;
    width: 100%;
    max-width: 640px;
    display: flex;
    /* Компактные отступы + учёт системной полосы iOS (safe-area-inset-bottom) */
    padding: 6px 8px calc(6px + var(--safe-bottom));
    gap: 4px;
    background: color-mix(in srgb, var(--tg-bg) 92%, transparent);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    z-index: 30;
}

.tabbar__btn {
    flex: 1;
    min-width: 0;
    appearance: none;
    border: none;
    background: transparent;
    color: var(--tg-hint);
    font-family: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 2px;
    border-radius: 11px;
    cursor: pointer;
    transition: color 0.15s ease, background-color 0.15s ease, transform 0.12s ease;
}

.tabbar__btn:active {
    transform: scale(0.94);
}

.tabbar__btn.is-active {
    color: var(--accent);
    background: var(--accent-soft);
}

.tabbar__icon {
    font-size: 18px;
    line-height: 1;
}

.tabbar__text {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ------------------------------- Модалка -------------------------------- */

.modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.modal[hidden] {
    display: none;
}

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    animation: fade-in 0.18s ease;
}

.modal__sheet {
    position: relative;
    width: 100%;
    max-width: 640px;
    max-height: 72vh;
    display: flex;
    flex-direction: column;
    background: var(--tg-bg);
    border-radius: 20px 20px 0 0;
    border-top: 1px solid var(--border);
    padding-bottom: var(--safe-bottom);
    animation: slide-up 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes slide-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

.modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px 10px;
    border-bottom: 1px solid var(--border);
}

.modal__title {
    font-size: 15px;
    font-weight: 800;
}

.modal__close {
    appearance: none;
    border: none;
    background: var(--surface);
    color: var(--tg-text);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
}

.modal__list {
    overflow-y: auto;
    padding: 10px 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    -webkit-overflow-scrolling: touch;
}

.modal__item {
    appearance: none;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--tg-text);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    padding: 13px 15px;
    border-radius: 11px;
    cursor: pointer;
}

.modal__item:active {
    background: var(--accent-soft);
    border-color: var(--accent);
}

.modal__item.is-used {
    opacity: 0.35;
    pointer-events: none;
}

/* --------------------------- Публичный режим ---------------------------- */

.noscript {
    max-width: 640px;
    margin: 0 auto;
    padding: 24px 18px;
    color: var(--tg-text);
}

.noscript h1 {
    font-size: 20px;
    margin: 0 0 8px;
}

.noscript a {
    color: var(--tg-link);
}

.public-panel {
    animation: fade-in 0.26s ease;
}

.public-card {
    padding: 22px 18px;
    border-radius: var(--radius);
    background:
        radial-gradient(120% 140% at 100% 0%, var(--accent-soft) 0%, transparent 58%),
        linear-gradient(160deg, var(--surface) 0%, var(--surface-2) 100%);
    border: 1px solid var(--border);
    box-shadow: var(--shadow), inset 0 2px 0 var(--accent);
    text-align: center;
}

.public-card__logo {
    font-size: 40px;
    line-height: 1;
    filter: drop-shadow(0 0 12px var(--accent-soft));
}

.public-card__title {
    margin: 10px 0 8px;
    font-size: 20px;
    font-weight: 800;
    background: linear-gradient(92deg, var(--tg-text), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.public-card__text {
    margin: 0 0 6px;
    font-size: 13.5px;
    color: var(--tg-hint);
    line-height: 1.5;
}

/* В публичном режиме нижняя навигация и вкладки не нужны */
body.is-public .tabbar {
    display: none;
}

body.is-public .content {
    padding-bottom: 24px;
}

/* --------------------------- Адаптив / светлая -------------------------- */

@media (min-width: 480px) {
    .driver-grid { grid-template-columns: repeat(4, 1fr); }
    .countdown__num { font-size: 28px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
}
