:root {
  color-scheme: light dark;
  --bg: var(--tg-theme-bg-color, #0b0d1c);
  --surface: var(--tg-theme-secondary-bg-color, rgba(24, 27, 54, .88));
  --text: var(--tg-theme-text-color, #f8f8ff);
  --muted: var(--tg-theme-hint-color, #a8acc4);
  --accent: var(--tg-theme-button-color, #7367f0);
  --accent-text: var(--tg-theme-button-text-color, #fff);
  --line: rgba(255, 255, 255, .11);
  --success: #4fd1a1;
  --danger: #ff6b83;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}
button, input { font: inherit; }
a { color: #9f96ff; }
.hidden { display: none !important; }

.ambient {
  position: fixed;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  filter: blur(80px);
  opacity: .23;
  pointer-events: none;
}
.ambient-one { top: -110px; right: -80px; background: #825bff; }
.ambient-two { bottom: -130px; left: -100px; background: #27b9d2; }

.mini-app {
  min-height: 100vh;
  padding: max(18px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 80% 0, rgba(123, 92, 255, .18), transparent 38%),
    linear-gradient(160deg, var(--bg), color-mix(in srgb, var(--bg) 78%, #171a3b));
}

.payment-card {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .24);
  backdrop-filter: blur(22px);
}

.brand-row { display: flex; align-items: center; gap: 11px; }
.brand-row > div:nth-child(2) { display: flex; flex-direction: column; min-width: 0; }
.brand-row strong { letter-spacing: -.02em; }
.brand-row small { margin-top: 2px; color: var(--muted); font-size: 12px; }
.brand-mark {
  display: block;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  object-fit: cover;
  object-position: center;
  border: 1px solid rgba(255, 255, 255, .16);
  box-shadow: 0 9px 25px rgba(98, 89, 255, .34);
}
.balance-pill {
  margin-left: auto;
  padding: 7px 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255,255,255,.045);
}
.balance-pill span { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.balance-pill b { margin-top: 2px; font-size: 13px; }

.hero-copy { padding: 34px 2px 22px; }
.eyebrow {
  display: inline-flex;
  padding: 6px 10px;
  border: 1px solid rgba(137, 117, 255, .28);
  border-radius: 999px;
  color: #b9b2ff;
  background: rgba(109, 87, 255, .10);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .11em;
  text-transform: uppercase;
}
h1 { margin: 14px 0 8px; font-size: clamp(28px, 8vw, 39px); line-height: 1.04; letter-spacing: -.045em; }
.hero-copy p { margin: 0; color: var(--muted); }

.quick-amounts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.quick-amounts button {
  min-height: 45px;
  padding: 8px 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  background: rgba(255,255,255,.045);
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.quick-amounts button:active { transform: scale(.96); }
.quick-amounts button.active { border-color: #8f7dff; background: rgba(119, 94, 255, .18); }

.amount-field { display: block; margin-top: 20px; }
.amount-field > span:first-child { display: block; margin: 0 0 8px 2px; color: var(--muted); font-size: 13px; }
.input-wrap {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(0,0,0,.12);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input-wrap:focus-within { border-color: #8d7aff; box-shadow: 0 0 0 4px rgba(119, 94, 255, .12); }
.input-wrap input {
  width: 100%;
  min-height: 60px;
  padding: 0 10px 0 17px;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 25px;
  font-weight: 750;
}
.input-wrap b { padding-right: 17px; color: var(--muted); font-size: 20px; }
.hint { margin: 7px 2px 0; color: var(--muted); font-size: 12px; }
.hint.error, .status-text.error { color: var(--danger); }

.summary-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding: 14px 15px;
  border: 1px solid rgba(79, 209, 161, .2);
  border-radius: 16px;
  background: rgba(79, 209, 161, .07);
}
.summary-card span { color: var(--muted); font-size: 13px; }
.summary-card strong { color: var(--success); white-space: nowrap; }

.terms-row { display: grid; grid-template-columns: 22px 1fr; gap: 10px; margin-top: 18px; align-items: start; color: var(--muted); font-size: 13px; line-height: 1.4; }
.terms-row input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.provider-note { margin: 12px 2px 16px; color: var(--muted); font-size: 11px; line-height: 1.45; }

.pay-button, .secondary-button, .primary-link {
  width: 100%;
  min-height: 54px;
  border: 0;
  border-radius: 17px;
  font-weight: 800;
  cursor: pointer;
}
.pay-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--accent-text);
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 64%, #37c7e4));
  box-shadow: 0 13px 28px color-mix(in srgb, var(--accent) 28%, transparent);
}
.pay-button:disabled { opacity: .42; cursor: not-allowed; box-shadow: none; }
.pay-button.loading b { animation: slide 1s ease infinite; }
.secondary-button { margin-top: 10px; color: var(--text); border: 1px solid var(--line); background: rgba(255,255,255,.05); }
.status-text { min-height: 18px; margin: 12px 4px 0; color: var(--muted); text-align: center; font-size: 13px; }
.status-text.success { color: var(--success); }
@keyframes slide { 50% { transform: translateX(5px); } }

.state-panel { padding: 55px 8px 28px; text-align: center; }
.state-panel .state-icon { display: grid; place-items: center; width: 62px; height: 62px; margin: 0 auto; border-radius: 20px; background: rgba(119,94,255,.15); color: #b8afff; font-size: 28px; }
.state-panel p { color: var(--muted); line-height: 1.55; }

.public-page { padding: 32px 16px; background: radial-gradient(circle at 80% 0, #25205a 0, #101225 37%, #090b16 100%); }
.page-card { position: relative; max-width: 780px; margin: 0 auto; padding: clamp(22px, 5vw, 52px); border: 1px solid var(--line); border-radius: 28px; background: rgba(21,24,47,.88); box-shadow: 0 30px 90px rgba(0,0,0,.28); }
.hero.compact { margin-bottom: 24px; }
.hero.compact p, .legal p, .legal li, .notice { color: #bec1d2; line-height: 1.68; }
.legal h1 { font-size: clamp(30px, 7vw, 48px); }
.legal h2 { margin-top: 34px; font-size: 23px; }
.legal h3 { margin-top: 26px; }
.legal ul { padding-left: 22px; }
.legal code, .notice code { padding: 2px 6px; border-radius: 6px; background: rgba(255,255,255,.08); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: #aeb2c9; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
tr:last-child td { border-bottom: 0; }
.notice { margin: 22px 0; padding: 4px 18px; border-left: 3px solid #7967ff; border-radius: 8px 16px 16px 8px; background: rgba(121,103,255,.08); }
.primary-link { display: inline-flex; align-items: center; justify-content: center; padding: 0 20px; width: auto; min-width: 190px; color: white; text-decoration: none; background: linear-gradient(135deg, #7565f5, #4e8aff); }
footer { display: flex; gap: 9px; justify-content: center; margin-top: 44px; padding-top: 18px; border-top: 1px solid var(--line); color: #8e92ab; font-size: 12px; }

@media (max-width: 380px) {
  .payment-card { padding: 14px; border-radius: 23px; }
  .quick-amounts { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
