:root {
  --bg-base: #0B0E14;
  --bg-surface: #131826;
  --bg-surface-2: #1B2233;
  --text-primary: #E7EAF0;
  --text-secondary: #8891A5;
  --up: #34D399;
  --down: #FB7185;
  --gold: #F0B429;
  --border: rgba(231, 234, 240, 0.08);
  --font-display: "Space Grotesk", "Vazirmatn", sans-serif;
  --font-body: "Vazirmatn", "Inter", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  min-height: 100vh;
  padding-bottom: 76px;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- کارت دور live (فقط نمایشی) ---------- */
.live-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 18px;
}
.live-card.hidden { display: none; }
.live-card-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-secondary); margin-bottom: 10px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--down); box-shadow: 0 0 8px var(--down); animation: pulse 1.4s infinite ease-in-out; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.live-price-row { display: flex; align-items: baseline; gap: 8px; font-family: var(--font-mono); font-size: 14px; margin-bottom: 2px; }
.live-label { color: var(--text-secondary); font-family: var(--font-body); font-size: 12px; min-width: 62px; }
.live-lock-price { color: var(--gold); font-weight: 700; }
.live-current-price { font-weight: 700; }
.live-current-price.up { color: var(--up); }
.live-current-price.down { color: var(--down); }
.live-price-delta { font-size: 12px; font-weight: 700; }
.live-price-delta.up { color: var(--up); }
.live-price-delta.down { color: var(--down); }
.live-card .sparkline { height: 34px; margin: 6px 0 2px; }
.sparkline-lock-line { stroke: var(--text-secondary); stroke-width: 1.2; stroke-dasharray: 3 2; vector-effect: non-scaling-stroke; }
.sparkline-price-line { fill: none; stroke: var(--up); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.sparkline-price-line.down { stroke: var(--down); }
.live-closes-in { font-size: 11px; color: var(--text-secondary); text-align: left; font-family: var(--font-mono); }

.betting-label { font-family: var(--font-display); font-weight: 700; font-size: 13px; color: var(--up); text-align: center; margin-bottom: 6px; }
.hidden { display: none !important; }

/* ---------- بخش کیف‌پول ---------- */
.wallet-section { margin-bottom: 18px; }
.wallet-btn { margin-bottom: 4px; }
.wallet-connected { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; }
.wallet-address { font-family: var(--font-mono); font-size: 13px; color: var(--up); margin-bottom: 12px; }
.deposit-chips { margin-bottom: 12px; }
.deposit-custom-row { display: flex; gap: 8px; margin-bottom: 10px; }
.deposit-input { flex: 1; background: var(--bg-surface-2); border: 1px solid var(--border); border-radius: 10px; color: var(--text-primary); font-family: var(--font-mono); padding: 0 12px; font-size: 14px; }
.cta-btn.small { width: auto; padding: 10px 16px; font-size: 13px; }
.link-btn { background: none; border: none; color: var(--text-secondary); font-size: 12px; text-decoration: underline; width: 100%; padding: 6px; }
.link-btn.danger { color: var(--down); }
.divider { display: flex; align-items: center; text-align: center; color: var(--text-secondary); font-size: 11px; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-bottom: 1px solid var(--border); }
.divider span { padding: 0 10px; }

/* ---------- آمار رفرال ---------- */
.referral-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.ref-stat-box { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 6px; text-align: center; }
.ref-stat-value { font-family: var(--font-mono); font-weight: 700; font-size: 16px; color: var(--gold); }
.ref-stat-label { font-size: 10px; color: var(--text-secondary); margin-top: 4px; }
.ref-total-box { background: rgba(240, 180, 41, 0.08); border: 1px solid var(--gold); border-radius: 12px; padding: 12px 14px; text-align: center; font-size: 13px; margin-bottom: 14px; }
.ref-total-box b { font-family: var(--font-mono); color: var(--gold); font-size: 16px; }
.ref-total-note { font-size: 10px; color: var(--text-secondary); margin-top: 4px; }
.withdraw-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 14px; }

/* ---------- بنر شرط فعلی کاربر ---------- */
.my-bets-banner { background: var(--bg-surface); border: 1px solid var(--gold); border-radius: 12px; padding: 10px 14px; font-size: 12px; text-align: center; margin-bottom: 14px; color: var(--text-primary); }
.my-bets-banner.hidden { display: none; }

/* ---------- بنر رتبه‌ی شخصی ---------- */
.my-rank-banner { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; font-size: 13px; text-align: center; color: var(--text-secondary); }
.my-rank-banner b { color: var(--gold); font-family: var(--font-mono); font-size: 15px; }

/* ---------- نوار بالا ---------- */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.balance-chip, .stats-chip { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 999px; padding: 8px 14px; font-family: var(--font-mono); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.balance-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 8px var(--gold); }
.balance-chip .unit { color: var(--text-secondary); font-size: 11px; }
.identity-banner { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 12px; font-size: 12px; color: var(--text-secondary); border-bottom: 1px solid var(--border); cursor: pointer; }
.identity-banner #displayNameValue { color: var(--text-primary); font-weight: 600; }
.identity-banner .info-dot { color: var(--gold); font-size: 11px; }

/* ---------- پنل‌ها ---------- */
.panel { display: none; padding: 20px 16px; animation: fadeIn 0.25s ease; }
.panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.panel-title { font-family: var(--font-display); font-weight: 700; font-size: 20px; margin-bottom: 16px; }

/* ---------- حلقه‌ی شمارش معکوس ---------- */
.ring-wrap { position: relative; width: 220px; height: 220px; margin: 12px auto 8px; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--bg-surface-2); stroke-width: 10; }
.ring-pools { fill: none; stroke: var(--up); stroke-width: 10; stroke-dasharray: 603.19 603.19; transition: stroke-dasharray 0.6s ease, stroke-dashoffset 0.6s ease; }
.ring-pools-down { fill: none; stroke: var(--down); stroke-width: 10; stroke-linecap: butt; transition: stroke-dasharray 0.6s ease, stroke-dashoffset 0.6s ease; }
.ring-time { fill: none; stroke: var(--gold); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 515.22 515.22; transition: stroke-dashoffset 0.25s linear; }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.countdown { font-family: var(--font-mono); font-weight: 700; font-size: 34px; letter-spacing: 1px; color: var(--gold); }
.ring-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* ---------- قیمت ---------- */
.price-ticker { text-align: center; font-family: var(--font-mono); font-size: 24px; font-weight: 700; margin-top: 6px; }
.price-delta { font-size: 14px; margin-inline-start: 6px; }
.price-delta.up { color: var(--up); }
.price-delta.down { color: var(--down); }
.sparkline { display: block; width: 100%; height: 44px; margin: 6px 0 2px; }
.sparkline polyline { fill: none; stroke: var(--gold); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.entry-price { text-align: center; color: var(--text-secondary); font-size: 12px; font-family: var(--font-mono); margin-top: 4px; margin-bottom: 18px; }

/* ---------- نوار استخر بالا/پایین ---------- */
.pools-bar { height: 10px; border-radius: 999px; background: var(--down); overflow: hidden; margin-bottom: 8px; }
.pools-bar-up { height: 100%; width: 50%; background: var(--up); transition: width 0.6s ease; }
.pools-legend { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-secondary); margin-bottom: 22px; }
.legend-item.up b, .legend-item.up span { color: var(--up); }
.legend-item.down b, .legend-item.down span { color: var(--down); }
.legend-item b { font-family: var(--font-mono); color: var(--text-primary); }

/* ---------- دکمه‌های جهت ---------- */
.direction-row { display: flex; gap: 12px; margin-bottom: 8px; }
.dir-btn { flex: 1; padding: 18px 8px; border-radius: 16px; border: 1.5px solid var(--border); background: var(--bg-surface); color: var(--text-primary); font-family: var(--font-display); font-weight: 700; font-size: 15px; display: flex; flex-direction: column; align-items: center; gap: 6px; transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease; }
.dir-btn:active { transform: scale(0.96); }
.dir-btn .dir-icon { font-size: 22px; }
.dir-up.selected { border-color: var(--up); background: rgba(52,211,153,0.12); }
.dir-down.selected { border-color: var(--down); background: rgba(251,113,133,0.12); }

/* ---------- مبلغ ---------- */
.amount-row { margin-top: 18px; }
.amount-row.hidden { display: none; }
.amount-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 10px; text-align: center; }
.amount-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.amount-chip { flex: 0 1 calc(33.333% - 7px); padding: 12px 4px 10px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--bg-surface); color: var(--text-primary); font-family: var(--font-mono); font-weight: 700; font-size: 14px; transition: transform 0.15s ease, background 0.15s ease; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.amount-chip .chip-multiplier { font-size: 11px; font-weight: 500; color: var(--text-secondary); }
.amount-chip:active { transform: scale(0.94); background: var(--gold); color: #1B1200; }
.amount-chip:active .chip-multiplier { color: #1B1200; }
.amount-chip:disabled { opacity: 0.35; }

/* ---------- تاریخچه ---------- */
.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-row { background: var(--bg-surface); border: 1px solid var(--border); border-inline-start: 3px solid var(--text-secondary); border-radius: 12px; padding: 12px 14px; font-size: 13px; display: flex; justify-content: space-between; align-items: center; }
.history-row.win { border-inline-start-color: var(--up); }
.history-row.lose { border-inline-start-color: var(--down); }
.history-row.void { border-inline-start-color: var(--gold); }
.history-row .h-main { display: flex; flex-direction: column; gap: 3px; }
.history-row .h-dir { font-weight: 600; }
.history-row .h-date { color: var(--text-secondary); font-size: 11px; font-family: var(--font-mono); }
.history-row .h-amount { font-family: var(--font-mono); font-weight: 700; text-align: left; }
.history-row.win .h-amount { color: var(--up); }
.history-row.lose .h-amount { color: var(--down); }
.history-row.void .h-amount { color: var(--gold); }

/* ---------- لیدربورد ---------- */
.leaderboard-list { display: flex; flex-direction: column; gap: 10px; }
.leaderboard-row { display: flex; justify-content: space-between; align-items: center; background: var(--bg-surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.leaderboard-row .rank { font-family: var(--font-mono); color: var(--gold); width: 28px; }
.leaderboard-row .name { flex: 1; margin-inline-start: 8px; }
.leaderboard-row .wins { font-family: var(--font-mono); color: var(--up); }

/* ---------- واریز / دعوت ---------- */
.hint { color: var(--text-secondary); font-size: 13px; margin-bottom: 10px; line-height: 1.8; }
.hint.warn { color: var(--gold); }
.code-box { background: var(--bg-surface); border: 1px dashed var(--border); border-radius: 12px; padding: 14px; font-family: var(--font-mono); font-size: 13px; word-break: break-all; margin-bottom: 16px; cursor: pointer; }
.cta-btn { width: 100%; padding: 14px; border-radius: 12px; border: none; background: var(--gold); color: #1B1200; font-family: var(--font-display); font-weight: 700; font-size: 15px; }

/* ---------- نوار پایین (تب‌ها) ---------- */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--bg-surface); border-top: 1px solid var(--border); padding: 8px 4px calc(8px + env(safe-area-inset-bottom)); }
.tab-btn { flex: 1; background: none; border: none; color: var(--text-secondary); font-size: 12px; padding: 8px 2px; border-radius: 10px; font-family: var(--font-body); }
.tab-btn.active { color: var(--gold); background: rgba(240,180,41,0.1); }

/* ---------- toast ---------- */
.toast { position: fixed; top: 14px; left: 50%; transform: translateX(-50%) translateY(-140%); background: var(--bg-surface-2); border: 1px solid var(--border); color: var(--text-primary); padding: 12px 18px; border-radius: 12px; font-size: 13px; z-index: 100; transition: transform 0.3s ease; max-width: 88%; text-align: center; }
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--down); color: var(--down); }
.toast.success { border-color: var(--up); color: var(--up); }
