/* Modern Leaderboard Design - Compact & Responsive */
:root {
    --primary-color: #00AEEF;
    /* UNICEF Cyan */
    --secondary-color: #374EA2;
    /* UNICEF Dark Blue */
    --glass-bg: rgba(255, 255, 255, 0.75);
    /* Bright Glass */
    --glass-border: rgba(0, 0, 0, 0.05);
    --text-color: #333;
    /* Dark text */
    --gold: #D4AF37;
    /* Darker Gold for visibility */
    --silver: #757575;
    /* Darker Silver */
    --bronze: #A0522D;
    /* Darker Bronze */
    --font-family: 'Poppins', sans-serif;

    /* Font Size Variables (Adjustable via Settings) */
    --fs-header-title: 1.2rem;
    --fs-podium-score: 1.3rem;
    --fs-podium-name: 1.2rem;
    --fs-list-text: 1rem;
    --fs-list-score: 1.1rem;

    /* Podium Name Settings */
    --color-podium-name: #333;
    --weight-podium-name: 700;
}

body {
    font-family: var(--font-family);
    color: var(--text-color);
    background: linear-gradient(to left, #8f94fb, #4e54c8);
    /* Fallback */
    background: -webkit-linear-gradient(to left, #8f94fb, #4e54c8);
    /* Chrome 10-25, Safari 5.1-6 */
    background: linear-gradient(45deg, #00AEEF, #a1ffce);
    /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
    /* Bright Fun Gradient: Cyan to Light Green */
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    height: 100vh;
    margin: 0;
    padding: 10px;
    /* Reduced specific padding */
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    overflow: hidden;
    position: relative;
    /* For pseudo-elements */
}

/* ANIMATED BACKGROUND SQUARES/CIRCLES */
.circles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    margin: 0;
    padding: 0;
    z-index: -1;
}

.circles li {
    position: absolute;
    display: block;
    list-style: none;
    width: 20px;
    height: 20px;
    background: rgba(255, 255, 255, 0.4);
    animation: animate 25s linear infinite;
    bottom: -150px;
    border-radius: 20%;
    /* Soft squares */
}

/* Individual Settings for variety */
.circles li:nth-child(1) {
    left: 25%;
    width: 80px;
    height: 80px;
    animation-delay: 0s;
    background: rgba(255, 255, 255, 0.3);
}

.circles li:nth-child(2) {
    left: 10%;
    width: 20px;
    height: 20px;
    animation-delay: 2s;
    animation-duration: 12s;
    background: rgba(255, 255, 255, 0.4);
}

.circles li:nth-child(3) {
    left: 70%;
    width: 20px;
    height: 20px;
    animation-delay: 4s;
}

.circles li:nth-child(4) {
    left: 40%;
    width: 60px;
    height: 60px;
    animation-delay: 0s;
    animation-duration: 18s;
    background: rgba(255, 215, 0, 0.3);
    /* Gold tint */
}

.circles li:nth-child(5) {
    left: 65%;
    width: 20px;
    height: 20px;
    animation-delay: 0s;
}

.circles li:nth-child(6) {
    left: 75%;
    width: 110px;
    height: 110px;
    animation-delay: 3s;
    background: rgba(255, 255, 255, 0.25);
}

.circles li:nth-child(7) {
    left: 35%;
    width: 150px;
    height: 150px;
    animation-delay: 7s;
}

.circles li:nth-child(8) {
    left: 50%;
    width: 25px;
    height: 25px;
    animation-delay: 15s;
    animation-duration: 45s;
}

.circles li:nth-child(9) {
    left: 20%;
    width: 15px;
    height: 15px;
    animation-delay: 2s;
    animation-duration: 35s;
}

.circles li:nth-child(10) {
    left: 85%;
    width: 150px;
    height: 150px;
    animation-delay: 0s;
    animation-duration: 11s;
    background: rgba(0, 174, 239, 0.2);
    /* Cyan tint */
}

@keyframes animate {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
        border-radius: 0;
    }

    100% {
        transform: translateY(-1000px) rotate(720deg);
        opacity: 0;
        border-radius: 50%;
    }
}

.leaderboard-container {
    width: 100%;
    max-width: 1250px;
    /* Increased from 1100px */
    height: 95vh;
    /* Occupy almost full height */
    background: rgba(255, 255, 255, 0.3);
    /* Much more transparent to show background */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1rem;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

/* Header Section - Two Row Layout */
header {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 0;
    flex-shrink: 0;
    padding: 5px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px 15px 0 0;
}

/* ... restored header contents ... */
.header-row-top {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    position: relative;
    min-height: 85px;
}

.header-logo {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 85px;
    height: 85px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: none;
}

.header-date {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    padding: 5px 20px;
    border-radius: 20px;
    font-weight: 700;
    color: #444;
    font-size: 1rem;
    box-shadow: none;
    border: none;
    min-width: 120px;
    display: flex;
    justify-content: center;
}

.header-row-bottom {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

h1 {
    font-size: var(--fs-header-title);
    font-weight: 700;
    margin: 0;
    background: var(--primary-color);
    -webkit-background-clip: text;
    background-clip: text;
    color: var(--primary-color);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 1px;
    line-height: 1.3;
}

h2 {
    font-size: 1.5rem;
    color: #a0a0e0;
    margin: 0;
    background: linear-gradient(90deg, #374EA2, #00AEEF, #374EA2);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: shineText 4s linear infinite;
    font-weight: 700;
    text-transform: uppercase;
}

@keyframes shineText {
    to {
        background-position: 200% center;
    }
}

/* Podium Section (Top 3) - BIGGER */
.podium-container {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 25px;
    margin-bottom: 5px;
    /* Reduced from 20px */
    padding-bottom: 5px;
    /* Reduced from 30px */
    border-bottom: none;

    /* Make podium BIGGER */
    flex-shrink: 0;
    min-height: 260px;
}

.podium-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    width: 30%;
    /* Wider items */
    /* Use percentage width */
    /* overflow: hidden; removed to show crown */
}

/* Shimmer Effect */
/* Shimmer moved to .podium-info */

@keyframes shimmer {
    0% {
        left: -100%;
    }

    20% {
        left: 200%;
    }

    /* Fast pass */
    100% {
        left: 200%;
    }

    /* Wait */
}

/* removed duplicate styles */

.podium-item.gold {
    order: 2;
    z-index: 3;
}

.podium-item.silver {
    order: 1;
    z-index: 2;
    transform: scale(0.95) translateY(10px);
}

.podium-item.bronze {
    order: 3;
    z-index: 1;
    transform: scale(0.9) translateY(20px);
}

.avatar-wrapper {
    position: relative;
    margin-bottom: 10px;
}

.crown-icon {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.2rem;
    /* Reduced size */
    filter: drop-shadow(0 0 8px gold);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateX(-50%) translateY(0);
    }

    50% {
        transform: translateX(-50%) translateY(-5px);
    }
}

/* Adjusted Avatar Sizes - BIGGER */
.avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid #fff;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.6);
}

.podium-item.gold .avatar {
    border-color: var(--gold);
    width: 110px;
    height: 110px;
    border-width: 5px;
}

.podium-item.silver .avatar {
    border-color: var(--silver);
    width: 95px;
    height: 95px;
}

.podium-item.bronze .avatar {
    border-color: var(--bronze);
    width: 85px;
    height: 85px;
}

/* Duplicates removed */

.podium-rank {
    position: absolute;
    bottom: -8px;
    background: #0f3460;
    color: #fff;
    width: 24px;
    height: 24px;
    font-size: 0.9rem;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    border: 2px solid #fff;
}

/* New Podium Grid Layout */
.podium-info-grid {
    background: rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    width: 100%;
    padding: 8px;
    /* Reduced padding */
    display: grid;
    grid-template-columns: 80px 1fr 100px;
    /* Increased right col width */
    gap: 10px;
    align-items: center;
    position: relative;
    overflow: hidden;
}

/* Shimmer on Grid */
.podium-info-grid::after {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.4) 50%, rgba(255, 255, 255, 0) 100%);
    transform: skewX(-25deg);
    animation: shimmer 6s infinite;
    z-index: 5;
    pointer-events: none;
}

.col-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-right: 1px solid rgba(0, 0, 0, 0.1);
    padding-right: 5px;
}

.podium-rank-new {
    font-size: 2.5rem;
    /* Large rank */
    font-weight: 800;
    line-height: 1;
    display: flex;
    align-items: flex-start;
    color: #fff;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
}

/* Rank Colors */
.podium-item.gold .podium-rank-new {
    color: var(--gold);
}

.podium-item.silver .podium-rank-new {
    color: var(--silver);
}

.podium-item.bronze .podium-rank-new {
    color: var(--bronze);
}

.streak-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: #555;
    font-weight: 600;
    margin-top: 2px;
}

.streak-value {
    font-size: 0.7rem;
    font-weight: 700;
    color: #333;
}

.col-mid {
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}

.podium-name {
    font-weight: var(--weight-podium-name);
    font-size: var(--fs-podium-name);
    color: var(--color-podium-name);
    margin-bottom: 2px;
    line-height: 1.2;
    white-space: normal;
    text-align: center;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.podium-motto {
    font-size: 0.85rem;
    font-style: italic;
    color: black;
    /* Changed to black */
    margin-bottom: 3px;
    white-space: normal;
    line-height: 1.1;
    max-height: 2.4em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.podium-money {
    color: #4caf50;
    font-weight: 800;
    font-size: var(--fs-podium-score);
}

.col-right {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    /* Push logo to top/fill */
    align-items: center;
    height: 100%;
    text-align: center;
    padding: 2px;
}

.col-right img {
    width: 100%;
    height: 100%;
    /* Fill available height */
    max-height: 70px;
    /* Increased limit */
    object-fit: contain;
    /* Maintain aspect ratio */
    margin-bottom: 0;
    flex-grow: 1;
}

.podium-donor-text-small {
    font-size: 1.2rem;
    /* Decreased to 1.2rem as requested */
    font-weight: 800;
    color: #333;
    line-height: 1;
    word-break: break-word;
    margin-top: 2px;
}


/* List Section (Rest of the players) */
.list-container {
    flex-grow: 1;
    /* Takes all remaining space */
    overflow-y: hidden;
    /* JS handles "rolling", but prevents raw scrollbar ugly overlap */
    position: relative;
    padding-right: 5px;
    display: flex;
    flex-direction: column;
}

.list-item {
    display: grid;
    /* Rank | Avatar | Name (fills space) | Money | Donor (Right) */
    grid-template-columns: 40px 50px 1fr auto auto;
    align-items: center;
    background: rgba(255, 255, 255, 0.25);
    /* More transparent */
    margin-bottom: 8px;
    padding: 8px 15px;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    gap: 15px;
    backdrop-filter: blur(5px);
    /* Add slight blur */
    -webkit-backdrop-filter: blur(5px);
}

.list-rank {
    font-size: 1.1rem;
    font-weight: bold;
    color: #888;
}

.list-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Removed .list-details styling */

.list-name-block {
    display: flex;
    flex-direction: row;
    /* Horizontal row */
    align-items: center;
    width: 100%;
    gap: 15px;
    overflow: hidden;
}

/* ... list-name ... */
.list-name {
    font-weight: 600;
    font-size: var(--fs-list-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.list-streak {
    font-size: 0.7rem;
    color: #e67e22;
    font-weight: 600;
}

.list-motto {
    font-size: 0.85rem;
    color: black;
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
    /* Fill space */
    text-align: center;
    /* Center in filled space */
}

.list-donor {
    font-size: 0.9rem;
    opacity: 1;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    background: rgba(0, 0, 0, 0.05);
    /* Darker pill for contrast */
    padding: 5px 15px;
    border-radius: 20px;
    width: fit-content;
    justify-self: end;
    /* Align Right */
    color: black;
    font-weight: 700;
}

.list-donor-img {
    width: 36px;
    /* Increased 80% (20->36) */
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.list-money {
    font-weight: 700;
    color: #4caf50;
    font-size: var(--fs-list-score);
    text-align: right;
    margin-right: 15px;
}

/* Corner Stats Summary */
.stat-corner {
    position: absolute;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    pointer-events: none;
    width: 200px;
}

.top-left {
    top: 150px;
    left: 20px;
}

.top-right {
    top: 150px;
    right: 20px;
}

.stat-label-small {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 2px;
}

.top-left .stat-label-small {
    color: white;
    opacity: 0.9;
}

.top-right .stat-label-small {
    color: white;
    opacity: 0.9;
}

.stat-value-18 {
    font-size: 18px;
    font-weight: 800;
    color: white;
    line-height: 1;
}

.stat-change-small {
    font-size: 0.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 3px;
    margin-top: 2px;
    color: white;
}

.change-up {
    color: #ffd700;
    /* Gold for Increase */
}

.change-down {
    color: #ff4757;
    /* Red for Decrease */
}

.chart-mini-line {
    width: 180px;
    height: 60px;
    margin-top: 5px;
}

#weekly-income-chart {
    width: 100% !important;
    height: 100% !important;
}

/* Arrow Icons */
.arrow-up::before {
    content: "▲";
}

.arrow-down::before {
    content: "▼";
}

/* ========== MOBILE RESPONSIVE STYLES ========== */
@media (max-width: 768px) {
    body {
        padding: 5px;
    }

    .leaderboard-container {
        padding: 10px;
        width: 100%;
        max-width: 100%;
        flex-direction: column;
        gap: 10px;
        position: relative;
    }

    header {
        padding: 12px 10px;
    }

    .header-row-top {
        flex-direction: column;
        gap: 6px;
        min-height: auto;
    }

    .header-logo {
        display: none !important;
        /* Hide logo on mobile to prevent overlap */
    }

    .header-row-top h1 {
        font-size: 1rem;
        letter-spacing: 0;
    }

    .header-date {
        position: static !important;
        transform: none !important;
        font-size: 0.7rem;
        background: none;
        border: none;
        padding: 0;
        min-width: auto;
    }

    .header-row-bottom h2 {
        font-size: 0.9rem;
        margin: 0;
    }

    /* PODIUM - Stack vertically on mobile */
    .podium-container {
        flex-direction: column;
        align-items: center;
        gap: 12px;
        min-height: auto;
        margin-bottom: 12px;
        padding-bottom: 12px;
        position: relative;
        z-index: 10;
    }

    .podium-item {
        width: 100%;
        max-width: 140px;
        transform: none !important;
        padding: 8px;
    }

    .podium-item.silver {
        transform: none !important;
    }

    .podium-item.bronze {
        transform: none !important;
    }

    .podium-rank-new {
        width: 28px !important;
        height: 28px !important;
        font-size: 0.75rem !important;
    }

    .avatar {
        width: 50px;
        height: 50px;
        border: 2px solid #fff;
    }

    .podium-info {
        padding: 6px;
        text-align: center;
    }

    .podium-info h3 {
        font-size: 0.8rem;
        margin: 2px 0;
    }

    .podium-info .score {
        font-size: 0.75rem;
        margin: 0;
    }

    /* LIST - Adjust grid columns for mobile */
    .list-container {
        flex-grow: 1;
        overflow-y: auto;
        padding-right: 3px;
        position: relative;
        z-index: 5;
    }

    .list-item {
        grid-template-columns: 32px 36px 1fr 45px auto;
        gap: 6px;
        padding: 6px 8px;
        margin-bottom: 5px;
        font-size: 0.85rem;
        background: rgba(255, 255, 255, 0.2);
    }

    .list-rank {
        font-size: 0.85rem;
        min-width: 32px;
    }

    .list-avatar {
        width: 32px;
        height: 32px;
    }

    .list-name-block {
        gap: 6px;
        overflow: hidden;
    }

    .list-name {
        font-size: 0.8rem;
        min-width: 50px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .list-streak {
        font-size: 0.6rem;
        display: none;
    }

    .list-motto {
        display: none;
    }

    .list-money {
        font-size: 0.75rem;
        font-weight: 600;
        margin-right: 4px;
        min-width: 45px;
        text-align: right;
    }

    .list-donor {
        padding: 2px 6px;
        gap: 3px;
        font-size: 0.65rem;
        background: rgba(0, 0, 0, 0.1);
        border-radius: 4px;
        white-space: nowrap;
    }

    .list-donor-img {
        width: 20px;
        height: 20px;
    }

    /* STATS SECTION - Reposition below content */
    #stats-section {
        position: relative !important;
        width: 100% !important;
        height: auto !important;
        z-index: 1;
        padding: 10px 0;
        gap: 8px;
    }

    .stat-corner {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        padding: 10px 8px;
        font-size: 0.65rem;
        width: 100%;
        max-width: none;
        background: rgba(255, 255, 255, 0.15);
        margin-bottom: 8px;
    }

    .stat-corner.top-left {
        transform: none !important;
    }

    .stat-corner.top-right {
        transform: none !important;
    }

    .stat-label-small {
        font-size: 0.6rem;
    }

    .stat-value-18 {
        font-size: 1rem;
    }

    .chart-mini-line {
        width: 100%;
        height: 40px;
    }
}

@media (max-width: 480px) {
    .leaderboard-container {
        padding: 6px;
        gap: 6px;
    }

    header {
        padding: 10px 6px;
    }

    .header-row-top h1 {
        font-size: 0.9rem;
    }

    .header-row-bottom h2 {
        font-size: 0.8rem;
    }

    .podium-container {
        gap: 10px;
        margin-bottom: 10px;
        padding-bottom: 10px;
    }

    .podium-item {
        max-width: 120px;
        padding: 6px;
    }

    .podium-rank-new {
        width: 24px !important;
        height: 24px !important;
        font-size: 0.65rem !important;
    }

    .avatar {
        width: 45px;
        height: 45px;
    }

    .podium-info {
        padding: 4px;
    }

    .podium-info h3 {
        font-size: 0.75rem;
        margin: 1px 0;
    }

    .podium-info .score {
        font-size: 0.65rem;
        margin: 0;
    }

    .list-item {
        grid-template-columns: 28px 32px 1fr 40px auto;
        gap: 4px;
        padding: 5px 6px;
        margin-bottom: 4px;
        font-size: 0.75rem;
    }

    .list-rank {
        font-size: 0.75rem;
        min-width: 28px;
    }

    .list-avatar {
        width: 28px;
        height: 28px;
    }

    .list-name-block {
        gap: 4px;
    }

    .list-name {
        font-size: 0.7rem;
        min-width: 40px;
    }

    .list-streak {
        display: none;
    }

    .list-money {
        font-size: 0.7rem;
        margin-right: 2px;
        min-width: 40px;
    }

    .list-donor {
        padding: 1px 4px;
        gap: 2px;
        font-size: 0.6rem;
        display: none;
        /* Hide donor completely on very small screens */
    }

    .list-donor-img {
        width: 18px;
        height: 18px;
    }

    #stats-section {
        padding: 6px 0;
    }

    .stat-corner {
        padding: 8px 6px;
        font-size: 0.6rem;
        margin-bottom: 6px;
    }

    .stat-label-small {
        font-size: 0.55rem;
    }

    .stat-value-18 {
        font-size: 0.9rem;
    }

    .chart-mini-line {
        height: 35px;
    }
}