:root {
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --primary: #38bdf8;
    --primary-glow: rgba(56, 189, 248, 0.3);
    --gold: #fbbf24;
    --gold-glow: rgba(251, 191, 36, 0.3);
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --danger: #ef4444;
    --success: #22c55e;
    --glass: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Outfit', 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    line-height: 1.5;
    overflow-x: hidden;
    user-select: none;
}

.container {
    max-width: 500px;
    margin: 0 auto;
    padding: 20px;
    padding-bottom: 180px; /* Increased to avoid elements hiding behind tabs/footer */
}

.page {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Container animation removed to prevent jittery nested buttons. Only individual elements scale now. */


h1,
h2,
h3,
h4 {
    margin-top: 0;
    font-weight: 700;
}

.btn {
    display: block;
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 14px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, #0ea5e9, #2563eb);
    color: white;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:active {
    transform: translateY(2px) scale(0.98);
    box-shadow: 0 2px 6px var(--primary-glow);
}

.btn-gold:active {
    transform: translateY(2px) scale(0.98);
}

.btn-gold {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

.btn:disabled {
    opacity: 0.6;
    filter: grayscale(0.8);
    cursor: not-allowed;
    pointer-events: none;
    box-shadow: none;
    transform: none !important;
}

.btn-primary:disabled {
    background: #475569;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-main);
}

/* Tabs */
.tabs {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    display: flex;
    justify-content: space-around;
    padding: 8px;
    z-index: 10000; /* Ensure tabs are always on top */
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 10px 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    border-radius: 16px;
    transition: all 0.3s ease;
}

.tab-btn:active {
    transform: scale(0.92);
    background: rgba(255, 255, 255, 0.05);
}


.tab-btn span:first-child {
    font-size: 1.4rem;
}

.tab-btn span:last-child {
    font-size: 0.7rem;
    font-weight: 600;
}

.tab-btn.active {
    background: var(--glass);
    color: var(--primary);
}

/* Mining Pulse */
.mining-visual {
    width: 80px;
    height: 80px;
    background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
    border-radius: 50%;
    margin: 12px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.mining-visual::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border: 2px solid var(--primary);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }

    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

.mining-visual.stopped::after {
    display: none !important;
    animation: none !important;
}

.coin-icon {
    font-size: 2rem;
    filter: drop-shadow(0 0 8px var(--primary));
}

/* Stats */
.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-item {
    background: var(--glass);
    padding: 12px;
    border-radius: 16px;
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-bottom: 4px;
}

.stat-value {
    font-weight: 700;
    font-size: 1.1rem;
}

/* Leaderboard */
.leaderboard-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 8px;
    background: var(--glass);
    transition: transform 0.2s ease;
}

.leaderboard-item:active {
    transform: scale(0.98);
}

.rank-badge {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-weight: 800;
    margin-right: 12px;
}

.rank-1 {
    background: var(--gold);
    color: #000;
}

.rank-2 {
    background: #cbd5e1;
    color: #000;
}

.rank-3 {
    background: #b45309;
    color: #fff;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-dark);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    width: 100%;
    max-width: 400px;
    padding: 30px;
    position: relative;
    animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    color: var(--text-dim);
    cursor: pointer;
}

/* Premium Shop */
.premium-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.1), transparent);
    border: 1px solid var(--primary-glow);
    border-radius: 16px;
    margin-bottom: 12px;
}

.shop-icon {
    font-size: 2.2rem;
}

.shop-info {
    flex: 1;
}

.shop-title {
    font-weight: 700;
    font-size: 0.95rem;
}

.shop-cost {
    font-size: 0.8rem;
    color: var(--primary);
}

/* Header Controls */
.header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 12px;
}

.lang-btn-group {
    display: flex;
    gap: 8px;
}

.header-btn {
    font-size: 1rem !important;
    padding: 6px 14px !important;
    border-radius: 12px !important;
    font-weight: 600 !important;
    transition: all 0.2s ease;
}

.bonus-btn {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid var(--success);
    animation: glow-pulse 2s infinite;
}

@keyframes glow-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.2);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(34, 197, 94, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
}

/* Leaderboard Enhancements */
.leaderboard-item {
    padding: 14px 18px !important;
}

.leaderboard-name-group {
    flex: 1;
    min-width: 0; /* Important for flex child truncation */
}

.leaderboard-name-group .name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    max-width: 140px; /* Aggressive truncation for very small screens */
}

.leaderboard-score-group {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.prize-tag-mini {
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.score-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    color: var(--text-main);
}

.score-unit {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-left: 2px;
}

/* Info & Guide Redesign */
.info-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-top: 20px;
}

.guide-card {
    padding: 20px;
    background: linear-gradient(135deg, rgba(35, 55, 95, 0.4), transparent);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    display: flex;
    gap: 15px;
    align-items: flex-start;
    transition: transform 0.2s ease;
}

.guide-card:active {
    transform: scale(0.98);
}

.guide-icon {
    font-size: 2rem;
    padding: 10px;
    background: var(--glass);
    border-radius: 14px;
    min-width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.guide-content {
    flex: 1;
}

.guide-content h4 {
    margin: 0 0 5px 0;
    color: var(--primary);
    font-size: 1.1rem;
}

.guide-content p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-dim);
    line-height: 1.4;
}

/* Profile Sync */
.profile-stats-sync {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

/* Daily Bonus Streak Overhaul */
.streak-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.streak-day {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 12px 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    transition: all 0.3s ease;
}

.streak-day.claimed {
    background: rgba(16, 185, 129, 0.15);
    border-color: var(--success);
    color: var(--success);
}

.streak-day.active {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), transparent);
    border-color: var(--primary);
    box-shadow: 0 0 15px var(--primary-glow);
    animation: active-pulse 2s infinite;
}

.streak-day.upcoming {
    opacity: 0.5;
    filter: grayscale(0.5);
}

.streak-day .val {
    font-weight: 800;
    font-size: 0.9rem;
    margin: 4px 0;
}

.streak-icon {
    font-size: 0.8rem;
    margin-top: 5px;
}

@keyframes active-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 10px var(--primary-glow);
    }

    50% {
        transform: scale(1.03);
        box-shadow: 0 0 20px var(--primary-glow);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 10px var(--primary-glow);
    }
}

/* Task System Overhaul */
.task-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

.task-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.task-card:active {
    transform: scale(0.98);
}

.task-card-icon {
    font-size: 2rem;
    width: 55px;
    height: 55px;
    min-width: 55px;
    background: var(--glass);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.05);
}

.task-card-content {
    flex: 1;
}

.task-card-content b {
    display: block;
    font-size: 0.95rem;
    margin-bottom: 4px;
    color: white;
}

.task-reward-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(245, 158, 11, 0.1);
    color: var(--gold);
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
}

.task-card-action {
    display: flex;
    align-items: center;
}

.btn-task {
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 700;
    min-width: 85px;
    transition: all 0.2s ease;
}

.btn-task-verify {
    background: var(--accent);
    color: white;
}

.btn-task-claim {
    background: var(--success);
    color: white;
}

.task-card.loading::after {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 200%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

.user-rank-footer {
    position: sticky;
    bottom: 105px; /* Moved up to clear the navigation tabs */
    z-index: 9000;
    margin: 0 15px;
    padding: 14px 20px;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.15), rgba(16, 185, 129, 0.15));
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* Responsive Design for Small Screens */
@media (max-width: 380px) {
    .container {
        padding: 15px;
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.3rem;
    }

    h3 {
        font-size: 1.1rem;
    }

    #total-balance {
        font-size: 2.5rem !important;
    }

    .stat-value {
        font-size: 0.95rem;
    }

    .btn {
        padding: 12px;
        font-size: 0.9rem;
    }

    .tabs {
        padding: 5px;
        bottom: 15px;
        left: 15px;
        right: 15px;
    }

    .tab-btn span:first-child {
        font-size: 1.2rem;
    }

    .tab-btn span:last-child {
        font-size: 0.6rem;
    }

    .shop-icon {
        font-size: 1.8rem;
    }

    .premium-item {
        padding: 12px;
        gap: 10px;
    }
}

/* Energy Purchase Animation */
@keyframes floatUp {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }

    80% {
        transform: translateY(-80px) scale(1.3);
        opacity: 0.8;
    }

    100% {
        transform: translateY(-120px) scale(0.8);
        opacity: 0;
    }
}

.energy-particle {
    position: fixed;
    font-size: 1.6rem;
    pointer-events: none;
    z-index: 9999;
    animation: floatUp 1s ease-out forwards;
}

@keyframes energyBarFlash {
    0% {
        box-shadow: 0 0 0px var(--primary);
    }

    40% {
        box-shadow: 0 0 20px 6px var(--primary);
    }

    100% {
        box-shadow: 0 0 0px var(--primary);
    }
}

.energy-bar-flash {
    animation: energyBarFlash 0.8s ease-out;
}

/* Ban Screen */
.ban-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a0505 0%, #000000 100%);
    z-index: 10000;
    display: none;
    /* JS will toggle flex */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
}

.ban-content {
    background: rgba(30, 0, 0, 0.6);
    padding: 30px;
    border-radius: 20px;
    border: 1px solid rgba(239, 68, 68, 0.3);
    box-shadow: 0 0 50px rgba(139, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    max-width: 400px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.ban-icon {
    font-size: 80px;
    margin-bottom: 20px;
    color: var(--danger);
    text-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
    animation: banPulse 2s infinite;
}

.ban-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--danger);
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.ban-msg {
    font-size: 15px;
    color: #e2e8f0;
    margin-bottom: 30px;
    line-height: 1.6;
    opacity: 0.9;
}

@keyframes banPulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}