/* =========================================================================
   BTTC MINER — "FORGE" THEME
   একটি স্বতন্ত্র ডিজাইন: obsidian/espresso ব্যাকগ্রাউন্ডে molten copper ও
   গোল্ড অ্যাকসেন্ট, একটি ধাতু-গলানোর ভাটির (forge/smelting) অনুভূতি নিয়ে —
   সাধারণ নিয়ন-সায়ান/ব্ল্যাক ক্রিপ্টো থিমের বদলে।
========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;600;700;800&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
    /* --- Core palette --- */
    --bg: #0f0b08;
    --bg-elevated: #150f0a;
    --surface: #1c140d;
    --surface-2: #241a11;
    --border: #34271a;

    --ember: #ff7a45;
    --ember-dim: #b8562f;
    --gold: #e3a542;
    --gold-soft: #f0c878;
    --copper-1: #ff8a4c;
    --copper-2: #e3a542;

    --text-main: #f5ede0;
    --text-muted: #a89478;
    --text-faint: #6f6150;

    --success: #5fd38d;
    --danger: #ef5350;
    --pending: #e3a542;

    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 9px;

    --font-display: 'Sora', 'Segoe UI', sans-serif;
    --font-body: 'Inter', 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-body);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

html, body {
    background: var(--bg);
    color: var(--text-main);
}

body {
    display: flex;
    justify-content: center;
    min-height: 100vh;
    background:
        radial-gradient(ellipse 600px 400px at 50% -10%, rgba(255,122,69,0.10), transparent 60%),
        var(--bg);
    overflow: hidden;
}

.app-container {
    width: 100%;
    max-width: 430px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* ============================= HEADER ================================= */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 14px;
    padding-top: max(20px, env(safe-area-inset-top));
    flex-shrink: 0;
    gap: 10px;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.avatar-badge {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: linear-gradient(145deg, var(--copper-1), var(--copper-2));
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1rem;
    color: #1a0f06;
    flex-shrink: 0;
}

.header-name-block { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.header-eyebrow { font-size: 0.66rem; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-faint); font-weight: 600; }
#userName {
    font-family: var(--font-display);
    font-size: 1.08rem;
    font-weight: 700;
    color: var(--text-main);
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.streak-chip {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 6px 10px;
    border-radius: 999px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--gold-soft);
    flex-shrink: 0;
}
.streak-chip svg { width: 13px; height: 13px; }

/* ============================= SECTIONS ================================ */
.section {
    display: none;
    width: 100%;
    flex-grow: 1;
    overflow-y: auto;
    padding: 4px 20px 100px;
}
.section.active { display: flex; flex-direction: column; }
.section::-webkit-scrollbar { display: none; }

.section-heading {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 6px 0 4px;
}
.section-subtext {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 18px;
}
.section-label {
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-faint);
    font-weight: 700;
    margin: 22px 0 10px;
}
.section-label:first-of-type { margin-top: 4px; }

/* ============================= HOME: CURRENT BALANCE CARD ============== */
.home-balance-card {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    margin: 6px 0 18px;
    text-align: center;
}
.home-balance-card .hb-label {
    font-size: 0.72rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-faint);
    font-weight: 700;
}
.home-balance-card .hb-amount {
    font-family: var(--font-mono);
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.01em;
    margin: 4px 0 2px;
}
.home-balance-card .hb-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============================= HOME: ORE GAUGE ========================= */
.gauge-wrap {
    position: relative;
    width: 224px;
    height: 224px;
    margin: 4px auto 22px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gauge-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge-track { fill: none; stroke: var(--surface-2); stroke-width: 10; }
.gauge-fill {
    fill: none;
    stroke: url(#gaugeGradient);
    stroke-width: 10;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.4s ease;
    filter: drop-shadow(0 0 8px rgba(255,122,69,0.45));
}

.gauge-center {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.gauge-label { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
.gauge-balance {
    font-family: var(--font-mono);
    font-size: 2.15rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.02em;
}
.gauge-unit { font-size: 0.75rem; color: var(--gold); font-weight: 600; margin-top: 2px; letter-spacing: 0.05em; }

.claim-wrap {
    position: relative;
    width: 100%;
}

.claim-btn {
    width: 100%;
    background: linear-gradient(90deg, var(--copper-1), var(--gold));
    color: #1a0f06;
    border: none;
    border-radius: 999px;
    padding: 16px;
    font-family: var(--font-display);
    font-size: 1.02rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(255,122,69,0.28);
    transition: transform 0.1s, opacity 0.2s, box-shadow 0.1s;
    min-height: 44px;
}
.claim-btn:active { transform: scale(0.97); }
.claim-btn:disabled { opacity: 0.4; box-shadow: none; cursor: default; }
.claim-btn.claiming { opacity: 0.85; cursor: wait; }

/* ছোট, lightweight "+X BTTC" floating feedback -- claim সফল হলে ওপরে ভেসে
   উঠে হালকা fade হয়ে যায়। কোনো heavy confetti/particle লাইব্রেরি ব্যবহার
   করা হয়নি, নিছক CSS keyframe animation। */
.claim-fx {
    position: absolute;
    top: -4px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    pointer-events: none;
}
.claim-fx-text {
    position: absolute;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--gold-soft);
    text-shadow: 0 0 10px rgba(227,165,66,0.45);
    animation: claim-float 1.1s ease-out forwards;
}
@keyframes claim-float {
    0%   { opacity: 0; transform: translateY(0) scale(0.92); }
    18%  { opacity: 1; transform: translateY(-8px) scale(1); }
    100% { opacity: 0; transform: translateY(-46px) scale(1); }
}

.timer-text {
    text-align: center;
    margin-top: 14px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
}
.timer-text.ready { color: var(--success); font-weight: 700; }

/* --- Daily streak strip --- */
.streak-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-top: 32px;
}
.streak-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.streak-card-title { font-family: var(--font-display); font-weight: 700; font-size: 0.95rem; }
.streak-card-sub { font-size: 0.72rem; color: var(--text-faint); }

.streak-pips { display: flex; gap: 6px; margin-bottom: 14px; }
.streak-pip {
    flex: 1;
    aspect-ratio: 1;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-faint);
    font-weight: 700;
}
.streak-pip.done { background: linear-gradient(145deg, var(--copper-1), var(--copper-2)); color: #1a0f06; border-color: transparent; }
.streak-pip.today { border-color: var(--gold); color: var(--gold-soft); box-shadow: 0 0 0 2px rgba(227,165,66,0.2); }

.checkin-btn {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 12px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    transition: 0.15s;
}
.checkin-btn.available { background: linear-gradient(90deg, var(--copper-1), var(--gold)); color: #1a0f06; border: none; }
.checkin-btn:disabled { opacity: 0.55; cursor: default; }

/* ============================= CARDS (tasks/friends) =================== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    width: 100%;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
.card-icon {
    width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
    background: var(--surface-2);
    display: flex; align-items: center; justify-content: center;
    color: var(--gold);
}
.card-icon svg { width: 20px; height: 20px; }
.card-info { flex-grow: 1; min-width: 0; }
.card-info h4 { font-size: 0.92rem; font-weight: 600; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-info p { margin-top: 3px; color: var(--gold-soft); font-size: 0.82rem; font-weight: 700; font-family: var(--font-mono); }

.action-btn {
    background: linear-gradient(90deg, var(--copper-1), var(--gold));
    color: #1a0f06;
    border: none;
    padding: 9px 16px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.82rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: 0.15s;
}
.action-btn:active { transform: scale(0.95); }
.action-btn.done { background: var(--surface-2); color: var(--success); }
.action-btn:disabled { opacity: 0.6; cursor: default; }

.empty-state {
    text-align: center;
    color: var(--text-faint);
    font-size: 0.85rem;
    padding: 30px 10px;
}

/* ============================= LEADERBOARD ============================= */
.my-rank-banner {
    background: linear-gradient(120deg, rgba(255,122,69,0.14), rgba(227,165,66,0.08));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}
.my-rank-banner .rank-num { font-family: var(--font-display); font-size: 1.6rem; font-weight: 800; color: var(--gold-soft); }
.my-rank-banner .rank-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }

.leader-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 6px;
    border-bottom: 1px solid var(--border);
}
.leader-row:last-child { border-bottom: none; }
.leader-rank {
    width: 26px; text-align: center;
    font-family: var(--font-mono); font-weight: 700; font-size: 0.85rem;
    color: var(--text-faint);
}
.leader-rank.top1 { color: #ffd166; }
.leader-rank.top2 { color: #d9d9d9; }
.leader-rank.top3 { color: #c9884f; }
.leader-avatar {
    width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
    background: var(--surface-2);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-weight: 700; font-size: 0.8rem; color: var(--gold);
}
.leader-name { flex-grow: 1; font-size: 0.88rem; font-weight: 500; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leader-balance { font-family: var(--font-mono); font-size: 0.85rem; font-weight: 700; color: var(--gold-soft); }

/* ============================= FRIENDS ================================= */
.ref-box {
    display: flex;
    gap: 8px;
    width: 100%;
    margin-bottom: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 4px 4px 4px 14px;
    align-items: center;
}
.ref-box input {
    flex-grow: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    outline: none;
}
.ref-box button {
    background: var(--surface-2);
    color: var(--text-main);
    border: none;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.82rem;
}

.share-btn {
    width: 100%;
    background: linear-gradient(90deg, var(--copper-1), var(--gold));
    color: #1a0f06;
    border: none;
    padding: 14px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.92rem;
    cursor: pointer;
    margin-bottom: 8px;
}

/* ============================= WALLET =================================== */
.balance-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
}
.balance-card .bc-label { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 6px; }
.balance-card .bc-amount { font-family: var(--font-mono); font-size: 1.9rem; font-weight: 700; color: var(--text-main); }
.balance-card .bc-note { font-size: 0.76rem; color: var(--ember); margin-top: 10px; font-weight: 600; }

.input-group { width: 100%; margin-bottom: 18px; }
.input-group label { display: block; margin-bottom: 8px; color: var(--text-muted); font-size: 0.85rem; font-weight: 500; }
.input-group input {
    width: 100%; padding: 13px 14px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--surface); color: var(--text-main);
    font-size: 0.95rem; outline: none; font-family: var(--font-mono);
}
.input-group input:focus { border-color: var(--gold); }

.withdraw-btn {
    width: 100%;
    background: linear-gradient(90deg, var(--copper-1), var(--gold));
    color: #1a0f06;
    border: none;
    padding: 15px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    margin-bottom: 6px;
}
.withdraw-btn:disabled { opacity: 0.5; cursor: default; }

.history-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.history-row:last-child { border-bottom: none; }
.history-amount { font-family: var(--font-mono); font-weight: 700; font-size: 0.9rem; color: var(--text-main); }
.history-date { font-size: 0.72rem; color: var(--text-faint); margin-top: 2px; }
.status-pill {
    font-size: 0.7rem; font-weight: 700; padding: 4px 10px; border-radius: 999px;
    text-transform: capitalize;
}
.status-pill.pending { background: rgba(227,165,66,0.15); color: var(--pending); }
.status-pill.processing { background: rgba(90,160,230,0.15); color: #5aa0e6; }
.status-pill.approved { background: rgba(95,211,141,0.15); color: var(--success); }
.status-pill.rejected { background: rgba(239,83,80,0.15); color: var(--danger); }

/* ============================= BOTTOM NAV =============================== */
.bottom-nav {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 10px 6px calc(10px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(21,15,10,0.85), var(--bg-elevated) 30%);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
}

.nav-btn {
    background: none;
    border: none;
    color: var(--text-faint);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 6px 10px;
    font-family: var(--font-body);
    font-size: 0.66rem;
    font-weight: 600;
    transition: color 0.2s;
}
.nav-btn svg { width: 21px; height: 21px; transition: 0.2s; }
.nav-btn.active { color: var(--gold-soft); }
.nav-btn.active svg { filter: drop-shadow(0 0 6px rgba(227,165,66,0.5)); }

/* ============================= TOAST ===================================== */
.toast {
    position: fixed;
    bottom: 96px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 11px 18px;
    border-radius: 999px;
    font-size: 0.83rem;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: 0.25s;
    z-index: 999;
    max-width: 85%;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-icon { display: inline-block; margin-right: 6px; font-weight: 700; }
.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.info .toast-icon { color: var(--gold-soft); }

/* ============================= EMPTY STATES (icon variant) ============= */
.empty-state-block {
    text-align: center;
    padding: 44px 20px;
    color: var(--text-faint);
}
.empty-state-icon {
    width: 46px; height: 46px;
    margin: 0 auto 12px;
    border-radius: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    color: var(--gold);
}
.empty-state-icon svg { width: 22px; height: 22px; }
.empty-state-title { font-size: 0.92rem; font-weight: 700; color: var(--text-main); margin-bottom: 4px; }
.empty-state-sub { font-size: 0.8rem; color: var(--text-faint); }

/* ============================= CONFIRM MODAL ============================ */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(8,5,3,0.6);
    backdrop-filter: blur(2px);
    display: flex; align-items: flex-end; justify-content: center;
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s;
    z-index: 1000;
}
.modal-overlay.show { opacity: 1; pointer-events: auto; }
.modal-card {
    width: 100%; max-width: 430px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 22px 22px 0 0;
    padding: 22px 20px calc(20px + env(safe-area-inset-bottom));
    transform: translateY(16px);
    transition: transform 0.25s ease;
}
.modal-overlay.show .modal-card { transform: translateY(0); }
.modal-title { font-family: var(--font-display); font-size: 1.05rem; font-weight: 700; color: var(--text-main); margin-bottom: 4px; text-align: center; }
.modal-sub { font-size: 0.83rem; color: var(--text-muted); text-align: center; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; }
.modal-btn {
    flex: 1; padding: 14px; border-radius: var(--radius-sm);
    font-weight: 700; font-size: 0.92rem; cursor: pointer; border: none;
}
.modal-btn.cancel { background: var(--surface-2); color: var(--text-main); border: 1px solid var(--border); }
.modal-btn.confirm { background: linear-gradient(90deg, var(--copper-1), var(--gold)); color: #1a0f06; }
.modal-btn:disabled { opacity: 0.5; }

/* ============================= MISC POLISH ============================== */
.claim-btn, .checkin-btn, .action-btn, .withdraw-btn, .modal-btn {
    -webkit-tap-highlight-color: transparent;
}
.claim-btn span.dot-loading::after {
    content: '...';
}

/* ============================= SMALL SCREEN SAFETY (320px+) ============= */
@media (max-width: 340px) {
    .section { padding-left: 14px; padding-right: 14px; }
    .header { padding-left: 14px; padding-right: 14px; }
    .gauge-wrap { width: 200px; height: 200px; }
    .gauge-balance { font-size: 1.8rem; }
    .modal-card { padding-left: 16px; padding-right: 16px; }
}

/* ছোট উচ্চতার স্ক্রিনে (short viewport) সব element visible রাখতে compact
   spacing -- কোনো element overlap করবে না। */
@media (max-height: 700px) {
    .gauge-wrap { width: 196px; height: 196px; margin: 2px auto 16px; }
    .home-balance-card { padding: 12px 16px; margin: 4px 0 12px; }
    .streak-card { margin-top: 20px; }
}

/* ============================================================================
   AUTH GATE — Telegram initData ভেরিফাই না হওয়া পর্যন্ত পুরো অ্যাপ ঢাকা থাকে
   ============================================================================ */
.auth-gate {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 11, 8, 0.97);
    backdrop-filter: blur(4px);
}
.auth-gate.show {
    display: flex;
}
.auth-gate-card {
    text-align: center;
    padding: 32px;
    max-width: 320px;
}
.auth-gate-card p {
    color: var(--text-main);
    font-family: var(--font-display);
    font-size: 1rem;
    line-height: 1.5;
}
.auth-gate.auth-gate-error .auth-gate-card p {
    color: var(--danger);
    font-weight: 600;
}
.auth-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 20px;
    border: 3px solid var(--border);
    border-top-color: var(--ember);
    border-radius: 50%;
    animation: auth-spin 0.8s linear infinite;
}
@keyframes auth-spin {
    to { transform: rotate(360deg); }
}
