@font-face {
  font-family: "Intro";
  src: url("fonts/Intro.woff2") format("woff2"),
    url("fonts/Intro.woff") format("woff");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Intro", cursive, sans-serif;
  background-color: #212121;
  color: #f0f0f0;
  user-select: none;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* --- Основной контейнер игры --- */
.game-container {
  display: flex;
  flex-direction: column; /* <-- ИЗМЕНИТЕ НА column */
  width: 100%;
  height: 100%;
  transition: width 0.2s ease, height 0.2s ease;
  container-type: inline-size;
  position: relative;
}
body.proportional-mode .game-container {
  box-shadow: 0 0 1.56cqw rgba(0, 0, 0, 0.5); /* Было: 20px */
  width: auto;
  height: auto;
}
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1cqw 2cqw;
  background-color: #1a1a1a;
  border-bottom: 0.31cqw solid #444;
  flex-shrink: 0;
}

.header-stat-block {
  display: flex;
  flex-direction: column;
  min-width: 15cqw;
}

.header-stat-block.align-left {
  align-items: flex-start;
}
.header-stat-block.align-right {
  align-items: flex-end;
}

.stat-value {
  font-size: clamp(16px, 2.2cqw, 32px);
  font-weight: normal; /* Шрифт Intro сам по себе жирный */
  color: #fff;
}
.stat-label {
  font-size: clamp(10px, 1.1cqw, 16px);
  color: #aaa;
}

.gears-balance {
  display: flex;
  align-items: center;
  margin-top: 0.5cqw;
}
.gear-icon {
  width: 2cqw;
  height: 2cqw;
  margin-left: 0.5cqw;
}

.main-balance {
  align-items: center; /* Он всегда по центру */
}
.main-balance .main-balance-value {
  font-size: clamp(24px, 3.8cqw, 55px);
  color: #ffd700;
  text-shadow: 0 0 0.39cqw #ffc400;
  font-variant-numeric: tabular-nums;
}
.main-balance .passive-income-value {
  font-size: clamp(12px, 1.4cqw, 18px);
  color: #00e676;
}

.header-right-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

/* Новый стиль для кнопки рекламы */
.reward-ad-btn {
  display: flex;
  align-items: center;
  background-color: #28a745; /* Зеленый цвет, как на скрине */
  border: none;
  padding: 0.4cqw 1cqw;
  border-radius: 0.6cqw;
  cursor: pointer;
  transition: background-color 0.2s;
  box-shadow: 0 0.3cqw 0 #1c7430; /* Тень для объема */
}
.reward-ad-btn:hover {
  background-color: #218838;
}
.reward-ad-btn:active {
  transform: translateY(0.2cqw);
  box-shadow: 0 0.1cqw 0 #1c7430;
}

.ad-icon {
  width: 2cqw;
  height: 2cqw;
  margin-right: 0.8cqw;
}

.ad-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  color: white;
}

.ad-title {
  font-size: 0.9cqw;
  font-weight: bold;
}

.ad-timer {
  font-size: 0.8cqw;
}

/* Обновляем таймер, когда он активен */
#ad-timer.active {
  color: #ffd700; /* Делаем таймер золотым, когда он тикает */
  font-weight: bold;
}

.settings-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5cqw;
  margin-left: 1cqw;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}
.settings-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}
.settings-btn img {
  width: 2cqw;
  height: 2cqw;
}

/* --- СТИЛИ ДЛЯ МОДАЛЬНОГО ОКНА --- */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 10000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.modal-content {
  background-color: #333;
  padding: 2.5cqw;
  border-radius: 1cqw;
  border: 0.15cqw solid #555;
  width: 90%;
  max-width: 40cqw;
  position: relative;
  box-shadow: 0 5px 25px rgba(0, 0, 0, 0.5);
}

.close-modal-btn {
  position: absolute;
  top: 0.5cqw;
  right: 1cqw;
  background: none;
  border: none;
  font-size: 3cqw;
  color: #aaa;
  cursor: pointer;
}

.modal-content h2 {
  text-align: center;
  margin-bottom: 2cqw;
}

.settings-row {
  display: flex;
  flex-direction: column;
  margin-bottom: 2cqw;
}
.settings-row label {
  margin-bottom: 1cqw;
  font-size: 1.4cqw;
}

.reset-progress-btn {
  background-color: #dc3545; /* Красный */
  color: white;
  border: none;
  padding: 1cqw;
  border-radius: 0.5cqw;
  font-family: "Intro", sans-serif;
  font-size: 1.5cqw;
  cursor: pointer;
}
.reset-progress-btn:hover {
  background-color: #c82333;
}

/* Класс для скрытия модального окна */
.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.main-content {
  display: flex;
  flex-grow: 1; /* Занимает все оставшееся место */
  overflow: hidden; /* Важно, чтобы избежать двойных скроллбаров */
}

/* --- Левая колонка: Мир игры (Гараж) --- */
.game-world {
  flex: 2;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding: 1.56cqw; /* Было: 20px */
  position: relative;
  /* cursor: pointer; */
  background-image: url("img/garage_background.png"); /* Путь к вашему файлу */
  background-size: cover; /* Масштабирует картинку, чтобы она полностью покрыла блок, сохраняя пропорции */
  background-position: bottom; /* Центрирует картинку внутри блока */
  background-repeat: no-repeat;
}

#car-display {
  width: 100%;
  flex-grow: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  margin-bottom: 2cqw;
  position: relative;
  margin-bottom: -0.5cqw;
  /* padding-top: 4vh; */
  cursor: pointer;
}

.car-transition-out {
  animation-duration: 0.2s;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards; /* Остается невидимой в конце */
}
.car-transition-in {
  animation-duration: 0.2s;
  animation-timing-function: ease-out;
  animation-fill-mode: forwards;
}

/* Анимация ухода ВЛЕВО */
@keyframes out-left {
  to {
    opacity: 0;
    transform: translateY(5vh) translateX(-20%) scale(0.8);
  }
}
.out-left {
  animation-name: out-left;
}

/* Анимация ухода ВПРАВО */
@keyframes out-right {
  to {
    opacity: 0;
    transform: translateY(5vh) translateX(20%) scale(0.8);
  }
}
.out-right {
  animation-name: out-right;
}

/* Анимация прихода СЛЕВА */
@keyframes in-left {
  from {
    opacity: 0;
    transform: translateY(5vh) translateX(-20%) scale(0.8);
  }
}
.in-left {
  animation-name: in-left;
}

/* Анимация прихода СПРАВА */
@keyframes in-right {
  from {
    opacity: 0;
    transform: translateY(5vh) translateX(20%) scale(0.8);
  }
}
.in-right {
  animation-name: in-right;
}

#car-image {
  width: 100%;
  max-width: 100%;
  max-height: 95%;
  object-fit: contain;

  transition: transform 0.1s ease-out;
  filter: drop-shadow(0 0.31cqw 1.17cqw rgba(0, 0, 0, 0.5));
  pointer-events: none;
}
#car-display:hover #car-image {
  transform: scale(1.02);
}
#car-display:active #car-image {
  transform: scale(0.98);
}
#car-image.locked {
  filter: brightness(0) drop-shadow(0 0.31cqw 1.17cqw rgba(255, 255, 255, 0.2));
}
.locked-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  background-color: rgba(0, 0, 0, 0.7);
  padding: 1.5cqw 2.5cqw;
  border-radius: 1cqw;
  font-size: 1.8cqw;
  font-weight: bold;
  text-align: center;
  pointer-events: none; /* Чтобы не мешал кликам */
  border: 0.15cqw solid #fff;
}

/* --- Шкала опыта --- */
#project-info {
  width: 90%;
  max-width: 46.875cqw; /* Было: 600px */
  margin-top: 1.56cqw; /* Было: 20px */
  text-align: center;
}

#project-name {
  margin-bottom: 0.78cqw; /* Было: 10px */
  /* Используем clamp для ограничения мин/макс размера шрифта */
  font-size: clamp(16px, 1.875cqw, 30px); /* Было: 1.5em */
}

#exp-bar-container {
  width: 100%;
  height: 2.34cqw; /* Было: 30px */
  background-color: #1a1a1a;
  border-radius: 1.17cqw; /* Было: 15px */
  border: 0.15cqw solid #444; /* Было: 2px */
  overflow: hidden;
  position: relative;
}

#exp-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #0077ff, #00c6ff);
  border-radius: 1.17cqw; /* Было: 15px */
  transition: width 0.3s linear;
}

#exp-bar-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-weight: bold;
  text-shadow: 0.07cqw 0.07cqw 0.15cqw black; /* Было: 1px 1px 2px */
  font-size: clamp(10px, 1cqw, 18px); /* Новый масштабируемый шрифт */
}

/* --- Правая колонка: Панель магазина --- */
.shop-panel {
  flex: 1;
  background-color: #333;
  border-left: 0.31cqw solid #444; /* Было: 4px */
  display: flex;
  flex-direction: column;
  padding: 1.56cqw; /* Было: 20px */
}

#money-display {
  font-size: clamp(24px, 3.125cqw, 50px); /* Было: 2.5em */
  color: #ffd700;
  text-shadow: 0 0 0.39cqw #ffc400; /* Было: 5px */
}

.shop-panel h3 {
  text-align: center;
  margin-bottom: 0.78cqw; /* Было: 10px */
  font-size: clamp(14px, 1.5cqw, 24px); /* Новый масштабируемый шрифт */
}

#upgrades-container {
  flex-grow: 1;
  overflow-y: scroll;
  /* padding: 0.78cqw; */
  padding-left: 1cqw;
  /* margin-right: -0.78cqw; */
}

/* --- Карточка улучшения --- */
.upgrade-card {
  background-color: #424242;
  border-radius: 0.625cqw;
  padding: 1.17cqw;
  margin: 0 1cqw 0.78cqw 0;
  border: 0.07cqw solid #555;
  cursor: pointer;
  transition: transform 0.2s ease-out, background-color 0.2s ease-out;

  /* Используем Grid для сложного макета */
  display: grid;
  grid-template-columns: 5cqw 1fr auto; /* Иконка | Центральный блок | Уровень */
  grid-template-rows: auto;
  gap: 0 1.25cqw; /* Отступ только между колонками */
  align-items: center;
  position: relative; /* Нужно для позиционирования уровня */
  overflow: hidden; /* И для того, чтобы уровень красиво обрезался */
}
.upgrade-card:hover {
  background-color: #535353;
  transform: scale(1.02);
}
.upgrade-icon {
  width: 5cqw;
  height: 5cqw;
  object-fit: contain;
  /* Убираем фон и рамку */
}
.upgrade-details {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  position: relative; /* <-- ДОБАВЬТЕ ЭТО, чтобы z-index сработал */
  z-index: 1; /* <-- ДОБАВЬТЕ ЭТО */
}

.upgrade-details h4 {
  font-size: clamp(12px, 1.4cqw, 22px);
  margin: 0;
  color: #fff;
}

.upgrade-details .upgrade-bonus {
  font-size: clamp(10px, 1.1cqw, 16px);
  color: #00e676; /* Зеленый для бонусов */
}

.upgrade-details .cost {
  font-size: clamp(11px, 1.2cqw, 18px);
  font-weight: normal;
  color: #ffd700; /* Золотой для цены */
  margin-top: 0.3cqw;
}

/* 3. Большое число уровня справа */
.upgrade-level {
  /* --- ИЗМЕНЕНИЯ И ДОБАВЛЕНИЯ --- */
  display: block; /* <-- ВАЖНО: Делаем элемент блочным */
  position: absolute;
  right: 1cqw;
  top: 50%;
  transform: translateY(-50%);

  font-size: 7cqw;
  font-weight: bold;
  color: rgba(255, 255, 255, 0.08); /* <-- Сделал чуть менее прозрачным */
  pointer-events: none;
  font-style: normal;

  z-index: 0; /* <-- Убедимся, что он под текстом, но виден */
  line-height: 1; /* <-- Убираем лишние отступы у текста */
}

.upgrade-details .cost.shake-error {
  color: #dc3545; /* Красный цвет при ошибке */
  animation: shake 0.5s ease-in-out;
}

.upgrade-level,
.upgrade-info .upgrade-bonus {
  font-size: clamp(10px, 1cqw, 16px); /* Новый масштабируемый шрифт */
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  10%,
  30%,
  50%,
  70%,
  90% {
    transform: translateX(-5px);
  }
  20%,
  40%,
  60%,
  80% {
    transform: translateX(5px);
  }
}

/* Класс, который мы будем добавлять через JS */
.upgrade-card .cost.shake-error {
  color: #dc3545; /* Красный цвет при ошибке */
  animation: shake 0.5s ease-in-out;
}

/* --- Контейнер для частиц --- */
#particle-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
  overflow: hidden;
}

.project-header {
  display: flex;
  justify-content: space-between; /* Распределяем элементы по краям */
  align-items: center;
  width: 100%;
  margin-bottom: 0.78cqw; /* Было: 10px */
}

#project-name {
  margin: 0 1cqw; /* Отступы по бокам от названия */
  flex-grow: 1; /* Название занимает все свободное место в центре */
  text-align: center;
}

.arrow-btn {
  background-color: #444;
  border: 0.15cqw solid #666;
  color: #fff;
  border-radius: 50%;
  width: 3.5cqw;
  height: 3.5cqw;
  cursor: pointer;
  transition: background-color 0.2s;
  flex-shrink: 0;
  padding: 0; /* Убираем внутренние отступы, чтобы картинка прилегала */
  display: flex; /* Используем flex для центрирования картинки */
  justify-content: center;
  align-items: center;
}
.arrow-btn img {
  width: 60%; /* Размер иконки относительно кнопки */
  height: 60%;
  object-fit: contain;
}

.arrow-btn:hover:not(:disabled) {
  background-color: #555;
}

#staff-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* Чтобы не мешали кликам */
}

.staff-member {
  position: absolute;
  width: 10cqw; /* Размер персонажа */
  /* Добавим простую анимацию "работы" */
  animation: breathing 4s ease-in-out infinite;

  /* НОВОЕ СВОЙСТВО: привязываем трансформацию к низу картинки */
  transform-origin: bottom center;
}

.staff-member img {
  width: 100%;
}

@keyframes breathing {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.03); /* Слегка увеличивается в середине цикла */
  }
}

/* Позиционируем каждого персонажа */
#staff-intern_anya {
  bottom: 34%;
  left: 15%;
  animation-delay: -0.5s;
}
#staff-mechanic_lena {
  bottom: 35%;
  left: 25%;
  animation-delay: -1.2s;
}
#staff-designer_katya {
  bottom: 36%;
  left: 35%;
  animation-delay: -0.2s;
}
#staff-painter_olga {
  bottom: 35%;
  right: 15%;
  animation-delay: -2.7s;
}
#staff-manager_sveta {
  bottom: 36%;
  right: 25%;
  animation-delay: -1.8s;
}
#staff-engineer_irina {
  bottom: 38%;
  right: 35%;
  animation-delay: -3.5s;
}

.car-transition {
  animation-duration: 0.4s; /* Длительность анимации */
  animation-fill-mode: forwards; /* Анимация застывает в конечном состоянии */
  animation-timing-function: ease-in-out;
}

/* --- ЭКРАН ЗАГРУЗКИ --- */
#loader-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #212121;
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: opacity 0.2s ease-out; /* Плавное исчезновение */
}

.loader-content {
  text-align: center;
}

.loader-spinner {
  width: 60px;
  height: 60px;
  border: 5px solid #555;
  border-top-color: #ffd700;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

#loader-text {
  color: #f0f0f0;
  font-size: 1.2em;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* --- СТИЛИ ДЛЯ ВКЛАДОК МАГАЗИНА --- */
.shop-tabs {
  display: flex;
  margin-bottom: 1.56cqw; /* Было: 20px */
}

.tab-btn {
  flex-grow: 1;
  padding: 1cqw;
  font-family: "Intro", sans-serif;
  font-size: clamp(12px, 1.5cqw, 20px);
  border: 0.15cqw solid #555;
  background-color: #444;
  color: #aaa;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

.tab-btn:first-child {
  border-radius: 0.8cqw 0 0 0.8cqw;
  border-right: none;
}
.tab-btn:last-child {
  border-radius: 0 0.8cqw 0.8cqw 0;
}

.tab-btn.active {
  background-color: #555;
  color: #fff;
}

.shop-content {
  flex-grow: 1;
  position: relative;
  overflow: hidden; /* Важно для работы скролла */
}

.tab-pane {
  display: none; /* По умолчанию все вкладки скрыты */
  height: 100%;
  /* overflow-y: scroll; Теперь скролл будет здесь */
}

.tab-pane.active {
  display: block; /* Показываем только активную */
}

/* Переносим стили скролла на новые контейнеры */
#upgrades-container,
#blueprints-container {
  height: 100%;
  overflow-y: scroll;
  padding: 10px;
  margin-right: -10px;
}

/* --- СТИЛИ ДЛЯ "ЗАНАВЕСА" СБРОСА --- */
#reset-curtain {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: white;
  z-index: 99999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease-in-out;
}

#reset-curtain.visible {
  opacity: 1;
  pointer-events: auto;
}

.offline-amount {
  color: #ffd700;
  text-align: center;
  font-size: 4cqw;
  margin: 1cqw 0;
  text-shadow: 0 0 0.5cqw #ffc400;
}
.offline-text {
  text-align: center;
  color: #aaa;
  font-size: 1.5cqw;
}
