:root {
  --bg: #0b1120;
  --surface: #131c31;
  --surface-2: #1c2844;
  --primary: #10b981;
  --accent: #3b82f6;
  --gold: #f59e0b;
  --text: #f8fafc;
  --muted: #94a3b8;
  --border: rgba(148, 163, 184, 0.16);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  background: #040711;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: flex;
  justify-content: center;
  min-height: 100dvh;
}

.app-shell {
  width: 100%;
  max-width: 480px;
  min-height: 100dvh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
}

.topbar {
  position: sticky; top: 0; z-index: 25;
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: rgba(11, 17, 32, 0.94); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; }
.logo-box {
  width: 36px; height: 36px; border-radius: 11px;
  background: linear-gradient(135deg, #10b981, #3b82f6);
  display: grid; place-items: center; font-size: 1.15rem;
}
.brand h1 { font-size: 1.05rem; font-weight: 800; letter-spacing: -0.02em; }
.user-id-tag { font-size: 0.72rem; color: var(--muted); }

.topbar-right { display: flex; align-items: center; gap: 8px; }
.btn-install {
  background: var(--accent); color: #fff; border: none;
  border-radius: 8px; padding: 6px 10px; font-size: 0.76rem; font-weight: 700; cursor: pointer;
}

.wallet-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid rgba(245, 158, 11, 0.35);
  padding: 5px 12px; border-radius: 999px; cursor: pointer;
}
.coin-icon { font-size: 1.1rem; }
.wallet-pill strong { display: block; font-size: 0.9rem; color: #fcd34d; line-height: 1.1; }
.wallet-pill small { display: block; font-size: 0.68rem; color: var(--primary); font-weight: 700; }

.main-content {
  flex: 1; padding: 14px 16px calc(82px + var(--safe-bottom)); overflow-y: auto;
}

.view { display: none; animation: fadeIn 0.2s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.hero-banner, .ref-banner {
  background: linear-gradient(135deg, #1e293b 0%, #0f2922 100%);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 16px; padding: 16px; margin-bottom: 16px;
}
.ref-banner {
  background: linear-gradient(135deg, #1e1b4b 0%, #0f2942 100%);
  border-color: rgba(59, 130, 246, 0.35);
}
.pill-hot {
  display: inline-block; font-size: 0.68rem; font-weight: 800;
  background: rgba(16, 185, 129, 0.18); color: #6ee7b7;
  padding: 3px 8px; border-radius: 999px; margin-bottom: 8px;
}
.hero-banner h2, .ref-banner h2 { font-size: 1.04rem; line-height: 1.35; margin-bottom: 6px; }
.hero-banner p, .ref-banner p { font-size: 0.82rem; color: var(--muted); line-height: 1.4; }

.stats-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px;
}
.stat-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px; text-align: center;
}
.stat-box strong { display: block; font-size: 1.25rem; color: #fcd34d; margin-bottom: 3px; }
.stat-box span { font-size: 0.75rem; color: var(--muted); }

.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.section-head h3 { font-size: 0.95rem; font-weight: 700; }
.hint-text { font-size: 0.75rem; color: var(--muted); }

.providers-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.provider-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 13px; text-align: left; cursor: pointer; display: flex;
  flex-direction: column; justify-content: space-between; gap: 8px;
}
.provider-card:active { transform: scale(0.97); }
.provider-badge {
  align-self: flex-start; font-size: 0.65rem; font-weight: 800;
  padding: 2px 7px; border-radius: 6px; color: #fff;
}
.provider-card h4 { font-size: 0.92rem; color: var(--text); }
.provider-card p { font-size: 0.75rem; color: var(--muted); line-height: 1.35; }

.offers-list { display: flex; flex-direction: column; gap: 10px; }
.offer-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.offer-left { display: flex; align-items: center; gap: 11px; flex: 1; min-width: 0; }
.offer-icon {
  width: 46px; height: 46px; border-radius: 12px; background: var(--surface-2);
  display: grid; place-items: center; font-size: 1.5rem; flex-shrink: 0;
}
.offer-info h4 { font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.offer-info p { font-size: 0.76rem; color: var(--muted); margin-top: 2px; line-height: 1.3; }
.offer-tag {
  display: inline-block; font-size: 0.66rem; color: #93c5fd;
  background: rgba(59, 130, 246, 0.15); padding: 1px 6px; border-radius: 4px; margin-top: 4px;
}

.btn-reward {
  background: linear-gradient(135deg, #10b981, #059669); color: #fff; border: none;
  border-radius: 10px; padding: 9px 11px; font-size: 0.78rem; font-weight: 800;
  cursor: pointer; flex-shrink: 0;
}
.btn-reward.claimed { background: var(--surface-2); color: var(--muted); cursor: default; }

.balance-card {
  background: linear-gradient(135deg, #065f46, #1e3a8a);
  border-radius: 16px; padding: 18px; text-align: center; margin-bottom: 14px;
}
.balance-card span { font-size: 0.8rem; opacity: 0.85; }
.balance-card h2 { font-size: 1.7rem; margin: 4px 0; color: #fde68a; }
.balance-card p { font-size: 0.85rem; opacity: 0.9; }

.card-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 16px; margin-bottom: 14px;
}
.card-box h3 { font-size: 0.98rem; margin-bottom: 10px; }
.card-box label { display: block; font-size: 0.78rem; color: var(--muted); margin: 10px 0 5px; }
.card-box input, .card-box select {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 11px; font-size: 0.9rem;
}

.preset-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 8px; }
.preset-btn {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px; font-size: 0.76rem; font-weight: 600; cursor: pointer;
}

.btn-primary {
  width: 100%; margin-top: 12px; background: var(--primary); color: #fff;
  border: none; border-radius: 10px; padding: 12px; font-size: 0.92rem; font-weight: 700; cursor: pointer;
}
.btn-secondary {
  background: var(--accent); color: #fff; border: none; border-radius: 10px;
  padding: 10px 14px; font-size: 0.84rem; font-weight: 700; cursor: pointer; flex-shrink: 0;
}

.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px; display: flex; justify-content: space-between; align-items: center;
}
.history-item strong { font-size: 0.88rem; display: block; }
.history-item small { font-size: 0.74rem; color: var(--muted); }
.status-pill {
  font-size: 0.72rem; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  background: rgba(245, 158, 11, 0.18); color: #fcd34d;
}

.muted { font-size: 0.82rem; color: var(--muted); line-height: 1.45; margin-bottom: 10px; }
.copy-row { display: flex; gap: 8px; }
.postback-code {
  display: block; background: var(--bg); padding: 10px; border-radius: 8px;
  font-size: 0.74rem; color: #6ee7b7; word-break: break-all; border: 1px solid var(--border);
}

.modal {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.82);
  display: flex; align-items: flex-end; justify-content: center; z-index: 50;
}
.modal-sheet {
  width: 100%; max-width: 480px; height: 85dvh; background: var(--surface);
  border-radius: 20px 20px 0 0; display: flex; flex-direction: column; overflow: hidden;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.btn-close {
  background: var(--surface-2); color: var(--text); border: none;
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
}
.modal-body { flex: 1; padding: 16px; overflow-y: auto; }
.wall-iframe { width: 100%; height: 100%; border: none; border-radius: 12px; background: #fff; }

.bottom-nav {
  position: fixed; bottom: 0; width: 100%; max-width: 480px;
  background: rgba(19, 28, 49, 0.96); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border); display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 8px 0 calc(8px + var(--safe-bottom)); z-index: 30;
}
.nav-btn {
  background: transparent; border: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 0.72rem; font-weight: 600; cursor: pointer;
}
.nav-btn.active { color: var(--primary); }
.nav-icon { font-size: 1.2rem; }

.hidden { display: none !important; }
.toast {
  position: fixed; bottom: calc(74px + var(--safe-bottom)); left: 50%;
  transform: translateX(-50%); background: #1e293b; color: #fff;
  padding: 10px 16px; border-radius: 999px; font-size: 0.82rem;
  opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 60;
}
.toast.show { opacity: 1; }
