/* ===== assets/css/style.css ===== */
:root {
    --primary: #4F46E5;
    --primary-dark: #4338CA;
    --primary-light: #818CF8;
    --bg-light: #F3F4F6;
    --bg-dark: #111827;
    --card-light: #FFFFFF;
    --card-dark: #1F2937;
    --text-light: #1F2937;
    --text-dark: #F9FAFB;
    --text-muted-light: #6B7280;
    --text-muted-dark: #9CA3AF;
    --border-light: #E5E7EB;
    --border-dark: #374151;
    --shadow-light: 0 4px 20px rgba(0,0,0,0.08);
    --shadow-dark: 0 4px 20px rgba(0,0,0,0.3);
    --radius: 16px;
    --nav-height: 68px;
    --header-height: 60px;
    --transition: 0.3s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-light);
    color: var(--text-light);
    transition: background var(--transition), color var(--transition);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

body.dark {
    background: var(--bg-dark);
    color: var(--text-dark);
}

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    transition: opacity 0.5s ease;
}
.loading-overlay.hide {
    opacity: 0;
    pointer-events: none;
}

/* ===== APP CONTAINER ===== */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 480px;
    margin: 0 auto;
    background: inherit;
    position: relative;
    overflow: hidden;
}

/* ===== HEADER ===== */
.app-header {
    height: var(--header-height);
    min-height: var(--header-height);
    flex-shrink: 0;
    z-index: 100;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
body.dark .app-header {
    border-bottom-color: rgba(255,255,255,0.05);
}

/* ===== MAIN CONTENT ===== */
.app-main {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: calc(var(--nav-height) + 16px);
    scroll-behavior: smooth;
}
.app-main::-webkit-scrollbar {
    width: 4px;
}
.app-main::-webkit-scrollbar-thumb {
    background: var(--primary-light);
    border-radius: 8px;
}

/* ===== BOTTOM NAV ===== */
.app-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: var(--nav-height);
    background: var(--card-light);
    border-top: 1px solid var(--border-light);
    z-index: 200;
    transition: background var(--transition), border-color var(--transition);
}
body.dark .app-bottom-nav {
    background: var(--card-dark);
    border-top-color: var(--border-dark);
}

.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--text-muted-light);
    font-size: 10px;
    padding: 4px 0;
    cursor: pointer;
    transition: color var(--transition);
    position: relative;
}
body.dark .nav-btn {
    color: var(--text-muted-dark);
}
.nav-btn i {
    font-size: 22px;
    transition: transform var(--transition);
}
.nav-btn.active {
    color: var(--primary);
}
.nav-btn.active i {
    transform: scale(1.05);
}
.nav-btn span {
    font-weight: 500;
    font-size: 9px;
    letter-spacing: 0.3px;
}
.nav-btn .badge-nav {
    position: absolute;
    top: 2px;
    right: 50%;
    transform: translateX(calc(50% + 16px));
    background: #EF4444;
    color: #fff;
    font-size: 9px;
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
}

/* ===== CARDS ===== */
.card-custom {
    background: var(--card-light);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-light);
    transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
    overflow: hidden;
}
body.dark .card-custom {
    background: var(--card-dark);
    border-color: var(--border-dark);
    box-shadow: var(--shadow-dark);
}

/* ===== QUIZ CARD ===== */
.quiz-card {
    padding: 20px;
    border-radius: var(--radius);
    background: var(--card-light);
    border: 1px solid var(--border-light);
    transition: all var(--transition);
}
body.dark .quiz-card {
    background: var(--card-dark);
    border-color: var(--border-dark);
}

.quiz-option {
    padding: 14px 18px;
    border-radius: 12px;
    background: var(--bg-light);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
}
body.dark .quiz-option {
    background: var(--bg-dark);
}
.quiz-option:hover {
    transform: translateX(4px);
}
.quiz-option.selected-correct {
    border-color: #22C55E;
    background: #DCFCE7;
}
body.dark .quiz-option.selected-correct {
    background: #064E3B;
}
.quiz-option.selected-wrong {
    border-color: #EF4444;
    background: #FEE2E2;
}
body.dark .quiz-option.selected-wrong {
    background: #7F1D1D;
}
.quiz-option .option-label {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}
.quiz-option .option-text {
    flex: 1;
}

/* ===== TIMER ===== */
.timer-ring {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    border: 4px solid var(--primary);
    position: relative;
    transition: all 0.3s ease;
}
.timer-ring.warning {
    border-color: #F59E0B;
    color: #F59E0B;
}
.timer-ring.danger {
    border-color: #EF4444;
    color: #EF4444;
    animation: pulse 0.5s ease infinite alternate;
}
@keyframes pulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.05); }
}

/* ===== PROGRESS BAR ===== */
.progress-custom {
    height: 6px;
    border-radius: 10px;
    background: var(--border-light);
    overflow: hidden;
}
body.dark .progress-custom {
    background: var(--border-dark);
}
.progress-custom .progress-bar {
    background: var(--primary);
    transition: width 0.4s ease;
    border-radius: 10px;
}

/* ===== LEVEL BADGE ===== */
.level-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 14px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 13px;
    background: var(--primary);
    color: #fff;
}

/* ===== MODAL CUSTOM ===== */
.modal-content {
    border-radius: var(--radius);
    border: none;
    background: var(--card-light);
}
body.dark .modal-content {
    background: var(--card-dark);
}
.modal-header {
    border-bottom: 1px solid var(--border-light);
}
body.dark .modal-header {
    border-bottom-color: var(--border-dark);
}
.modal-footer {
    border-top: 1px solid var(--border-light);
}
body.dark .modal-footer {
    border-top-color: var(--border-dark);
}

/* ===== TOAST ===== */
.toast-custom {
    background: var(--card-light);
    border-radius: 12px;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-light);
    padding: 12px 20px;
    min-width: 200px;
    max-width: 360px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideUp 0.3s ease;
}
body.dark .toast-custom {
    background: var(--card-dark);
    border-color: var(--border-dark);
    box-shadow: var(--shadow-dark);
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== LEADERBOARD ===== */
.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--bg-light);
    margin-bottom: 8px;
    transition: background var(--transition);
}
body.dark .leaderboard-item {
    background: var(--bg-dark);
}
.leaderboard-item .rank {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    background: var(--border-light);
    color: var(--text-muted-light);
    flex-shrink: 0;
}
body.dark .leaderboard-item .rank {
    background: var(--border-dark);
    color: var(--text-muted-dark);
}
.leaderboard-item .rank.top1 { background: #FCD34D; color: #92400E; }
.leaderboard-item .rank.top2 { background: #D1D5DB; color: #374151; }
.leaderboard-item .rank.top3 { background: #FCA5A5; color: #7F1D1D; }
.leaderboard-item .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--border-light);
    flex-shrink: 0;
}
.leaderboard-item .info {
    flex: 1;
    min-width: 0;
}
.leaderboard-item .info .name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.leaderboard-item .info .detail {
    font-size: 12px;
    color: var(--text-muted-light);
}
body.dark .leaderboard-item .info .detail {
    color: var(--text-muted-dark);
}
.leaderboard-item .score {
    font-weight: 700;
    font-size: 15px;
    color: var(--primary);
}

/* ===== DEPOSIT / WITHDRAW ===== */
.method-card {
    padding: 16px;
    border-radius: 12px;
    border: 2px solid var(--border-light);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    background: var(--card-light);
}
body.dark .method-card {
    background: var(--card-dark);
    border-color: var(--border-dark);
}
.method-card:hover {
    border-color: var(--primary-light);
}
.method-card.selected {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.08);
}
body.dark .method-card.selected {
    background: rgba(79, 70, 229, 0.15);
}
.method-card i {
    font-size: 32px;
    color: var(--primary);
}
.method-card .label {
    font-weight: 600;
    font-size: 13px;
    margin-top: 6px;
}

/* ===== HISTORY ===== */
.history-item {
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--bg-light);
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
body.dark .history-item {
    background: var(--bg-dark);
}
.history-item .left .title {
    font-weight: 600;
    font-size: 14px;
}
.history-item .left .sub {
    font-size: 12px;
    color: var(--text-muted-light);
}
body.dark .history-item .left .sub {
    color: var(--text-muted-dark);
}
.history-item .right {
    text-align: right;
}
.history-item .right .amount {
    font-weight: 700;
}
.history-item .right .status {
    font-size: 11px;
    padding: 2px 10px;
    border-radius: 20px;
}
.status-success { background: #DCFCE7; color: #15803D; }
.status-pending { background: #FEF3C7; color: #B45309; }
.status-failed { background: #FEE2E2; color: #B91C1C; }
body.dark .status-success { background: #064E3B; color: #86EFAC; }
body.dark .status-pending { background: #78350F; color: #FCD34D; }
body.dark .status-failed { background: #7F1D1D; color: #FCA5A5; }

/* ===== CONFETI ===== */
.confetti-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}
.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    top: -10px;
    animation: confettiFall linear forwards;
}
@keyframes confettiFall {
    0% { transform: translateY(0) rotate(0deg) scale(1); opacity: 1; }
    100% { transform: translateY(110vh) rotate(720deg) scale(0.3); opacity: 0; }
}

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

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
    .app-container {
        max-width: 100%;
    }
    .app-header {
        padding: 10px 16px !important;
    }
    .app-header .fs-6 {
        font-size: 15px !important;
    }
    .quiz-option {
        padding: 12px 14px;
        font-size: 14px;
    }
    .timer-ring {
        width: 52px;
        height: 52px;
        font-size: 20px;
    }
    .level-badge {
        font-size: 11px;
        padding: 3px 10px;
    }
}

@media (min-width: 768px) {
    .app-container {
        border-left: 1px solid var(--border-light);
        border-right: 1px solid var(--border-light);
    }
    body.dark .app-container {
        border-color: var(--border-dark);
    }
}

/* ===== UTILITY ===== */
.text-primary-custom { color: var(--primary); }
.bg-primary-custom { background: var(--primary); }
.border-primary-custom { border-color: var(--primary); }

.shadow-custom { box-shadow: var(--shadow-light); }
body.dark .shadow-custom { box-shadow: var(--shadow-dark); }

.rounded-custom { border-radius: var(--radius); }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

.cursor-pointer { cursor: pointer; }
.user-select-none { user-select: none; }

.transition { transition: all var(--transition); }

.overflow-ellipsis {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, var(--border-light) 25%, #E5E7EB 50%, var(--border-light) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease infinite;
    border-radius: 8px;
}
body.dark .skeleton {
    background: linear-gradient(90deg, var(--border-dark) 25%, #374151 50%, var(--border-dark) 75%);
    background-size: 200% 100%;
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}