@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --neon-blue: #00d4ff;
  --neon-purple: #bf00ff;
  --neon-orange: #ff6a00;
  --dark: #050508;
  --panel-bg: rgba(0, 0, 0, 0.75);
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--dark);
  font-family: 'Orbitron', monospace;
  color: #fff;
  user-select: none;
}

#canvas { position: fixed; inset: 0; z-index: 0; }

/* ── Car image stage ─────────────────────────────────────── */
#car-stage {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-bottom: 220px; /* leave room for selectors panel */
  pointer-events: none;
}

#car-make-label {
  font-size: 11px;
  letter-spacing: 5px;
  color: var(--neon-blue);
  text-shadow: 0 0 12px var(--neon-blue);
  margin-bottom: 12px;
  text-transform: uppercase;
  min-height: 18px;
}

#car-img,
#car-model {
  max-width: min(88vw, 480px);
  max-height: 38vh;
  width: min(88vw, 480px);
  height: min(38vh, 320px);
}

#car-img {
  object-fit: contain;
  filter: drop-shadow(0 0 24px rgba(0,212,255,0.5)) drop-shadow(0 8px 32px rgba(0,0,0,0.8));
  transition: opacity 0.28s ease;
}

#car-model {
  --poster-color: transparent;
  background: transparent;
  filter: drop-shadow(0 0 24px rgba(0,212,255,0.5)) drop-shadow(0 8px 32px rgba(0,0,0,0.8));
  pointer-events: all;
}

/* slide-out: кар уезжает влево */
#car-img.slide-out {
  animation: slideOut 0.28s ease forwards;
}
/* slide-in: новый кар въезжает справа */
#car-img.slide-in {
  animation: slideIn 0.42s ease forwards;
}

@keyframes slideOut {
  0%   { transform: translateX(0)    scale(1);    opacity: 1; }
  100% { transform: translateX(-60px) scale(0.92); opacity: 0; }
}
@keyframes slideIn {
  0%   { transform: translateX(60px) scale(0.92); opacity: 0; }
  100% { transform: translateX(0)    scale(1);    opacity: 1; }
}

/* ── HUD overlay ─────────────────────────────────────────── */
#hud {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column;
  justify-content: flex-end;
  pointer-events: none;
}

/* ── Selectors panel ─────────────────────────────────────── */
#selectors {
  pointer-events: all;
  background: var(--panel-bg);
  backdrop-filter: blur(8px);
  border-top: 1px solid rgba(0, 212, 255, 0.3);
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.selector-row {
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0.3;
  transition: opacity 0.3s;
}
.selector-row.active { opacity: 1; }

.selector-label {
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--neon-blue);
  text-transform: uppercase;
  min-width: 52px;
}

.carousel {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
}

.carousel-btn {
  background: none;
  border: 1px solid rgba(0, 212, 255, 0.4);
  color: var(--neon-blue);
  font-size: 16px;
  width: 32px; height: 32px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  display: flex; align-items: center; justify-content: center;
  font-family: inherit;
}
.carousel-btn:hover { background: rgba(0, 212, 255, 0.15); border-color: var(--neon-blue); }
.carousel-btn:disabled { opacity: 0.2; cursor: default; }

.carousel-value {
  flex: 1;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
  text-shadow: 0 0 8px var(--neon-blue);
}
.carousel-value.placeholder { color: rgba(255,255,255,0.3); font-weight: 400; }

/* ── Find button ─────────────────────────────────────────── */
#btn-find {
  pointer-events: all;
  background: linear-gradient(135deg, var(--neon-blue), var(--neon-purple));
  border: none;
  color: #fff;
  font-family: 'Orbitron', monospace;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 3px;
  padding: 14px;
  border-radius: 4px;
  cursor: pointer;
  text-transform: uppercase;
  transition: opacity 0.2s, transform 0.1s;
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.4);
}
#btn-find:disabled { opacity: 0.3; cursor: default; box-shadow: none; }
#btn-find:not(:disabled):active { transform: scale(0.97); }

/* ── Top controls ────────────────────────────────────────── */
#top-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  pointer-events: none;
}

#btn-mute,
#btn-settings {
  pointer-events: all;
  background: var(--panel-bg);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  height: 36px;
  border-radius: 4px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

#btn-mute {
  font-size: 18px;
  width: 36px;
  border-radius: 50%;
}

#btn-settings {
  min-width: 52px;
  max-width: 118px;
  padding: 0 10px;
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--neon-blue);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#onboarding {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0,0,0,0.9);
  backdrop-filter: blur(6px);
}
#onboarding.visible { display: flex; }

#onboarding-panel {
  width: min(100%, 360px);
  border: 1px solid rgba(0,212,255,0.55);
  background: rgba(5,5,20,0.96);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 0 36px rgba(0,212,255,0.22);
}

.onboarding-title {
  color: var(--neon-blue);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  text-align: center;
  text-transform: uppercase;
  margin-bottom: 16px;
  line-height: 1.35;
}

.choice-grid {
  display: grid;
  gap: 10px;
}

.choice-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(0,212,255,0.38);
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  min-height: 44px;
  padding: 12px;
  text-transform: uppercase;
}
.choice-btn:active { transform: scale(0.98); }

/* ── Result overlay ──────────────────────────────────────── */
#result-overlay {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(0,0,0,0.88);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(6px);
}
#result-overlay.visible { display: flex; }

#result-card {
  background: rgba(5,5,20,0.95);
  border: 1px solid var(--neon-blue);
  border-radius: 8px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 0 40px rgba(0, 212, 255, 0.2);
}

.result-pager {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.result-pager[hidden] { display: none; }
#res-count {
  color: rgba(255,255,255,0.55);
  font-family: 'Orbitron', monospace;
  font-size: 11px;
  letter-spacing: 1px;
  text-align: center;
  text-transform: uppercase;
}
.result-nav {
  width: 40px;
  height: 34px;
  border-radius: 4px;
  border: 1px solid rgba(0,212,255,0.45);
  background: rgba(0,212,255,0.08);
  color: var(--neon-blue);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}
.result-nav:disabled {
  border-color: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.22);
  cursor: default;
}

.result-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: -4px 0 12px;
}
.result-dots[hidden] { display: none; }
.result-dot {
  width: 24px;
  height: 4px;
  border: 0;
  border-radius: 999px;
  background: rgba(255,255,255,0.18);
  cursor: pointer;
  padding: 0;
}
.result-dot.active {
  background: var(--neon-blue);
  box-shadow: 0 0 10px rgba(0,212,255,0.65);
}

.result-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--neon-blue);
  margin-bottom: 16px;
  text-shadow: 0 0 8px var(--neon-blue);
  line-height: 1.4;
}

.result-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  gap: 12px;
}
.result-row:last-of-type { border-bottom: none; }
.result-key { color: rgba(255,255,255,0.45); letter-spacing: 1px; text-transform: uppercase; flex-shrink: 0; }
.result-val { color: #fff; text-align: right; word-break: break-all; }

.seller-verdict {
  margin: 4px 0 8px;
  border-left: 2px solid rgba(255,177,0,0.65);
  color: rgba(255,255,255,0.64);
  font-family: system-ui, sans-serif;
  font-size: 11px;
  line-height: 1.3;
  padding-left: 8px;
}

.seller-verdict.bad {
  border-left-color: rgba(255,70,100,0.75);
  color: #ff9aad;
}

.seller-verdict.good {
  border-left-color: rgba(0,255,150,0.5);
  color: rgba(112,255,189,0.78);
}

.problems-block {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.problems-title {
  color: var(--neon-orange);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.problems-list {
  display: grid;
  gap: 6px;
  list-style: none;
}

.problems-list li {
  color: rgba(255,255,255,0.84);
  font-family: system-ui, sans-serif;
  font-size: 12px;
  line-height: 1.3;
}

.problems-list li::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--neon-orange);
  vertical-align: 2px;
}

.problems-sources {
  color: rgba(255,255,255,0.42);
  font-size: 9px;
  letter-spacing: 1px;
  margin-top: 8px;
  text-transform: uppercase;
}

.score-bar {
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  margin: 12px 0;
  overflow: hidden;
}
.score-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--neon-blue), var(--neon-purple));
  border-radius: 2px;
  transition: width 0.6s ease;
}

.result-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 12px;
  min-height: 24px;
}

.result-badge {
  border: 1px solid rgba(0,212,255,0.28);
  border-radius: 4px;
  color: rgba(255,255,255,0.82);
  font-family: system-ui, sans-serif;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  padding: 6px 8px;
  text-transform: uppercase;
}

.result-badge.good {
  border-color: rgba(0,255,150,0.34);
  color: #70ffbd;
}

.result-badge.warn {
  border-color: rgba(255,177,0,0.45);
  color: var(--neon-orange);
}

.result-badge.bad {
  border-color: rgba(255,70,100,0.45);
  color: #ff6a86;
}

.result-badge.info,
.score-source {
  border-color: rgba(0,212,255,0.32);
  color: rgba(142,231,255,0.86);
}

.score-source {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  border: 1px solid rgba(0,212,255,0.28);
  border-radius: 4px;
  font-family: system-ui, sans-serif;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  margin: -2px 0 8px;
  padding: 6px 8px;
  text-transform: uppercase;
}

.score-source[hidden] { display: none; }

.score-source.base {
  border-color: rgba(255,177,0,0.42);
  color: var(--neon-orange);
}

.data-quality {
  border-left: 2px solid rgba(255,177,0,0.72);
  color: var(--neon-orange);
  font-family: system-ui, sans-serif;
  font-size: 11px;
  line-height: 1.3;
  margin: 2px 0 8px;
  padding-left: 8px;
}

.data-quality[hidden] {
  display: none;
}

.result-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.btn-open {
  flex: 1;
  background: linear-gradient(135deg, var(--neon-blue), var(--neon-purple));
  border: none;
  color: #fff;
  font-family: 'Orbitron', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 12px;
  border-radius: 4px;
  cursor: pointer;
  text-transform: uppercase;
  text-decoration: none;
  display: flex; align-items: center; justify-content: center;
}

.btn-open[hidden] {
  display: none;
}

.btn-close {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.6);
  font-family: 'Orbitron', monospace;
  font-size: 11px;
  letter-spacing: 1px;
  padding: 12px 16px;
  border-radius: 4px;
  cursor: pointer;
}

/* ── Loading spinner ─────────────────────────────────────── */
#loader {
  position: fixed; inset: 0; z-index: 40;
  background: var(--dark);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 20px;
  transition: opacity 0.5s;
}
#loader.hidden { opacity: 0; pointer-events: none; }

.loader-text {
  font-size: 11px;
  letter-spacing: 4px;
  color: var(--neon-blue);
  text-transform: uppercase;
}

.spinner {
  width: 40px; height: 40px;
  border: 2px solid rgba(0,212,255,0.2);
  border-top-color: var(--neon-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Notification toast ──────────────────────────────────── */
#toast {
  position: fixed; bottom: 200px; left: 50%; transform: translateX(-50%);
  z-index: 50;
  background: rgba(0,0,0,0.9);
  border: 1px solid var(--neon-orange);
  color: var(--neon-orange);
  font-size: 10px;
  letter-spacing: 2px;
  padding: 8px 16px;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  white-space: nowrap;
}
#toast.show { opacity: 1; }
