:root {
    --bg-color: #0b0f19;
    --card-bg: rgba(20, 25, 40, 0.4);
    --card-border: rgba(255, 255, 255, 0.06);
    --primary: #8b5cf6;
    --primary-glow: rgba(139, 92, 246, 0.4);
    --accent: #f59e0b;
    --accent-glow: rgba(245, 158, 11, 0.3);
    --text-main: #ffffff;
    --text-muted: #94a3b8;
    --success: #10b981;
    --danger: #ef4444;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    padding-bottom: 90px; /* Space for bottom nav */
}

/* --- Animated Premium Background --- */
.bg-mesh {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: -2;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, rgba(139, 92, 246, 0.12) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(245, 158, 11, 0.08) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(16, 185, 129, 0.05) 0px, transparent 50%);
}

.bg-glow, .bg-glow-2 {
    position: fixed;
    border-radius: 50%;
    filter: blur(90px);
    z-index: -1;
    opacity: 0.5;
    animation: drift 12s infinite alternate ease-in-out;
}

.bg-glow {
    width: 300px; height: 300px;
    background: var(--primary-glow);
    top: -10%; left: -10%;
}

.bg-glow-2 {
    width: 350px; height: 350px;
    background: var(--accent-glow);
    bottom: -10%; right: -10%;
    animation-duration: 15s;
    animation-delay: -5s;
}

@keyframes drift {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(40px, 40px) scale(1.1); }
}

/* Premium Glassmorphism Utility */
.premium-glass {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow: 0 10px 40px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.05);
}

.premium-glass-btn {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
}

.premium-glass-modal {
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.95) 0%, rgba(15, 23, 42, 0.98) 100%);
    border-top: 1px solid rgba(255,255,255,0.1);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
}

/* --- Layout & Tabs --- */
.main-content {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    padding: 24px;
    min-height: 100vh;
}

.tab-content {
    display: none;
    animation: fade-in-up 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.tab-content.active {
    display: block;
}

@keyframes fade-in-up {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-header {
    margin-bottom: 24px;
    text-align: center;
}
.page-header h2 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 6px;
}
.page-header p {
    color: var(--text-muted);
    font-size: 15px;
}

/* --- Icons --- */
i[data-lucide] {
    stroke-width: 2;
    vertical-align: middle;
}
.icon-sm { width: 20px; height: 20px; }

/* --- Home Tab: Header --- */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-radius: 20px;
    margin-bottom: 30px;
}

.profile-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #ec4899);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
    border: 2px solid rgba(255,255,255,0.1);
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-name {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.2px;
}
.user-id {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 2px;
}
.settings-btn {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
}
.settings-btn:active { background: rgba(255,255,255,0.1); }

/* --- Home Tab: Balance --- */
.balance-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 30px;
}

.coin-animation {
    width: 140px;
    height: 140px;
    background: linear-gradient(135deg, #fef08a, #f59e0b);
    border-radius: 50%;
    box-shadow: 
        0 15px 35px var(--accent-glow),
        inset 0 0 0 4px rgba(255,255,255,0.4),
        inset 0 0 15px rgba(255,255,255,0.8),
        inset 0 -12px 25px rgba(217, 119, 6, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    animation: float-3d 4s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
    position: relative;
    color: #b45309; /* Darker amber for icon */
}
.coin-animation .coin-icon {
    width: 60px; height: 60px;
}

@keyframes float-3d {
    0% { transform: translateY(0px) scale(1); }
    50% { transform: translateY(-12px) scale(1.02); box-shadow: 0 25px 50px var(--accent-glow), inset 0 0 0 4px rgba(255,255,255,0.4), inset 0 -12px 25px rgba(217, 119, 6, 0.8); }
    100% { transform: translateY(0px) scale(1); }
}

.balance-value {
    font-size: 52px;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 6px;
    background: linear-gradient(180deg, #ffffff 0%, #fcd34d 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -1px;
}
.balance-label {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* --- Daily Bonus Card --- */
.daily-bonus-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-radius: 20px;
    margin-bottom: 24px;
    cursor: pointer;
    transition: 0.2s;
}
.daily-bonus-card:active { transform: scale(0.97); }
.daily-bonus-card.claimed { opacity: 0.6; pointer-events: none; }

.bonus-info h4 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.bonus-info p { font-size: 13px; color: var(--text-muted); }
.bonus-icon-wrapper {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    display: flex; align-items: center; justify-content: center;
}

/* --- Buttons --- */
.actions { display: flex; flex-direction: column; gap: 14px; }

.btn {
    width: 100%;
    padding: 16px 20px;
    border-radius: 18px;
    border: none;
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: 0.2s;
    color: white;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #6d28d9);
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.25);
}
.btn-secondary {
    background: rgba(30, 41, 59, 0.6);
}
.btn-icon {
    width: 54px; padding: 0; background: rgba(30, 41, 59, 0.6);
}
.mt-15 { margin-top: 15px; }

/* --- Tasks --- */
.tasks-list { display: flex; flex-direction: column; gap: 12px; }
.task-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px; border-radius: 18px;
}
.task-left { display: flex; align-items: center; gap: 14px; }
.task-icon {
    width: 42px; height: 42px; border-radius: 12px;
    background: rgba(255,255,255,0.05);
    display: flex; align-items: center; justify-content: center;
    color: var(--primary);
}
.task-info h4 { font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.task-info p { font-size: 13px; color: var(--accent); font-weight: 600; display: flex; align-items: center; gap: 4px;}
.task-action {
    width: 36px; height: 36px; border-radius: 50%;
    background: rgba(255,255,255,0.08); display: flex; align-items: center; justify-content: center;
    transition: 0.2s; cursor: pointer;
}
.task-action.completed { background: var(--success); color: white; }
.task-action:active { transform: scale(0.9); }

/* --- Friends --- */
.referral-card {
    padding: 20px; border-radius: 20px; margin-bottom: 24px;
}
.ref-stats {
    display: flex; justify-content: space-between; margin-bottom: 20px;
}
.stat { flex: 1; text-align: center; }
.stat span { display: block; font-size: 24px; font-weight: 800; color: var(--accent); margin-bottom: 4px; }
.stat label { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.divider { width: 1px; background: rgba(255,255,255,0.1); flex: none; margin: 0 10px; }
.ref-actions { display: flex; gap: 10px; }

.section-title { font-size: 16px; font-weight: 700; margin-bottom: 14px; padding-left: 5px; }
.friends-list { display: flex; flex-direction: column; gap: 10px; }
.friend-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; border-radius: 16px; background: var(--card-bg); border: 1px solid var(--card-border);
}
.friend-name { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.friend-reward { font-size: 14px; color: var(--success); font-weight: 700; }

.empty-state {
    padding: 30px; text-align: center; color: var(--text-muted); font-size: 14px;
    display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.empty-icon { width: 40px; height: 40px; opacity: 0.5; }

/* --- Leaderboard --- */
.leaderboard-list {
    border-radius: 20px; overflow: hidden; padding: 10px 0;
}
.lb-item {
    display: flex; align-items: center; padding: 12px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.lb-item:last-child { border-bottom: none; }
.lb-item.is-me { background: rgba(139, 92, 246, 0.1); }
.lb-rank { width: 30px; font-weight: 700; color: var(--text-muted); font-size: 15px; }
.lb-rank.top-1 { color: #f59e0b; font-size: 18px; }
.lb-rank.top-2 { color: #94a3b8; font-size: 17px; }
.lb-rank.top-3 { color: #d97706; font-size: 16px; }
.lb-name { flex: 1; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 10px;}
.lb-score { font-size: 15px; font-weight: 700; color: var(--accent); }

/* --- Bottom Nav --- */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; width: 100%;
    height: 70px; display: flex; justify-content: space-around; align-items: center;
    border-top-left-radius: 24px; border-top-right-radius: 24px;
    z-index: 100;
}
.nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    color: var(--text-muted); cursor: pointer; transition: 0.2s; flex: 1;
}
.nav-item i { width: 22px; height: 22px; transition: 0.2s; }
.nav-item span { font-size: 11px; font-weight: 600; }
.nav-item.active { color: var(--primary); }
.nav-item.active i { transform: translateY(-2px); }

/* --- Modal --- */
.modal {
    position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    z-index: 1000; display: flex; align-items: flex-end;
    visibility: hidden; opacity: 0; transition: all 0.3s;
}
.modal.active { visibility: visible; opacity: 1; }
.modal-content {
    width: 100%; border-radius: 32px 32px 0 0; padding: 32px 24px 40px;
    transform: translateY(100%); transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex; flex-direction: column; gap: 20px; box-shadow: 0 -10px 40px rgba(0,0,0,0.5);
}
.modal.active .modal-content { transform: translateY(0); }
.modal-header { display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { font-size: 22px; font-weight: 700; }
.close-btn {
    background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
    width: 36px; height: 36px; border-radius: 50%; color: white;
    display: flex; align-items: center; justify-content: center; cursor: pointer;
}

.exchange-rate {
    display: flex; align-items: center; justify-content: center; gap: 15px;
    padding: 20px; border-radius: 20px;
}
.rate-item { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.rate-icon { width: 32px; height: 32px; }
.rate-icon.coin { color: var(--accent); }
.rate-icon.star { color: #facc15; fill: #facc15; }
.rate-item span { font-size: 15px; font-weight: 700; }
.rate-divider { color: var(--text-muted); opacity: 0.5; }
.modal-desc { font-size: 14px; color: var(--text-muted); text-align: center; line-height: 1.5; }

/* Utilities */
.spin { animation: spin 1s linear infinite; }
@keyframes spin { 100% { transform: rotate(360deg); } }
.loading-spinner { display: flex; justify-content: center; padding: 30px; color: var(--primary); }

/* Toasts */
#toast-container {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
    z-index: 10000; display: flex; flex-direction: column; gap: 12px;
    width: calc(100% - 40px); max-width: 400px; pointer-events: none;
}
.toast {
    background: rgba(15, 23, 42, 0.9); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.1); padding: 14px 18px; border-radius: 16px;
    color: #fff; font-size: 14px; font-weight: 500; box-shadow: 0 15px 30px rgba(0,0,0,0.3);
    display: flex; align-items: center; gap: 12px;
    animation: toast-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; pointer-events: auto;
}
.toast-icon { width: 20px; height: 20px; }
.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.info .toast-icon { color: var(--primary); }
@keyframes toast-in {
    from { opacity: 0; transform: translateY(-20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.toast.hide { opacity: 0; transform: translateY(-10px); transition: 0.3s; }
