/* =========================================
   1. CORE VARIABLES (PERMANENT DARK THEME)
   ========================================= */
:root {
    /* Brand Colors */
    --primary: #6366f1;       /* Indigo 500 (lighter for dark bg) */
    --primary-glow: rgba(99, 102, 241, 0.3);
    --secondary: #ec4899;     /* Pink 500 */
    
    /* Status Colors */
    --gold: #fbbf24;
    --silver: #94a3b8;
    --bronze: #d97706;
    
    /* Dark Backgrounds */
    --bg-body: #020617;       /* Deep Midnight */
    --bg-card: #0f172a;       /* Slate 900 */
    --bg-glass: rgba(15, 23, 42, 0.8);
    
    /* Text */
    --text-main: #f8fafc;     /* Slate 50 */
    --text-muted: #94a3b8;    /* Slate 400 */
    
    /* Effects */
    --radius-lg: 24px;
    --radius-sm: 12px;
    --shadow-soft: 0 10px 40px -10px rgba(0,0,0,0.6);
    --shadow-hover: 0 20px 40px -10px rgba(99, 102, 241, 0.2);
    --glass-blur: blur(20px);
    --transition-bounce: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =========================================
   2. GLOBAL RESET & TYPOGRAPHY
   ========================================= */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-body);
    /* Subtle Dark Mesh Gradient */
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(236, 72, 153, 0.1) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    margin: 0;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* Custom Scrollbar (Dark) */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-body); }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #475569; }

/* =========================================
   3. HEADER (DARK GLASS)
   ========================================= */
header {
    background: var(--bg-glass);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding: 1rem 5%;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.logo {
    font-size: 1.8rem;
    font-weight: 900;
    letter-spacing: -1px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Language & Mode Buttons (Dark) */
.openbtn, .mode-btn {
    background: #1e293b;
    color: var(--text-main);
    width: 45px;
    height: 45px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: var(--transition-bounce);
}

.openbtn:hover, .mode-btn:hover {
    transform: translateY(-3px);
    background: var(--primary);
    border-color: var(--primary);
}

/* Language Dropdown (Dark) */
.lang-dropdown {
    position: absolute;
    top: 50px;
    right: 0;
    background: var(--bg-card);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    padding: 10px;
    z-index: 1001;
}

.lang-dropdown button {
    background: transparent;
    border: none;
    color: var(--text-main);
    padding: 8px 15px;
    cursor: pointer;
    font-weight: 600;
    border-radius: 5px;
    text-align: left;
}

.lang-dropdown button:hover {
    background: var(--primary);
}

/* Search Bar (Dark Style) */
.search-container {
    max-width: 800px;
    margin: 30px auto 10px;
    padding: 0 20px;
}

#searchInput {
    width: 100%;
    padding: 18px 25px 18px 55px;
    border-radius: 50px;
    border: 1px solid rgba(255,255,255,0.1);
    background-color: #1e293b;
    color: white;
    font-size: 1.05rem;
    box-shadow: var(--shadow-soft);
    transition: var(--transition-smooth);
    box-sizing: border-box;
    /* Indigo Icon for Dark Mode */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23818cf8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: 20px center !important;
    background-size: 20px !important;
}

#searchInput:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 5px var(--primary-glow);
}

/* =========================================
   4. SIDEBAR (DARK DRAWER)
   ========================================= */
.sidebar {
    height: 100%;
    width: 0;
    position: fixed;
    z-index: 1100;
    top: 0;
    left: 0;
    background-color: #0f172a;
    box-shadow: 30px 0 50px rgba(0,0,0,0.5);
    overflow-x: hidden;
    transition: 0.5s cubic-bezier(0.22, 1, 0.36, 1);
    padding-top: 80px;
}

.sidebar-content {
    padding: 20px 30px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.side-link {
    background: transparent;
    border: none;
    color: var(--text-main);
    text-align: left;
    font-size: 1.1rem;
    padding: 16px 20px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-weight: 600;
    transition: var(--transition-smooth);
}

.side-link:hover {
    background-color: #1e293b;
    padding-left: 30px;
    color: var(--primary);
}

.side-link.active {
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    color: white;
}

.sidebar .closebtn {
    position: absolute;
    top: 20px;
    right: 25px;
    font-size: 36px;
    color: var(--text-main);
    text-decoration: none;
    opacity: 0.5;
}

/* =========================================
   5. TABLE (DARK UI)
   ========================================= */
.leaderboard-container {
    max-width: 1000px;
    margin: 40px auto;
    padding: 0 20px;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 16px;
}

thead th {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 0 25px 10px;
    text-align: left;
}

tbody tr {
    background: var(--bg-card);
    box-shadow: var(--shadow-soft);
    border-radius: var(--radius-lg);
    transition: var(--transition-bounce);
}

tbody tr:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
    background: #1e293b;
}

td {
    padding: 25px;
    border: none;
    color: var(--text-main);
}

td:first-child { border-top-left-radius: var(--radius-lg); border-bottom-left-radius: var(--radius-lg); }
td:last-child { border-top-right-radius: var(--radius-lg); border-bottom-right-radius: var(--radius-lg); }

/* Rank & Crown Styles */
.rank {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--text-muted);
    width: 70px;
    text-align: center;
}

.crown {
    display: inline-block !important;
    font-size: 1.6rem;
    margin-right: 8px;
    color: #fbbf24 !important;
    filter: drop-shadow(0 0 8px rgba(251, 191, 36, 0.4));
    animation: float 3s ease-in-out infinite;
}

/* 1st Place Gold Effect */
.rank-gold {
    background: linear-gradient(135deg, #fbbf24, #d97706);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 900 !important;
    filter: drop-shadow(0 0 5px rgba(251, 191, 36, 0.3));
}

/* =========================================
   6. VOTING (DARK)
   ========================================= */
.vote-container {
    display: flex;
    align-items: center;
    gap: 15px;
    background: #1e293b;
    padding: 6px 8px 6px 20px;
    border-radius: 50px;
    border: 1px solid rgba(255,255,255,0.05);
}

.vote-btn {
    background: #334155;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-bounce);
    color: #94a3b8;
}

.vote-btn:hover {
    background: #475569;
    color: #f43f5e;
}

.vote-btn.active {
    background: #f43f5e !important;
    color: white !important;
    box-shadow: 0 8px 20px rgba(244, 63, 94, 0.4);
}

.vote-count {
    color: var(--text-main);
    font-weight: 800;
}

/* Progress Bar */
.popularity-bar {
    height: 8px;
    background: #334155;
    border-radius: 20px;
    margin-top: 15px;
}

.popularity-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 20px;
}

/* Animations */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* =========================================
   7. MOBILE ADAPTIVE
   ========================================= */
@media (max-width: 768px) {
    .header-top { padding: 0 10px; }
    table { border-spacing: 0 12px; }
    td { padding: 15px 12px; }
    .rank { font-size: 1.1rem; width: 40px; }
    .leader-cell strong { font-size: 1rem; }
    td:nth-child(3), th:nth-child(3) { display: none; } /* Hide category on mobile */
}