/* ================= ВЕКТОР × Что по дрифту ================= */
:root {
  --red: #e10600;
  --red-2: #ff2b30;
  --red-soft: rgba(225, 6, 0, .16);
  --bg: #0a0a0c;
  --bg-2: #111114;
  --glass: rgba(255, 255, 255, .045);
  --glass-strong: rgba(255, 255, 255, .07);
  --line: rgba(255, 255, 255, .09);
  --txt: #f4f4f6;
  --muted: #9a9aa6;
  --radius: 20px;
  --shadow: 0 20px 60px rgba(0, 0, 0, .55);
  --red-glow: 0 10px 40px rgba(225, 6, 0, .38);
  --font: 'Manrope', 'Inter', -apple-system, 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--txt);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* фон: мягкие красные пятна + верхняя виньетка */
.bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(60% 40% at 80% -5%, rgba(225, 6, 0, .22), transparent 60%),
    radial-gradient(50% 45% at -5% 100%, rgba(225, 6, 0, .12), transparent 55%),
    linear-gradient(180deg, #0d0d10, #08080a 60%);
}
.bg::after {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, .022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .022) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(circle at 50% 30%, #000, transparent 80%);
}

.app { position: relative; z-index: 1; min-height: 100%; display: flex; flex-direction: column; }
/* Контейнер широкий — это нужно экрану выбора пилота (#s2), чтобы на ПК
   в ряд помещалось больше карточек. Остальные экраны сами держат узкую колонку (см. ниже). */
.container { width: 100%; max-width: 940px; margin: 0 auto; flex: 1; display: flex; flex-direction: column;
  padding: calc(22px + env(safe-area-inset-top)) calc(18px + env(safe-area-inset-right))
           calc(40px + env(safe-area-inset-bottom)) calc(18px + env(safe-area-inset-left)); }
/* узкие экраны: приветствие, форма и финальные — читаемая колонка по центру */
#s1, #s3, #sDone, #sVoted, #sClosed { width: 100%; max-width: 560px; margin-left: auto; margin-right: auto; }

/* ---------- ЛОГОТИП ---------- */
.logo { display: inline-flex; align-items: center; gap: 12px; user-select: none; }
.logo svg { display: block; }
.logo .lock { display: flex; flex-direction: column; line-height: 1; }
.logo .name { font-weight: 800; letter-spacing: 3px; font-size: 22px; color: #fff; white-space: nowrap; }
.logo .sub { font-size: 9px; font-weight: 800; letter-spacing: 1.4px; color: #ec1c17; margin-top: 5px; text-transform: uppercase; white-space: nowrap; }
/* компактный чёткий логотип в шапках/админке */
.logo-vec { gap: 9px; }
.logo-vec .name { font-weight: 800; color: #fff; line-height: 1; }
.logo-vec svg { flex: 0 0 auto; }

/* ---------- ЭКРАНЫ ---------- */
.screen { display: none; flex: 1; flex-direction: column; animation: in .45s cubic-bezier(.2, .7, .2, 1); }
.screen.active { display: flex; }
@keyframes in { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: none; } }

.badge {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 7px;
  font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: #ffb3b0;
  background: var(--red-soft); border: 1px solid rgba(225, 6, 0, .3);
  padding: 7px 14px; border-radius: 999px; margin-bottom: 16px;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); box-shadow: 0 0 10px var(--red); }

h1 { font-size: clamp(28px, 8vw, 40px); line-height: 1.08; font-weight: 800; letter-spacing: -.5px; }
h1 .accent { color: var(--red); }
.lead { color: var(--muted); font-size: 16px; line-height: 1.6; margin-top: 14px; }

/* ---------- КНОПКИ ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; cursor: pointer; border: none; font-family: var(--font);
  font-size: 17px; font-weight: 800; letter-spacing: .3px; color: #fff;
  padding: 18px 24px; border-radius: 16px;
  background: linear-gradient(135deg, var(--red), var(--red-2));
  box-shadow: var(--red-glow); transition: transform .14s ease, box-shadow .2s, filter .2s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(.975); }
.btn .arr { transition: transform .2s; }
.btn:hover .arr { transform: translateX(4px); }
.btn.ghost {
  background: var(--glass); color: var(--txt); border: 1px solid var(--line); box-shadow: none;
}
.btn.ghost:hover { border-color: var(--red); color: #ffb3b0; }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: grayscale(.4); }

/* убираем жёлтую системную обводку фокуса на кнопках/вкладках */
button:focus, button:focus-visible, a:focus, a:focus-visible { outline: none; }

/* ---------- ЭКРАН 1: ПРИВЕТСТВИЕ ---------- */
#s1 { justify-content: center; align-items: center; text-align: center; gap: 8px; padding: 30px 4px; }
#s1 .badge { align-self: center; }
.cobrand { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-bottom: 24px; animation: pop .6s cubic-bezier(.2, .7, .2, 1); }
.cobrand .hero-logo { margin: 0; }
.cobrand .x { font-size: 22px; font-weight: 800; color: var(--muted); line-height: 1; margin: 2px 0; }
.cobrand .drift img { display: block; }
.cobrand .drift .drift-fallback { font-weight: 800; letter-spacing: 3px; color: #79d2e6; font-size: 16px; }
#s1 h1 { margin-top: 6px; }
#s1 .lead { max-width: 420px; }
#s1 .btn { max-width: 380px; margin-top: 34px; padding: 20px; font-size: 18px; }
.counter { margin-top: 20px; font-size: 13px; color: var(--muted); }
.counter b { color: var(--txt); }

/* ---------- ШАПКА (экраны 2-3) ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.topbar .logo .name { font-size: 18px; letter-spacing: 4px; }
.topbar .back { background: var(--glass); border: 1px solid var(--line); color: var(--muted);
  width: 42px; height: 42px; border-radius: 12px; cursor: pointer; font-size: 18px; }
.topbar .back:hover { color: var(--txt); border-color: var(--red); }

/* ---------- ЭКРАН 2: КАРТОЧКИ ---------- */
/* Адаптивная сетка: телефон — 2 колонки, ПК — до 5. Иначе 23 пилота = бесконечная прокрутка. */
.cars { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 14px; margin-top: 18px; }
.car {
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; backdrop-filter: blur(10px); transition: transform .18s, border-color .2s, box-shadow .2s;
  display: flex; flex-direction: column;
}
.car:active { transform: scale(.99); }
.car.picked { border-color: var(--red); box-shadow: var(--red-glow); }
.car .ph {
  position: relative; aspect-ratio: 5 / 4; background: linear-gradient(135deg, #16161b, #0d0d11);
  display: flex; align-items: center; justify-content: center; border-bottom: 1px solid var(--line);
}
.car .ph img { width: 100%; height: 100%; object-fit: cover; }
.car .ph .noimg { color: #3a3a44; font-size: 40px; }
.car .num {
  position: absolute; top: 10px; left: 10px; min-width: 40px; height: 34px; padding: 0 10px;
  border-radius: 10px; background: rgba(0, 0, 0, .55); border: 1px solid var(--red);
  color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: 15px;
  backdrop-filter: blur(4px);
}
.car .info { padding: 14px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.car .owner { font-weight: 700; font-size: 16.5px; line-height: 1.25; }
.car .cap { font-size: 12px; color: var(--muted); margin-top: -6px; }
.car .bar { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .07); overflow: hidden; }
.car .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--red), var(--red-2)); transition: width .6s; }
.car .stat { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }
.car .vote {
  margin-top: auto; padding: 13px; border-radius: 13px; border: 1px solid rgba(225, 6, 0, .35);
  background: var(--red-soft); color: #ffb3b0; font-weight: 800; cursor: pointer; font-family: var(--font);
  font-size: 15px; transition: .18s;
}
.car .vote:hover { background: rgba(225, 6, 0, .28); }
.car.picked .vote { background: var(--red); color: #fff; border-color: var(--red); }

/* нижняя панель подтверждения */
.confirm {
  position: sticky; bottom: calc(14px + env(safe-area-inset-bottom)); margin-top: 22px;
  background: rgba(18, 18, 22, .82); border: 1px solid var(--red); border-radius: 18px;
  padding: 14px 16px; display: none; align-items: center; gap: 12px; justify-content: space-between;
  box-shadow: var(--shadow); backdrop-filter: blur(14px); animation: pop .3s;
}
.confirm.show { display: flex; }
.confirm .t { font-size: 14px; }
.confirm .t b { color: var(--red-2); }
.confirm .go { flex: 0 0 auto; width: auto; padding: 12px 20px; font-size: 15px; }

/* ---------- ЭКРАН 3: ФОРМА ---------- */
.form { margin-top: 26px; background: var(--glass); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px 20px; backdrop-filter: blur(10px); }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 12px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.field input {
  width: 100%; padding: 16px; border-radius: 14px; border: 1px solid var(--line);
  background: #0c0c10; color: var(--txt); font-size: 17px; font-family: var(--font); transition: .2s;
}
.field input:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.field.err input { border-color: var(--red-2); }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 7px; }
.field.err .hint { color: var(--red-2); }
.chosen { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); margin-bottom: 18px; }
.chosen b { color: var(--txt); }
.privacy { font-size: 11px; color: #6a6a75; margin-top: 14px; text-align: center; line-height: 1.5; }

/* ---------- ФИНАЛ / СТАТУСЫ ---------- */
.final { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; padding: 30px; }
.final .ico { font-size: 66px; animation: pop .5s cubic-bezier(.2, .7, .2, 1); }
.final h1 { color: var(--red); }
.final .lead { max-width: 360px; }
.final .btn { max-width: 320px; margin-top: 26px; }

footer { text-align: center; color: #55555f; font-size: 12px; padding: 18px; }
footer b { color: var(--muted); }

.loading { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--muted); padding: 30px; }

/* ===================== ПОЛИРОВКА / «КОНФЕТКА» ===================== */

/* индикатор шагов */
.steps { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.steps .step { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 700; white-space: nowrap; }
.steps .step b { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px;
  background: var(--glass); border: 1px solid var(--line); color: var(--muted); transition: .3s; }
.steps .step.active { color: var(--txt); }
.steps .step.active b { background: linear-gradient(135deg, var(--red), var(--red-2)); border-color: transparent; color: #fff; box-shadow: 0 4px 16px rgba(225, 6, 0, .45); }
.steps .step.done { color: var(--txt); }
.steps .step.done b { background: rgba(225, 6, 0, .18); border-color: rgba(225, 6, 0, .5); color: #ff8f8c; }
.steps .dash { flex: 1; height: 2px; border-radius: 2px; background: var(--line); }
.steps .dash.done { background: linear-gradient(90deg, var(--red), rgba(225, 6, 0, .2)); }
@media (max-width: 360px) { .steps .step span { display: none; } .steps { gap: 8px; } }

/* красивая заглушка логотипа «Что по дрифту», пока нет файла */
.cobrand .drift .drift-fallback {
  display: inline-block; font-weight: 800; font-size: 15px; letter-spacing: 1px;
  background: linear-gradient(135deg, #57e0f0, #b06ab3); -webkit-background-clip: text; background-clip: text; color: transparent;
  padding: 6px 14px; border: 1px solid rgba(120, 200, 230, .28); border-radius: 12px;
}

/* карточка-лидер */
.car { position: relative; }
.car.leader { border-color: rgba(255, 205, 60, .5); box-shadow: 0 12px 40px rgba(255, 185, 40, .16); }
/* медаль — чипом в карточке, а НЕ поверх таблички: табличка занимает всю ширину
   и любая наклейка сверху перекрывала номер пилота */
.car .ribbon { align-self: flex-start; display: inline-flex; align-items: center;
  background: linear-gradient(135deg, #ffd23f, #ff9d00); color: #241a00; font-weight: 800; font-size: 11px;
  padding: 4px 9px; border-radius: 999px; box-shadow: 0 3px 10px rgba(255, 170, 0, .35); white-space: nowrap; }
/* выбранная карточка важнее лидера по рамке */
.car.picked { border-color: var(--red); box-shadow: var(--red-glow); }

/* вспышка при выборе */
@keyframes flash { 0% { box-shadow: 0 0 0 0 rgba(225, 6, 0, .55); } 100% { box-shadow: 0 0 0 18px rgba(225, 6, 0, 0); } }
.car.flash { animation: flash .6s ease-out; }

/* мягкий подъём карточек и кнопок на устройствах с мышью */
@media (hover: hover) {
  .car:hover { transform: translateY(-3px); border-color: rgba(225, 6, 0, .35); }
  .car.leader:hover { border-color: rgba(255, 205, 60, .7); }
  .vote:hover { transform: translateY(-1px); }
}

/* блик на главных кнопках */
.btn { position: relative; overflow: hidden; }
.btn::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, .16), transparent 46%); }
.btn.ghost::after { display: none; }

/* финальный экран: выбранное авто + конфетти */
#sDone { position: relative; }
.donecar { display: inline-block; font-size: 15px; color: var(--txt); background: var(--glass);
  border: 1px solid var(--line); padding: 9px 18px; border-radius: 999px; margin-top: 4px; }
.donecar b { color: var(--red-2); }
.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 3; }
/* внешний элемент — падение с боковым дрейфом; внутренний — трепет/переворот бумажки */
.confetti i { position: absolute; top: -30px; will-change: transform;
  animation-name: cfall; animation-timing-function: cubic-bezier(.18, .5, .5, 1); animation-fill-mode: forwards; }
.confetti i b { display: block; will-change: transform;
  animation-name: cflutter; animation-iteration-count: infinite; animation-direction: alternate; animation-timing-function: ease-in-out; }
@keyframes cfall { to { transform: translate3d(var(--dx, 0), 116vh, 0); } }
@keyframes cflutter { from { transform: rotate3d(1, .7, 0, -30deg); } to { transform: rotate3d(1, .7, .3, 250deg); } }

/* ===================== ПРЕМИУМ-АПГРЕЙД ===================== */

/* «живой» пульс индикатора голосования */
.badge.live .dot { animation: livepulse 1.6s ease-in-out infinite; }
@keyframes livepulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(225, 6, 0, .6); } 50% { box-shadow: 0 0 0 6px rgba(225, 6, 0, 0); } }

/* чипы доверия на главной */
.trust { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.trust .chip { font-size: 12.5px; font-weight: 700; color: #cfd2da; background: var(--glass);
  border: 1px solid var(--line); padding: 8px 13px; border-radius: 999px; white-space: nowrap; }

/* привлекающий пульс главной кнопки */
.btn.cta { animation: ctaGlow 2.6s ease-in-out infinite; }
@keyframes ctaGlow { 0%, 100% { box-shadow: 0 10px 40px rgba(225, 6, 0, .38); } 50% { box-shadow: 0 14px 54px rgba(225, 6, 0, .62); } }

/* счётчик — заметнее */
.counter b { color: #fff; font-size: 17px; }

/* скелетоны загрузки */
.car.skeleton { pointer-events: none; }
.car.skeleton .ph::before { display: none; }
.sk { display: block; border-radius: 8px; background: linear-gradient(90deg, #17171d 25%, #22222c 50%, #17171d 75%);
  background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
.sk-title { height: 16px; width: 62%; }
.sk-sub { height: 11px; width: 40%; }
.sk-bar { height: 6px; width: 100%; }
.sk-btn { height: 42px; width: 100%; margin-top: 4px; border-radius: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* медали топ-3 (серебро/бронза; золото — базовый .ribbon) */
.car .ribbon.r2 { background: linear-gradient(135deg, #eef1f7, #a9b3c6); color: #20242e; box-shadow: 0 4px 14px rgba(180, 190, 210, .45); }
.car .ribbon.r3 { background: linear-gradient(135deg, #f0a978, #c9743c); color: #241407; box-shadow: 0 4px 14px rgba(200, 120, 60, .45); }

/* клетчатый акцент на фото-заглушке — фоном .ph (номер/лента остаются в углах) */
.car .ph {
  background:
    linear-gradient(135deg, rgba(255,255,255,.02) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.02) 50%, rgba(255,255,255,.02) 75%, transparent 75%) 0 0 / 20px 20px,
    linear-gradient(135deg, #16161b, #0d0d11);
}
.car .ph .noimg { font-size: 46px; filter: drop-shadow(0 8px 16px rgba(0, 0, 0, .5)); color: #454552; }

/* мягкая живая подсветка фона */
.bg::before { content: ""; position: absolute; inset: -20%; pointer-events: none;
  background: radial-gradient(38% 30% at 28% 22%, rgba(225, 6, 0, .10), transparent 62%);
  animation: aurora 15s ease-in-out infinite alternate; }
@keyframes aurora { from { transform: translate(0, 0); opacity: .75; } to { transform: translate(12%, 8%); opacity: 1; } }

/* ---------- НОМЕРНАЯ ТАБЛИЧКА ПИЛОТА (когда фото нет) ---------- */
/* Стиль афиши «Что по дрифту»: скошенная плашка, неоновый номер, бирюза/фиолет через карточку. */
.car .plate {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; overflow: hidden;
}
.car .plate.cy { --pl: #4ad5e6; --pl-soft: rgba(74, 213, 230, .42); }
.car .plate.vi { --pl: #a06fe0; --pl-soft: rgba(160, 111, 224, .42); }

/* свечение под табличкой + косые «трековые» полосы */
.car .plate::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(58% 62% at 50% 50%, var(--pl-soft), transparent 72%);
  opacity: .5;
}
.car .plate::after {
  content: ""; position: absolute; inset: 0; opacity: .6;
  background: repeating-linear-gradient(115deg, transparent 0 20px, rgba(255, 255, 255, .022) 20px 23px);
}
.car .plate-in {
  position: relative; transform: skewX(-11deg); padding: 12px 30px; border-radius: 14px;
  background: linear-gradient(165deg, #14151c, #090a0d);
  border: 2.5px solid var(--pl);
  box-shadow: 0 0 24px var(--pl-soft), inset 0 1px 0 rgba(255, 255, 255, .14), inset 0 0 20px rgba(0, 0, 0, .7);
}
.car .plate-n {
  display: block; transform: skewX(11deg);
  font-size: clamp(48px, 15vw, 76px); font-weight: 900; font-style: italic; line-height: 1.02;
  letter-spacing: 1px; padding-right: 2px;
  color: #fff; /* фолбэк: на старых телефонах без background-clip цифра остаётся белой, а не пропадает */
  filter: drop-shadow(0 0 14px var(--pl-soft));
}
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .car .plate-n {
    background: linear-gradient(180deg, #fff 18%, var(--pl) 92%);
    -webkit-background-clip: text; background-clip: text; color: transparent;
  }
}
.car .plate-cap {
  position: relative; font-size: 11px; font-weight: 800; letter-spacing: 5px;
  text-transform: uppercase; color: var(--pl); opacity: .85;
}
/* выбранная карточка — табличка оживает */
.car.picked .plate-in { box-shadow: 0 0 34px var(--pl-soft), inset 0 1px 0 rgba(255, 255, 255, .18), inset 0 0 20px rgba(0, 0, 0, .7); }

/* уважаем настройку «уменьшить движение» */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
