/* ============================================
   ریست و تنظیمات پایه
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

@import url('https://fonts.googleapis.com/css2?family=Vazir:wght@300;400;700;900&display=swap');

body {
    font-family: 'Vazir', Tahoma, sans-serif;
    min-height: 100vh;
    overflow: hidden;
    color: #fff;
    background: #0a0a1a;
}

/* ============================================
   پس‌زمینه متحرک
   ============================================ */

#bgCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background: linear-gradient(135deg, #0a0a1a 0%, #1a0a2e 25%, #16213e 50%, #0a1a2e 75%, #0a0a1a 100%);
    background-size: 400% 400%;
    animation: gradientMove 15s ease infinite;
}

@keyframes gradientMove {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ستاره‌ها */
.stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, #eee, transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.8), transparent),
        radial-gradient(1px 1px at 90px 40px, #fff, transparent),
        radial-gradient(1px 1px at 130px 80px, rgba(255,255,255,0.6), transparent),
        radial-gradient(2px 2px at 160px 30px, #ddd, transparent);
    background-size: 200px 100px;
    animation: twinkle 3s ease-in-out infinite alternate;
}

@keyframes twinkle {
    0% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* ذرات */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    background-image: 
        radial-gradient(3px 3px at 10% 20%, rgba(255,215,0,0.3), transparent),
        radial-gradient(2px 2px at 30% 60%, rgba(255,215,0,0.2), transparent),
        radial-gradient(4px 4px at 50% 10%, rgba(255,215,0,0.4), transparent),
        radial-gradient(2px 2px at 70% 80%, rgba(255,215,0,0.2), transparent),
        radial-gradient(3px 3px at 90% 40%, rgba(255,215,0,0.3), transparent);
    background-size: 100% 100%;
    animation: floatParticles 8s ease-in-out infinite alternate;
}

@keyframes floatParticles {
    0% { transform: translateY(0px) scale(1); opacity: 0.5; }
    100% { transform: translateY(-30px) scale(1.1); opacity: 1; }
}

/* ============================================
   کانتینر اصلی بازی
   ============================================ */

#app {
    position: relative;
    z-index: 2;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 40px;
    padding: 20px 18px 10px;
    max-width: 430px;
    width: 100%;
    min-height: 720px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    margin: 10px auto;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}

/* ============================================
   هدر
   ============================================ */

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 215, 0, 0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: 0.3s;
}

.user-info:hover {
    transform: scale(1.02);
}

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffd700, #f7971e);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
}

.user-level {
    font-size: 11px;
    color: #8892b0;
}

.stats-header {
    display: flex;
    gap: 12px;
}

.stat-item {
    background: rgba(255, 255, 255, 0.06);
    padding: 4px 12px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    font-weight: bold;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.stat-icon {
    font-size: 14px;
}

/* ============================================
   نوار تجربه
   ============================================ */

.xp-container {
    margin: 12px 0 8px;
}

.xp-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #8892b0;
    margin-bottom: 4px;
}

.xp-bar {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 30px;
    height: 8px;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.xp-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #f7971e, #ffd700, #f7971e);
    background-size: 200% 100%;
    border-radius: 30px;
    transition: width 0.3s ease;
    animation: xpShine 2s linear infinite;
}

@keyframes xpShine {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.xp-glow {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.2), transparent);
    animation: xpGlow 2s ease-in-out infinite;
}

@keyframes xpGlow {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ============================================
   دکمه الماس
   ============================================ */

.diamond-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 15px 0 12px;
    position: relative;
}

.diamond-btn {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    border: none;
    background: radial-gradient(circle at 30% 25%, #ffd700, #b8860b 50%, #8b6508);
    font-size: 90px;
    cursor: pointer;
    position: relative;
    box-shadow: 
        0 0 60px rgba(255, 215, 0, 0.2),
        0 0 120px rgba(255, 215, 0, 0.1),
        inset 0 -10px 0 rgba(0, 0, 0, 0.3),
        inset 0 10px 20px rgba(255, 255, 255, 0.2);
    transition: 0.08s ease;
    user-select: none;
    color: #fff;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.diamond-btn::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border-radius: 50%;
    background: linear-gradient(45deg, #ffd700, #ff6b6b, #ffd700, #ff6b6b);
    background-size: 400% 400%;
    z-index: -1;
    animation: borderGlow 3s ease infinite;
    opacity: 0.6;
}

@keyframes borderGlow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.diamond-btn:active {
    transform: scale(0.88);
    box-shadow: 
        0 0 80px rgba(255, 215, 0, 0.4),
        0 0 160px rgba(255, 215, 0, 0.2),
        inset 0 -5px 0 rgba(0, 0, 0, 0.3);
}

.diamond-shine {
    position: absolute;
    top: 10%;
    left: 20%;
    width: 30%;
    height: 20%;
    background: radial-gradient(ellipse, rgba(255, 255, 255, 0.6), transparent);
    border-radius: 50%;
    transform: rotate(-30deg);
    pointer-events: none;
}

.diamond-text {
    position: relative;
    z-index: 1;
}

/* پاپ‌آپ کلیک */
.click-popup {
    position: absolute;
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 40px;
    font-weight: 900;
    pointer-events: none;
    opacity: 0;
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.8);
    z-index: 10;
}

.click-popup.show {
    animation: popUp 0.6s ease-out forwards;
}

@keyframes popUp {
    0% {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(0.5);
    }
    50% {
        opacity: 1;
        transform: translateX(-50%) translateY(-60px) scale(1.4);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-140px) scale(1);
    }
}

/* ============================================
   آمار کلیک
   ============================================ */

.click-stats {
    display: flex;
    justify-content: space-around;
    background: rgba(255, 255, 255, 0.03);
    padding: 10px 8px;
    border-radius: 30px;
    margin: 6px 0 14px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.stat-box {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    color: #bcc4e0;
}

.stat-box .stat-icon {
    font-size: 16px;
}

/* ============================================
   جایزه روزانه
   ============================================ */

.daily-reward {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.1), rgba(255, 215, 0, 0.02));
    border: 1px solid rgba(255, 215, 0, 0.2);
    border-radius: 20px;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 6px 0 10px;
    cursor: pointer;
    transition: 0.3s;
}

.daily-reward:hover {
    background: rgba(255, 215, 0, 0.15);
    transform: scale(1.02);
}

.daily-reward .claim-btn {
    background: #ffd700;
    color: #0a0a1a;
    padding: 4px 16px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: bold;
}

/* ============================================
   منوی پایین
   ============================================ */

.bottom-nav {
    display: flex;
    justify-content: space-around;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 30px;
    padding: 6px 4px;
    margin-top: auto;
    border: 1px solid rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
}

.nav-btn {
    background: transparent;
    border: none;
    color: #8892b0;
    padding: 6px 8px;
    border-radius: 30px;
    cursor: pointer;
    transition: 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 44px;
}

.nav-btn .nav-icon {
    font-size: 22px;
}

.nav-btn .nav-label {
    font-size: 9px;
}

.nav-btn.active {
    color: #ffd700;
    background: rgba(255, 215, 0, 0.1);
}

.nav-btn:hover {
    color: #fff;
    transform: translateY(-2px);
}

/* ============================================
   صفحات
   ============================================ */

.page {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 26, 0.95);
    backdrop-filter: blur(30px);
    z-index: 999;
    padding: 20px 18px;
    overflow-y: auto;
    flex-direction: column;
}

.page:not(.hidden) {
    display: flex;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.page-header h2 {
    font-size: 24px;
    color: #ffd700;
}

.close-btn {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: #8892b0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    transition: 0.3s;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    transform: rotate(90deg);
}

.page-content {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
}

/* ============================================
   آیتم‌های فروشگاه و ارتقا
   ============================================ */

.shop-item, .upgrade-item, .mission-item {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 20px;
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: 0.3s;
}

.shop-item:hover, .upgrade-item:hover, .mission-item:hover {
    background: rgba(255, 255, 255, 0.07);
    transform: translateX(4px);
}

.shop-item .info, .upgrade-item .info, .mission-item .info {
    flex: 1;
}

.shop-item .name, .upgrade-item .name, .mission-item .name {
    font-size: 16px;
    font-weight: bold;
}

.shop-item .desc, .upgrade-item .desc, .mission-item .desc {
    font-size: 13px;
    color: #8892b0;
}

.shop-item .price, .upgrade-item .price {
    background: rgba(255, 215, 0, 0.1);
    padding: 4px 14px;
    border-radius: 30px;
    font-size: 13px;
    color: #ffd700;
}

.buy-btn, .upgrade-btn, .claim-mission-btn {
    background: linear-gradient(135deg, #ffd700, #f7971e);
    color: #0a0a1a;
    border: none;
    padding: 8px 20px;
    border-radius: 30px;
    font-weight: bold;
    cursor: pointer;
    font-size: 14px;
    transition: 0.3s;
}

.buy-btn:hover, .upgrade-btn:hover, .claim-mission-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(255, 215, 0, 0.3);
}

.buy-btn:disabled, .upgrade-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* ============================================
   پروفایل
   ============================================ */

.profile-header {
    text-align: center;
    padding: 20px 0;
}

.profile-avatar {
    font-size: 80px;
    margin-bottom: 8px;
}

.profile-name {
    font-size: 22px;
    font-weight: bold;
}

.profile-level {
    color: #ffd700;
    font-size: 14px;
}

.profile-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 16px 0;
}

.profile-stat {
    background: rgba(255, 255, 255, 0.04);
    padding: 12px;
    border-radius: 16px;
    display: flex;
    justify-content: space-between;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.profile-stat span:first-child {
    color: #8892b0;
}

.profile-stat span:last-child {
    font-weight: bold;
    color: #ffd700;
}

.profile-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.action-btn {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 30px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
    background: linear-gradient(135deg, #ffd700, #f7971e);
    color: #0a0a1a;
}

.action-btn:hover {
    transform: scale(1.03);
}

.action-btn.danger {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: #fff;
}

/* ============================================
   لیدربورد
   ============================================ */

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    margin-bottom: 6px;
    border-right: 3px solid transparent;
    transition: 0.3s;
}

.leaderboard-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.leaderboard-item .rank {
    font-weight: bold;
    color: #ffd700;
    width: 40px;
}

.leaderboard-item .username {
    flex: 1;
    margin: 0 10px;
}

.leaderboard-item .coins {
    color: #ffd700;
    font-weight: bold;
}

.leaderboard-item .level {
    color: #8892b0;
    font-size: 13px;
    margin-left: 8px;
}

.leaderboard-item.top1 {
    border-right-color: #ffd700;
    background: rgba(255, 215, 0, 0.08);
}

.leaderboard-item.top2 {
    border-right-color: #c0c0c0;
    background: rgba(192, 192, 192, 0.05);
}

.leaderboard-item.top3 {
    border-right-color: #cd7f32;
    background: rgba(205, 127, 50, 0.05);
}

.leaderboard-item.me {
    border-right-color: #ff6b6b;
    background: rgba(255, 107, 107, 0.08);
}

/* ============================================
   مودال‌ها
   ============================================ */

.modal {
    display: flex;
    justify-content: center;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    z-index: 9999;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #1a1f35;
    padding: 30px;
    border-radius: 30px;
    width: 90%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.modal-content h2 {
    text-align: center;
    color: #ffd700;
    margin-bottom: 16px;
}

.login-modal .login-icon {
    text-align: center;
    font-size: 60px;
    margin-bottom: 12px;
}

.modal-content input {
    width: 100%;
    padding: 14px;
    margin: 6px 0;
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(255, 255, 255, 0.04);
    color: #fff;
    font-size: 16px;
    font-family: 'Vazir', Tahoma, sans-serif;
}

.modal-content input:focus {
    outline: none;
    border-color: #ffd700;
}

.login-btn {
    width: 100%;
    padding: 14px;
    margin: 6px 0;
    border: none;
    border-radius: 30px;
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
    background: linear-gradient(135deg, #ffd700, #f7971e);
    color: #0a0a1a;
}

.register-btn {
    width: 100%;
    padding: 14px;
    margin: 6px 0;
    border: none;
    border-radius: 30px;
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.login-message {
    text-align: center;
    font-size: 13px;
    margin-top: 10px;
    color: #ff6b6b;
}

/* بسته‌های خرید سکه */
.coin-packs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 16px 0;
}

.coin-pack {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 215, 0, 0.1);
    border-radius: 20px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: 0.3s;
}

.coin-pack:hover {
    background: rgba(255, 215, 0, 0.1);
    transform: scale(1.05);
}

.coin-pack .pack-icon {
    font-size: 30px;
    display: block;
}

.coin-pack .pack-amount {
    font-size: 18px;
    font-weight: bold;
    display: block;
    margin: 4px 0;
}

.coin-pack .pack-price {
    font-size: 14px;
    color: #ffd700;
}

.close-modal-btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 30px;
    font-size: 16px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    color: #8892b0;
    transition: 0.3s;
}

.close-modal-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ============================================
   ماموریت‌ها
   ============================================ */

.mission-item .progress {
    font-size: 13px;
    color: #8892b0;
}

.mission-item .progress-bar {
    width: 100px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    margin-top: 4px;
}

.mission-item .progress-bar .fill {
    height: 100%;
    background: linear-gradient(90deg, #ffd700, #f7971e);
    border-radius: 10px;
    transition: width 0.5s ease;
}

/* ============================================
   ریسپانسیو
   ============================================ */

@media (max-width: 450px) {
    #app {
        padding: 14px 12px 8px;
        min-height: 650px;
        border-radius: 28px;
        margin: 6px;
    }
    
    .diamond-btn {
        width: 160px;
        height: 160px;
        font-size: 70px;
    }
    
    .stats-header {
        gap: 6px;
    }
    
    .stat-item {
        padding: 2px 8px;
        font-size: 12px;
    }
    
    .nav-btn .nav-label {
        display: none;
    }
    
    .nav-btn {
        min-width: 36px;
        padding: 6px;
    }
    
    .nav-btn .nav-icon {
        font-size: 24px;
    }
    
    .profile-stats {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }
    
    .coin-packs {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }
    
    .click-stats {
        flex-wrap: wrap;
        gap: 4px;
    }
    
    .stat-box {
        font-size: 12px;
    }
}

@media (max-width: 380px) {
    .diamond-btn {
        width: 130px;
        height: 130px;
        font-size: 55px;
    }
    
    .stat-item {
        font-size: 10px;
        padding: 2px 6px;
    }
    
    .stats-header {
        gap: 4px;
    }
}