@import url("https://fonts.googleapis.com/css2?family=Inter:wght@500;600&family=Space+Grotesk:wght@400;500;600;700&display=swap");

:root {
  --space-deep: #05050f;
  --space-mid: #0c0a1f;
  --nebula-purple: #7c3aed;
  --nebula-pink: #c026d3;
  --cosmic-cyan: #22d3ee;
  --star-gold: #fbbf24;
  --glass: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.12);
  --text: #f0f4ff;
  --hint: #b8c4ef;
  --accent: var(--tg-theme-button-color, #8b5cf6);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", Inter, system-ui, sans-serif;
  background: var(--space-deep);
  color: var(--text);
  overflow-x: hidden;
}

.cosmos-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(124, 58, 237, 0.35), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 10%, rgba(34, 211, 238, 0.18), transparent 50%),
    radial-gradient(ellipse 70% 50% at 50% 100%, rgba(192, 38, 211, 0.22), transparent 55%),
    linear-gradient(180deg, #05050f 0%, #0a0820 45%, #120a28 100%);
}

.stars-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 20px 30px, rgba(255, 255, 255, 0.9), transparent),
    radial-gradient(1px 1px at 80px 120px, rgba(255, 255, 255, 0.7), transparent),
    radial-gradient(1.5px 1.5px at 160px 60px, rgba(255, 255, 255, 0.85), transparent),
    radial-gradient(1px 1px at 240px 180px, rgba(255, 255, 255, 0.6), transparent),
    radial-gradient(1px 1px at 320px 40px, rgba(255, 255, 255, 0.75), transparent),
    radial-gradient(1.5px 1.5px at 400px 140px, rgba(251, 191, 36, 0.8), transparent);
  background-size: 420px 220px;
  animation: drift 90s linear infinite;
  opacity: 0.55;
}

.stars-layer-2 {
  opacity: 0.35;
  background-size: 520px 280px;
  animation: drift 140s linear infinite reverse;
}

@keyframes drift {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-220px);
  }
}

.app {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px 32px;
}

.screen {
  width: 100%;
}

.screen.hidden {
  display: none !important;
}

#checkout-screen {
  animation: screenIn 0.22s ease-out;
}

@keyframes screenIn {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.checkout-header {
  margin-bottom: 16px;
}

.checkout-subtitle {
  margin: 8px 0 0;
  color: var(--hint);
  font-size: 14px;
  line-height: 1.45;
}

.hero {
  margin-bottom: 20px;
  text-align: center;
}

.hero-icon {
  font-size: 42px;
  line-height: 1;
  margin-bottom: 8px;
  filter: drop-shadow(0 0 18px rgba(139, 92, 246, 0.65));
}

.hero-badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.35), rgba(34, 211, 238, 0.2));
  border: 1px solid rgba(167, 139, 250, 0.45);
  color: #e9d5ff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 12px;
  box-shadow: 0 0 20px rgba(124, 58, 237, 0.25);
}

.hero h1 {
  margin: 0 0 8px;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 0%, #c4b5fd 45%, #67e8f9 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 40px rgba(139, 92, 246, 0.3);
}

.hero p {
  margin: 0;
  color: var(--hint);
  line-height: 1.55;
  font-size: 14px;
}

#shop-view {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#shop-view > .card,
#shop-view > .tabs {
  margin-bottom: 0;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 0;
  padding: 5px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
}

.tab {
  flex: 1;
  border: 0;
  border-radius: 14px;
  padding: 10px 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: var(--hint);
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.tab.active {
  background: linear-gradient(135deg, #7c3aed 0%, #6366f1 50%, #0891b2 100%);
  color: #fff;
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.35);
}

.payment-toggle {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.payment-option {
  flex: 1;
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 10px 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.04);
  color: var(--hint);
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.payment-option.active {
  background: rgba(124, 58, 237, 0.25);
  border-color: rgba(167, 139, 250, 0.6);
  color: var(--text);
}

.payment-option small {
  display: block;
  font-weight: 500;
  font-size: 11px;
  opacity: 0.85;
  margin-top: 4px;
}

.payment-title-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.payment-icon.sbp-icon {
  flex-shrink: 0;
  display: block;
  border-radius: 6px;
}

.checkout-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
}

.checkout-card .field-label {
  margin: 0;
}

.checkout-back {
  border: 0;
  background: transparent;
  color: var(--cosmic-cyan);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  padding: 0 0 12px;
  cursor: pointer;
}

.checkout-title {
  margin: 12px 0 0;
  font-size: 24px;
  line-height: 1.25;
}

.checkout-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  margin-bottom: 0;
  border-radius: 16px;
  background: rgba(124, 58, 237, 0.12);
  border: 1px solid rgba(167, 139, 250, 0.25);
}

.checkout-preview-media {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: rgba(124, 58, 237, 0.12);
  border: 1px solid rgba(167, 139, 250, 0.25);
  font-size: 32px;
  overflow: hidden;
  box-sizing: border-box;
}

.checkout-preview-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

.checkout-preview-media .premium-icon {
  width: 44px;
  height: 44px;
}

.checkout-preview-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.checkout-preview-body h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
}

.checkout-preview-body p {
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
  color: var(--hint);
}

.checkout-price {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: #e9d5ff;
}

.checkout-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(5, 5, 15, 0.45);
  border: 1px solid rgba(139, 92, 246, 0.25);
  font-size: 14px;
  line-height: 1.4;
}

.checkout-row span:first-child {
  color: var(--hint);
}

.checkout-row span:last-child {
  font-weight: 600;
  text-align: right;
  word-break: break-word;
}

.checkout-pay {
  width: 100%;
  min-width: 0;
  margin-top: 0;
  padding: 14px 16px;
  font-size: 16px;
}

.payment-toggle.checkout-payments {
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.payment-option {
  text-align: left;
  padding: 14px 14px;
}

.payment-option-price {
  display: block;
  margin-top: 6px;
  font-size: 15px;
  font-weight: 700;
  color: #e9d5ff;
}

.card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 16px;
  margin-bottom: 16px;
  backdrop-filter: blur(16px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.field-label {
  display: block;
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: #c4b5fd;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.input-wrap.recipient-field {
  position: relative;
  min-width: 0;
  overflow: hidden;
}

.input-wrap.recipient-field.has-self-btn input {
  padding-right: 62px;
}

.btn.recipient-self {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
  flex-shrink: 0;
  width: auto;
  min-width: 0;
  height: 30px;
  margin: 0;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 30px;
  border-radius: 9px;
  background: rgba(139, 92, 246, 0.3);
  color: #f3e8ff;
  border: 1px solid rgba(167, 139, 250, 0.55);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.btn.recipient-self.active {
  background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.45);
}

.input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(5, 5, 15, 0.55);
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: inset 0 0 20px rgba(124, 58, 237, 0.08);
}

.input-prefix {
  color: var(--cosmic-cyan);
  font-weight: 700;
}

input {
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
}

input::placeholder {
  color: rgba(156, 168, 217, 0.55);
}

.packages {
  display: grid;
  gap: 14px;
}

.custom-stars-card {
  margin-bottom: 0;
}

.custom-stars-hint {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.4;
  color: #c4b5fd;
}

.custom-stars-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.custom-stars-input-wrap {
  flex: 1;
  min-width: 0;
}

.custom-stars-input-wrap input {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #ffffff;
  caret-color: #c4b5fd;
}

.custom-stars-input-wrap input::placeholder {
  color: rgba(196, 181, 253, 0.55);
}

.custom-stars-suffix {
  color: #fbbf24;
  font-size: 18px;
  flex-shrink: 0;
}

.custom-stars-buy {
  width: auto;
  min-width: 96px;
  align-self: stretch;
}

.custom-stars-price {
  margin: 12px 0 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  color: #e9d5ff;
}

.custom-stars-price.muted {
  color: #c4b5fd;
  font-weight: 500;
  opacity: 0.85;
}

.subscribe-icon {
  font-size: 42px;
  text-align: center;
  margin-bottom: 12px;
}

.subscribe-title {
  margin: 0 0 10px;
  text-align: center;
  font-size: 24px;
  line-height: 1.25;
}

.subscribe-text {
  margin: 0 0 18px;
  text-align: center;
  color: #c4b5fd;
  line-height: 1.5;
  font-size: 15px;
}

.subscribe-link {
  display: block;
  width: 100%;
  text-align: center;
  text-decoration: none;
  margin-bottom: 10px;
}

.subscribe-check {
  width: 100%;
}

.package {
  position: relative;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 88px;
  align-items: center;
  gap: 12px;
  min-height: 88px;
  padding: 14px 14px 14px 12px;
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  backdrop-filter: blur(12px);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.package:hover {
  border-color: rgba(167, 139, 250, 0.45);
}

.package-media {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: rgba(124, 58, 237, 0.12);
  border: 1px solid rgba(167, 139, 250, 0.25);
  overflow: hidden;
}

.package-media-stars {
  font-size: 34px;
  line-height: 1;
  box-shadow: 0 0 16px rgba(124, 58, 237, 0.2);
}

.package-media-premium {
  background: rgba(107, 147, 255, 0.1);
  border-color: rgba(151, 111, 255, 0.28);
  padding: 10px;
  box-sizing: border-box;
  align-items: center;
  justify-content: center;
}

.premium-icon {
  display: block;
  flex-shrink: 0;
  object-fit: contain;
  object-position: center;
}

.premium-icon-lg {
  width: 48px;
  height: 48px;
  margin: 0;
}

.tab-icon {
  width: 16px;
  height: 16px;
  vertical-align: middle;
  margin-right: 4px;
  display: inline-block;
  object-fit: contain;
  object-position: center;
}

.premium-tab-icon {
  filter: drop-shadow(0 0 6px rgba(151, 111, 255, 0.35));
}

.tab:not(.active) .premium-tab-icon {
  opacity: 0.72;
}

.package-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.gift-thumb {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.gift-thumb-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 36px;
  background: transparent;
  border: 0;
}

.package-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.package-price {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  color: #e9d5ff;
}

.package-meta {
  margin: 0;
  font-size: 13px;
  line-height: 1.2;
  color: var(--hint);
}

.package.popular {
  border-color: rgba(251, 191, 36, 0.55);
  box-shadow:
    0 0 0 1px rgba(251, 191, 36, 0.2),
    0 0 24px rgba(251, 191, 36, 0.12);
}

.package-badge {
  position: absolute;
  top: -10px;
  right: 16px;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #1a1033;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  box-shadow: 0 0 14px rgba(251, 191, 36, 0.45);
}

.btn {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}

.btn:active {
  transform: scale(0.97);
}

.btn.primary {
  background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 45%, #06b6d4 100%);
  color: #fff;
  width: 88px;
  min-width: 88px;
  padding: 12px 10px;
  font-size: 14px;
  flex-shrink: 0;
  box-shadow:
    0 4px 18px rgba(99, 102, 241, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn.primary:disabled {
  opacity: 0.55;
  cursor: wait;
  box-shadow: none;
}

.btn.secondary {
  width: 100%;
  margin-top: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid var(--glass-border);
}

.hidden {
  display: none;
}

#result-screen h2 {
  margin: 0 0 8px;
  font-size: 20px;
  background: linear-gradient(135deg, #fff, #a5f3fc);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

#result-text {
  color: var(--hint);
  line-height: 1.5;
  white-space: pre-wrap;
}

.empty-state {
  text-align: center;
  color: var(--hint);
  padding: 28px 12px;
  border-radius: 20px;
  border: 1px dashed rgba(167, 139, 250, 0.3);
  background: rgba(124, 58, 237, 0.06);
}

.notice-card {
  font-size: 13px;
  line-height: 1.55;
  color: #c4b5fd;
  border-color: rgba(34, 211, 238, 0.35);
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.12), rgba(34, 211, 238, 0.08));
  box-shadow: 0 0 24px rgba(124, 58, 237, 0.12);
}

.error {
  color: #fca5a5;
  font-size: 14px;
  margin-top: 8px;
}
