html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden; /* Жестко запрещает странице двигаться вправо-влево */
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body { 
  margin: 0; 
  min-height: 100vh; 
  background-color: #0b1120; 
  color: #f8fafc; 
  font-family: 'Segoe UI', system-ui, sans-serif; 
  display: flex; 
  flex-direction: column;
  align-items: center; 
  overflow-x: hidden; 
}

#confetti-canvas { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 99; }

.walkout-overlay { position: fixed; inset: 0; background: radial-gradient(circle, rgba(245, 158, 11, 0.3) 0%, rgba(0, 0, 0, 0.95) 75%); z-index: 90; display: none; align-items: center; justify-content: center; animation: walkoutFlash 1.2s ease-in-out forwards; }
.walkout-text { font-size: 40px; font-weight: 900; letter-spacing: 4px; color: #f59e0b; text-shadow: 0 0 30px rgba(245, 158, 11, 0.9); }
@keyframes walkoutFlash { 0% { opacity: 0; transform: scale(0.9); } 50% { opacity: 1; transform: scale(1.05); } 100% { opacity: 0; transform: scale(1.1); } }

.main-container { 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  gap: 12px; 
  padding: 16px 12px; /* Чуть уменьшили боковые отступы с 16px до 12px */
  width: 100%; 
  max-width: 480px; 
  box-sizing: border-box; /* Обязательно, чтобы падинги не раздували блок шире экрана */
  text-align: center; 
  position: relative; 
  z-index: 10; 
}
.top-bar { display: flex; justify-content: space-between; align-items: center; width: 100%; }

.coins-badge { background: #1e293b; border: 1px solid #10b981; color: #34d399; font-weight: 800; padding: 6px 14px; border-radius: 20px; font-size: 15px; transition: 0.2s; cursor: pointer; }
.coins-badge:hover { background: #064e3b; transform: scale(1.05); }

.counter { font-size: 14px; font-weight: 600; color: #94a3b8; }
.reset-btn { background: none; border: none; color: #64748b; cursor: pointer; font-size: 16px; }
.reset-btn:hover { color: #ef4444; }

.pack-selector { 
  position: relative; 
  display: flex; 
  background: #1e293b; 
  padding: 4px; 
  border-radius: 12px; 
  z-index: 1;
  /* Убрали gap, чтобы кнопки стояли вплотную и ползунок ездил ровно */
}

/* 2. Тот самый плавающий серый ползунок */
.pack-selector::before {
  content: '';
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(50% - 4px); /* Занимает ровно половину места */
  background: #334155;    /* Тот самый серый цвет активной кнопки */
  border-radius: 8px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); /* Плавное и естественное скольжение */
  z-index: -1; /* Прячем прямоугольник ПОД текстом кнопок */
}

/* 3. Магия: если нажата кнопка "Элитный", ползунок уезжает вправо */
.pack-selector:has([data-pack="elite"].active)::before {
  transform: translateX(100%);
}

.pack-tab { 
  flex: 1; /* Делаем кнопки идеально одинаковыми по ширине */
  background: transparent !important; /* Важно: убираем жесткий фон, теперь фон дает ползунок! */
  border: none; 
  color: #94a3b8; 
  font-weight: 700; 
  padding: 8px 16px; 
  border-radius: 8px; 
  cursor: pointer; 
  font-size: 13px; 
  transition: color 0.3s ease; 
  z-index: 2; /* Текст должен быть ПОВЕРХ ползунка */
  white-space: nowrap;
}

/* 5. У активной кнопки меняется ТОЛЬКО цвет текста на белый */
.pack-tab.active { 
  color: #f8fafc; 
}

.stage { height: 330px; display: flex; align-items: center; justify-content: center; }
.pack-box { 
  width: 190px; 
  height: 270px; 
  background: linear-gradient(145deg, #1e293b, #0f172a); 
  border: 2px dashed #475569; 
  border-radius: 18px; 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  justify-content: center; 
  gap: 12px; 
  cursor: pointer; 
  user-select: none; 
  -webkit-user-select: none; 
  /* 👇 Добавляем плавность для самой коробки 👇 */
  transition: all 0.3s ease;
}
.pack-box.elite-pack { border: 2px solid #f59e0b; background: linear-gradient(145deg, #2d1a04, #0f172a); box-shadow: 0 0 25px rgba(245, 158, 11, 0.25); }
.pack-icon { font-size: 44px; }
.pack-label { font-weight: 800; font-size: 14px; color: #cbd5e1; }

.shake { animation: shakePack 0.4s infinite; }
@keyframes shakePack { 0%, 100% { transform: rotate(0deg) scale(1); } 25% { transform: rotate(-6deg) scale(1.06); } 75% { transform: rotate(6deg) scale(1.06); } }

.card { display: none; width: 220px; height: 320px; border-radius: 18px; padding: 18px; box-sizing: border-box; flex-direction: column; justify-content: space-between; align-items: center; }
.card-icon { background: linear-gradient(135deg, #ffffff, #d1d5db); color: #000; box-shadow: 0 0 40px rgba(255, 255, 255, 0.8); }
.card-gold { background: linear-gradient(135deg, #f59e0b, #92400e); color: #111827; box-shadow: 0 0 35px rgba(245, 158, 11, 0.7); }
.card-silver { background: linear-gradient(135deg, #e2e8f0, #64748b); color: #0f172a; box-shadow: 0 0 20px rgba(226, 232, 240, 0.35); }
.card-bronze { background: linear-gradient(135deg, #b45309, #78350f); color: #fef3c7; box-shadow: 0 0 20px rgba(180, 83, 9, 0.3); }
.card-rating { font-size: 38px; font-weight: 900; align-self: flex-start; }
.card-photo { width: 130px; height: 130px; object-fit: contain; filter: drop-shadow(0 6px 10px rgba(0,0,0,0.5)); }
.card-name { font-size: 16px; font-weight: 800; text-transform: uppercase; }
.card-club { font-size: 12px; font-weight: 600; opacity: 0.85; }

.card-popup { animation: cardEntrance 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
@keyframes cardEntrance { 0% { opacity: 0; transform: scale(0.3) rotate(-8deg); } 100% { opacity: 1; transform: scale(1) rotate(0); } }

.action-buttons { display: flex; gap: 10px; width: 100%; justify-content: center; }
.btn { background: #111827; color: #f59e0b; border: 2px solid #f59e0b; border-radius: 12px; padding: 12px 20px; font-size: 14px; font-weight: 800; text-transform: uppercase; cursor: pointer; transition: 0.2s; z-index: 5; position: relative; }
.btn:hover:not(:disabled) { background: #f59e0b; color: #111827; box-shadow: 0 0 20px rgba(245, 158, 11, 0.5); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-sell { background: #064e3b; color: #34d399; border-color: #34d399; }
.btn-sell:hover:not(:disabled) { background: #34d399; color: #064e3b; }

.nav-buttons { 
  display: flex; 
  gap: 8px; 
  width: 100%; 
  max-width: 100%;
  box-sizing: border-box;
  position: relative; 
  z-index: 5; 
  margin-top: 10px;
}

.btn-secondary { 
  flex: 1; 
  background: #1e293b; 
  color: #38bdf8; 
  border: 1px solid #38bdf8;
  border-radius: 10px;
  padding: 8px 4px;      /* Внутренние отступы сверху/снизу */
  font-size: 11px;       /* Удобный размер шрифта */
  font-weight: 800;
  cursor: pointer; 
  touch-action: manipulation; 
  box-sizing: border-box;
  white-space: normal; 
  text-align: center;
  min-height: 63px;
}
.btn-secondary:hover { opacity: 0.8; }

.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.85); backdrop-filter: blur(6px); justify-content: center; align-items: center; z-index: 100; }
.modal-window { background: #1e293b; width: 92%; max-width: 520px; border-radius: 16px; padding: 20px; border: 1px solid #334155; max-height: 90vh; overflow-y: auto; }
.modal-wide { max-width: 650px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.close-btn { background: none; border: none; font-size: 26px; color: #94a3b8; cursor: pointer; }

.filters-bar { display: flex; gap: 6px; margin-bottom: 12px; overflow-x: auto; white-space: nowrap; padding-bottom: 5px; scrollbar-width: none; }
.filter-btn { background: #0f172a; border: 1px solid #334155; color: #94a3b8; padding: 5px 12px; border-radius: 6px; font-size: 12px; cursor: pointer; }
.filter-btn.active { background: #38bdf8; color: #0f172a; font-weight: 700; }

.modal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; max-height: 420px; overflow-y: auto; }
.mini-card { border-radius: 12px; padding: 10px; display: flex; flex-direction: column; align-items: center; position: relative; text-align: center; height: 190px; box-sizing: border-box; }
.mini-card-rating { position: absolute; top: 6px; left: 6px; font-size: 12px; font-weight: 800; }
.mini-card-count { position: absolute; top: 6px; right: 6px; background: rgba(15, 23, 42, 0.9); color: #38bdf8; border-radius: 10px; font-size: 10px; font-weight: 800; padding: 2px 5px; }
.mini-card-photo { width: 50px; height: 50px; object-fit: contain; margin-top: 14px; }
.mini-card-name { font-size: 11px; font-weight: 800; margin-top: 6px; text-transform: uppercase; line-height: 1.1; }
.mini-card-club { font-size: 9px; opacity: 0.8; margin-top: 2px; }
.mini-card-sell-btn { margin-top: auto; background: #10b981; color: #064e3b; border: none; border-radius: 6px; font-size: 11px; font-weight: 800; padding: 6px; cursor: pointer; width: 100%; }
.mini-card-sell-btn:hover { background: #34d399; }

.slot-locked { background: #0f172a; border: 2px dashed #334155; justify-content: center; }
.slot-locked .mini-placeholder-icon { font-size: 26px; margin: 0 0 8px; color: #475569; }
.slot-locked .mini-placeholder-text { font-size: 9px; color: #64748b; font-weight: 700; }

.pitch { width: 100%; height: 520px; background: radial-gradient(circle, #15803d 0%, #14532d 100%); border: 2px solid #86efac; border-radius: 12px; position: relative; margin-bottom: 12px; overflow: hidden; }
.pitch-circle { width: 80px; height: 80px; border: 2px solid rgba(255, 255, 255, 0.25); border-radius: 50%; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }
.pitch-line { position: absolute; width: 100%; height: 2px; background: rgba(255, 255, 255, 0.25); top: 50%; }
.pitch-penalty-box { position: absolute; width: 140px; height: 50px; border: 2px solid rgba(255, 255, 255, 0.25); left: 50%; transform: translateX(-50%); }
.pitch-penalty-box.top { top: 0; border-top: none; }
.pitch-penalty-box.bottom { bottom: 0; border-bottom: none; }
.pitch-formation { display: flex; flex-direction: column; justify-content: space-around; height: 100%; padding: 10px 0; position: relative; z-index: 2; }
.pitch-row { display: flex; justify-content: space-around; width: 100%; }
.pitch-slot { width: 55px; height: 65px; border: 2px dashed rgba(255, 255, 255, 0.4); border-radius: 6px; background: rgba(15, 23, 42, 0.6); display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; color: #86efac; font-size: 10px; font-weight: 800; padding: 2px; position: relative; }
.pitch-slot.active-slot { border-color: #38bdf8; box-shadow: 0 0 15px rgba(56, 189, 248, 0.8); background: rgba(15, 23, 42, 0.9); transform: scale(1.1); z-index: 10; }

.pitch-slot.occupied { border: 1px solid #f59e0b; background: rgba(15, 23, 42, 0.9); color: #fff; border-radius: 6px; position: relative; width: 18vw; max-width: 75px; min-height: 85px; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 6px 2px; box-sizing: border-box; text-align: center; }
.pitch-slot.occupied div:nth-child(1) { font-size: 10px !important; color: #94a3b8; font-weight: bold; margin-bottom: 2px; }
.pitch-slot.occupied div:nth-child(2) { font-size: clamp(8.5px, 2.6vw, 11px); letter-spacing: -0.3px; font-weight: bold; line-height: 1.1; width: 100%; word-break: break-word; }
.pitch-slot.occupied div:nth-child(3) { font-size: 15px; font-weight: 900; margin-top: 4px; }

.slot-remove-btn { position: absolute; top: -5px; right: -5px; width: 22px; height: 22px; background-color: #ef4444; color: white; border: 2px solid #1e293b; border-radius: 50%; cursor: pointer; display: flex; justify-content: center; align-items: center; font-size: 14px; font-weight: bold; padding: 0; line-height: 1; z-index: 10; }
.slot-remove-btn:hover { background-color: #dc2626; transform: scale(1.1); }

.squad-picker-grid { display: flex; gap: 8px; overflow-x: auto; padding: 8px 0; }
.squad-picker-card { min-width: 80px; background: #0f172a; border: 1px solid #334155; border-radius: 8px; padding: 6px; cursor: pointer; text-align: center; font-size: 10px; }
.squad-picker-card:hover { border-color: #38bdf8; }

.market-buy-btn { background: #f59e0b; color: #111827; border: none; padding: 6px; width: 100%; margin-top: auto; border-radius: 6px; font-weight: 800; cursor: pointer; transition: all 0.1s ease; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.market-buy-btn:hover:not(:disabled) { background: #fbbf24; transform: scale(1.05); }
.market-buy-btn:active:not(:disabled) { transform: scale(0.95); }
.market-buy-btn:disabled { opacity: 0.5; cursor: not-allowed; background: #b45309; color: #fef3c7; }

.bank-options { display: flex; flex-direction: column; gap: 10px; }
.bank-btn { background: linear-gradient(135deg, #10b981, #047857); color: #fff; border: none; padding: 15px; border-radius: 12px; font-size: 16px; font-weight: 800; cursor: pointer; }
.bank-btn:hover { opacity: 0.9; }

.quests-list, .leaderboard-list { display: flex; flex-direction: column; gap: 8px; max-height: 380px; overflow-y: auto; }
.quest-item { background: #0f172a; border: 1px solid #334155; border-radius: 10px; padding: 12px; display: flex; justify-content: space-between; align-items: center; text-align: left; }
.quest-info h4 { margin: 0 0 4px; font-size: 14px; }
.quest-info p { margin: 0; font-size: 11px; color: #94a3b8; }
.claim-btn { background: #10b981; color: #064e3b; border: none; padding: 8px; border-radius: 8px; font-weight: 800; cursor: pointer; }
.claim-btn:disabled { background: #334155; color: #64748b; cursor: not-allowed; }

.leader-row { display: flex; justify-content: space-between; background: #0f172a; padding: 10px; border-radius: 8px; border: 1px solid #334155; font-size: 14px; }
.leader-rank { font-weight: 800; color: #f59e0b; width: 30px; }

.sbc-slots-container { display: flex; gap: 15px; justify-content: center; margin: 20px 0; }
.sbc-slot { width: 90px; height: 125px; border: 2px dashed #475569; border-radius: 12px; background: #0f172a; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 30px; color: #475569; cursor: pointer; position: relative; }
.sbc-slot.filled { border: 2px solid #8b5cf6; background: rgba(139, 92, 246, 0.1); }

@media (max-width: 400px) {
  .pitch { height: 480px; }
  .pitch-slot { width: 48px; height: 58px; font-size: 9px; }
}

.tg-link-btn { display: block; margin-top: 15px; background: #2481cc; color: #fff; text-decoration: none; padding: 10px 20px; border-radius: 8px; font-size: 14px; font-weight: 700; width: 100%; box-sizing: border-box; text-align: center; transition: 0.2s; position: relative; z-index: 5; }
.tg-link-btn:hover { background: #1d69a6; transform: scale(1.02); }
