
:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f3f5f8;
  --surface-3: #e9edf3;
  --text: #101828;
  --muted: #667085;
  --muted-2: #98a2b3;
  --line: #e4e7ec;

  --primary: #246bfd;
  --primary-hover: #1859e8;
  --primary-soft: #edf4ff;

  --success: #17a55b;
  --success-soft: #eaf8f0;
  --danger: #d92d20;
  --danger-soft: #fff1f0;
  --warning: #b77900;
  --warning-soft: #fff7dc;

  --shadow-sm: 0 1px 2px rgba(16,24,40,.03), 0 8px 24px rgba(16,24,40,.045);
  --shadow-md: 0 16px 42px rgba(16,24,40,.10);

  --radius: 18px;
  --radius-sm: 14px;
  --nav-h: 74px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #181b20;
  --surface: #22262d;
  --surface-2: #292e36;
  --surface-3: #313741;
  --text: #f6f7f9;
  --muted: #a7afbc;
  --muted-2: #7e8795;
  --line: #343a44;

  --primary: #3f7df7;
  --primary-hover: #5b91fb;
  --primary-soft: #22365c;

  --success: #53c985;
  --success-soft: #1d3828;
  --danger: #ff7a70;
  --danger-soft: #412524;
  --warning: #e9b642;
  --warning-soft: #3c321d;

  --shadow-sm: 0 8px 24px rgba(0,0,0,.13);
  --shadow-md: 0 18px 46px rgba(0,0,0,.26);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}
body {
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: var(--tg-viewport-stable-height, 100vh);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button, a { -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; display: block; }

/* ===== Bootstrap ===== */

.boot {
  min-height: 72vh;
  display: grid;
  place-items: center;
  place-content: center;
  gap: 10px;
  color: var(--muted);
  text-align: center;
}
.boot strong { color: var(--text); font-size: 22px; }

.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--primary);
  border: 2px solid var(--primary);
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -1.5px;
}

/* ===== App shell ===== */

.app-shell {
  max-width: 760px;
  margin: 0 auto;
  padding: 18px 14px 30px;
}

.demo-banner {
  padding: 9px 12px;
  border-radius: 12px;
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 10.5px;
  line-height: 1.4;
  margin-bottom: 14px;
  text-align: center;
  font-weight: 750;
}

/* ===== Header ===== */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  gap: 12px;
  margin: 0 2px 18px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-lockup .brand-mark {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border-width: 2px;
  font-size: 20px;
}

.brand-name {
  font-size: 21px;
  line-height: 1.05;
  font-weight: 900;
  letter-spacing: -.55px;
}
.brand-sub {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.35;
  margin-top: 5px;
}

.icon-btn,
.back-btn {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
  flex: 0 0 auto;
}
.icon-btn svg,
.back-btn svg,
.nav-icon svg,
.category-icon svg,
.meta-icon svg,
.field-icon svg {
  width: 21px;
  height: 21px;
  stroke-width: 1.9;
}

/* ===== Balance ===== */

.balance-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 17px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}
.balance-kicker {
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}
.balance-value {
  font-size: 25px;
  line-height: 1.05;
  font-weight: 900;
  letter-spacing: -.65px;
  margin-top: 7px;
}
.balance-value small {
  font-size: 12px;
  color: var(--muted);
  font-weight: 750;
  letter-spacing: 0;
}

.btn {
  min-height: 44px;
  border: 0;
  border-radius: 13px;
  padding: 0 17px;
  font-weight: 820;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .12s ease, background .12s ease;
}
.btn:active { transform: scale(.985); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
}
.btn-ghost {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--line);
}
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-full { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ===== Section headings ===== */

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 24px 2px 12px;
}
.section-head h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.2;
  font-weight: 900;
  letter-spacing: -.35px;
}
.section-link {
  border: 0;
  background: transparent;
  color: var(--primary);
  padding: 4px;
}

/* ===== Home categories ===== */

.category-list {
  display: grid;
  gap: 11px;
}

.category-card {
  width: 100%;
  min-height: 96px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 15px 14px;
  border-radius: 19px;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  box-shadow: var(--shadow-sm);
}

.category-icon {
  width: 48px;
  height: 48px;
  border-radius: 15px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: var(--primary);
  background: var(--primary-soft);
}

.category-content {
  flex: 1;
  min-width: 0;
  display: block;
}
.category-title {
  display: block;
  font-size: 15px;
  line-height: 1.25;
  font-weight: 900;
  letter-spacing: -.15px;
}
.category-desc {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  margin-top: 6px;
  line-height: 1.45;
  max-width: 94%;
}
.chevron {
  color: var(--muted-2);
  font-size: 25px;
  line-height: 1;
  flex: 0 0 auto;
}

/* ===== Popular ===== */

.popular-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
}

.product-tile {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 18px;
  padding: 11px;
  box-shadow: var(--shadow-sm);
  text-align: left;
}

.product-art {
  aspect-ratio: 1.42 / 1;
  border-radius: 14px;
  display: grid;
  place-items: center;
  margin-bottom: 11px;
  overflow: hidden;
  font-size: 34px;
  line-height: 1;
  font-weight: 900;
  background: var(--surface-2);
}
.art-apple {
  background: #f4f5f7;
  color: #20242b;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
html[data-theme="dark"] .art-apple {
  background: #2b3038;
  color: #f5f7fa;
}
.art-star {
  color: #eda900;
  background: #fff7d7;
}
html[data-theme="dark"] .art-star {
  background: #38321d;
}
.art-steam {
  background: #173a66;
  color: #fff;
}
.art-roblox {
  background: #24272d;
  color: #fff;
}

.product-title {
  font-size: 13px;
  font-weight: 850;
  min-height: 33px;
  line-height: 1.28;
}
.product-price {
  margin-top: 5px;
  font-size: 10.8px;
  color: var(--muted);
}

/* ===== Lists ===== */

.page-header {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 2px 0 17px;
}
.page-header-copy { min-width: 0; }
.page-title {
  font-size: 21px;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -.45px;
}
.page-sub {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.35;
  margin-top: 4px;
}

.list { display: grid; gap: 10px; }
.list-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 13px;
  box-shadow: var(--shadow-sm);
}
.list-row.clickable { cursor: pointer; }
.list-title {
  font-weight: 850;
  font-size: 14px;
  line-height: 1.3;
}
.list-sub {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.4;
  margin-top: 5px;
}
.list-price {
  font-weight: 850;
  text-align: right;
  white-space: nowrap;
  font-size: 12.5px;
}

/* ===== Product page ===== */

.hero {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  padding: 17px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 13px;
}
.hero-brand {
  display: flex;
  gap: 14px;
  align-items: center;
}
.hero-art {
  width: 80px;
  height: 80px;
  border-radius: 18px;
  background: var(--surface-2);
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 27px;
}
.hero-title {
  font-size: 19px;
  line-height: 1.2;
  font-weight: 900;
  letter-spacing: -.35px;
}
.hero-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.4;
}
.stock {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 9px;
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 10.8px;
  font-weight: 800;
}
.stock::before {
  content: "";
  width: 6px;
  height: 6px;
  background: currentColor;
  border-radius: 50%;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 9px;
}
.choice {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 15px;
  padding: 13px;
  min-height: 74px;
  text-align: left;
  position: relative;
}
.choice.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary) inset;
}
.choice.selected::after {
  content: "✓";
  position: absolute;
  top: 8px;
  right: 9px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
}
.choice-name {
  font-weight: 900;
  font-size: 15px;
  line-height: 1.2;
}
.choice-price {
  color: var(--muted);
  font-size: 10.8px;
  line-height: 1.35;
  margin-top: 6px;
}

.info-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 14px;
  box-shadow: var(--shadow-sm);
}
.info-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.info-row:last-child { border-bottom: 0; }
.meta-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: var(--primary);
  background: var(--primary-soft);
  flex: 0 0 auto;
}
.info-title {
  font-weight: 850;
  font-size: 13px;
  line-height: 1.3;
}
.info-sub {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  margin-top: 3px;
}

.sticky-buy {
  position: sticky;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 7px);
  margin-top: 14px;
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  border: 1px solid var(--line);
  backdrop-filter: blur(18px);
  padding: 11px;
  border-radius: 18px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.total-label {
  color: var(--muted);
  font-size: 10.8px;
}
.total-value {
  font-weight: 900;
  font-size: 19px;
  line-height: 1.15;
  margin-top: 3px;
}

/* ===== Checkout ===== */

.checkout-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 10px;
}
.checkout-product {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 7px;
}
.checkout-art {
  width: 54px;
  height: 54px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  font-weight: 900;
}
.checkout-name {
  font-weight: 900;
  line-height: 1.3;
}
.checkout-sub {
  color: var(--muted);
  font-size: 11.5px;
  margin-top: 4px;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  font-size: 12.5px;
  line-height: 1.35;
}
.detail-row .label { color: var(--muted); }
.detail-row.total {
  margin-top: 5px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 15px;
  font-weight: 900;
}
.balance-payment {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.notice {
  padding: 12px 13px;
  border-radius: 13px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.45;
  margin: 10px 0;
}

/* ===== Forms ===== */

.form-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px;
  box-shadow: var(--shadow-sm);
}
.field { margin-bottom: 13px; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  font-size: 12px;
  line-height: 1.3;
  font-weight: 850;
  margin-bottom: 7px;
}
.input,
.select {
  width: 100%;
  height: 46px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  padding: 0 13px;
  font-size: 16px;
}
.input:focus,
.select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent);
}

/* ===== Processing / result ===== */

.status-screen {
  min-height: calc(100vh - 150px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 0;
  text-align: center;
}
.status-ring {
  width: 102px;
  height: 102px;
  border-radius: 50%;
  border: 6px solid var(--surface-3);
  border-top-color: var(--primary);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.success-ring {
  width: 102px;
  height: 102px;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 45px;
  font-weight: 500;
  animation: pop .28s ease-out;
}
@keyframes pop {
  from { transform: scale(.82); opacity: .4; }
  to { transform: scale(1); opacity: 1; }
}

.status-title {
  margin-top: 22px;
  font-size: 23px;
  line-height: 1.15;
  font-weight: 900;
  letter-spacing: -.45px;
}
.status-sub {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
  max-width: 330px;
}
.status-card {
  width: 100%;
  max-width: 440px;
  margin-top: 20px;
  text-align: left;
}

.code-card {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 19px;
  padding: 15px;
  margin-top: 20px;
  box-shadow: var(--shadow-sm);
  text-align: left;
}
.code-label {
  color: var(--muted);
  font-size: 11px;
}
.code-value {
  margin: 8px 0 12px;
  padding: 15px;
  border-radius: 13px;
  background: var(--surface-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px;
  font-weight: 850;
  letter-spacing: .6px;
  overflow-wrap: anywhere;
  text-align: center;
}

/* ===== Orders / profile ===== */

.orders-list { display: grid; gap: 9px; }
.order-card {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.order-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.order-name {
  font-weight: 850;
  font-size: 13.5px;
}
.order-meta {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  margin-top: 5px;
}
.badge {
  font-size: 10.5px;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }

.empty {
  padding: 34px 18px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.error {
  padding: 14px;
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: 14px;
  margin: 10px 0;
}
.loading {
  padding: 36px 0;
  text-align: center;
  color: var(--muted);
}

.profile-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.profile-name {
  font-size: 18px;
  font-weight: 900;
}
.profile-meta {
  color: var(--muted);
  font-size: 11.5px;
  margin-top: 4px;
}

/* ===== Bottom nav ===== */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(760px, 100%);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding: 9px 12px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  z-index: 50;
}

.nav-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 13px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 750;
}
.nav-icon {
  height: 22px;
  display: grid;
  place-items: center;
}
.nav-btn.active { color: var(--primary); }

/* ===== Toast ===== */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  z-index: 100;
  box-shadow: var(--shadow-md);
  font-size: 12px;
  max-width: calc(100% - 28px);
  text-align: center;
}
html[data-theme="dark"] .toast {
  background: #f3f4f6;
  color: #111827;
}

/* ===== Responsive ===== */

@media (min-width: 560px) {
  .popular-grid { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .choice-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
}

@media (max-width: 380px) {
  .app-shell { padding-left: 11px; padding-right: 11px; }
  .brand-name { font-size: 19px; }
  .brand-sub { font-size: 10.8px; }
  .balance-value { font-size: 22px; }
  .balance-card { padding: 15px 13px; }
  .btn { padding: 0 13px; }
  .category-card { padding: 13px 12px; }
  .category-icon { width: 44px; height: 44px; }
  .category-title { font-size: 14px; }
  .category-desc { font-size: 10.8px; }
}
