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

:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17,24,39,0.8);
    --bg-glass: rgba(255,255,255,0.05);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #6366f1;
    --accent-glow: rgba(99,102,241,0.3);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --border: rgba(255,255,255,0.08);
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --nav-height: 70px;
    --gradient-1: linear-gradient(135deg, #6366f1, #8b5cf6);
    --gradient-2: linear-gradient(135deg, #10b981, #06b6d4);
    --gradient-3: linear-gradient(135deg, #f59e0b, #ef4444);
}

[data-theme="light"] {
    --bg-primary: #f1f5f9;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255,255,255,0.9);
    --bg-glass: rgba(0,0,0,0.03);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: rgba(0,0,0,0.08);
    --shadow: 0 4px 24px rgba(0,0,0,0.08);
}

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

html { font-size: 16px; -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    padding-bottom: calc(var(--nav-height) + 20px);
    -webkit-font-smoothing: antialiased;
}

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 4px; }

/* === LOADER === */
.app-loader {
    position: fixed; inset: 0; z-index: 9999;
    background: var(--bg-primary);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    transition: opacity 0.4s;
}
.app-loader.hidden { opacity: 0; pointer-events: none; }
.loader-spinner {
    width: 48px; height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text { margin-top: 16px; color: var(--text-secondary); font-size: 0.875rem; }

/* === APP HEADER === */
.app-header {
    position: sticky; top: 0; z-index: 100;
    padding: 16px 20px;
    background: rgba(10,14,26,0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
[data-theme="light"] .app-header { background: rgba(241,245,249,0.85); }
.header-left { display: flex; align-items: center; gap: 12px; }
.header-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--gradient-1);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1rem; color: #fff;
    overflow: hidden;
}
.header-avatar img { width: 100%; height: 100%; object-fit: cover; }
.header-name { font-weight: 600; font-size: 0.95rem; }
.header-balance { font-size: 0.8rem; color: var(--success); font-weight: 500; }
.header-actions { display: flex; gap: 8px; }
.header-btn {
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--bg-glass); border: 1px solid var(--border);
    color: var(--text-secondary); font-size: 1.1rem;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.3s;
}
.header-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* === PAGE CONTAINER === */
.page { display: none; padding: 20px; animation: fadeIn 0.3s; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* === CARDS === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    transition: transform 0.2s;
}
.card:hover { transform: translateY(-2px); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 1rem; font-weight: 600; }
.card-badge {
    padding: 4px 10px; border-radius: 20px;
    font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
}
.badge-success { background: rgba(16,185,129,0.15); color: var(--success); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-info { background: rgba(59,130,246,0.15); color: var(--info); }

/* === BALANCE CARD === */
.balance-card {
    background: var(--gradient-1);
    border: none; color: #fff; text-align: center;
    padding: 28px; position: relative; overflow: hidden;
}
.balance-card::before {
    content: ''; position: absolute; top: -50%; right: -50%;
    width: 100%; height: 100%; border-radius: 50%;
    background: rgba(255,255,255,0.08);
}
.balance-label { font-size: 0.85rem; opacity: 0.85; margin-bottom: 4px; }
.balance-amount { font-size: 2.2rem; font-weight: 800; letter-spacing: -1px; }
.balance-sub { font-size: 0.8rem; opacity: 0.7; margin-top: 4px; }

/* === STATS GRID === */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.stat-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 16px;
    text-align: center; backdrop-filter: blur(10px);
}
.stat-icon { font-size: 1.5rem; margin-bottom: 6px; }
.stat-value { font-size: 1.3rem; font-weight: 700; }
.stat-label { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.5px; }

/* === PROGRESS BAR === */
.progress-bar {
    width: 100%; height: 8px; background: var(--bg-glass);
    border-radius: 4px; overflow: hidden; margin: 8px 0;
}
.progress-fill {
    height: 100%; border-radius: 4px;
    background: var(--gradient-1);
    transition: width 0.6s ease;
}

/* === SPIN PAGE (Reference Design Match) === */
.spin-page-wrap {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; padding: 16px;
    min-height: calc(100vh - 140px);
}
.spin-title {
    font-size: 2rem; font-weight: 800; color: #dc2626;
    text-align: center; text-transform: uppercase;
    letter-spacing: 0.05em; margin-bottom: 24px;
    text-shadow: 1px 2px 4px rgba(0,0,0,0.15);
}

/* Wheel Container */
.spin-wheel-container {
    position: relative;
    width: 320px; height: 320px;
    margin-bottom: 8px;
}
@media (min-width: 480px) {
    .spin-wheel-container { width: 400px; height: 400px; }
}

/* Canvas */
.spin-canvas {
    width: 100%; height: 100%;
    border-radius: 50%;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25), 0 0 0 4px rgba(0,0,0,0.05);
}
.spin-transition {
    transition: transform 4s cubic-bezier(0.14, 0.9, 0.38, 1);
}

/* Center Golden Hub */
.spin-center-hub {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10; display: flex; flex-direction: column;
    align-items: center;
}
.spin-center-pointer {
    width: 0; height: 0;
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-bottom: 30px solid #facc15;
    position: absolute; top: -25px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    z-index: 0;
}
.spin-center-btn {
    width: 64px; height: 64px;
    background: linear-gradient(135deg, #fde047, #eab308, #a16207);
    border-radius: 50%;
    border: 4px solid #ca8a04;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3), inset 0 2px 4px rgba(255,255,255,0.4);
    display: flex; align-items: center; justify-content: center;
    position: relative; z-index: 10;
}
.spin-center-inner {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, #fef9c3, #facc15);
    border-radius: 50%;
}

/* Red Stand */
.spin-stand {
    position: absolute; bottom: -32px;
    left: 50%; transform: translateX(-50%);
    width: 128px; height: 64px;
    background: linear-gradient(to bottom, #dc2626, #991b1b);
    clip-path: polygon(20% 0%, 80% 0%, 100% 100%, 0% 100%);
    z-index: -1;
}
.spin-stand-base {
    position: absolute; bottom: -40px;
    left: 50%; transform: translateX(-50%);
    width: 160px; height: 16px;
    background: #7f1d1d;
    border-radius: 0 0 6px 6px;
    z-index: -1;
}

/* Result Text */
.spin-result {
    height: 40px;
    font-size: 1.4rem; font-weight: 700;
    color: #15803d;
    text-align: center;
    margin-top: 40px; margin-bottom: 20px;
}
.spin-result.pulse { animation: resultPulse 1s ease-in-out infinite; }
@keyframes resultPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* 3D Spin Button */
.spin-btn-3d {
    background: #ef4444;
    color: #fff; font-weight: 700;
    font-size: 1.4rem; font-family: inherit;
    padding: 14px 48px;
    border-radius: 9999px;
    border: 4px solid #b91c1c;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    box-shadow: 0 6px 0 #991b1b, 0 10px 10px rgba(0,0,0,0.3);
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}
.spin-btn-3d:hover { background: #dc2626; }
.spin-btn-3d:active {
    box-shadow: 0 2px 0 #991b1b, 0 4px 6px rgba(0,0,0,0.3);
    transform: translateY(4px);
}
.spin-btn-3d:disabled {
    opacity: 0.75; cursor: wait;
}
.spin-btn-3d:disabled:active {
    transform: none;
    box-shadow: 0 6px 0 #991b1b, 0 10px 10px rgba(0,0,0,0.3);
}

/* Spin Counter Bar */
.spin-counter-bar {
    display: flex; justify-content: center; gap: 24px;
    margin-top: 16px; font-size: 0.85rem;
    color: var(--text-secondary);
}
.spin-counter-bar strong {
    color: var(--text-primary);
}

/* === LISTS === */
.list-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 0; border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-left { display: flex; align-items: center; gap: 12px; }
.list-icon {
    width: 40px; height: 40px; border-radius: var(--radius-xs);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
}
.list-title { font-size: 0.9rem; font-weight: 500; }
.list-subtitle { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.list-right { text-align: right; }
.list-amount { font-size: 0.95rem; font-weight: 600; }
.list-amount.positive { color: var(--success); }
.list-amount.negative { color: var(--danger); }
.list-date { font-size: 0.7rem; color: var(--text-muted); }

/* === BUTTONS === */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 12px 24px; border: none; border-radius: var(--radius-sm);
    font-size: 0.9rem; font-weight: 600; cursor: pointer;
    transition: all 0.3s; gap: 8px; font-family: inherit;
}
.btn-primary { background: var(--gradient-1); color: #fff; box-shadow: 0 4px 15px var(--accent-glow); }
.btn-primary:hover { transform: translateY(-2px); }
.btn-success { background: var(--gradient-2); color: #fff; }
.btn-outline {
    background: transparent; border: 1px solid var(--border);
    color: var(--text-primary);
}
.btn-outline:hover { background: var(--bg-glass); }
.btn-sm { padding: 8px 16px; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* === FORMS === */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.8rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.form-input, .form-select {
    width: 100%; padding: 12px 16px;
    background: var(--bg-glass); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-primary);
    font-size: 0.9rem; font-family: inherit; outline: none;
    transition: border-color 0.3s;
}
.form-input:focus, .form-select:focus { border-color: var(--accent); }
.form-select { appearance: none; cursor: pointer; }

/* === BOTTOM NAV === */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: var(--nav-height);
    background: rgba(10,14,26,0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-around;
    padding: 0 8px; z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom, 0);
}
[data-theme="light"] .bottom-nav { background: rgba(255,255,255,0.95); }
.nav-item {
    display: flex; flex-direction: column; align-items: center;
    gap: 4px; cursor: pointer; padding: 8px 12px;
    border-radius: var(--radius-sm); transition: all 0.3s;
    color: var(--text-muted); text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}
.nav-item.active { color: var(--accent); }
.nav-item:active { transform: scale(0.92); }
.nav-icon { font-size: 1.3rem; }
.nav-label { font-size: 0.65rem; font-weight: 500; }

/* === MODAL === */
.modal-overlay {
    position: fixed; inset: 0; z-index: 2000;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
    display: none; align-items: center; justify-content: center;
    padding: 20px; animation: fadeIn 0.2s;
}
.modal-overlay.active { display: flex; }
.modal-box {
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px;
    max-width: 380px; width: 100%; text-align: center;
    animation: slideUp 0.3s;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-icon { font-size: 3rem; margin-bottom: 12px; }
.modal-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 8px; }
.modal-text { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 20px; }
.modal-img { width: 100%; border-radius: var(--radius-sm); margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

/* === TOAST === */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; }
.toast {
    padding: 12px 20px; border-radius: var(--radius-sm);
    background: var(--bg-secondary); border: 1px solid var(--border);
    color: var(--text-primary); font-size: 0.85rem;
    box-shadow: var(--shadow); animation: slideIn 0.3s;
    display: flex; align-items: center; gap: 8px;
}
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }

/* === WITHDRAWAL METHODS === */
.method-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.method-card {
    background: var(--bg-glass); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 16px; text-align: center;
    cursor: pointer; transition: all 0.3s;
}
.method-card:hover, .method-card.selected { border-color: var(--accent); background: var(--accent-glow); }
.method-icon { font-size: 1.8rem; margin-bottom: 6px; }
.method-name { font-size: 0.8rem; font-weight: 500; }

/* === LEADERBOARD === */
.lb-tabs { display: flex; gap: 6px; margin-bottom: 16px; overflow-x: auto; }
.lb-tab {
    padding: 8px 16px; border-radius: 20px;
    background: var(--bg-glass); border: 1px solid var(--border);
    color: var(--text-secondary); font-size: 0.8rem; font-weight: 500;
    cursor: pointer; white-space: nowrap; transition: all 0.3s;
}
.lb-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.lb-rank { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.lb-rank:last-child { border-bottom: none; }
.lb-position {
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem; font-weight: 700; background: var(--bg-glass); flex-shrink: 0;
}
.lb-rank:nth-child(1) .lb-position { background: linear-gradient(135deg,#ffd700,#ffaa00); color: #000; }
.lb-rank:nth-child(2) .lb-position { background: linear-gradient(135deg,#c0c0c0,#a0a0a0); color: #000; }
.lb-rank:nth-child(3) .lb-position { background: linear-gradient(135deg,#cd7f32,#b8860b); color: #fff; }
.lb-info { flex: 1; min-width: 0; }
.lb-name { font-size: 0.9rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-score { font-size: 0.75rem; color: var(--text-muted); }
.lb-value { font-weight: 700; color: var(--accent); font-size: 0.9rem; flex-shrink: 0; }

/* === CHECKIN === */
.checkin-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 6px; margin: 16px 0; }
.checkin-day {
    aspect-ratio: 1; border-radius: var(--radius-xs);
    background: var(--bg-glass); border: 1px solid var(--border);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    font-size: 0.65rem; color: var(--text-muted);
}
.checkin-day.completed { background: rgba(16,185,129,0.15); border-color: var(--success); color: var(--success); }
.checkin-day.today { border-color: var(--accent); color: var(--accent); }
.checkin-reward { font-weight: 700; font-size: 0.8rem; }

/* === PROFILE === */
.profile-header { text-align: center; padding: 20px 0; }
.profile-avatar {
    width: 80px; height: 80px; border-radius: 50%;
    background: var(--gradient-1); margin: 0 auto 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem; font-weight: 800; color: #fff; overflow: hidden;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-name { font-size: 1.2rem; font-weight: 700; }
.profile-username { font-size: 0.85rem; color: var(--text-muted); }
.profile-info { margin-top: 16px; }
.info-row { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--text-muted); font-size: 0.85rem; }
.info-value { font-weight: 500; font-size: 0.85rem; }

/* === REFERRAL === */
.referral-link-box {
    display: flex; gap: 8px; padding: 12px;
    background: var(--bg-glass); border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.referral-link-box input {
    flex: 1; background: none; border: none; color: var(--text-primary);
    font-size: 0.8rem; outline: none; font-family: inherit;
}
.copy-btn {
    padding: 8px 16px; border: none; border-radius: var(--radius-xs);
    background: var(--accent); color: #fff; font-size: 0.8rem;
    font-weight: 600; cursor: pointer; white-space: nowrap;
}

/* === ANNOUNCEMENT BANNER === */
.announcement-banner {
    background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(139,92,246,0.15));
    border: 1px solid rgba(99,102,241,0.3);
    border-radius: var(--radius-sm); padding: 14px 16px;
    margin-bottom: 16px; font-size: 0.85rem;
}

/* === PAGINATION === */
.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 16px; }
.page-btn {
    width: 36px; height: 36px; border-radius: var(--radius-xs);
    background: var(--bg-glass); border: 1px solid var(--border);
    color: var(--text-secondary); font-size: 0.85rem;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.3s;
}
.page-btn.active, .page-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* === EMPTY STATE === */
.empty-state { text-align: center; padding: 40px 20px; }
.empty-icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.5; }
.empty-text { color: var(--text-muted); font-size: 0.9rem; }

/* === SKELETON LOADING === */
.skeleton {
    background: linear-gradient(90deg, var(--bg-glass) 25%, rgba(255,255,255,0.08) 50%, var(--bg-glass) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-xs);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* === TAB FILTERS === */
.tab-filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 16px; }
.tab-filter {
    padding: 8px 16px; border-radius: 20px;
    background: var(--bg-glass); border: 1px solid var(--border);
    color: var(--text-secondary); font-size: 0.8rem; font-weight: 500;
    cursor: pointer; white-space: nowrap; transition: all 0.3s;
}
.tab-filter.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* === SECTION TITLE === */
.section-title {
    font-size: 1rem; font-weight: 600;
    margin-bottom: 12px; display: flex;
    align-items: center; gap: 8px;
}

/* === RESPONSIVE === */
@media (max-width: 360px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .stat-card { padding: 12px; }
    .balance-amount { font-size: 1.8rem; }
    .wheel-wrapper { width: 260px; height: 260px; }
}
