/* --- CSS VARIABLES & RESET --- */
:root {
    --bg-color: #061e24;
    /* Deep Teal/Black background */
    --header-bg-color: #18182f;
    /* Darker header */
    --card-bg: #0f2e38;
    --accent-cyan: #1de3eb;
    --accent-purple: #7c3aed;
    --text-white: #ffffff;
    --muted: #93a4c3;
    --text-gray: #9ca3af;
    --sidebar-bg: rgba(8, 16, 37, 0.92);
    --text-gray: #9ca3af;
    --gold: #ffd700;
    --silver: #c0c0c0;
    --bronze: #cd7f32;
    --font-main: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-main);
}

body {
    background-color: var(--bg-color);
    color: var(--text-white);
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

/* --- MOBILE CONTAINER SIMULATION --- */
.mobile-container {
    width: 100%;
    max-width: 414px;
    /* iPhone Max width */
    background-color: var(--bg-color);
    position: relative;
    padding-bottom: 90px;
    /* Space for bottom nav */
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

/* --- HEADER --- */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    position: sticky;
    top: 0;
    background-color: var(--header-bg-color);
    z-index: 10;
}

.logo {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--accent-cyan);
    letter-spacing: 1px;
}

.header-icons i {
    font-size: 1.2rem;
    margin-left: 15px;
    color: var(--text-gray);
    cursor: pointer;
}

/* --- HERO SECTION --- */
.hero {
    margin: 0 15px 20px 15px;
    height: 180px;
    background: linear-gradient(135deg, #2ce5c6 0%, #7c3aed 100%);
    border-radius: 20px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    padding: 20px;
}

.hero h1 {
    font-size: 1.5rem;
    line-height: 1.2;
    width: 50%;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.hero img {
    position: absolute;
    right: -20px;
    top: 10px;
    width: 60%;
    transform: rotate(-15deg);
    filter: drop-shadow(0 10px 10px rgba(0, 0, 0, 0.3));
}

/* --- CATEGORY PILLS (Horizontal Scroll) --- */
.categories {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 0 15px 20px 15px;
    scrollbar-width: none;
    /* Firefox */
}

.categories::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

.pill {
    padding: 6px 16px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-gray);
    border: none;
    cursor: pointer;
    transition: 0.3s;
    text-decoration: none;
}

.pill.active {
    background-color: var(--text-white);
    color: var(--bg-color);
}

/* --- SECTIONS & GRIDS --- */
.section-title {
    padding: 0 15px 10px 15px;
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;

}

.title-see-all a {
    font-size: 0.75rem;
    color: var(--accent-cyan);
    text-decoration: none;
    font-weight: 600;
}


.game-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 0 15px 25px 15px;
}

.game-card {
    display: flex;
    flex-direction: column;
}

.thumb {
    width: 100%;
    aspect-ratio: 1/1;
    border-radius: 12px;
    overflow: hidden;
    background-color: #222;
    margin-bottom: 6px;
    position: relative;
}

.thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.game-title {
    font-size: 0.7rem;
    font-weight: 500;
    color: #ddd;
}

/* --- PROMO BANNER --- */
.promo-banner {
    background-color: #2a3b42;
    /* Slightly lighter than bg */
    margin: 10px 15px 30px 15px;
    padding: 20px;
    border-radius: 15px;
    border: 1px solid #364e56;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.promo-content h3 {
    font-size: 1.2rem;
    margin-bottom: 5px;
    text-transform: uppercase;
}

.promo-content p {
    font-size: 0.7rem;
    color: var(--text-gray);
    margin-bottom: 10px;
}

.promo-link {
    font-size: 0.75rem;
    color: var(--accent-cyan);
    text-decoration: none;
    font-weight: 600;
}

.promo-image img {
    width: 70px;
    height: 70px;
    object-fit: contain;
}

/* --- BOTTOM NAVIGATION --- */
.bottom-nav {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 40px);
    max-width: 374px;
    height: 60px;
    background: rgb(24 24 47);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 100;
}

.nav-item {
    color: var(--text-gray);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.3s;
}

.nav-item.active {
    color: var(--text-white);
}

span.one-liner {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.flickity-page-dots {
    bottom: 10px;
}

.flickity-page-dots .dot {
    background: #ffffff;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background 0.3s;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    width: 250px;
    height: calc(100vh - 60px);
    background: var(--sidebar-bg);
    border-right: 1px solid #253e61;
    transform: translateX(0);
    transition: transform 0.3s ease;
    z-index: 10;
    overflow-y: auto;
    padding-bottom: 100px;
}

.sidebar.closed {
    transform: translateX(-100%);
}

.sidebar-content a {
    display: block;
    padding: 7px 14px;
    margin: 5px 0;
    font-size: 14px;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--muted);
    margin: 12px;
    border-left: 4px solid transparent;
}

.sidebar-content a span:first-child {
    margin-right: 10px;
}

.sidebar-content a:hover {
    background: rgba(0, 168, 89, 0.08);
    color: #fff;
    border-left: 4px solid var(--green);
    padding-left: 18px;
}

.sidebar-content a.active {
    background: rgba(0, 168, 89, 0.16);
    color: #00a859;
    border-left: 4px solid var(--pink);
    padding-left: 18px;
}

/* Main Content */
.main-content {
    margin-top: 50px;
    margin-left: 250px;
    padding: 20px;
    transition: margin-left 0.3s ease;
    min-height: calc(100vh - 70px);
}

.main-content.sidebar-closed {
    margin-left: 0;
}

/* Mobile Styles */
@media (max-width: 768px) {
    .search-field {
        width: 200px;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.8);
        z-index: 9;
        display: none;
    }

    .overlay.active {
        display: block;
    }
}

@media (max-width: 480px) {
    .search-field {
        width: 150px;
    }

    .top-bar {
        padding: 0 10px;
    }
}

.sidebar-content a {
    text-decoration: none;
}

/* Hide scrollbar by default */
.sidebar::-webkit-scrollbar {
    width: 8px;
    background: transparent;
    /* Invisible scroll track */
}

.sidebar::-webkit-scrollbar-thumb {
    background: transparent;
    /* Hide thumb by default */
    border-radius: 4px;
}

/* When hovering over sidebar, show colored scrollbar */
.sidebar:hover::-webkit-scrollbar-thumb {
    background: #16213e;
    /* scrollbar thumb color */
}

/* Optional: slight hover effect on the thumb itself */
.sidebar:hover::-webkit-scrollbar-thumb:hover {
    background: #16213e;
}

/* Smooth scrollbar appearance for Firefox */
.sidebar {
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
}

.sidebar:hover {
    scrollbar-color: #16213e transparent;
}

hr.svelte-mpqqis {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin: 15px 0;
}

@media (min-width: 768px) {
    .sidebar {
        transform: translateX(0);
        top: 0;
        height: 100vh;
    }
}

.game-hero {
    position: relative;
    text-align: center;
    color: white;
}

.game-hero img {
    width: 100%;
    height: auto;
}

.absolute-buttons {
    position: absolute;
    bottom: 0px;
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: flex-end;
    padding-bottom: 20px;
    width: 100%;
    height: 100px;
    background: linear-gradient(0deg, #061e24, transparent);
}

.play-button {
    background-color: #28a745;
    color: white;
    padding: 8px 20px;
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    flex: 1;
}

.like-button {
    background-color: #e91e63;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.like-button.liked {
    background-color: #dc3545;
}

.game-description {
    padding: 20px;
    background-color: rgba(255, 255, 255, 0.1);
    margin-bottom: 60px;
    /* Space for bottom nav */

}

.alert {
    background-color: #f44336;
    /* Red */
    color: white;
    padding: 15px;
    margin: auto;
    border-radius: 5px;
    position: fixed;
    z-index: 1;
    bottom: 90px;
    left: 16px;
    right: 16px;
    max-width: 374px;
    text-align: center;
}

.alert.success {
    background-color: #4BB543;
}

/* Green */

.alert.info {
    background-color: #2196F3;
}

/* Blue */

.alert.warning {
    background-color: #ff9800;
}

/* Orange */

.alert.danger {
    background-color: rgb(244 67 54 / 60%);
}

/* Red */

.alert.closebtn {
    position: absolute;
    top: 10px;
    right: 25px;
    color: white;
    font-weight: bold;
    font-size: 22px;
    line-height: 20px;
    cursor: pointer;
    transition: 0.3s;
}

.alert.closebtn:hover {
    color: black;
}

.alert.closebtn:after {
    content: "×";
    font-size: 20px;
    line-height: 20px;
    position: absolute;
    right: 10px;
    top: 0;
}

.alert.closebtn:hover:after {
    color: black;
}

/* --- NEW: PROFILE SPECIFIC STYLES --- */
.profile-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 20px 40px 20px;
}

.avatar-container {
    position: relative;
    margin-bottom: 20px;
}

.avatar {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--accent-cyan);
    padding: 3px;
    /* Gap between border and image */
    background-color: var(--bg-color);
}

.username {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.usertag {
    color: var(--text-gray);
    font-size: 0.9rem;
    margin-bottom: 25px;
}

.edit-profile-btn {
    padding: 10px 30px;
    background: linear-gradient(135deg, var(--accent-cyan) 0%, #26baa0 100%);
    color: var(--bg-color);
    border: none;
    border-radius: 25px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(44, 229, 198, 0.3);
}

/* --- NEW: STATS GRID --- */
.stats-container {
    padding: 0 20px 30px 20px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.stat-card {
    background-color: var(--card-bg);
    border-radius: 16px;
    padding: 25px 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-icon {
    font-size: 1.4rem;
    color: var(--accent-cyan);
    margin-bottom: 15px;
    /* Subtle glow effect on icon */
    filter: drop-shadow(0 0 5px rgba(44, 229, 198, 0.4));
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 800;
    margin-bottom: 5px;
    color: var(--text-white);
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
}

/* --- TOGGLE SWITCH --- */
.toggle-container {
    display: flex;
    background-color: var(--card-bg);
    margin: 0 40px 25px 40px;
    padding: 4px;
    border-radius: 25px;
    position: relative;
}

.toggle-btn {
    flex: 1;
    text-align: center;
    padding: 8px 0;
    font-size: 0.85rem;
    color: var(--text-gray);
    border-radius: 20px;
    cursor: pointer;
    transition: 0.3s;
    z-index: 2;
}

.toggle-btn.active {
    color: var(--bg-color);
    font-weight: 700;
}

/* Sliding background for toggle */
.toggle-bg {
    position: absolute;
    left: 4px;
    top: 4px;
    width: calc(50% - 4px);
    height: calc(100% - 8px);
    background-color: var(--accent-cyan);
    border-radius: 20px;
    transition: 0.3s;
    z-index: 1;
}

/* Logic to move the slider based on class (simulated with CSS for now) */
.toggle-container.right .toggle-bg {
    left: 50%;
}


/* --- PODIUM SECTION (TOP 3) --- */
.podium {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    /* Align to bottom so heights vary upwards */
    gap: 15px;
    margin-bottom: 40px;
    padding: 0 20px;
}

.podium-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    text-align: center;
}

/* Rank 1 Styling */
.podium-item.first {
    margin-bottom: 20px;
}

/* Push it up slightly visually */
.podium-item.first .avatar {
    width: 100px;
    height: 100px;
    border-color: var(--gold);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

.podium-item.first .crown {
    display: block;
}

/* Rank 2 & 3 Styling */
.podium-item.second .avatar {
    width: 80px;
    height: 80px;
    border-color: var(--silver);
}

.podium-item.third .avatar {
    width: 80px;
    height: 80px;
    border-color: var(--bronze);
}

.avatar {
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid transparent;
    margin-bottom: 10px;
}

.crown {
    display: none;
    position: absolute;
    top: -25px;
    color: var(--gold);
    font-size: 1.5rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
    animation: float 2s infinite ease-in-out;
}

@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-5px);
    }

    100% {
        transform: translateY(0px);
    }
}

.rank-badge {
    position: absolute;
    bottom: 54px;
    /* Adjust based on name height */
    background-color: var(--bg-color);
    color: var(--text-white);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
    border: 2px solid var(--card-bg);
}

.podium-item.first .rank-badge {
    background-color: var(--gold);
    color: #000;
    border-color: var(--gold);
}

.podium-item.second .rank-badge {
    background-color: var(--silver);
    color: #000;
    border-color: var(--silver);
}

.podium-item.third .rank-badge {
    background-color: var(--bronze);
    color: #000;
    border-color: var(--bronze);
}

.podium-name {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.podium-score {
    font-size: 0.8rem;
    color: var(--accent-cyan);
    font-weight: 700;
}


/* --- LIST SECTION (4th - 10th) --- */
.leaderboard-list {
    padding: 0 20px;
    padding-bottom: 20px;
}

.list-item {
    display: flex;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.03);
    margin-bottom: 10px;
    padding: 10px 15px;
    border-radius: 12px;
    transition: 0.2s;
}

.list-item:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.rank-num {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-gray);
    width: 30px;
}

.list-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 15px;
    object-fit: cover;
}

.list-info {
    flex: 1;
}

.list-name {
    font-size: 0.9rem;
    font-weight: 600;
}

.list-games {
    font-size: 0.7rem;
    color: var(--text-gray);
}

.list-score {
    font-weight: 700;
    color: var(--accent-cyan);
}
header a{
    text-decoration: none;
}

/* Challenges Page */

/* --- CHALLENGES LIST PADDING --- */
        .challenges-list {
            padding: 10px 20px 30px 20px;
        }


        /* --- NEW: TOURNAMENT CARD DESIGN --- */
        .challenge-card {
            background-color: var(--card-bg);
            border-radius: 16px;
            overflow: hidden; /* Ensures banner corners match card */
            margin-bottom: 25px;
            border: 1px solid rgba(255,255,255,0.05);
            box-shadow: 0 10px 20px rgba(0,0,0,0.2);
        }

        /* Crucial part for untrimmed banners: 
           We use an actual img tag, set width to 100%, and height to auto.
           This ensures the whole image is shown, regardless of its aspect ratio.
        */
        .challenge-banner {
            width: 100%;
            height: auto; 
            display: block; /* Removes bottom gap often seen with inline images */
            border-bottom: 1px solid rgba(255,255,255,0.05);
        }

        .challenge-content {
            padding: 20px;
        }

        .challenge-title {
            font-size: 1.3rem;
            font-weight: 700;
            margin-bottom: 15px;
            color: var(--text-white);
        }

        /* Date Section */
        .challenge-dates {
            display: flex;
            gap: 20px;
            margin-bottom: 25px;
            padding-bottom: 15px;
            border-bottom: 1px solid rgba(255,255,255,0.1);
        }

        .date-block {
            display: flex;
            align-items: flex-start;
        }

        .date-icon {
            color: var(--accent-cyan);
            margin-right: 10px;
            margin-top: 3px;
            font-size: 1rem;
        }

        .date-label {
            font-size: 0.7rem;
            color: var(--text-gray);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            display: block;
            margin-bottom: 3px;
        }

        .date-value {
            font-size: 0.9rem;
            font-weight: 600;
        }

        /* Action Buttons */
        .challenge-actions {
            display: flex;
            gap: 10px;
        }

        .btn {
            flex: 1; /* Buttons take equal width */
            padding: 12px;
            border-radius: 12px;
            font-weight: 700;
            font-size: 0.9rem;
            cursor: pointer;
            transition: 0.3s;
            text-align: center;
            border: none;
        }

        /* Primary Button (Join) - Solid Cyan */
        .btn-primary {
            background: linear-gradient(135deg, var(--accent-cyan) 0%, #26baa0 100%);
            color: var(--bg-color);
            box-shadow: 0 4px 15px rgba(44, 229, 198, 0.2);
        }
        .btn-primary:hover {
            box-shadow: 0 6px 20px rgba(44, 229, 198, 0.4);
        }

        /* Secondary Button (Details) - Outlined style */
        .btn-secondary {
            background-color: transparent;
            border: 2px solid rgba(44, 229, 198, 0.3);
            color: var(--accent-cyan);
        }
        .btn-secondary:hover {
            background-color: rgba(44, 229, 198, 0.1);
            border-color: var(--accent-cyan);
        }