/* УКАЗЫВАЕМ НА ЛОКАЛЬНЫЙ ФАЙЛ ШРИФТА */
@font-face {
  font-family: 'BattleCityFont';
  /* Присваиваем шрифту собственное имя */
  src: url('../fonts/1.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Luxury / Cyberpunk Palette */
  --color-bg-dark: #050505;
  --color-bg-dark-gradient: linear-gradient(135deg, #050505 0%, #0a0a0a 100%);

  --color-accent-gold: #FFD700;
  --color-accent-gold-glow: rgba(255, 215, 0, 0.4);

  --color-accent-green: #00FF88;
  --color-accent-red: #FF0055;
  --color-text-primary: #FFFFFF;
  --color-text-secondary: #B0B0B0;

  --font-display: 'Orbitron', sans-serif;
  /* For headers, stats */
  --font-body: 'Inter', sans-serif;
  /* For descriptions */

  --glass-bg: rgba(20, 20, 20, 0.65);
  --glass-border: 1px solid rgba(255, 255, 255, 0.08);
  --glass-blur: blur(12px);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);

  /* Telegram Theme Overrides */
  --tg-theme-bg-color: var(--color-bg-dark);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  /* Цвет фона будет установлен TelegramWebAppManager согласно теме */
  background-color: #000 !important;
  /* Отключить прокрутку для Telegram Mini App */
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
  /* Предотвратить выделение текста в Mini App */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  /* Предотвратить перетаскивание изображений */
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
  user-drag: none;
}

body {
  display: flex;
  flex-direction: column;
  background-color: #000 !important;
}

#main {
  flex: 1 1 auto;
  position: relative;
  overflow: hidden;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #000 !important;

  /* Учет безопасной зоны для Telegram Mini App */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-top: var(--safe-area-inset-top, env(safe-area-inset-top));
  padding-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom));
}

canvas {
  image-rendering: -moz-crisp-edges;
  image-rendering: -webkit-crisp-edges;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  /* Убедиться, что canvas не перекрывается тач-кнопками */
  position: relative;
  z-index: 1;
  /* Предотвратить выделение текста и перетаскивание */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  touch-action: none;
}

#help {
  display: none;
}

#tg-only-message {
  display: none;
  width: 100%;
  text-align: center;
  color: #ccc;
  font-family: Arial, sans-serif;
  font-size: 18px;
  align-self: center;
}

/* --- Стили сенсорного управления --- */

#touch-controls {
  display: flex;
  pointer-events: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  z-index: 100;
  box-sizing: border-box;
}

#touch-controls.layout-swapped {
  flex-direction: row-reverse;
}

#d-pad,
#action-buttons {
  pointer-events: auto;
}

#d-pad {
  display: grid;
  height: 100%;
  width: 45%;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  gap: 2px;
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.3));
}

#d-pad .touch-button {
  background: linear-gradient(145deg, #5e5e5e, #3a3a3a);
  border: 1px solid #2f2f2f;
  box-shadow: inset 0 2px 1px rgba(255, 255, 255, 0.1), inset 0 -1px 1px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.1s ease;
}

#touch-up {
  border-radius: 8px 8px 0 0;
}

#touch-down {
  border-radius: 0 0 8px 8px;
}

#touch-left {
  border-radius: 8px 0 0 8px;
}

#touch-right {
  border-radius: 0 8px 8px 0;
}

#d-pad .touch-button::before {
  content: '';
  width: 0;
  height: 0;
  border-style: solid;
  opacity: 0.8;
  transition: all 0.1s ease;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.4));
}

#touch-up::before {
  border-width: 0 10px 16px 10px;
  border-color: transparent transparent #cfcfcf transparent;
}

#touch-down::before {
  border-width: 16px 10px 0 10px;
  border-color: #cfcfcf transparent transparent transparent;
}

#touch-left::before {
  border-width: 10px 16px 10px 0;
  border-color: transparent #cfcfcf transparent transparent;
}

#touch-right::before {
  border-width: 10px 0 10px 16px;
  border-color: transparent transparent transparent #cfcfcf;
}

#d-pad .touch-button:active {
  transform: scale(0.95);
  background: linear-gradient(145deg, #3a3a3a, #505050);
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.6);
}

#touch-a,
#touch-b {
  position: relative;
  border-radius: 50%;
  box-sizing: border-box;
  box-shadow: 0 8px 10px rgba(0, 0, 0, 0.3), inset 0 2px 1px rgba(255, 255, 255, 0.3);
  transition: transform 0.1s ease-out, box-shadow 0.1s ease-out;
  font-family: Arial, sans-serif;
  font-weight: bold;
  font-size: 24px;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.4);
}

#touch-a::before,
#touch-b::before {
  content: attr(data-label);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  -webkit-transform: translate(-50%, -50%);
  color: white;
}

#touch-a::after,
#touch-b::after {
  content: '';
  position: absolute;
  top: 5%;
  left: 10%;
  width: 80%;
  height: 40%;
  border-radius: 50%;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0.0));
  transition: opacity 0.1s ease-out;
}

#touch-a {
  background: radial-gradient(circle at 50% 40%, #ff5252, #c62828);
}

#touch-b {
  background: radial-gradient(circle at 50% 40%, #ffeb3b, #f9a825);
}

#touch-a:active {
  transform: scale(0.95) translateY(2px);
  box-shadow: 0 0 25px 5px rgba(255, 82, 82, 0.7), inset 0 4px 8px rgba(0, 0, 0, 0.6);
}

#touch-b:active {
  transform: scale(0.95) translateY(2px);
  box-shadow: 0 0 25px 5px rgba(255, 235, 59, 0.7), inset 0 4px 8px rgba(0, 0, 0, 0.6);
}

#touch-a:active::after,
#touch-b:active::after {
  opacity: 0;
}

/* --- Расположение --- */
#touch-controls {
  flex: 0 0 auto;
  height: 25vh;
  min-height: 150px;
  max-height: 200px;
  width: 100%;
  background-color: #282828;
  border-top: 1px solid #444;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  box-sizing: border-box;
  /* Убедиться, что контролы не перекрывают canvas */
  position: relative;
  z-index: 100;
}

#action-buttons {
  display: flex;
  height: 100%;
  width: 45%;
  justify-content: space-around;
  align-items: center;
  gap: 15px;
}

#touch-b,
#touch-a {
  width: 38%;
  height: auto;
  aspect-ratio: 1 / 1;
}

@media (orientation: landscape) {
  body {
    flex-direction: row;
  }

  #main {
    width: 100%;
    height: 100%;
  }

  #touch-controls {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 2vh;
    background-color: transparent;
    pointer-events: none;
    align-items: flex-end;
    max-height: none;
  }

  #d-pad {
    width: 24vh;
    height: 24vh;
    min-width: 120px;
    min-height: 120px;
  }

  #action-buttons {
    width: 28vh;
    height: 14vh;
  }

  #touch-b,
  #touch-a {
    width: 12vh;
    height: 12vh;
    min-width: 60px;
    min-height: 60px;
    padding-bottom: 0;
    font-size: 2.5vh;
  }
}

/* Дополнительные стили для маленьких экранов */
@media (max-width: 480px) {
  #touch-controls {
    height: 22vh;
    min-height: 130px;
    padding: 10px;
  }

  #d-pad .touch-button {
    min-width: 50px;
    min-height: 50px;
  }

  #touch-a,
  #touch-b {
    min-width: 55px;
    min-height: 55px;
    font-size: 20px;
  }
}

/* Стили для очень маленьких экранов */
@media (max-height: 500px) and (orientation: portrait) {
  #touch-controls {
    height: 20vh;
    min-height: 100px;
    padding: 8px;
  }
}

/* Улучшенная поддержка безопасных зон для iPhone */
@supports (padding: max(0px)) {
  #touch-controls {
    padding-bottom: max(15px, env(safe-area-inset-bottom));
  }
}

#touch-up {
  grid-column: 2;
  grid-row: 1;
}

#touch-down {
  grid-column: 2;
  grid-row: 3;
}

#touch-left {
  grid-column: 1;
  grid-row: 2;
}

#touch-right {
  grid-column: 3;
  grid-row: 2;
}

/* --- ULTRA-PREMIUM SHOP RE-DESIGN --- */

#shop-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background: #000;
  background-image:
    radial-gradient(at 0% 0%, rgba(132, 0, 255, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(255, 215, 0, 0.12) 0px, transparent 50%),
    radial-gradient(at 50% 100%, rgba(255, 0, 85, 0.12) 0px, transparent 50%);
  z-index: 9999;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  color: var(--color-text-primary);
  opacity: 0;
  transform: scale(1.05);
  transition: all 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
  display: none;
  font-family: 'Inter', sans-serif;
}


#shop-overlay.visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

/* Header & Glassmorphism */
.shop-header {
  padding: 25px 15px;
  background: rgba(8, 8, 8, 0.75);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(255, 215, 0, 0.1);
}

.shop-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.shop-back-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
}

.shop-title-main {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 900;
  color: #fff;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

/* Balance Dashboard */
.shop-balance-dashboard {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.01) 100%);
  border: 1px solid rgba(255, 215, 0, 0.2);
  border-radius: 20px;
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.balance-info label {
  font-size: 10px;
  font-weight: 800;
  color: #FFD700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  display: block;
}

.balance-info .value {
  font-size: 32px;
  font-weight: 900;
  font-family: var(--font-display);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.balance-coin-anim {
  animation: coinFloat 2.5s ease-in-out infinite;
  display: inline-block;
}

@keyframes coinFloat {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-5px);
  }
}

/* Sections */
.shop-content {
  padding: 20px 10px 40px;
  max-width: 500px;
  margin: 0 auto;
}

.shop-section-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 30px 0 15px;
}

.shop-section-head h2 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 900;
  color: #fff;
  letter-spacing: 2px;
}

.shop-section-head .line {
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, #FFD700, transparent);
  border-radius: 1px;
}

/* Top Up Scroller */
.topup-scroller {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 5px 0 15px;
  scrollbar-width: none;
}

.topup-scroller::-webkit-scrollbar {
  display: none;
}

.premium-topup-card {
  flex: 0 0 135px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 20px 15px;
  text-align: center;
  position: relative;
  transition: transform 0.2s, background 0.2s;
}

.premium-topup-card:active {
  transform: scale(0.95);
}

.premium-topup-card.featured {
  background: rgba(255, 215, 0, 0.08);
  border-color: rgba(255, 215, 0, 0.4);
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.1);
}

.card-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: #FF0055;
  color: #fff;
  font-size: 8px;
  font-weight: 900;
  padding: 4px 10px;
  border-radius: 6px;
  text-transform: uppercase;
}

.topup-gold-amount {
  font-size: 24px;
  font-weight: 900;
  color: #fff;
  display: block;
}

.topup-gold-label {
  font-size: 10px;
  font-weight: 700;
  color: #FFD700;
  margin-bottom: 15px;
  display: block;
}

.topup-button-mini {
  background: #fff;
  color: #000;
  padding: 8px 0;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 900;
}

/* UPGRADE GRID - 2 COLUMNS ALWAYS */
.modern-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.modern-item-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  padding: 15px 12px;
  position: relative;
  display: flex;
  flex-direction: column;
  transition: all 0.3s;
}

.modern-item-card:active {
  background: rgba(255, 255, 255, 0.05);
  transform: translateY(-2px);
}

.item-level-tag {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 9px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.3);
}

.item-icon-box {
  width: 45px;
  height: 45px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin: 0 auto 10px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.item-name {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  text-align: center;
  margin-bottom: 5px;
  text-transform: uppercase;
  height: 2.6em;
  display: flex;
  align-items: center;
  justify-content: center;
}

.item-desc {
  font-size: 9.5px;
  color: rgba(255, 255, 255, 0.4);
  text-align: center;
  line-height: 1.3;
  margin-bottom: 12px;
  height: 2.6em;
  overflow: hidden;
}

.item-progress-track {
  height: 4px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 2px;
  margin-bottom: 12px;
}

.item-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #FFD700, #FFA500);
  border-radius: 2px;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
}

.item-buy-btn {
  margin-top: auto;
  height: 38px;
  background: #fff;
  color: #000;
  border-radius: 10px;
  border: none;
  font-size: 12px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.2s;
}

.item-buy-btn:disabled {
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.2);
}

.item-buy-btn.purchased {
  background: transparent !important;
  border: 1px solid rgba(0, 255, 136, 0.3) !important;
  color: #00FF88 !important;
}

/* Custom Scrollbar */
#shop-overlay::-webkit-scrollbar {
  width: 4px;
}

#shop-overlay::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

@media (max-width: 360px) {
  .modern-grid {
    gap: 8px;
  }

  .modern-item-card {
    padding: 12px 8px;
  }
}

/* --- PREMIUM ACHIEVEMENTS OVERLAY --- */

#achievements-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background: #000;
  background-image:
    radial-gradient(at 0% 0%, rgba(0, 200, 150, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 50%, rgba(255, 180, 0, 0.1) 0px, transparent 50%);
  z-index: 9999;
  overflow-y: auto;
  overflow-x: hidden;
  display: none;
  font-family: 'Inter', sans-serif;
}

#achievements-overlay.visible {
  display: block;
}

.achievements-container {
  padding: 15px;
  min-height: 100%;
}

.achievements-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.achievements-back-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-family: 'Orbitron', sans-serif;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 15px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
}

.achievements-back-btn:active {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(0.95);
}

.achievements-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 24px;
  font-weight: 900;
  color: #fff;
  margin: 0;
  text-shadow: 0 0 15px rgba(0, 255, 150, 0.4);
}

.achievements-stats {
  display: flex;
  gap: 10px;
  align-items: center;
}

.achievements-count {
  font-family: 'Orbitron', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: #00FF88;
}

.achievements-percent {
  font-family: 'Orbitron', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
}

.achievements-progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  margin-bottom: 30px;
  overflow: hidden;
}

.achievements-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #00FF88, #00D4AA);
  border-radius: 3px;
  transition: width 0.5s ease;
  box-shadow: 0 0 10px rgba(0, 255, 136, 0.3);
}

.achievement-category-section {
  margin-bottom: 35px;
}

.achievement-category-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  opacity: 0.9;
}

.achievement-category-title::before {
  content: '';
  display: block;
  width: 3px;
  height: 18px;
  background: #00FF88;
  border-radius: 2px;
  box-shadow: 0 0 12px #00FF88;
}

.achievements-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 600px) {
  .achievements-grid {
    gap: 10px;
  }
}

@media (max-width: 480px) {
  .achievements-grid {
    grid-template-columns: 1fr;
  }
}

.achievement-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
  overflow: hidden;
}

.achievement-card.unlocked {
  background: rgba(0, 255, 136, 0.06);
  border-color: rgba(0, 255, 136, 0.2);
}

.achievement-card.locked {
  opacity: 0.6;
}

.achievement-icon {
  font-size: 28px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 14px;
  flex-shrink: 0;
}

.achievement-card.unlocked .achievement-icon {
  background: rgba(0, 255, 136, 0.12);
  color: #00FF88;
  text-shadow: 0 0 10px #00FF88;
}

.achievement-info {
  flex: 1;
  min-width: 0;
}

.achievement-name {
  font-family: 'Orbitron', sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.achievement-card.locked .achievement-name {
  color: rgba(255, 255, 255, 0.5);
}

.achievement-desc {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 6px;
  line-height: 1.2;
  height: 2.4em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.achievement-status {
  font-family: 'Orbitron', sans-serif;
  font-size: 10px;
  font-weight: 700;
  color: #00FF88;
}

.achievement-progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.achievement-progress-track {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

.achievement-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #FFD700, #FFA500);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.achievement-progress-text {
  font-family: 'Orbitron', sans-serif;
  font-size: 9px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  white-space: nowrap;
}

/* ==========================================
   GARAGE HUB (HEAVY LUXURY)
   ========================================== */
#garage-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 50%, #0d0d1a 0%, #05050a 100%);
  z-index: 1000;
  display: none;
  flex-direction: column;
  font-family: 'Inter', sans-serif;
  color: white;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.garage-header {
  padding: 30px 20px 10px;
  text-align: center;
}

.garage-header h1 {
  font-family: 'Orbitron', sans-serif;
  font-size: 24px;
  letter-spacing: 4px;
  margin: 0;
  background: linear-gradient(to bottom, #fff, #ffd700);
  -webkit-background-clip: text;
  background_clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 15px rgba(255, 215, 0, 0.3));
}

.garage-canvas-container {
  width: 100%;
  height: 300px;
  position: relative;
  margin: 10px 0;
  margin: 10px 0;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 215, 0, 0.05) 0%, transparent 70%),
    linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
    linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
  background-size: 100% 100%, 100% 2px, 3px 100%;
  animation: holo-scan 10s linear infinite;
}

@keyframes holo-scan {
  0% {
    background-position: 0 0, 0 0, 0 0;
  }

  100% {
    background-position: 0 0, 0 100%, 0 0;
  }
}

#garage-3d-canvas {
  width: 100% !important;
  height: 100% !important;
  outline: none;
}

.pedestal-glow {
  position: absolute;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
  width: 160px;
  height: 40px;
  background: radial-gradient(ellipse at center, rgba(255, 215, 0, 0.3) 0%, transparent 70%);
  filter: blur(5px);
  pointer-events: none;
}

.garage-content {
  padding: 0 20px 40px;
}

.garage-card {
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  padding: 25px;
  margin-bottom: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

/* Main Stats Grid */
.garage-main-stats {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.stat-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  /* 3 Equal columns */
  gap: 10px;
  align-items: center;
  justify-items: center;
  margin-top: 10px;
  width: 100%;
}

.stat-grid-3 .p-stat-item {
  align-items: center;
  text-align: center;
}

.p-stat-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.p-stat-label {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.p-stat-value {
  font-family: 'Orbitron', sans-serif;
  font-size: 20px;
  color: white;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

.p-stat-value.gold {
  color: #ffd700;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
}

.p-stat-value.level {
  color: #00f2ff;
  text-shadow: 0 0 10px rgba(0, 242, 255, 0.4);
}

.garage-progress-container {
  margin-top: 25px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.garage-progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.garage-progress-label {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
}

.garage-progress-percent {
  font-family: 'Orbitron', sans-serif;
  font-size: 14px;
  color: #ffd700;
}

.p-progress-bg {
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  overflow: hidden;
}

.p-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #ffd700, #ff8c00);
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.garage-back-btn {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: white;
  padding: 18px;
  border-radius: 20px;
  font-family: 'Orbitron', sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.garage-back-btn:active {
  transform: scale(0.98);
  background: rgba(255, 255, 255, 0.1);
}

.p-stat-value.credits {
  color: #cccccc;
  text-shadow: 0 0 10px rgba(200, 200, 200, 0.4);
}

.p-stat-value.xp {
  color: #ff9900;
  text-shadow: 0 0 10px rgba(255, 153, 0, 0.4);
}

.garage-main-stats {
  grid-template-columns: repeat(2, 1fr) !important;
}

@media (min-width: 400px) {
  .garage-main-stats {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}

/* --- TECH TREE STYLES --- */
.garage-tech-tree {
  margin-top: 30px;
}

.tech-tree-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 16px;
  letter-spacing: 2px;
  margin-bottom: 20px;
  color: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  gap: 10px;
}

.tech-tree-tabs {
  display: flex;
  overflow-x: auto;
  gap: 10px;
  margin-bottom: 20px;
  padding-bottom: 10px;
  scrollbar-width: none;
}

.tech-tree-tabs::-webkit-scrollbar {
  display: none;
}

.tech-tab {
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.3s ease;
}

.tech-tab.active {
  background: rgba(255, 215, 0, 0.1);
  border-color: #ffd700;
  color: #ffd700;
}

.tech-modules-grid {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.tech-module-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.3s ease;
}

.tech-module-card.researched {
  border-color: rgba(0, 242, 255, 0.3);
}

.tech-module-card.purchased {
  border-color: rgba(255, 215, 0, 0.3);
  background: rgba(255, 215, 0, 0.02);
}

.module-info {
  display: flex;
  gap: 15px;
  align-items: center;
}

.module-icon {
  font-size: 24px;
  width: 50px;
  height: 50px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.module-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.module-name {
  font-weight: 700;
  font-size: 14px;
}

.module-desc {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
}

.module-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-tech {
  padding: 8px 15px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.btn-research {
  background: #00f2ff;
  color: #000;
}

.btn-purchase {
  background: #ffd700;
  color: #000;
}

.btn-locked {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.3);
  cursor: not-allowed;
}

.status-badge {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.status-researched {
  color: #00f2ff;
}

.status-purchased {
  color: #ffd700;
}

.cost-tag {
  font-size: 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* --- AAA PREMIUM TECH TREE (HEAVY LUXURY) --- */

.tech-tree-container {
  position: relative;
  padding: 0;
  background: #050508;
  border: 1px solid rgba(0, 242, 255, 0.2);
  border-radius: 4px;
  overflow: hidden;
  min-height: 480px;
  margin-top: 20px;
  box-shadow:
    0 0 20px rgba(0, 0, 0, 0.8),
    inset 0 0 50px rgba(0, 50, 100, 0.2);
}

/* --- DOM MAIN MENU OVERHAUL --- */
#main-menu-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  /* Allow canvas clicks if needed, but buttons need pointer-events:auto */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 50;
  font-family: 'Orbitron', sans-serif;
}

.menu-logo-container {
  margin-bottom: 40px;
  text-align: center;
  animation: logoFloat 3s ease-in-out infinite;
}

.menu-logo-main {
  font-size: 64px;
  font-weight: 900;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 4px;
  text-shadow:
    0 0 10px #00f2ff,
    0 0 20px #00f2ff,
    0 0 40px #00f2ff;
  background: linear-gradient(180deg, #fff, #aaddff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.menu-logo-sub {
  font-size: 18px;
  color: #00f2ff;
  letter-spacing: 8px;
  margin-top: -10px;
  text-shadow: 0 0 5px #00f2ff;
  opacity: 0.8;
}

.menu-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 280px;
  perspective: 1000px;
  pointer-events: auto;
  /* Enable clicks */
}

.menu-item-dom {
  position: relative;
  padding: 10px 20px;
  background: rgba(0, 15, 30, 0.6);
  border: 1px solid rgba(0, 242, 255, 0.3);
  color: rgba(255, 255, 255, 0.7);
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.2s ease-out;
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
  backdrop-filter: blur(5px);
  overflow: hidden;
  text-align: center;
}

.menu-item-dom::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0, 242, 255, 0.4), transparent);
  transition: left 0.4s;
}

/* Selected / Hover State */
.menu-item-dom.selected,
.menu-item-dom:hover {
  background: rgba(0, 242, 255, 0.15);
  border-color: #00f2ff;
  color: #fff;
  transform: scale(1.02) translateZ(20px);
  box-shadow:
    0 0 15px rgba(0, 242, 255, 0.4),
    inset 0 0 10px rgba(0, 242, 255, 0.2);
  text-shadow: 0 0 8px #00f2ff;
}

.menu-item-dom.selected::before,
.menu-item-dom:hover::before {
  left: 100%;
  transition: left 0.6s;
}

/* Icon Support */
.menu-item-icon {
  margin-right: 10px;
  font-size: 20px;
}

@keyframes logoFloat {

  0%,
  100% {
    transform: translateY(0);
    filter: drop-shadow(0 0 15px rgba(0, 242, 255, 0.5));
  }

  50% {
    transform: translateY(-10px);
    filter: drop-shadow(0 0 25px rgba(0, 242, 255, 0.8));
  }
}

/* Stats/High Score Floating Panel */
#menu-highscore {
  position: absolute;
  top: 20px;
  right: 20px;
  text-align: right;
  z-index: 55;
}

.hs-label {
  font-size: 10px;
  color: #888;
  letter-spacing: 2px;
  display: block;
}

.hs-value {
  font-size: 24px;
  color: #FFD700;
  font-weight: 900;
  text-shadow: 0 0 10px #FFD700;
}

/* Holographic Grid Background */
.tech-tree-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 200%;
  height: 200%;
  background-image:
    linear-gradient(rgba(0, 242, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 242, 255, 0.03) 1px, transparent 1px),
    radial-gradient(circle at 50% 50%, rgba(0, 242, 255, 0.05) 0%, transparent 60%);
  background-size: 30px 30px, 30px 30px, 100% 100%;
  transform: perspective(500px) rotateX(20deg) translateY(-50px) translateZ(-50px);
  pointer-events: none;
  animation: grid-pan 60s linear infinite;
  z-index: 0;
}

@keyframes grid-pan {
  0% {
    transform: perspective(500px) rotateX(20deg) translateY(-50px) translateZ(-50px) translateY(0);
  }

  100% {
    transform: perspective(500px) rotateX(20deg) translateY(-50px) translateZ(-50px) translateY(30px);
  }
}


/* --- HOLO STATS BARS --- */
.holo-bar-container {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
  margin-top: 4px;
}

.holo-bar-fill {
  height: 100%;
  border-radius: 4px;
  box-shadow: 0 0 10px currentColor;
  position: relative;
}

.holo-bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transform: skewX(-20deg) translateX(-150%);
  animation: shine 2s infinite;
}

@keyframes shine {
  100% {
    transform: skewX(-20deg) translateX(150%);
  }
}

.stat-label {
  font-size: 10px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.6);
  letter-spacing: 1px;
}

/* --- RESPONSIVE TABS --- */
.tech-tree-tabs {
  display: flex;
  overflow-x: auto;
  gap: 4px;
  /* Tight gap */
  margin-bottom: 20px;
  padding: 5px 0 15px 0;
  /* More padding for shadows */
  scrollbar-width: none;
  /* Firefox */
  -ms-overflow-style: none;
  /* IE */
  width: 100%;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
  /* Smooth iOS scrolling */
  justify-content: space-between;
  /* Distribute space */
}

.tech-tree-tabs::-webkit-scrollbar {
  display: none;
  /* Chrome/Safari */
}

.tech-tab {
  flex: 1;
  /* Make them fill available space */
  padding: 10px 0;
  /* No side padding, centering instead */
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  /* Slightly smaller radius */
  font-size: 10px;
  /* Compact font */
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  text-align: center;
  /* Center text */
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 60px;
  /* Minimum touch target */
}

.tech-tab:active {
  transform: scale(0.95);
}

.tech-tree-container::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%);
  background-size: 100% 4px;
  pointer-events: none;
  z-index: 1;
}

/* SVG Container for Connectors */
.tech-tree-container svg {
  z-index: 2 !important;
  filter: drop-shadow(0 0 5px rgba(0, 242, 255, 0.5));
}

/* Connecting Lines (SVG) */
line {
  transition: all 0.5s ease;
  stroke-linecap: round;
}

.connector-locked {
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 1;
  stroke-dasharray: 5, 5;
}

.connector-available {
  stroke: #ffd700;
  stroke-width: 2;
  stroke-dasharray: 10, 5;
  animation: flow-line 2s linear infinite;
  filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.6));
}

.connector-researched {
  stroke: #00f2ff;
  stroke-width: 3;
  stroke-dasharray: 20, 10;
  animation: flow-line 1s linear infinite reverse;
  filter: drop-shadow(0 0 8px rgba(0, 242, 255, 0.8));
}

@keyframes flow-line {
  to {
    stroke-dashoffset: -30;
  }
}

/* --- TECH NODES (AAA HEXAGONS) --- */
.tech-node {
  position: absolute;
  width: 64px;
  height: 74px;
  /* Hex aspect ratio approx */
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  cursor: pointer;
  z-index: 10;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  /* Custom Hexagon Shape using SVG mask or clip-path with border hack */
  background: rgba(10, 15, 25, 0.95);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

/* Hexagon Border Effect using Pseudo-element */
.tech-node::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  right: 2px;
  bottom: 2px;
  background: rgba(20, 25, 35, 1);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  z-index: -1;
  transition: background 0.3s;
}

/* Outer Glow/Border Color */
.tech-node::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #333;
  /* Default Border Color */
  z-index: -2;
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  transition: background 0.3s, box-shadow 0.3s;
}

/* STATE: LOCKED */
.tech-node.locked {
  filter: grayscale(1) opacity(0.6);
}

.tech-node.locked::after {
  background: #333;
}

/* STATE: RESEARCHABLE */
.tech-node.researchable {
  animation: pulse-node 2s infinite;
}

.tech-node.researchable::after {
  background: #00f2ff;
  box-shadow: 0 0 15px rgba(0, 242, 255, 0.3);
}

.tech-node.researchable::before {
  background: rgba(0, 40, 50, 1);
}

/* STATE: PURCHASED */
.tech-node.purchased::after {
  background: #ffd700;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

.tech-node.purchased::before {
  background: linear-gradient(135deg, rgba(40, 35, 10, 1), rgba(60, 50, 0, 1));
}

/* STATE: SELECTED */
.tech-node.selected {
  transform: translate(-50%, -50%) scale(1.15);
  z-index: 12;
}

.tech-node.selected::after {
  background: #fff;
  box-shadow: 0 0 25px rgba(255, 255, 255, 0.6);
}

@keyframes pulse-node {
  0% {
    transform: translate(-50%, -50%) scale(1);
  }

  50% {
    transform: translate(-50%, -50%) scale(1.05);
  }

  100% {
    transform: translate(-50%, -50%) scale(1);
  }
}

/* --- POPOVER (AAA STYLE) --- */
.node-popover {
  position: absolute;
  top: 20px;
  /* Position at top right or custom */
  right: 20px;
  width: 240px;
  background: rgba(10, 12, 16, 0.95);
  border: 1px solid rgba(255, 215, 0, 0.3);
  padding: 0;
  z-index: 100;
  color: #fff;
  backdrop-filter: blur(15px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
  display: none;
  transform-origin: top right;
  animation: pop-in 0.3s ease-out;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.9) translate(10px, -10px);
  }

  to {
    opacity: 1;
    transform: scale(1) translate(0, 0);
  }
}

.node-popover-header {
  background: linear-gradient(90deg, rgba(255, 215, 0, 0.1), transparent);
  padding: 12px 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.node-popover h3 {
  margin: 0;
  font-family: 'Orbitron', sans-serif;
  font-size: 14px;
  color: #ffd700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.node-popover-body {
  padding: 15px;
}

.node-popover p {
  font-size: 11px;
  line-height: 1.4;
  color: #aaa;
  margin-bottom: 15px;
}

.node-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-tech {
  width: 100%;
  padding: 10px;
  border: none;
  font-family: 'Orbitron', sans-serif;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.btn-tech::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: 0.5s;
}

.btn-tech:hover::before {
  left: 100%;
}

.btn-research {
  background: #00f2ff;
  color: #000;
  box-shadow: 0 0 10px rgba(0, 242, 255, 0.3);
}

.btn-purchase {
  background: #ffd700;
  color: #000;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.btn-purchase:hover {
  background: #fff;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
}

.status-badge {
  display: inline-block;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 9px;
  text-align: center;
  border-radius: 4px;
}