/**
 * Nano Banana WebApp - Modals Styles
 */

/* ===== PAYMENT TABS ===== */
.topup-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 10px;
}

.payment-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.payment-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px 12px;
  border-radius: 14px;
  border: 2px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.45);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
}

.payment-tab .tab-icon {
  font-size: 28px;
  line-height: 1;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.payment-tab .tab-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* Card tab active */
.payment-tab[data-tab="card"].active {
  background: linear-gradient(135deg, rgba(59,130,246,0.2), rgba(99,102,241,0.15));
  border-color: rgba(59,130,246,0.5);
  color: #fff;
  box-shadow: 0 4px 20px rgba(59,130,246,0.25),
              inset 0 1px 0 rgba(255,255,255,0.1);
}

/* Stars tab active */
.payment-tab[data-tab="stars"].active {
  background: linear-gradient(135deg, rgba(255,193,7,0.15), rgba(255,152,0,0.12));
  border-color: rgba(255,193,7,0.5);
  color: #fff;
  box-shadow: 0 4px 20px rgba(255,193,7,0.2),
              inset 0 1px 0 rgba(255,255,255,0.1);
}

.payment-tab:not(.active):hover {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.7);
  border-color: rgba(255,255,255,0.15);
  transform: translateY(-1px);
}

.payment-tab.active .tab-icon {
  transform: scale(1.15);
}

/* Active indicator dot */
.payment-tab.active::after {
  content: '';
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 3px;
  border-radius: 2px;
}

.payment-tab[data-tab="card"].active::after {
  background: linear-gradient(90deg, #3b82f6, #6366f1);
  box-shadow: 0 0 8px rgba(59,130,246,0.6);
}

.payment-tab[data-tab="stars"].active::after {
  background: linear-gradient(90deg, #fbbf24, #f59e0b);
  box-shadow: 0 0 8px rgba(251,191,36,0.6);
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-card);
  color: white;
  padding: 12px 24px;
  border-radius: var(--border-radius);
  font-size: 14px;
  z-index: 1000;
  opacity: 0;
  transition: var(--transition);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success {
  background: var(--success);
}

.toast.error {
  background: var(--error);
}

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 20px;
  pointer-events: none;  /* iOS bug fix - защита от блокировки кликов */
}

.modal-overlay.active {
  display: flex;
  pointer-events: auto;  /* iOS bug fix - разрешить клики когда активен */
}

.modal {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 24px;
  width: 100%;
  max-width: 360px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 20px;
}

.topup-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-top: 14px; /* Space for popular badge */
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}

.topup-option {
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  position: relative;
  overflow: visible;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: all 0.3s var(--ease-spring),
              box-shadow 0.3s var(--ease-smooth);
  /* Fix mobile tap */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Ripple for topup options */
.topup-option::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(106, 106, 255, 0.4) 0%, transparent 70%);
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
  pointer-events: none;
  border-radius: inherit;
}

.topup-option:active::before {
  animation: rippleEffect 0.5s ease-out;
}

.topup-option:hover {
  border-color: rgba(106, 106, 255, 0.5);
  background: rgba(106, 106, 255, 0.12);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 4px 15px rgba(106, 106, 255, 0.2);
}

.topup-option:active {
  transform: scale(0.97);
  box-shadow: none;
}

.topup-option.selected {
  border-color: var(--accent-primary);
  background: linear-gradient(135deg, rgba(106, 106, 255, 0.2), rgba(138, 43, 226, 0.15));
  box-shadow: 0 0 15px rgba(106, 106, 255, 0.3),
              inset 0 0 10px rgba(106, 106, 255, 0.1);
  animation: neonPulse 3s ease-in-out infinite;
  --glow-color: var(--glow-primary);
}

.topup-option .package-name {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.topup-option .tokens-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  margin-bottom: 4px;
}

.topup-option .tokens-base {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
}

.topup-option .tokens-bonus {
  font-size: 16px;
  font-weight: 600;
  color: #4ade80;
  background: rgba(74, 222, 128, 0.15);
  padding: 2px 6px;
  border-radius: 6px;
}

.stars-bonus-hint {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.25);
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 4px;
}

.topup-option .price {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-primary);
}

/* Popular badge - только бейдж, без выделения */
.topup-option.popular {
  position: relative;
  /* НЕ меняем border/background - выглядит как обычная карточка */
}

/* Когда popular выбран - тогда выделяем */
.topup-option.popular.selected {
  border-color: var(--accent-primary);
  background: linear-gradient(135deg, rgba(106, 106, 255, 0.2), rgba(138, 43, 226, 0.15));
}

.topup-option .popular-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-purple), #ff6b9d, var(--accent-primary));
  background-size: 300% 100%;
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(138, 43, 226, 0.4);
  animation: shimmerBadge 3s ease-in-out infinite;
  z-index: 10;
}

@keyframes shimmerBadge {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.modal-actions {
  display: flex;
  gap: 12px;
}

.modal-actions .btn {
  flex: 1;
}

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.loading-overlay.hidden {
  display: none;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

.loading-text {
  color: var(--text-secondary);
  font-size: 14px;
}

/* ===== LIGHTBOX (FULLSCREEN ZOOM) ===== */
.lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 2000;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  /* Учитываем safe area для fullscreen */
  padding-top: var(--tg-safe-area-inset-top, 0);
  padding-bottom: var(--tg-safe-area-inset-bottom, 0);
  /* КРИТИЧНО: Блокируем все touch actions для предотвращения закрытия WebApp */
  touch-action: none;
  /* Предотвращаем выделение и drag */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.lightbox-overlay.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.lightbox-overlay.visible {
  opacity: 1;
}

/*
 * Кнопка закрытия lightbox перемещена в нижнюю панель контролов
 * чтобы не конфликтовать с кнопкой X Telegram (сверху справа)
 */
.lightbox-close {
  /* Стили теперь применяются через .lightbox-controls .lightbox-close */
  display: none;
}

.lightbox-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none; /* Для pinch-to-zoom */
  cursor: grab;
}

.lightbox-container.dragging {
  cursor: grabbing;
}

.lightbox-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: center center;
  transition: transform 0.1s ease-out;
  /* Полностью блокируем взаимодействие на уровне изображения */
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  touch-action: none;
  pointer-events: auto;
}

.lightbox-image.no-transition {
  transition: none;
}

.lightbox-controls {
  position: absolute;
  bottom: calc(24px + var(--tg-safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(0, 0, 0, 0.6);
  padding: 12px 20px;
  border-radius: 24px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.lightbox-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  transition: all 0.3s var(--ease-spring),
              box-shadow 0.3s var(--ease-smooth);
}

/* Ripple for lightbox buttons */
.lightbox-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.5) 0%, transparent 70%);
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
  pointer-events: none;
  border-radius: 50%;
}

.lightbox-btn:active::before {
  animation: rippleEffect 0.4s ease-out;
}

.lightbox-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.2),
              0 4px 10px rgba(0, 0, 0, 0.3);
}

.lightbox-btn:active {
  transform: scale(0.9);
  box-shadow: none;
}

/* Кнопка закрытия в нижней панели - увеличенная и красная для видимости */
.lightbox-controls .lightbox-close-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: rgba(244, 67, 54, 0.8);
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  margin-left: 8px;
}

.lightbox-controls .lightbox-close-btn:hover {
  background: rgba(244, 67, 54, 1);
  transform: scale(1.1);
}

.lightbox-controls .lightbox-close-btn:active {
  transform: scale(0.9);
}

.lightbox-zoom-level {
  font-size: 14px;
  font-weight: 600;
  color: white;
  min-width: 50px;
  text-align: center;
}

/* Zoomable image cursor hint */
.result-image.zoomable {
  cursor: zoom-in;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.result-image.zoomable:hover {
  transform: scale(1.02);
  box-shadow: 0 8px 30px rgba(106, 106, 255, 0.3);
}

.result-image.zoomable:active {
  transform: scale(0.98);
}

/* ===== CONFIRM SPEND MODAL ===== */
.confirm-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  padding: 20px;
}

.confirm-modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.confirm-modal {
  background: linear-gradient(145deg, #232347, #1a1a2e);
  border-radius: 20px;
  padding: 28px 24px;
  max-width: 340px;
  width: 100%;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.confirm-modal-overlay.visible .confirm-modal {
  transform: scale(1) translateY(0);
}

.confirm-modal-icon {
  font-size: 48px;
  text-align: center;
  margin-bottom: 12px;
  animation: iconPulse 2s ease-in-out infinite;
}

@keyframes iconPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.confirm-modal-title {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.confirm-modal-description {
  font-size: 14px;
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.4;
}

.confirm-modal-cost {
  background: rgba(106, 106, 255, 0.1);
  border: 1px solid rgba(106, 106, 255, 0.2);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 24px;
}

.cost-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.cost-row:not(:last-child) {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.cost-row .cost-label {
  font-size: 14px;
  color: var(--text-secondary);
}

.cost-row .cost-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.cost-row:first-child .cost-value {
  color: #ff6b6b;
  font-size: 18px;
}

.cost-row.balance .cost-value {
  color: #ffd700;
}

.cost-row.remaining .cost-value {
  color: #4caf50;
}

.cost-row.remaining.negative .cost-value {
  color: #f44336;
}

.confirm-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.confirm-btn {
  flex: 1;
  min-width: 120px;
  padding: 14px 20px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s var(--ease-spring),
              box-shadow 0.3s var(--ease-smooth);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* Ripple for confirm buttons */
.confirm-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.4) 0%, transparent 70%);
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
  pointer-events: none;
  border-radius: inherit;
}

.confirm-btn:active::before {
  animation: rippleEffect 0.5s ease-out;
}

.confirm-btn.cancel {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.confirm-btn.cancel:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(255, 255, 255, 0.1);
}

.confirm-btn.cancel:active {
  transform: scale(0.97);
  box-shadow: none;
}

.confirm-btn.confirm {
  background: linear-gradient(135deg, #6a6aff, #8a2be2);
  background-size: 200% 200%;
  color: white;
  box-shadow: 0 4px 15px rgba(106, 106, 255, 0.4),
              0 0 0 0 rgba(106, 106, 255, 0);
  border: 1px solid rgba(106, 106, 255, 0.3);
}

.confirm-btn.confirm:hover {
  background: linear-gradient(135deg, #7a7aff, #9a3bef);
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 25px rgba(106, 106, 255, 0.5),
              0 0 20px rgba(138, 43, 226, 0.3);
  animation: gradientShift 3s ease infinite;
}

.confirm-btn.confirm:active {
  transform: scale(0.97);
  box-shadow: 0 2px 10px rgba(106, 106, 255, 0.4);
}

.confirm-btn.confirm:disabled {
  background: #555;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
  border-color: transparent;
}

.confirm-btn .btn-icon {
  font-size: 16px;
  transition: transform 0.3s var(--ease-spring);
}

.confirm-btn:hover .btn-icon {
  transform: scale(1.15);
}

/* Insufficient balance state */
.confirm-modal.insufficient .confirm-btn.confirm {
  background: linear-gradient(135deg, #666, #444);
  box-shadow: none;
  cursor: not-allowed;
}

.confirm-modal.insufficient .cost-row.remaining .cost-value {
  color: #f44336;
}

/* Animation for tokens */
.cost-value.animating {
  animation: tokenCount 0.4s ease-out;
}

@keyframes tokenCount {
  0% { transform: scale(1.2); opacity: 0.7; }
  100% { transform: scale(1); opacity: 1; }
}

/* =====================================================
   GLASS BUTTONS (Premium Style)
   ===================================================== */

.confirm-btn-glass {
  position: relative;
  flex: 1;
  min-width: 120px;
  padding: 16px 24px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.confirm-btn-glass .btn-shine {
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  transition: left 0.5s ease;
}

.confirm-btn-glass:hover .btn-shine {
  left: 100%;
}

.confirm-btn-glass .btn-text {
  position: relative;
  z-index: 1;
}

/* Animated particles effect */
.confirm-btn-glass .btn-particles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
}

.confirm-btn-glass .btn-particles::before,
.confirm-btn-glass .btn-particles::after {
  content: '';
  position: absolute;
  width: 6px;
  height: 6px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  opacity: 0;
  filter: blur(1px);
}

.confirm-btn-glass.confirm:hover .btn-particles::before {
  animation: particleFloat1 1.5s ease-in-out infinite;
}

.confirm-btn-glass.confirm:hover .btn-particles::after {
  animation: particleFloat2 1.8s ease-in-out infinite 0.3s;
}

@keyframes particleFloat1 {
  0% {
    opacity: 0;
    transform: translate(20%, 80%) scale(0);
  }
  20% {
    opacity: 1;
    transform: translate(30%, 50%) scale(1);
  }
  80% {
    opacity: 0.8;
    transform: translate(70%, 20%) scale(0.8);
  }
  100% {
    opacity: 0;
    transform: translate(80%, 0%) scale(0);
  }
}

@keyframes particleFloat2 {
  0% {
    opacity: 0;
    transform: translate(70%, 90%) scale(0);
  }
  20% {
    opacity: 1;
    transform: translate(50%, 60%) scale(1);
  }
  80% {
    opacity: 0.8;
    transform: translate(30%, 30%) scale(0.6);
  }
  100% {
    opacity: 0;
    transform: translate(20%, 10%) scale(0);
  }
}

/* Cancel Button - Frosted Glass */
.confirm-btn-glass.cancel {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.1) 0%,
    rgba(255, 255, 255, 0.05) 100%
  );
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.8);
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.confirm-btn-glass.cancel:hover {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.15) 0%,
    rgba(255, 255, 255, 0.08) 100%
  );
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
  transform: translateY(-3px);
  box-shadow:
    0 8px 25px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.confirm-btn-glass.cancel:active {
  transform: translateY(-1px) scale(0.98);
}

/* Confirm Button - Gradient Glow */
.confirm-btn-glass.confirm {
  background: linear-gradient(
    135deg,
    #667eea 0%,
    #764ba2 50%,
    #f093fb 100%
  );
  background-size: 200% 200%;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow:
    0 4px 20px rgba(102, 126, 234, 0.4),
    0 0 40px rgba(118, 75, 162, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  animation: gradientFlow 4s ease infinite;
}

.confirm-btn-glass.confirm:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow:
    0 8px 30px rgba(102, 126, 234, 0.6),
    0 0 60px rgba(240, 147, 251, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.confirm-btn-glass.confirm:active {
  transform: translateY(-1px) scale(0.98);
}

.confirm-btn-glass.confirm:disabled {
  background: linear-gradient(135deg, #4a4a5a 0%, #3a3a4a 100%);
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
  animation: none;
}

@keyframes gradientFlow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Insufficient balance - update for glass buttons */
.confirm-modal.insufficient .confirm-btn-glass.confirm {
  background: linear-gradient(135deg, #4a4a5a 0%, #3a3a4a 100%);
  box-shadow: none;
  cursor: not-allowed;
  animation: none;
}

/* =====================================================
   WELCOME BONUS MODAL
   ===================================================== */

.welcome-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.welcome-modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.welcome-modal {
  position: relative;
  background: linear-gradient(145deg, rgba(30, 30, 50, 0.95), rgba(20, 20, 35, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  padding: 40px 32px;
  max-width: 360px;
  width: 90%;
  text-align: center;
  box-shadow:
    0 25px 80px rgba(0, 0, 0, 0.5),
    0 0 60px rgba(138, 43, 226, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transform: scale(0.8) translateY(30px);
  opacity: 0;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease;
  overflow: hidden;
}

.welcome-modal-overlay.visible .welcome-modal {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* Floating particles background */
.welcome-particles {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  pointer-events: none;
}

.welcome-particles .particle {
  position: absolute;
  width: 6px;
  height: 6px;
  background: linear-gradient(135deg, #ffd700, #ff6b6b);
  border-radius: 50%;
  opacity: 0.6;
  animation: floatParticle 4s ease-in-out infinite;
}

.welcome-particles .particle:nth-child(1) { left: 10%; top: 20%; animation-delay: 0s; }
.welcome-particles .particle:nth-child(2) { left: 85%; top: 15%; animation-delay: 0.5s; }
.welcome-particles .particle:nth-child(3) { left: 20%; top: 70%; animation-delay: 1s; }
.welcome-particles .particle:nth-child(4) { left: 75%; top: 75%; animation-delay: 1.5s; }
.welcome-particles .particle:nth-child(5) { left: 50%; top: 10%; animation-delay: 2s; }

@keyframes floatParticle {
  0%, 100% { transform: translateY(0) scale(1); opacity: 0.6; }
  50% { transform: translateY(-15px) scale(1.2); opacity: 1; }
}

/* Icon container */
.welcome-icon-container {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.welcome-icon-glow {
  position: absolute;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(255, 215, 0, 0.4) 0%, transparent 70%);
  border-radius: 50%;
  animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.3); opacity: 0.8; }
}

.welcome-icon {
  font-size: 72px;
  animation: bounceIn 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards,
             floatIcon 3s ease-in-out 0.8s infinite;
  filter: drop-shadow(0 8px 20px rgba(255, 215, 0, 0.4));
}

@keyframes bounceIn {
  0% { transform: scale(0) rotate(-20deg); opacity: 0; }
  50% { transform: scale(1.2) rotate(10deg); }
  70% { transform: scale(0.9) rotate(-5deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes floatIcon {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* Sparkles around icon */
.welcome-sparkles {
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.welcome-sparkles .sparkle {
  position: absolute;
  font-size: 20px;
  opacity: 0;
  animation: sparkleAnim 2s ease-in-out infinite;
}

.welcome-sparkles .sparkle:nth-child(1) { top: 0; left: 50%; transform: translateX(-50%); animation-delay: 0s; }
.welcome-sparkles .sparkle:nth-child(2) { top: 50%; right: 0; transform: translateY(-50%); animation-delay: 0.3s; }
.welcome-sparkles .sparkle:nth-child(3) { bottom: 0; left: 50%; transform: translateX(-50%); animation-delay: 0.6s; }
.welcome-sparkles .sparkle:nth-child(4) { top: 50%; left: 0; transform: translateY(-50%); animation-delay: 0.9s; }

@keyframes sparkleAnim {
  0%, 100% { opacity: 0; transform: scale(0.5); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* Title */
.welcome-title {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 8px;
  background: linear-gradient(135deg, #ffd700, #ff9500, #ff6b6b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 3s ease-in-out infinite;
  background-size: 200% 100%;
}

@keyframes shimmer {
  0% { background-position: 100% 0; }
  50% { background-position: 0 0; }
  100% { background-position: 100% 0; }
}

.welcome-subtitle {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.7);
  margin: 0 0 24px;
}

/* Bonus amount */
.welcome-bonus {
  margin: 0 0 20px;
}

.bonus-amount {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.bonus-number {
  font-size: 56px;
  font-weight: 800;
  background: linear-gradient(135deg, #6a6aff, #a855f7, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 40px rgba(168, 85, 247, 0.5);
}

.bonus-icon {
  font-size: 40px;
  animation: zap 0.5s ease-in-out infinite alternate;
}

@keyframes zap {
  0% { transform: scale(1) rotate(-5deg); }
  100% { transform: scale(1.1) rotate(5deg); }
}

.bonus-label {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-top: 4px;
}

/* Info text */
.welcome-info {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.6;
  margin: 0 0 28px;
}

.welcome-info strong {
  color: #ffd700;
}

.welcome-note {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  display: inline-block;
  margin-top: 6px;
}

/* CTA Button */
.welcome-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 40px;
  font-size: 17px;
  font-weight: 600;
  color: white;
  background: linear-gradient(135deg, #8b5cf6, #6366f1, #4f46e5);
  background-size: 200% 200%;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow:
    0 8px 30px rgba(99, 102, 241, 0.4),
    0 0 0 0 rgba(99, 102, 241, 0.4);
  transition: all 0.3s var(--ease-spring),
              box-shadow 0.3s var(--ease-smooth);
  animation: btnPulse 2s ease-in-out infinite,
             gradientShift 4s ease infinite;
}

/* Ripple for welcome button */
.welcome-btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.5) 0%, transparent 70%);
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
  pointer-events: none;
  border-radius: inherit;
}

.welcome-btn:active::after {
  animation: rippleEffect 0.5s ease-out;
}

.welcome-btn:hover {
  transform: translateY(-4px) scale(1.03);
  box-shadow:
    0 15px 45px rgba(99, 102, 241, 0.5),
    0 0 30px rgba(139, 92, 246, 0.4),
    0 0 0 0 rgba(99, 102, 241, 0.4);
}

.welcome-btn:active {
  transform: translateY(0) scale(0.97);
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.welcome-btn .btn-icon {
  font-size: 20px;
  transition: transform 0.3s var(--ease-spring);
}

.welcome-btn:hover .btn-icon {
  transform: translateX(6px) rotate(15deg) scale(1.1);
  animation: iconBounce 0.5s ease;
}

@keyframes btnPulse {
  0%, 100% { box-shadow: 0 8px 30px rgba(99, 102, 241, 0.4), 0 0 0 0 rgba(99, 102, 241, 0.4); }
  50% { box-shadow: 0 8px 30px rgba(99, 102, 241, 0.4), 0 0 0 12px rgba(99, 102, 241, 0); }
}

/* Hide modal closing animation */
.welcome-modal-overlay.closing {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.welcome-modal-overlay.closing .welcome-modal {
  transform: scale(0.9) translateY(-20px);
  opacity: 0;
}

/* =====================================================
   ADVANCED ANIME ANIMATIONS
   Энергия загрузки, материализация, 3D tilt, ударная волна
   ===================================================== */

/* --- ENERGY LOADING - Пульсирующие круги энергии --- */
@keyframes energyRing {
  0% {
    transform: scale(0.8);
    opacity: 0;
    border-width: 4px;
  }
  30% {
    opacity: 1;
  }
  100% {
    transform: scale(2);
    opacity: 0;
    border-width: 1px;
  }
}

@keyframes energyCore {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 20px var(--glow-primary),
                0 0 40px var(--glow-primary),
                inset 0 0 20px rgba(255, 255, 255, 0.3);
  }
  50% {
    transform: scale(1.1);
    box-shadow: 0 0 30px var(--glow-primary),
                0 0 60px var(--glow-purple),
                0 0 80px var(--glow-pink),
                inset 0 0 30px rgba(255, 255, 255, 0.5);
  }
}

@keyframes energySpark {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.energy-loader {
  position: relative;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.energy-loader .energy-core {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary), var(--glow-purple));
  animation: energyCore 1.5s ease-in-out infinite;
}

.energy-loader .energy-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 3px solid var(--accent-primary);
  opacity: 0;
}

.energy-loader .energy-ring:nth-child(1) { animation: energyRing 2s ease-out infinite; }
.energy-loader .energy-ring:nth-child(2) { animation: energyRing 2s ease-out infinite 0.4s; }
.energy-loader .energy-ring:nth-child(3) { animation: energyRing 2s ease-out infinite 0.8s; }

.energy-loader .energy-sparks {
  position: absolute;
  width: 100%;
  height: 100%;
  animation: energySpark 3s linear infinite;
}

.energy-loader .energy-sparks::before,
.energy-loader .energy-sparks::after {
  content: '';
  position: absolute;
  width: 6px;
  height: 6px;
  background: var(--accent-gold);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--glow-gold);
}

.energy-loader .energy-sparks::before {
  top: 0;
  left: 50%;
  transform: translateX(-50%);
}

.energy-loader .energy-sparks::after {
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}

/* Улучшенный status-bar с энергией */
.status-bar.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  min-height: 140px;
  background: linear-gradient(135deg,
    rgba(106, 106, 255, 0.15),
    rgba(193, 106, 255, 0.1),
    rgba(106, 106, 255, 0.15));
  backdrop-filter: blur(10px);
  border: 1px solid rgba(106, 106, 255, 0.3);
  animation: neonPulse 2s ease-in-out infinite;
  --glow-color: var(--glow-primary);
}

.status-bar.loading .status-message {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-primary);
  text-shadow: 0 0 10px var(--glow-primary);
  animation: textGlow 2s ease-in-out infinite;
}

@keyframes textGlow {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; text-shadow: 0 0 20px var(--glow-primary), 0 0 40px var(--glow-purple); }
}

/* --- RESULT MATERIALIZATION - Пиксельная сборка --- */
@keyframes materializeIn {
  0% {
    opacity: 0;
    filter: blur(20px) saturate(0) brightness(2);
    transform: scale(0.8) rotate(-2deg);
    clip-path: polygon(
      0% 0%, 5% 0%, 5% 5%, 0% 5%,
      0% 15%, 10% 15%, 10% 10%, 0% 10%,
      0% 25%, 15% 25%, 15% 20%, 0% 20%
    );
  }
  20% {
    opacity: 0.5;
    filter: blur(10px) saturate(0.5) brightness(1.5);
    clip-path: polygon(
      0% 0%, 30% 0%, 30% 30%, 0% 30%,
      0% 40%, 50% 40%, 50% 50%, 0% 50%,
      0% 60%, 70% 60%, 70% 70%, 0% 70%
    );
  }
  50% {
    filter: blur(5px) saturate(0.8) brightness(1.2);
    transform: scale(1.02) rotate(0.5deg);
    clip-path: polygon(
      0% 0%, 60% 0%, 60% 60%, 100% 60%,
      100% 100%, 0% 100%
    );
  }
  75% {
    filter: blur(2px) saturate(1) brightness(1.1);
    clip-path: polygon(
      0% 0%, 100% 0%, 100% 80%, 0% 80%
    );
  }
  100% {
    opacity: 1;
    filter: blur(0) saturate(1) brightness(1);
    transform: scale(1) rotate(0deg);
    clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%);
  }
}

@keyframes materializeGlow {
  0% {
    box-shadow: 0 0 60px rgba(106, 106, 255, 0.8),
                0 0 100px rgba(138, 43, 226, 0.6),
                inset 0 0 60px rgba(255, 255, 255, 0.3);
  }
  100% {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  }
}

@keyframes scanLine {
  0% {
    top: 0%;
    opacity: 1;
  }
  100% {
    top: 100%;
    opacity: 0;
  }
}

.result-image.materializing {
  animation: materializeIn 1s cubic-bezier(0.16, 1, 0.3, 1) forwards,
             materializeGlow 1s ease-out forwards;
}

/* Scan line overlay during materialization */
.result-image-container.materializing::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg,
    transparent,
    rgba(106, 106, 255, 0.8),
    rgba(255, 255, 255, 0.9),
    rgba(106, 106, 255, 0.8),
    transparent
  );
  box-shadow: 0 0 20px rgba(106, 106, 255, 0.8),
              0 0 40px rgba(106, 106, 255, 0.5);
  animation: scanLine 1s ease-out forwards;
  z-index: 10;
}

/* --- 3D TILT EFFECT - Parallax при наведении --- */
.card-3d-tilt {
  transform-style: preserve-3d;
  perspective: 1000px;
  transition: transform 0.3s var(--ease-smooth);
}

.card-3d-tilt:hover {
  transform: rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg)) scale(1.02);
}

.card-3d-tilt .card-content {
  transform: translateZ(20px);
  transition: transform 0.3s var(--ease-smooth);
}

.card-3d-tilt:hover .card-content {
  transform: translateZ(40px);
}

/* Применяем к карточкам */
.card {
  transform-style: preserve-3d;
  perspective: 1000px;
  transition: all 0.4s var(--ease-spring);
}

.card:hover {
  transform: translateY(-5px) rotateX(2deg);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4),
              0 0 20px rgba(106, 106, 255, 0.2);
}

/* Глубина для внутренних элементов */
.card .card-title {
  transform: translateZ(10px);
  transition: transform 0.3s var(--ease-smooth);
}

.card:hover .card-title {
  transform: translateZ(25px);
}

/* --- SHOCKWAVE - Ударная волна для модальных окон --- */
@keyframes shockwave {
  0% {
    transform: scale(0);
    opacity: 0.8;
    border-width: 8px;
  }
  50% {
    opacity: 0.4;
  }
  100% {
    transform: scale(3);
    opacity: 0;
    border-width: 1px;
  }
}

@keyframes modalImpact {
  0% {
    transform: scale(0.5) translateY(50px);
    opacity: 0;
  }
  60% {
    transform: scale(1.05) translateY(-10px);
  }
  80% {
    transform: scale(0.98) translateY(5px);
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

@keyframes impactFlash {
  0% {
    opacity: 0;
  }
  20% {
    opacity: 1;
    background: radial-gradient(circle at center,
      rgba(255, 255, 255, 0.9) 0%,
      rgba(106, 106, 255, 0.5) 30%,
      transparent 70%
    );
  }
  100% {
    opacity: 0;
  }
}

/* Shockwave элемент */
.modal-shockwave {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100px;
  height: 100px;
  margin: -50px 0 0 -50px;
  border-radius: 50%;
  border: 4px solid var(--accent-primary);
  pointer-events: none;
  opacity: 0;
}

.modal-overlay.shockwave-active .modal-shockwave:nth-child(1) {
  animation: shockwave 0.6s ease-out forwards;
}

.modal-overlay.shockwave-active .modal-shockwave:nth-child(2) {
  animation: shockwave 0.6s ease-out 0.1s forwards;
}

.modal-overlay.shockwave-active .modal-shockwave:nth-child(3) {
  animation: shockwave 0.6s ease-out 0.2s forwards;
}

/* Улучшенная анимация модальных окон */
.modal-overlay.active .modal {
  animation: modalImpact 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Flash при открытии */
.modal-overlay.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  animation: impactFlash 0.4s ease-out forwards;
}

/* Confirm modal с ударной волной */
.confirm-modal-overlay.visible .confirm-modal {
  animation: modalImpact 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.confirm-modal-overlay.visible::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 200px;
  height: 200px;
  margin: -100px 0 0 -100px;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(106, 106, 255, 0.4) 0%,
    transparent 70%
  );
  animation: shockwave 0.5s ease-out forwards;
  pointer-events: none;
}

/* --- PARTICLE EXPLOSION - Взрыв частиц при успехе --- */
@keyframes particleExplode {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--tx), var(--ty)) scale(0);
    opacity: 0;
  }
}

.success-particles {
  position: absolute;
  top: 50%;
  left: 50%;
  pointer-events: none;
}

.success-particles .particle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: particleExplode 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.success-particles .particle:nth-child(1) { --tx: -80px; --ty: -60px; background: #ff6b6b; }
.success-particles .particle:nth-child(2) { --tx: 70px; --ty: -70px; background: #ffd700; }
.success-particles .particle:nth-child(3) { --tx: 90px; --ty: 20px; background: #6a6aff; }
.success-particles .particle:nth-child(4) { --tx: -60px; --ty: 80px; background: #4caf50; }
.success-particles .particle:nth-child(5) { --tx: 40px; --ty: 90px; background: #ff9800; }
.success-particles .particle:nth-child(6) { --tx: -90px; --ty: 10px; background: #e91e63; }
.success-particles .particle:nth-child(7) { --tx: 0px; --ty: -90px; background: #00bcd4; }
.success-particles .particle:nth-child(8) { --tx: 60px; --ty: -40px; background: #9c27b0; }

/* --- HOVER GLOW для интерактивных элементов --- */
.interactive-glow {
  position: relative;
  overflow: visible;
}

.interactive-glow::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(45deg,
    var(--accent-primary),
    var(--glow-purple),
    var(--glow-pink),
    var(--accent-gold),
    var(--accent-primary)
  );
  background-size: 400% 400%;
  border-radius: inherit;
  opacity: 0;
  z-index: -1;
  transition: opacity 0.3s ease;
  animation: gradientShift 3s ease infinite;
  filter: blur(8px);
}

.interactive-glow:hover::before {
  opacity: 0.6;
}

/* --- TYPING ANIMATION для промптов --- */
@keyframes typingCursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.typing-indicator .dot {
  width: 6px;
  height: 6px;
  background: var(--accent-primary);
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-indicator .dot:nth-child(1) { animation-delay: 0s; }
.typing-indicator .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-8px); }
}

/* =====================================================
   BALANCE ANIMATIONS
   ===================================================== */

/* Glow effect when balance increases */
@keyframes balanceGlow {
  0% {
    box-shadow: 0 0 5px rgba(106, 106, 255, 0.5);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 25px rgba(106, 106, 255, 0.9),
                0 0 50px rgba(168, 85, 247, 0.6),
                0 0 75px rgba(255, 215, 0, 0.4);
    transform: scale(1.1);
  }
  100% {
    box-shadow: 0 0 5px rgba(106, 106, 255, 0.5);
    transform: scale(1);
  }
}

/* Bounce effect when balance changes */
@keyframes balanceBounce {
  0%, 100% { transform: scale(1); }
  25% { transform: scale(1.15); }
  50% { transform: scale(0.95); }
  75% { transform: scale(1.05); }
}

/* Shake effect when insufficient balance */
@keyframes balanceShake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
  20%, 40%, 60%, 80% { transform: translateX(4px); }
}

/* Color pulse for balance increase */
@keyframes balancePulseUp {
  0% { color: inherit; }
  50% { color: #4ade80; }
  100% { color: inherit; }
}

/* Color pulse for balance decrease */
@keyframes balancePulseDown {
  0% { color: inherit; }
  50% { color: #f87171; }
  100% { color: inherit; }
}

/* Balance badge animation states */
.balance-badge.glow {
  animation: balanceGlow 0.8s ease-out;
}

.balance-badge.bounce {
  animation: balanceBounce 0.5s ease-out;
}

.balance-badge.shake {
  animation: balanceShake 0.6s ease-out;
}

.balance-badge.pulse-up span {
  animation: balancePulseUp 0.6s ease-out;
}

.balance-badge.pulse-down span {
  animation: balancePulseDown 0.6s ease-out;
}

/* Balance card animations */
.balance-card.glow {
  animation: balanceGlow 1s ease-out;
}

.balance-card .amount.counting {
  transition: none;
}

/* Particle burst effect (for deductions) */
@keyframes particleBurst {
  0% {
    opacity: 1;
    transform: scale(0) translate(0, 0);
  }
  100% {
    opacity: 0;
    transform: scale(1) translate(var(--tx, 0), var(--ty, 0));
  }
}

.balance-particle {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-gold);
  pointer-events: none;
  animation: particleBurst 0.6s ease-out forwards;
}

/* Gradient shine effect */
@keyframes balanceShine {
  0% { background-position: -100% 0; }
  100% { background-position: 200% 0; }
}

.balance-badge.shine {
  background: linear-gradient(
    90deg,
    var(--accent-primary) 0%,
    var(--accent-gold) 25%,
    var(--accent-secondary) 50%,
    var(--accent-gold) 75%,
    var(--accent-primary) 100%
  );
  background-size: 200% 100%;
  animation: balanceShine 1.5s ease-in-out;
}

/* Number counter transition */
.balance-badge span,
.balance-card .amount {
  transition: transform 0.2s ease-out;
}

.balance-badge span.updating {
  transform: scale(1.1);
}

/* =====================================================
   TOPUP SUCCESS CELEBRATION
   ===================================================== */

.topup-success-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.topup-success-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.topup-success-container {
  text-align: center;
  transform: scale(0.5);
  opacity: 0;
  transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.topup-success-overlay.visible .topup-success-container {
  transform: scale(1);
  opacity: 1;
}

/* Animated checkmark circle */
.success-checkmark {
  width: 120px;
  height: 120px;
  margin: 0 auto 24px;
  position: relative;
}

.success-checkmark-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 0 40px rgba(34, 197, 94, 0.6),
    0 0 80px rgba(34, 197, 94, 0.4),
    0 0 120px rgba(34, 197, 94, 0.2);
  animation: successPulse 2s ease-in-out infinite;
}

.success-checkmark-icon {
  width: 60px;
  height: 60px;
  stroke: white;
  stroke-width: 3;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.success-checkmark-icon .checkmark-path {
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: drawCheck 0.6s ease-out 0.3s forwards;
}

@keyframes drawCheck {
  to { stroke-dashoffset: 0; }
}

@keyframes successPulse {
  0%, 100% {
    box-shadow:
      0 0 40px rgba(34, 197, 94, 0.6),
      0 0 80px rgba(34, 197, 94, 0.4),
      0 0 120px rgba(34, 197, 94, 0.2);
    transform: scale(1);
  }
  50% {
    box-shadow:
      0 0 60px rgba(34, 197, 94, 0.8),
      0 0 100px rgba(34, 197, 94, 0.5),
      0 0 150px rgba(34, 197, 94, 0.3);
    transform: scale(1.05);
  }
}

/* Success rings expanding */
.success-rings {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.success-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(34, 197, 94, 0.6);
  border-radius: 50%;
  animation: ringExpand 1.5s ease-out forwards;
}

.success-ring:nth-child(1) { animation-delay: 0.2s; }
.success-ring:nth-child(2) { animation-delay: 0.4s; }
.success-ring:nth-child(3) { animation-delay: 0.6s; }

@keyframes ringExpand {
  0% {
    width: 120px;
    height: 120px;
    opacity: 1;
  }
  100% {
    width: 300px;
    height: 300px;
    opacity: 0;
  }
}

/* Success title */
.success-title {
  font-size: 32px;
  font-weight: 800;
  background: linear-gradient(135deg, #22c55e, #4ade80, #86efac);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0 0 12px 0;
  animation: successTitleGlow 2s ease-in-out infinite;
}

@keyframes successTitleGlow {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.3); }
}

/* Success amount */
.success-amount {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
}

.success-amount-value {
  font-size: 56px;
  font-weight: 900;
  color: #ffd700;
  text-shadow:
    0 0 20px rgba(255, 215, 0, 0.8),
    0 0 40px rgba(255, 215, 0, 0.5),
    0 0 60px rgba(255, 215, 0, 0.3);
  animation: amountPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.5s both;
}

@keyframes amountPop {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.success-amount-icon {
  font-size: 40px;
  animation: iconFloat 2s ease-in-out infinite;
}

@keyframes iconFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-10px) rotate(10deg); }
}

.success-amount-label {
  font-size: 18px;
  color: #a3a3a3;
  text-transform: uppercase;
  letter-spacing: 3px;
  animation: fadeInUp 0.5s ease-out 0.7s both;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* New balance section */
.success-new-balance {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 16px;
  padding: 16px 32px;
  margin: 24px auto;
  display: inline-block;
  animation: fadeInUp 0.5s ease-out 0.9s both;
}

.success-new-balance-label {
  font-size: 14px;
  color: #a3a3a3;
  margin-bottom: 4px;
}

.success-new-balance-value {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
}

.success-new-balance-value span {
  color: #a855f7;
}

/* Bonus note */
.success-bonus-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 12px 0;
  padding: 10px 16px;
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.15), rgba(34, 197, 94, 0.1));
  border: 1px solid rgba(74, 222, 128, 0.3);
  border-radius: 12px;
  font-size: 14px;
  color: #4ade80;
  animation: bonusNoteAppear 0.5s ease-out 0.3s both;
}

.success-bonus-note .bonus-icon {
  font-size: 18px;
}

@keyframes bonusNoteAppear {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Close button */
.success-close-btn {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  border: none;
  padding: 16px 48px;
  border-radius: 14px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 24px;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
  transition: all 0.3s ease;
  animation: fadeInUp 0.5s ease-out 1.1s both;
}

.success-close-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 30px rgba(99, 102, 241, 0.6);
}

.success-close-btn:active {
  transform: translateY(0);
}

/* Flying coins animation */
.flying-coins {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  overflow: hidden;
}

.flying-coin {
  position: absolute;
  font-size: 24px;
  animation: coinFly 2s ease-out forwards;
}

@keyframes coinFly {
  0% {
    opacity: 1;
    transform: translateY(100vh) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translateY(-100px) rotate(720deg);
  }
}

/* Sparkles */
.success-sparkles {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.success-sparkle {
  position: absolute;
  font-size: 20px;
  animation: sparkleFloat 2s ease-in-out infinite;
}

.success-sparkle:nth-child(1) { top: -80px; left: -60px; animation-delay: 0s; }
.success-sparkle:nth-child(2) { top: -60px; left: 60px; animation-delay: 0.3s; }
.success-sparkle:nth-child(3) { top: 40px; left: -80px; animation-delay: 0.6s; }
.success-sparkle:nth-child(4) { top: 60px; left: 80px; animation-delay: 0.9s; }
.success-sparkle:nth-child(5) { top: -40px; left: 0; animation-delay: 0.15s; }
.success-sparkle:nth-child(6) { top: 80px; left: 0; animation-delay: 0.45s; }

@keyframes sparkleFloat {
  0%, 100% {
    opacity: 0.6;
    transform: scale(1) rotate(0deg);
  }
  50% {
    opacity: 1;
    transform: scale(1.3) rotate(180deg);
  }
}

/* ===== PAYMENT HISTORY ===== */
.payment-history-section {
  margin-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 12px;
}

.payment-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  transition: color 0.2s;
}

.payment-history-header:hover {
  color: var(--text-primary);
}

.payment-history-arrow {
  font-size: 10px;
  transition: transform 0.2s;
}

.payment-history-list {
  max-height: 200px;
  overflow-y: auto;
  margin-top: 8px;
}

.payment-history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  margin-bottom: 6px;
}

.payment-history-item:last-child {
  margin-bottom: 0;
}

.payment-history-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.payment-history-gens {
  font-size: 15px;
  font-weight: 600;
  color: var(--success);
}

.payment-history-date {
  font-size: 11px;
  color: var(--text-secondary);
}

.payment-history-amount {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.payment-history-empty,
.payment-history-loading {
  text-align: center;
  padding: 20px;
  color: var(--text-secondary);
  font-size: 13px;
}

/* ===== REFERRAL SECTION ===== */
.referral-section {
  margin-top: 20px;
  padding: 16px;
  background: linear-gradient(135deg, rgba(106, 106, 255, 0.1), rgba(138, 43, 226, 0.08));
  border: 1px solid rgba(106, 106, 255, 0.25);
  border-radius: var(--border-radius);
}

.referral-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.referral-icon {
  font-size: 20px;
}

.referral-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.referral-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 14px;
}

.referral-stat {
  flex: 1;
  text-align: center;
  padding: 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
}

.referral-stat-value {
  display: block;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-primary);
  margin-bottom: 2px;
}

.referral-stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.referral-link-container {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.referral-link-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.referral-link-input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.referral-btn {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.referral-btn svg {
  width: 18px;
  height: 18px;
}

.referral-btn.copy-btn {
  background: rgba(106, 106, 255, 0.2);
  color: var(--accent-primary);
  border: 1px solid rgba(106, 106, 255, 0.3);
}

.referral-btn.copy-btn:hover {
  background: rgba(106, 106, 255, 0.3);
  transform: scale(1.05);
}

.referral-btn.copy-btn:active {
  transform: scale(0.95);
}

.referral-btn.share-btn {
  background: linear-gradient(135deg, #0088cc, #229ed9);
  color: white;
  border: none;
}

.referral-btn.share-btn:hover {
  background: linear-gradient(135deg, #0099dd, #33aeea);
  transform: scale(1.05);
}

.referral-btn.share-btn:active {
  transform: scale(0.95);
}

.referral-hint {
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.4;
}

/* Referral animation on copy */
@keyframes referralCopied {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); background: rgba(74, 222, 128, 0.3); }
  100% { transform: scale(1); }
}

.referral-btn.copied {
  animation: referralCopied 0.3s ease;
}

/* =========================================
   Payment Method Modal
   ========================================= */

.payment-method-modal {
  max-width: 340px;
  padding: 24px;
}

.payment-method-header {
  text-align: center;
  margin-bottom: 20px;
}

.payment-method-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 8px 0;
}

.payment-method-info {
  font-size: 14px;
  color: var(--text-secondary);
}

.payment-method-gens {
  font-weight: 600;
  color: var(--accent-primary);
}

.payment-method-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.payment-method-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  text-align: left;
}

.payment-method-btn:hover {
  border-color: var(--accent-primary);
  background: var(--bg-tertiary);
}

.payment-method-btn:active {
  transform: scale(0.98);
}

.payment-method-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.payment-method-label {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.payment-method-price {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.payment-method-stars {
  border-color: rgba(255, 193, 7, 0.3);
}

.payment-method-stars:hover {
  border-color: rgba(255, 193, 7, 0.6);
  background: rgba(255, 193, 7, 0.05);
}

.payment-method-card:hover {
  border-color: var(--accent-primary);
}
