:root {
  --bg: #0f1115;
  --card: #1a1d24;
  --card-2: #22262f;
  --line: #2a2f3a;
  --gold: #f5b70a;
  --gold-2: #ffd75e;
  --gold-dark: #b8860b;
  --green: #22c55e;
  --red: #ef4444;
  --text: #ffffff;
  --muted: #9aa0aa;
  --radius: 18px;
  --tabbar-h: 68px;
  /* To'liq ekranda Telegram o'z tugmalarini tepaga qo'yadi: telegram-web-app.js bu o'zgaruvchilarni beradi */
  --safe-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
}

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

html { background: var(--bg); overscroll-behavior: none; }
body {
  margin: 0;
  background: transparent;
  min-height: 100vh;
  color: var(--text);
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.gold { color: var(--gold); }
.grow { flex: 1; }
.row { display: flex; gap: 10px; }

/* ---------- Coin ---------- */
.coin-svg {
  width: 64px;
  height: 64px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0' stop-color='%23ffe27a'/%3E%3Cstop offset='.5' stop-color='%23f5b70a'/%3E%3Cstop offset='1' stop-color='%23b8860b'/%3E%3C/linearGradient%3E%3ClinearGradient id='h' x1='1' y1='1' x2='0' y2='0'%3E%3Cstop offset='0' stop-color='%23ffe27a'/%3E%3Cstop offset='1' stop-color='%23c9930a'/%3E%3C/linearGradient%3E%3C/defs%3E%3Ccircle cx='50' cy='50' r='48' fill='url(%23g)'/%3E%3Ccircle cx='50' cy='50' r='38' fill='url(%23h)' stroke='%23a87a06' stroke-width='2'/%3E%3Ctext x='50' y='65' text-anchor='middle' font-family='Arial Black,Arial' font-weight='900' font-size='44' fill='%23a87a06'%3EA%3C/text%3E%3C/svg%3E") center / contain no-repeat;
}
.coin-svg.big { width: 150px; height: 150px; position: relative; z-index: 1; animation: float 4s ease-in-out infinite; }
.coin-svg.spin { animation: spin 1.2s linear infinite; }
.coin-svg.pop { animation: pop .45s ease; }

@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes spin { from { transform: rotateY(0); } to { transform: rotateY(360deg); } }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }

.loader, .fatal {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center;
}
.fatal h2 { margin: 8px 0 0; }
.fatal p { color: var(--muted); margin: 0; }

/* ---------- Layout ---------- */
main { padding: calc(16px + var(--safe-top)) 16px calc(var(--tabbar-h) + var(--safe-bottom) + 24px); }
.tab { display: none; animation: fade .25s ease; }
.tab.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-title { font-size: 26px; font-weight: 800; margin: 4px 0 16px; }
.section-title { font-size: 17px; font-weight: 700; margin: 24px 0 12px; }

.glass {
  background: linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .02));
  border: 1px solid rgba(255, 255, 255, .08);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
}

/* ---------- Home ---------- */
.home-top { display: flex; align-items: center; gap: 12px; }
.avatar.ring { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px rgba(245, 183, 10, .7); }
.hello { font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.level-line { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.level-name { font-size: 11px; font-weight: 800; color: var(--gold); text-transform: uppercase; letter-spacing: .8px; white-space: nowrap; }
.level-track { flex: 1; max-width: 120px; height: 5px; border-radius: 5px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.level-fill { height: 100%; width: 0; border-radius: 5px; background: linear-gradient(90deg, var(--gold), var(--gold-2)); transition: width .8s cubic-bezier(.2, .8, .2, 1); }
.streak-chip {
  display: flex; align-items: center; gap: 4px; padding: 7px 11px; border-radius: 999px;
  background: rgba(249, 115, 22, .14); border: 1px solid rgba(249, 115, 22, .35); color: #fdba74; font-size: 14px;
}

/* Bosh sahifa: tepada profil va balans, pastda ko'tarilib chiqqan panel ichida ikki tugma */
/* Bosh sahifa ekranga qotirilgan: surilmaydi, ortidagi bo'sh fon ko'rinmaydi */
#tab-home.active {
  position: fixed; inset: 0; z-index: 1; overflow: hidden; touch-action: none;
  display: flex; flex-direction: column; padding: calc(16px + var(--safe-top)) 16px 0;
}
.home-balance-area {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 20px; padding: 16px 0 32px; min-height: 160px;
}
.home-art { width: min(170px, 44vw); max-height: 28vh; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.balance-wrap { position: relative; }
.home-panel {
  /* Ekran chetidan chetigacha va pastki menyu ostigacha cho'ziladi */
  margin: 0 -16px; flex-shrink: 0;
  padding: 32px 16px calc(var(--tabbar-h) + var(--safe-bottom) + 40px);
  min-height: 46%;
  background: #08090b;
  border-radius: 32px 32px 0 0;
  border-top: 1px solid rgba(255, 255, 255, .07);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, .35);
}
.home-panel .quick-card { background: rgba(255, 255, 255, .05); }

.balance {
  font-family: 'Sora', 'Manrope', sans-serif;
  font-size: 48px; font-weight: 700; letter-spacing: -1px; line-height: 1;
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.balance-label { color: var(--muted); font-weight: 800; margin-top: 8px; text-transform: uppercase; letter-spacing: 5px; font-size: 12px; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick-card {
  position: relative; text-align: left; border-radius: 20px; padding: 14px; overflow: hidden;
  transition: transform .12s ease;
}
.quick-card:active { transform: scale(.96); }
.quick-icon {
  width: 40px; height: 40px; border-radius: 13px; display: flex; align-items: center; justify-content: center;
  font-size: 17px; margin-bottom: 12px;
}
.q-gold { background: rgba(245, 183, 10, .16); color: var(--gold); }
.q-blue { background: rgba(59, 130, 246, .16); }
.quick-title { font-weight: 800; font-size: 15px; }
.quick-sub { color: var(--muted); font-size: 12px; font-weight: 600; margin-top: 3px; }
.quick-card.ready { border-color: rgba(245, 183, 10, .55); }
.quick-card.ready::after {
  content: ''; position: absolute; top: 12px; right: 12px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--gold); box-shadow: 0 0 0 0 rgba(245, 183, 10, .7); animation: ping 1.6s infinite;
}
.quick-card.ready .quick-sub { color: var(--gold-2); }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(245, 183, 10, .7); } 100% { box-shadow: 0 0 0 10px rgba(245, 183, 10, 0); } }

#float-layer { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.float-plus {
  position: absolute; left: 50%; top: -10px; transform: translateX(-50%); white-space: nowrap;
  color: var(--gold-2); font-weight: 800; font-size: 28px;
  animation: floatUp 1.2s ease-out forwards; text-shadow: 0 2px 12px rgba(0, 0, 0, .5);
}
@keyframes floatUp { from { opacity: 1; transform: translate(-50%, 0); } to { opacity: 0; transform: translate(-50%, -80px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* ---------- Cards ---------- */
.card {
  background: rgba(26, 29, 36, .72); border: 1px solid rgba(255, 255, 255, .07); border-radius: var(--radius);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  padding: 16px; margin-bottom: 14px;
}
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-title { font-weight: 800; font-size: 17px; }
.card-sub { color: var(--muted); font-size: 13px; margin-top: 3px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  color: #1a1300; font-weight: 800; border-radius: 14px; padding: 12px 18px;
  transition: transform .1s ease, opacity .2s ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled { background: var(--card-2); color: var(--muted); cursor: default; transform: none; }
.btn-big { width: 100%; padding: 15px; font-size: 16px; }
.btn-ghost { background: var(--card-2); color: var(--text); }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 11px; }
.btn-ok { background: rgba(34, 197, 94, .15); color: var(--green); }

/* Daily */
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 14px; }
.day {
  background: var(--card-2); border-radius: 12px; padding: 8px 2px; text-align: center;
  border: 1px solid transparent;
}
.day-n { font-size: 11px; color: var(--muted); font-weight: 700; }
.day-r { font-size: 13px; font-weight: 800; margin-top: 2px; }
.day.done { background: rgba(245, 183, 10, .12); }
.day.done .day-r { color: var(--gold); }
.day.next { border-color: var(--gold); }
#daily-btn { width: 100%; }

/* Ad */
.ad-icon {
  width: 46px; height: 46px; border-radius: 14px; flex-shrink: 0;
  background: rgba(245, 183, 10, .15); color: var(--gold);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.progress { height: 8px; background: var(--card-2); border-radius: 8px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--gold-2)); border-radius: 8px; transition: width .4s ease; }
.progress-text { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin: 8px 0 14px; font-weight: 600; }

/* Lists */
.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  display: flex; align-items: center; gap: 12px;
  background: rgba(26, 29, 36, .72); border: 1px solid rgba(255, 255, 255, .07); border-radius: 16px; padding: 12px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.item-icon {
  width: 42px; height: 42px; border-radius: 12px; background: var(--card-2); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 19px;
}
.item-body { flex: 1; min-width: 0; }
.item-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.empty { color: var(--muted); text-align: center; padding: 18px; font-size: 14px; }

.badge { font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 8px; white-space: nowrap; }
.badge.pending { background: rgba(245, 183, 10, .15); color: var(--gold); }
.badge.approved { background: rgba(34, 197, 94, .15); color: var(--green); }
.badge.rejected { background: rgba(239, 68, 68, .15); color: var(--red); }

/* AdsGram Task */
#adsgram-task-slot:not(:empty) { margin-bottom: 10px; }
.adsgram-task {
  display: block; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px;
  --adsgram-task-font-size: 15px;
  --adsgram-task-icon-size: 42px;
  --adsgram-task-icon-title-gap: 12px;
  --adsgram-task-icon-border-radius: 12px;
  --adsgram-task-button-width: 84px;
}
.task-slot-reward { color: var(--gold); font-weight: 700; font-size: 13px; }
.task-slot-btn, .task-slot-claim, .task-slot-done {
  display: block; text-align: center; font-weight: 800; font-size: 13px; padding: 8px 10px; border-radius: 11px;
}
.task-slot-btn { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #1a1300; }
.task-slot-claim { background: var(--green); color: #04210f; }
.task-slot-done { background: var(--card-2); color: var(--muted); }

/* Referral */
.ref-hero { text-align: center; }
.ref-emoji { font-size: 44px; margin-bottom: 6px; }
.ref-rules { text-align: left; color: var(--muted); font-size: 14px; padding-left: 20px; margin: 12px 0 14px; line-height: 1.6; }
.ref-link {
  background: var(--card-2); border-radius: 12px; padding: 12px; font-size: 13px; color: var(--gold-2);
  word-break: break-all; margin-bottom: 12px; font-weight: 600;
}

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: rgba(26, 29, 36, .72); border: 1px solid rgba(255, 255, 255, .07); border-radius: 16px; padding: 12px 8px; text-align: center; }
.stat-value { font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 11px; margin-top: 3px; font-weight: 600; }

/* Avatar */
.avatar {
  border-radius: 50%; background: linear-gradient(135deg, var(--gold), var(--gold-dark)) center / cover no-repeat;
  display: flex; align-items: center; justify-content: center; font-weight: 800; color: #1a1300; flex-shrink: 0;
}
.avatar.sm { width: 34px; height: 34px; font-size: 14px; }
.avatar.md { width: 42px; height: 42px; font-size: 16px; }
.avatar.lg { width: 64px; height: 64px; font-size: 24px; }

/* Profile */
.profile-head { display: flex; align-items: center; gap: 14px; margin: 4px 0 18px; }
.profile-name { font-size: 21px; font-weight: 800; }
.label { font-size: 13px; color: var(--muted); font-weight: 700; margin: 16px 0 8px; }
.methods { display: flex; flex-direction: column; gap: 8px; }
.method {
  background: var(--card-2); border: 1.5px solid transparent; border-radius: 12px; padding: 12px; text-align: left; font-weight: 700;
}
.method.active { border-color: var(--gold); }
.input {
  width: 100%; margin: 12px 0; background: var(--card-2); border: 1.5px solid var(--line); border-radius: 12px;
  color: var(--text); font: inherit; padding: 13px 12px; outline: none;
}
.input:focus { border-color: var(--gold); }

/* Tabbar: suzib turuvchi panel */
.tabbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(10px + var(--safe-bottom)); z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  height: var(--tabbar-h); padding: 7px; border-radius: 24px;
  background: rgba(22, 24, 31, .82); backdrop-filter: blur(20px) saturate(1.4); -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, .08); box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
}
.tab-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 11px; font-weight: 700; border-radius: 17px; transition: color .2s ease, background .2s ease;
}
.tab-btn svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s ease; }
.tab-btn.active { color: var(--gold); background: rgba(245, 183, 10, .12); }
.tab-btn.active svg { transform: translateY(-1px); filter: drop-shadow(0 0 6px rgba(245, 183, 10, .6)); }

/* Gate */
.gate {
  position: fixed; inset: 0; z-index: 30; background: rgba(10, 11, 14, .96);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.gate-box { width: 100%; max-width: 360px; text-align: center; display: flex; flex-direction: column; gap: 10px; }
.gate-box h2 { margin: 0; }
.gate-box p { margin: 0 0 10px; }

/* Toast */
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 14px); z-index: 40;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px;
  font-weight: 700; text-align: center; box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: none; }
.toast.ok { border-color: rgba(34, 197, 94, .5); }
.toast.err { border-color: rgba(239, 68, 68, .5); }

/* ---------- Ikonkalar (SVG sprite, index.html) ---------- */
.ic {
  width: 1.15em; height: 1.15em; flex-shrink: 0; vertical-align: -.2em;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.btn .ic { width: 18px; height: 18px; }
.title-ic { display: flex; align-items: center; gap: 8px; }
.title-ic .ic { color: var(--gold); width: 20px; height: 20px; }
.hero-ic {
  width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(245, 183, 10, .14); color: var(--gold); box-shadow: 0 0 30px rgba(245, 183, 10, .2);
}
.hero-ic .ic { width: 30px; height: 30px; }
.quick-icon .ic, .ad-icon .ic { width: 21px; height: 21px; }
.q-blue { color: #60a5fa; }
.item-icon { color: var(--gold); }
.item-icon .ic { width: 21px; height: 21px; }
.streak-chip .ic { width: 16px; height: 16px; color: #fb923c; fill: rgba(249, 115, 22, .35); }
.badge { display: inline-flex; align-items: center; gap: 4px; }
.badge .ic { width: 13px; height: 13px; stroke-width: 2.5; }
.item-sub .ic { width: 13px; height: 13px; margin-right: 3px; }
.ok-text { color: var(--green); }
.task-slot-done .ic { width: 16px; height: 16px; stroke-width: 2.5; }
.toast { display: flex; align-items: center; justify-content: center; gap: 8px; }
.toast .ic { width: 19px; height: 19px; }
.toast.ok .ic { color: var(--green); }
.toast.err .ic { color: var(--red); }
.toast:not(.ok):not(.err) .ic { color: var(--gold); }

.loader-coin { width: 96px; height: auto; animation: spin 1.4s ease-in-out infinite; }

/* Pul yechish: miqdor va karta */
.amount-row { display: flex; gap: 8px; align-items: center; }
.amount-row .input { margin: 0; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.amount-row .btn { flex-shrink: 0; padding: 13px 14px; }
.methods.row { flex-direction: row; }
.method { display: flex; align-items: center; justify-content: center; gap: 8px; }
.method .ic { width: 18px; height: 18px; color: var(--muted); }
.method.active .ic { color: var(--gold); }
.card-input { font-size: 18px; font-weight: 700; letter-spacing: 1.5px; font-variant-numeric: tabular-nums; }

/* 3D rasmli ikonkalar (fonsiz PNG) */
.card-art { width: 56px; height: 56px; object-fit: contain; flex-shrink: 0; user-select: none; -webkit-user-drag: none; }
.quick-art { display: block; width: 44px; height: 44px; object-fit: contain; margin-bottom: 8px; user-select: none; -webkit-user-drag: none; }
.ref-hero-art { display: block; width: 150px; height: auto; margin: 0 auto 10px; user-select: none; -webkit-user-drag: none; }

/* Pastdan chiqadigan oyna (pul yechish) */
.sheet { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .6); display: flex; align-items: flex-end; }
.sheet-box {
  position: relative; width: 100%; max-height: calc(92vh - var(--safe-top)); overflow-y: auto; background: var(--bg);
  border-radius: 24px 24px 0 0; border-top: 1px solid var(--line); padding: 20px 16px calc(var(--safe-bottom) + 24px);
  animation: sheetUp .22s ease;
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-close {
  position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 50%;
  background: var(--card-2); color: var(--muted); display: flex; align-items: center; justify-content: center;
}
.sheet-close .ic { width: 18px; height: 18px; }
.sheet-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; padding-right: 40px; }
.sheet-head b { color: var(--text); }

/* Maqsadli vazifa progressi (5/5 do'st, 10/10 reklama) */
.task-progress { display: flex; align-items: center; gap: 8px; margin-top: 7px; }
.task-bar { flex: 1; height: 6px; border-radius: 6px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.task-bar i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--gold), var(--gold-2)); }
.task-progress span { font-size: 11px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
#tasks-list .item-title { white-space: normal; line-height: 1.3; }
