/* Garaje del Saber — стили.
   Крупные элементы, высокий контраст, всё кликабельное не меньше 48px:
   игра рассчитана на ребёнка 7 лет и на пальцы, а не только на мышку. */

:root {
  --bg: #141a2b;
  --bg-soft: #1e2740;
  --card: #263150;
  --line: #38456b;
  --text: #eef2ff;
  --muted: #9aa8cc;
  --accent: #ffb020;
  --good: #2ecc71;
  --bad: #ff6b6b;
  --radius: 18px;
}

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

body {
  margin: 0;
  font-family: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #24325c 0%, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
  font-size: 17px;
  overscroll-behavior: none;
}

.screen { display: none; min-height: 100vh; flex-direction: column; }
.screen.active { display: flex; }
.hidden { display: none !important; }

/* ───────────────────────── Вход */
.login-box {
  margin: auto;
  width: min(440px, 92vw);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px 24px 24px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}
.logo { font-size: 54px; line-height: 1; }
.login-box h1 { margin: 8px 0 4px; font-size: 26px; }
.tagline { margin: 0 0 18px; color: var(--muted); font-size: 15px; }

/* Выбор языка */
.lang-picker { display: flex; gap: 8px; justify-content: center; margin-bottom: 20px; }
.lang-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 14px; border-radius: 999px; border: 2px solid var(--line);
  background: var(--bg-soft); color: var(--muted); font: inherit; font-size: 14px; cursor: pointer;
}
.lang-btn.active { border-color: var(--accent); color: var(--text); }
/* Флаг — свой SVG, а не эмодзи: на Windows флаги-эмодзи не рисуются как
   картинки, а показываются буквами страны (DE, JP...) — шрифт Segoe UI Emoji
   не содержит флагов. Свой SVG выглядит одинаково во всех системах. */
.lang-btn .fl { display: inline-block; width: 24px; height: 17px; border-radius: 3px; overflow: hidden; flex: none; }
.lang-btn .fl svg { width: 100%; height: 100%; display: block; }

.tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.tab {
  flex: 1; padding: 12px 8px; border-radius: 12px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); font: inherit; font-size: 14px; cursor: pointer;
}
.tab.active { background: var(--bg-soft); color: var(--text); border-color: var(--accent); }

.auth-form { display: none; flex-direction: column; gap: 10px; text-align: left; }
.auth-form.active { display: flex; }
.auth-form label { font-size: 14px; color: var(--muted); }
input[type="text"] {
  width: 100%; padding: 14px 16px; border-radius: 12px;
  border: 2px solid var(--line); background: var(--bg-soft); color: var(--text);
  font: inherit; font-size: 18px;
}
input[type="text"]:focus { outline: none; border-color: var(--accent); }

.btn-primary {
  padding: 15px 20px; border: none; border-radius: 14px;
  background: linear-gradient(180deg, #ffc247, var(--accent));
  color: #2a1c00; font: inherit; font-weight: 800; font-size: 18px;
  cursor: pointer; box-shadow: 0 6px 0 #c8850f;
}
.btn-primary:active { transform: translateY(3px); box-shadow: 0 3px 0 #c8850f; }

.btn-ghost {
  padding: 11px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); font: inherit; font-size: 15px; cursor: pointer;
}
.btn-ghost:active { background: var(--bg-soft); }

.error { color: var(--bad); min-height: 22px; margin: 12px 0 0; font-size: 15px; }

/* ───────────────────────── Верхняя панель */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(20, 26, 43, .92);
  backdrop-filter: blur(8px); z-index: 5;
}
.player { display: flex; align-items: center; gap: 10px; }
.avatar { font-size: 30px; }
.player-name { font-weight: 800; }
.player-sub { font-size: 13px; color: var(--muted); }
.coins {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-soft); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 999px; font-weight: 800;
}
/* Свой SVG вместо эмодзи 🪙 — см. пояснение у .lang-btn .fl про флаги:
   на Windows без свежих обновлений эмодзи-монеты в системном шрифте нет. */
.coin-ico { width: 1.1em; height: 1.1em; display: inline-block; vertical-align: -0.15em; flex: none; }

/* ───────────────────────── Вкладки гаража */
.tabbar { display: flex; gap: 8px; padding: 12px 16px 0; }
.tabbtn {
  flex: 1; padding: 12px 6px; border-radius: 12px 12px 0 0;
  border: 1px solid var(--line); border-bottom: none;
  background: transparent; color: var(--muted); font: inherit; font-size: 15px; cursor: pointer;
}
.tabbtn.active { background: var(--card); color: var(--text); }

.view { display: none; padding: 16px; flex: 1; }
.view.active { display: block; }
.hint { color: var(--muted); font-size: 14px; margin: 0 0 14px; }

/* ───────────────────────── Сетка гаража */
/* Вертикальные карточки — сетка похожа на альбом с коллекцией */
.garage-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(172px, 1fr));
}
/* Обёртка вокруг коллекционной карточки: сама рамка теперь у .cc-inner,
   поэтому здесь только раскладка, без второго фона и второй рамки. */
.car-card {
  background: none; border: none; padding: 0; border-radius: var(--radius);
  cursor: pointer; display: flex; flex-direction: column; gap: 8px;
}
.car-card .thumb { position: relative; background: var(--bg-soft); border-radius: 12px; padding: 6px; }
.car-card .thumb svg.car-svg { width: 100%; height: auto; display: block; }
.car-card.locked .thumb svg.car-svg { filter: brightness(.28) grayscale(1); }
.car-emblem-badge {
  position: absolute; top: 6px; right: 6px; width: 34px; height: 34px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.45));
}
.car-emblem-badge svg { width: 100%; height: 100%; display: block; }
.car-title { font-weight: 800; font-size: 16px; }
.car-meta { font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.rarity { color: var(--accent); letter-spacing: 1px; }
.paint-row { display: flex; gap: 6px; flex-wrap: wrap; }
.paint-dot {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid rgba(255,255,255,.25);
  cursor: pointer; padding: 0;
}

/* ───────────────────────── Награды */
.awards-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.award {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 12px; text-align: center;
}
.award.locked { opacity: .38; }
.award .ico { font-size: 32px; }
.award .t { font-weight: 800; font-size: 14px; margin-top: 6px; }
.award .d { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ───────────────────────── Книга знаний */
.book-list { display: flex; flex-direction: column; gap: 10px; }
.book-item {
  background: var(--card); border: 1px solid var(--line);
  border-left: 4px solid var(--accent); border-radius: 12px; padding: 12px 14px;
}
.book-item .bq { font-size: 13px; color: var(--muted); }
.book-item .bf { margin-top: 4px; }

/* ───────────────────────── Экран игры */
.game-wrap { padding: 18px 16px 32px; max-width: 720px; width: 100%; margin: 0 auto; }
#game-title { margin: 0 0 4px; font-size: 22px; }

.car-stage { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.car-art svg { width: 100%; height: auto; display: block; }
.panels {
  position: absolute; inset: 6px;
  display: grid; gap: 4px; grid-auto-rows: 1fr;
  z-index: 3;
}
.panel {
  background: linear-gradient(145deg, #3d4a75, #2c3757);
  border: 2px solid #4c5b8c; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; cursor: pointer; transition: transform .12s;
}
.panel:active { transform: scale(.95); }
.panel.open {
  opacity: 0;
  pointer-events: none;
  animation: panelOpen .45s cubic-bezier(.34, 1.56, .64, 1) forwards;
}
/* Только transform и opacity — эти свойства анимирует видеокарта,
   а не процессор, поэтому даже слабый компьютер не тормозит. */
@keyframes panelOpen {
  0%   { transform: scale(1) rotate(0deg); opacity: 1; }
  35%  { transform: scale(1.3) rotate(-8deg); opacity: 1; }
  100% { transform: scale(.15) rotate(20deg); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .panel.open { animation: none; transition: opacity .3s; }
}

.progress-row { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.progress { flex: 1; height: 14px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--good), var(--accent)); transition: width .4s; }

/* ───────────────────────── Модальные окна */
.modal {
  position: fixed; inset: 0; background: rgba(8, 12, 22, .82);
  display: none; align-items: center; justify-content: center; padding: 16px; z-index: 20;
}
.modal.show { display: flex; }
.modal-card {
  position: relative;
  background: var(--card); border: 1px solid var(--line); border-radius: 22px;
  padding: 22px; width: min(560px, 94vw); max-height: 92vh; overflow-y: auto;
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
/* Крестик, чтобы закрыть вопрос, если отвечать пока не хочется.
   Крупный (48px), в углу карточки — палец ребёнка попадёт легко. */
.q-close {
  position: absolute; top: 10px; right: 10px;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--muted);
  font-size: 20px; line-height: 1; cursor: pointer; z-index: 2;
  display: flex; align-items: center; justify-content: center;
}
.q-close:active { transform: scale(.9); }
.q-theme { display: inline-block; padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 800; margin-bottom: 10px; max-width: calc(100% - 52px); }
.modal-card h3 { margin: 0 0 16px; font-size: 21px; line-height: 1.35; }

/* Силуэт внутри окна угадывания: во время ответа машину должно быть видно,
   иначе модальное окно закрывает то, что нужно угадать. */
.q-silhouette { display: none; margin: 0 0 14px; }
.q-silhouette.show { display: block; }
.q-silhouette .cc-art {
  border-radius: 14px;
  aspect-ratio: 4 / 3;
  max-height: 34vh;
}
.q-silhouette .cc-inner {
  aspect-ratio: auto; padding: 0; border: none; background: none; box-shadow: none;
}
.q-silhouette .cc-top, .q-silhouette .cc-info { display: none; }

.q-options { display: flex; flex-direction: column; gap: 10px; }
.opt {
  padding: 15px 16px; border-radius: 14px; border: 2px solid var(--line);
  background: var(--bg-soft); color: var(--text); font: inherit; font-size: 17px;
  text-align: left; cursor: pointer;
}
.opt:active { transform: scale(.99); }
.opt.correct { border-color: var(--good); background: rgba(46, 204, 113, .18); }
.opt.wrong { border-color: var(--bad); background: rgba(255, 107, 107, .16); }
.opt.dim { opacity: .35; }
.opt:disabled { cursor: default; }

.q-input-form { display: none; gap: 10px; }
.q-input-form.show { display: flex; flex-direction: column; }

.q-feedback { margin-top: 14px; font-size: 16px; line-height: 1.45; min-height: 8px; }
.q-feedback .ok { color: var(--good); font-weight: 800; }
.q-feedback .no { color: var(--bad); font-weight: 800; }
/* Факт, который «переехал» сюда из попапа после закрытия — тот же вид,
   что был всегда: акцентная полоска слева, чуть более спокойный фон. */
.q-feedback .fact {
  display: block; margin-top: 8px; padding: 12px 14px;
  background: var(--bg-soft); border-left: 4px solid var(--accent); border-radius: 10px; font-size: 15px;
}
.modal-actions { display: flex; gap: 10px; justify-content: space-between; margin-top: 16px; align-items: center; }

/* ───────────────────────── Факт поверх ответа */
/* Отдельный слой над самим модальным окном (z-index больше, чем у .modal):
   факт должен быть виднее ответа, а не мелкой строкой под кнопками. */
.fact-popup {
  position: fixed; inset: 0; z-index: 30; padding: 20px;
  background: rgba(5, 8, 16, .55);
  display: none; align-items: center; justify-content: center;
}
.fact-popup.show { display: flex; }
.fact-popup-card {
  position: relative; cursor: default;
  width: min(480px, 100%);
  background: var(--card); border: 1px solid var(--accent); border-radius: 20px;
  padding: 26px 24px; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.55), 0 0 0 6px rgba(255,176,32,.08);
  animation: factPop .32s cubic-bezier(.34, 1.56, .64, 1) both;
}
.fact-popup-close {
  position: absolute; top: 8px; right: 8px;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--muted);
  font-size: 18px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.fact-popup-close:active { transform: scale(.9); }
.fact-popup-icon { font-size: 34px; margin-bottom: 10px; }
.fact-popup-text { margin: 0; font-size: 19px; line-height: 1.5; font-weight: 700; }
/* Слова проявляются по одному слева направо: только opacity/transform —
   раскладка не меняется ни на кадр, поэтому текст не «прыгает». */
.fact-popup-text .fw {
  display: inline-block; opacity: 0;
  animation: factWordIn .35s ease-out forwards;
}
@keyframes factPop {
  from { transform: scale(.85); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
@keyframes factWordIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .fact-popup-card { animation: none; }
  .fact-popup-text .fw { animation: none; opacity: 1; }
}

.reward-card { text-align: center; }
.reward-art-wrap { position: relative; width: 100%; max-width: 340px; margin: 0 auto 8px; }
.reward-art svg { width: 100%; height: auto; display: block; }
.reward-emblem {
  position: absolute; right: -8px; bottom: -8px; width: 64px; height: 64px;
  animation: emblemPop .5s cubic-bezier(.34, 1.56, .64, 1) both; animation-delay: .3s;
}
.reward-emblem svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 4px 10px rgba(0,0,0,.5)); }
@keyframes emblemPop {
  from { transform: scale(0) rotate(-25deg); opacity: 0; }
  to { transform: scale(1) rotate(0); opacity: 1; }
}
.reward-sub { color: var(--muted); margin: 0 0 10px; }
.reward-fact { background: var(--bg-soft); border-radius: 12px; padding: 12px 14px; font-size: 15px; margin-bottom: 16px; }

/* ───────────────────────── Всплывашки */
.toasts { position: fixed; left: 0; right: 0; bottom: 18px; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 40; pointer-events: none; }
.toast {
  background: var(--card); border: 1px solid var(--accent); border-radius: 999px;
  padding: 12px 20px; font-weight: 800; box-shadow: 0 10px 30px rgba(0,0,0,.5);
  animation: pop .3s ease-out; max-width: 90vw; text-align: center;
}
@keyframes pop { from { transform: translateY(14px) scale(.9); opacity: 0; } }

.bottombar { display: flex; gap: 10px; justify-content: center; padding: 16px; border-top: 1px solid var(--line); }

/* ═════════════════════════ Коллекционная карточка машины ═════════════════════════
   Оформлена как карточка из коллекционной игры: рамка по редкости, эмблема марки
   в углу, блок характеристик. Внутри — либо реалистичный рендер (assets/cars/*.webp),
   либо схематичный SVG, если рендера ещё нет. */

.car-collect-card {
  --rx: 0deg; --ry: 0deg;      /* наклон, задаётся из cards.js */
  --mx: 50%;  --my: 50%;       /* положение блика */
  position: relative;
  perspective: 900px;
  border-radius: 18px;
}

/* Внутренний слой — он и наклоняется. Внешний нужен для перспективы.
   Пропорции 5:7 — как у настоящих коллекционных карточек. Машина при этом
   не мельчает: окно с картинкой внутри остаётся широким (см. .cc-art). */
.cc-inner {
  position: relative;
  aspect-ratio: 5 / 7;
  display: flex; flex-direction: column;
  border-radius: 18px;
  padding: 10px;
  background:
    linear-gradient(160deg, rgba(255,255,255,.08), rgba(255,255,255,0) 42%),
    linear-gradient(180deg, #2c3859, #1d2540);
  border: 3px solid var(--line);
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
  overflow: hidden;
  transform: rotateX(var(--rx)) rotateY(var(--ry));
  transform-style: preserve-3d;
  transition: transform .35s ease, box-shadow .35s ease;
  will-change: transform;
}
.cc-interactive { cursor: pointer; }
.cc-interactive.is-tilting .cc-inner { transition: none; }

/* Цветное свечение под карточкой — «аура» редкости */
.cc-glow {
  position: absolute; inset: 6px; border-radius: 20px; z-index: 0;
  filter: blur(18px); opacity: 0; transition: opacity .35s ease;
  pointer-events: none;
}
.cc-interactive:hover .cc-glow,
.cc-interactive.is-tilting .cc-glow { opacity: .75; }

/* ── Обычная: спокойная серо-синяя рамка */
.rar-common .cc-inner { border-color: #6b7ba8; }
.rar-common .cc-glow { background: radial-gradient(circle, #6b7ba8, transparent 70%); }

/* ── Редкая: золотая рамка и тёплое свечение */
.rar-rare .cc-inner {
  border-color: var(--accent);
  box-shadow: 0 10px 30px rgba(0,0,0,.45), 0 0 22px rgba(255,176,32,.25);
}
.rar-rare .cc-glow { background: radial-gradient(circle, #ffb020, transparent 70%); }

/* ── Легендарная: радужная рамка, голограмма и пульсация */
.rar-legend .cc-inner {
  border-color: transparent;
  background:
    linear-gradient(180deg, #2c3859, #1d2540) padding-box,
    linear-gradient(120deg, #ff6b6b, #ffb020, #2ecc71, #4a90d9, #8e44ad, #ff6b6b) border-box;
  background-size: auto, 300% 300%;
  animation: rainbowEdge 6s linear infinite;
  box-shadow: 0 10px 34px rgba(0,0,0,.5), 0 0 26px rgba(142,68,173,.3);
}
.rar-legend .cc-glow {
  background: conic-gradient(from 0deg, #ff6b6b, #ffb020, #2ecc71, #4a90d9, #8e44ad, #ff6b6b);
  animation: glowSpin 8s linear infinite;
}
@keyframes rainbowEdge {
  0%   { background-position: 0 0, 0% 50%; }
  100% { background-position: 0 0, 300% 50%; }
}
@keyframes glowSpin { to { transform: rotate(360deg); } }

/* Голографическая плёнка поверх картинки — только у легендарных */
.rar-legend .cc-art::after {
  content: '';
  position: absolute; inset: 0; pointer-events: none; border-radius: 12px;
  background:
    repeating-linear-gradient(105deg,
      rgba(255,0,128,.10) 0%, rgba(255,213,0,.10) 12%, rgba(0,255,170,.10) 24%,
      rgba(0,153,255,.10) 36%, rgba(170,0,255,.10) 48%, rgba(255,0,128,.10) 60%);
  background-size: 220% 220%;
  background-position: var(--mx) var(--my);
  mix-blend-mode: color-dodge;
  opacity: .55;
}

.cc-top {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px; min-height: 20px; position: relative; z-index: 2;
}
.cc-rarity { color: var(--accent); font-size: 15px; letter-spacing: 2px; }
.rar-legend .cc-rarity {
  background: linear-gradient(90deg, #ffb020, #ff6b6b, #8e44ad, #4a90d9, #ffb020);
  background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: rainbowText 4s linear infinite;
}
@keyframes rainbowText { to { background-position: 300% 0; } }
.cc-number { font-size: 11px; color: var(--muted); font-weight: 700; }

/* Окно с машиной — горизонтальное внутри вертикальной карточки.
   Так автомобиль занимает всю ширину и не мельчает, а снизу остаётся
   место под название и полосы характеристик. */
.cc-art {
  position: relative;
  border-radius: 12px;
  background: #141a2b;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  transform-style: preserve-3d;
}

/* Фон-подложка: двигается медленнее машины, создаёт глубину */
.cc-bg {
  position: absolute; inset: -8%;
  background:
    radial-gradient(ellipse at 50% 80%, rgba(120,150,220,.35) 0%, transparent 60%),
    radial-gradient(circle at 50% 78%, #38456b 0%, #10151f 75%);
}
.rar-rare .cc-bg   { background: radial-gradient(ellipse at 50% 80%, rgba(255,176,32,.28) 0%, transparent 60%), radial-gradient(circle at 50% 78%, #3d3a56 0%, #14121c 75%); }
.rar-legend .cc-bg { background: radial-gradient(ellipse at 50% 80%, rgba(190,120,255,.32) 0%, transparent 60%), radial-gradient(circle at 50% 78%, #40305e 0%, #150f22 75%); }

.cc-photo-wrap {
  position: relative; z-index: 1;
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}
/* object-fit: cover, а не contain — рендеры приходят вертикальными,
   с широкими прозрачными полями сверху и снизу. Contain вписал бы всю
   картинку вместе с пустотой, и машина стала бы крошечной; cover обрезает
   поля и заполняет кадр самим автомобилем. */
.cc-photo {
  width: 100%; height: 100%; object-fit: cover; object-position: center 50%;
  display: block;
  filter: drop-shadow(0 10px 16px rgba(0,0,0,.55));
}
.cc-photo.is-missing { display: none; }


/* Разворот картинки: генераторы плохо слушаются указаний про сторону,
   поэтому любой ракурс приводится к общему виду прямо здесь.
   Ставится флагом flip: true у машины в COLLECTIONS. */
.is-flipped .cc-photo { transform: scaleX(-1); }

/* Запасной силуэт: показывается, только если рендера нет или он не загрузился */
.cc-fallback { display: none; width: 100%; padding: 4px; }
.cc-fallback.is-shown { display: block; }
.cc-fallback svg { width: 100%; height: auto; display: block; }

/* Блик, который следует за наклоном */
.cc-shine {
  position: absolute; inset: 0; z-index: 2; pointer-events: none; border-radius: 12px;
  background: radial-gradient(circle at var(--mx) var(--my),
    rgba(255,255,255,.28) 0%, rgba(255,255,255,.08) 22%, transparent 55%);
  opacity: 0; transition: opacity .3s ease;
}
.cc-interactive:hover .cc-shine,
.cc-interactive.is-tilting .cc-shine { opacity: 1; }

/* Искры у легендарных */
.cc-sparks { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.cc-sparks i {
  position: absolute; border-radius: 50%; background: #fff;
  box-shadow: 0 0 6px 1px rgba(255,255,255,.9);
  opacity: 0; animation: sparkle 3.2s ease-in-out infinite;
}
@keyframes sparkle {
  0%, 100%   { opacity: 0; transform: scale(.4); }
  8%, 16%    { opacity: 1; transform: scale(1); }
  30%        { opacity: 0; transform: scale(.5); }
}

.cc-layer { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.cc-emblem {
  position: absolute; top: 8px; right: 8px;
  width: 44px; height: 44px;
  filter: drop-shadow(0 3px 8px rgba(0,0,0,.7));
}
.cc-emblem svg { width: 100%; height: 100%; display: block; }

/* Нижняя часть карточки: растягивается на всю оставшуюся высоту,
   характеристики прижимаются к низу. */
.cc-info {
  padding: 10px 2px 2px; position: relative; z-index: 2;
  flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0;
}
.cc-name { font-weight: 900; font-size: 18px; line-height: 1.2; }
.cc-name-hidden { color: var(--muted); letter-spacing: 3px; }
.cc-sub { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
/* Свой SVG вместо флага-эмодзи — см. пояснение у .lang-btn .fl выше. */
.cc-flag { display: inline-block; width: 20px; height: 14px; border-radius: 2px; overflow: hidden; flex: none; vertical-align: -2px; }
.cc-flag svg { width: 100%; height: 100%; display: block; }
.cc-dot { opacity: .5; }
.rar-legend .cc-rar-label { color: #d9a7ff; font-weight: 800; }
.rar-rare   .cc-rar-label { color: var(--accent); font-weight: 800; }

/* Значки типа кузова и редкости */
.cc-badges { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 7px; }
.cc-badge {
  font-size: 10px; font-weight: 800; padding: 4px 9px; border-radius: 999px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12);
  letter-spacing: .2px; white-space: nowrap;
}
.rar-rare   .cc-badge-rar { background: rgba(255,176,32,.18); border-color: rgba(255,176,32,.5); color: var(--accent); }
.rar-legend .cc-badge-rar { background: rgba(190,120,255,.2); border-color: rgba(190,120,255,.55); color: #d9a7ff; }

/* ── Полосы характеристик: прижаты к низу карточки */
.cc-specs { margin-top: auto; padding-top: 10px; display: flex; flex-direction: column; gap: 7px; }
.cc-spec-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 3px; }
.cc-spec-l { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.cc-spec-v { font-weight: 900; font-size: 13px; }
.cc-spec-u { font-size: 9px; font-weight: 700; color: var(--muted); margin-left: 2px; }
.cc-bar {
  height: 7px; border-radius: 999px; overflow: hidden;
  background: rgba(0,0,0,.4); border: 1px solid rgba(255,255,255,.06);
}
.cc-bar-fill {
  display: block; height: 100%; width: var(--pct);
  border-radius: 999px;
  background: linear-gradient(90deg, #4a90d9, #2ecc71);
  animation: barGrow .9s cubic-bezier(.2,.8,.3,1) both;
}
.rar-rare   .cc-bar-fill { background: linear-gradient(90deg, #ffb020, #ff8a3d); }
.rar-legend .cc-bar-fill { background: linear-gradient(90deg, #8e44ad, #ff6b6b, #ffb020); }
@keyframes barGrow { from { width: 0; } to { width: var(--pct); } }

/* ── Компактный вариант для сетки гаража */
.is-compact .cc-inner { padding: 7px; border-width: 2px; border-radius: 14px; }
.is-compact .cc-emblem { width: 28px; height: 28px; top: 5px; right: 5px; }
.is-compact .cc-name { font-size: 13px; }
.is-compact .cc-sub { font-size: 10px; margin-top: 2px; }
.is-compact .cc-flag { width: 17px; height: 12px; }
.is-compact .cc-badges { margin-top: 5px; gap: 4px; }
.is-compact .cc-badge { font-size: 9px; padding: 3px 7px; }
.is-compact .cc-info { padding: 8px 1px 1px; }
.is-compact .cc-specs { padding-top: 8px; gap: 5px; }
.is-compact .cc-bar { height: 5px; }
.is-compact .cc-spec-v { font-size: 11px; }
.is-compact .cc-spec-l { font-size: 9px; }
.is-compact .cc-rarity { font-size: 12px; letter-spacing: 1px; }
.is-compact .cc-number { font-size: 9px; }

/* В самой узкой сетке полосы характеристик уже не читаются —
   оставляем только самую наглядную, мощность. */
@media (max-width: 380px) {
  .is-compact .cc-spec:nth-child(n + 2) { display: none; }
}

/* ── Неоткрытая машина в сетке гаража: просто затемнена */
.is-hidden-id:not(.is-silhouette) .cc-photo,
.is-hidden-id:not(.is-silhouette) .cc-fallback svg { filter: brightness(.3) grayscale(1); }

/* ═══════════════ Режим силуэта: «что это за машина?» ═══════════════
   Машина показана чёрной тенью на светящемся фоне. Форму видно —
   поэтому угадать можно, — а цвет и детали приходят только в момент разгадки. */
.is-silhouette .cc-photo,
.is-silhouette .cc-fallback svg {
  filter: brightness(0) contrast(2);
  transition: filter .9s ease;
}
.is-silhouette .cc-bg {
  background:
    radial-gradient(ellipse at 50% 60%, rgba(255,255,255,.55) 0%, rgba(150,190,255,.28) 35%, transparent 68%),
    radial-gradient(circle at 50% 70%, #2a3a63 0%, #0d1220 78%);
}
.is-silhouette .cc-art { background: #0d1220; }

/* Проявление: тень наливается цветом, по карточке проходит вспышка */
.cc-develop .cc-photo,
.cc-develop .cc-fallback svg {
  animation: developCar 1.1s cubic-bezier(.3, .7, .3, 1) both;
}
@keyframes developCar {
  0%   { filter: brightness(0) contrast(2); }
  35%  { filter: brightness(.25) contrast(1.6) saturate(.3); }
  70%  { filter: brightness(1.5) contrast(1.1) saturate(1.4); }
  100% { filter: none; }
}
.cc-develop .cc-art::after {
  content: '';
  position: absolute; inset: 0; z-index: 5; pointer-events: none;
  background: radial-gradient(circle at 50% 60%, rgba(255,255,255,.95), transparent 65%);
  animation: developFlash 1.1s ease-out both;
}
@keyframes developFlash {
  0%, 40% { opacity: 0; }
  58%     { opacity: .85; }
  100%    { opacity: 0; }
}
.cc-develop .cc-bg { animation: developBg 1.1s ease-out both; }
@keyframes developBg {
  0%   { transform: scale(1); }
  58%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* Карточка на экране игры: вертикальная карточка высокая, поэтому
   ограничиваем ширину, чтобы она целиком помещалась на экране вместе
   с прогрессом и не требовала прокрутки. */
.car-stage { max-width: 360px; margin: 0 auto; }
.car-stage .cc-inner { border-radius: 14px; }

/* ── Появление карточки в награде: переворот + пробег блика */
.reward-card .car-collect-card .cc-inner {
  animation: cardFlip .8s cubic-bezier(.2, .8, .3, 1) both;
}
@keyframes cardFlip {
  from { transform: rotateY(85deg) scale(.85); opacity: 0; }
  60%  { opacity: 1; }
  to   { transform: rotateY(0) scale(1); opacity: 1; }
}
.cc-sweep .cc-art::before {
  content: '';
  position: absolute; inset: 0; z-index: 4; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(255,255,255,.55) 50%, transparent 65%);
  background-size: 300% 100%;
  animation: sweepLight 1.1s ease-out 1 both;
}
@keyframes sweepLight {
  from { background-position: -150% 0; }
  to   { background-position: 250% 0; }
}

/* ── Полноэкранный просмотр карточки */
.card-viewer {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(6, 9, 18, .93);
  display: none; align-items: center; justify-content: center;
  padding: 20px;
}
.card-viewer.show { display: flex; animation: fadeIn .25s ease both; }
@keyframes fadeIn { from { opacity: 0; } }
/* Вертикальная карточка целиком помещается в экран телефона:
   ширину ограничиваем ещё и по высоте окна (5:7 → высота ≈ ширина × 1.4). */
.card-viewer-inner { width: min(380px, 90vw, 62vh); }
.card-viewer .car-collect-card { animation: viewerPop .45s cubic-bezier(.2,.9,.3,1) both; }
@keyframes viewerPop { from { transform: scale(.85); opacity: 0; } }
.card-viewer-close {
  position: absolute; top: 18px; right: 18px;
  width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  font-size: 22px; cursor: pointer; line-height: 1;
}
.card-viewer-hint { text-align: center; color: var(--muted); font-size: 13px; margin-top: 14px; }

/* Уважаем системную настройку «меньше анимации» */
@media (prefers-reduced-motion: reduce) {
  .cc-inner, .cc-glow, .cc-shine, .cc-sparks i,
  .rar-legend .cc-inner, .rar-legend .cc-glow, .cc-bar-fill { animation: none !important; transition: none !important; }
  .cc-bar-fill { width: var(--pct); }
}

@media (max-width: 420px) {
  body { font-size: 16px; }
  .modal-card h3 { font-size: 19px; }
  .lang-btn { padding: 9px 11px; font-size: 13px; }
  .cc-spec-v { font-size: 13px; }
  .cc-name { font-size: 16px; }
}
