/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background-color: #1C1F26;
    color: #ffffff;
    line-height: 1.4;
    min-height: 100vh;
    overflow-x: hidden;
}

.app-container {
    max-width: 100%;
    min-height: 100vh;
    background-color: #1C1F26;
    position: relative;
    padding: 20px;
}

/* Header Controls */
.header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    position: relative;
}

.close-btn {
    background-color: #2D3648;
    border: none;
    border-radius: 30px;
    padding: 8px 16px;
    color: #ffffff;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.close-btn:hover {
    background-color: #3A4556;
    transform: translateY(-1px);
}

.close-btn:active {
    transform: translateY(0);
}

.close-btn::before {
    content: '';
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    background: linear-gradient(45deg, transparent 40%, #ffffff 40%, #ffffff 60%, transparent 60%),
                linear-gradient(-45deg, transparent 40%, #ffffff 40%, #ffffff 60%, transparent 60%);
    opacity: 0.8;
}

.close-text {
    margin-left: 20px;
}

.action-buttons {
    display: flex;
    align-items: center;
    gap: 0;
    position: relative;
}

.action-btn {
    background-color: #2D3648;
    border: none;
    padding: 8px 12px;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 31px;
}

.minimize-btn {
    border-radius: 30px 0 0 30px;
    border-right: 1px solid #1C1F26;
}

.menu-btn {
    border-radius: 0 30px 30px 0;
    min-width: 35px;
}

.action-btn:hover {
    background-color: #3A4556;
}

.check-icon {
    width: 14px;
    height: 14px;
    color: #ffffff;
}

.menu-dots {
    font-size: 18px;
    font-weight: 600;
    line-height: 1;
    color: #ffffff;
}

/* Dropdown Menu */
.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background-color: #2D3648;
    border-radius: 8px;
    padding: 8px;
    min-width: 180px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
}

.dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.refresh-btn {
    width: 100%;
    background: none;
    border: none;
    color: #ffffff;
    padding: 12px 16px;
    text-align: left;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
}

.refresh-btn:hover {
    background-color: #3A4556;
}

.refresh-icon {
    width: 16px;
    height: 16px;
    color: #ffffff;
}

/* Profile Section */
.profile-section {
    text-align: center;
    margin-bottom: 40px;
}

.profile-avatar {
    width: 81px;
    height: 81px;
    border-radius: 50%;
    margin: 0 auto 20px;
    overflow: hidden;
    background-color: #d4d4d4;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.app-title {
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    margin: 0;
}

/* Loading State */
.loading-container {
    text-align: center;
    padding: 60px 20px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #2D3648;
    border-top: 3px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    color: #9CA3AF;
    font-size: 14px;
}

/* Error State */
.error-container {
    text-align: center;
    padding: 60px 20px;
}

.error-icon {
    font-size: 48px;
    margin-bottom: 20px;
}

.error-title {
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 12px;
}

.error-message {
    color: #9CA3AF;
    font-size: 14px;
    margin-bottom: 24px;
    line-height: 1.5;
}

.retry-btn {
    background-color: #2D3648;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    color: #ffffff;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.retry-btn:hover {
    background-color: #3A4556;
    transform: translateY(-1px);
}

/* Empty State */
.empty-container {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 20px;
}

.empty-title {
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 12px;
}

.empty-message {
    color: #9CA3AF;
    font-size: 14px;
    line-height: 1.5;
}

/* Leaderboard */
.leaderboard-container {
    margin-top: 20px;
}

.leaderboard-list {
    background-color: #202832;
    border-radius: 5px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.leader-item {
    background-color: #202832;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    transition: background-color 0.2s ease;
}

.leader-item:not(:last-child) {
    border-bottom: 1px solid #2D3648;
}

.leader-item.top-1 {
    border-radius: 5px 5px 0 0;
}

.leader-item.top-9:last-child {
    border-radius: 0 0 5px 5px;
}

.leader-position {
    min-width: 23px;
    text-align: center;
    font-size: 25px;
    font-weight: 600;
    color: #ffffff;
}

.leader-position.position-4,
.leader-position.position-5,
.leader-position.position-6,
.leader-position.position-7,
.leader-position.position-8,
.leader-position.position-9 {
    color: #6F7785;
}

.leader-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #202832;
    font-weight: 600;
    font-size: 14px;
    overflow: hidden;
}

.leader-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.leader-info {
    flex: 1;
    min-width: 0;
}

.leader-name {
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.leader-username {
    font-size: 13px;
    font-weight: 600;
    color: #9DA4B0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.leader-score-section {
    display: flex;
    align-items: center;
    gap: 8px;
}

.leader-medal {
    width: 18px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.medal-gold {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    border-radius: 2px;
}

.medal-silver {
    background: linear-gradient(135deg, #C0C0C0 0%, #A8A8A8 100%);
    border-radius: 2px;
}

.medal-bronze {
    background: linear-gradient(135deg, #CD7F32 0%, #A0522D 100%);
    border-radius: 2px;
}

.leader-score {
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    min-width: 44px;
    text-align: center;
}

/* Responsive Design */
@media (min-width: 768px) {
    .app-container {
        max-width: 600px;
        margin: 0 auto;
        border-radius: 12px;
        min-height: auto;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    }
    
    .header-controls {
        margin-bottom: 40px;
    }
    
    .app-title {
        font-size: 20px;
    }
    
    .leaderboard-list {
        border-radius: 8px;
    }
    
    .leader-item.top-1 {
        border-radius: 8px 8px 0 0;
    }
    
    .leader-item.top-9:last-child {
        border-radius: 0 0 8px 8px;
    }
}

@media (min-width: 1024px) {
    .app-container {
        max-width: 800px;
        padding: 40px;
    }
    
    .profile-section {
        margin-bottom: 50px;
    }
    
    .app-title {
        font-size: 24px;
    }
    
    .leader-item {
        padding: 20px 24px;
    }
    
    .leader-name {
        font-size: 16px;
    }
    
    .leader-username {
        font-size: 14px;
    }
    
    .leader-score {
        font-size: 14px;
    }
}

/* Dark theme adjustments for Telegram */
body.tg-theme-dark {
    background-color: var(--tg-theme-bg-color, #1C1F26);
    color: var(--tg-theme-text-color, #ffffff);
}

/* Telegram Web App specific styles */
.tg-viewport {
    height: 100vh;
    overflow: hidden;
}

/* Animation for leader items */
.leader-item {
    opacity: 0;
    transform: translateY(20px);
    animation: slideIn 0.3s ease forwards;
}

.leader-item:nth-child(1) { animation-delay: 0.05s; }
.leader-item:nth-child(2) { animation-delay: 0.1s; }
.leader-item:nth-child(3) { animation-delay: 0.15s; }
.leader-item:nth-child(4) { animation-delay: 0.2s; }
.leader-item:nth-child(5) { animation-delay: 0.25s; }
.leader-item:nth-child(6) { animation-delay: 0.3s; }
.leader-item:nth-child(7) { animation-delay: 0.35s; }
.leader-item:nth-child(8) { animation-delay: 0.4s; }
.leader-item:nth-child(9) { animation-delay: 0.45s; }

@keyframes slideIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

