/* ============================================================
   LEADERBOARD PAGE — Premium Style
   Compatible: Chrome, Safari (macOS + iOS), Edge, Firefox,
   Android Chrome, Samsung Internet
============================================================ */

/* ============================================================
   iOS & TOUCH FIXES
============================================================ */
.leaderboard-card,
.leaderboard-container {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

.leaderboard-card,
.table tbody tr a,
.pagination .page-link {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* ============================================================
   LEADERBOARD CONTAINER
============================================================ */
.leaderboard-container {
    padding: 40px 0 60px;
    position: relative;
}

/* ============================================================
   LEADERBOARD CARDS (Top 3)
============================================================ */
.leaderboard-card {
    background:
        radial-gradient(120% 130% at 50% 0%, rgba(84, 243, 154, 0.15), transparent 60%),
        linear-gradient(160deg, #102532 0%, #0a1724 100%);
    border: 1px solid rgba(84, 243, 154, 0.15);
    border-radius: 24px;
    padding: 24px 20px;
    min-width: 180px;
    max-width: 220px;
    text-align: center;
    position: relative;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.leaderboard-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, #54F39A, transparent);
    opacity: 0.6;
}

.leaderboard-card:hover {
    transform: translateY(-8px);
    border-color: rgba(84, 243, 154, 0.4);
    box-shadow:
        0 24px 60px -20px rgba(84, 243, 154, 0.5),
        0 0 60px -20px rgba(34, 211, 238, 0.4);
}

/* Rank 1 */
.leaderboard-card.first-place {
    background:
        radial-gradient(120% 130% at 50% 0%, rgba(255, 211, 122, 0.2), transparent 60%),
        linear-gradient(160deg, #2a1f05 0%, #1a1424 100%);
    border-color: rgba(255, 211, 122, 0.4);
    transform: scale(1.05);
    padding-top: 40px;
    box-shadow:
        0 20px 50px -20px rgba(255, 211, 122, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.leaderboard-card.first-place::before {
    background: linear-gradient(90deg, transparent, #FFD37A, transparent);
    opacity: 1;
    box-shadow: 0 0 20px rgba(255, 211, 122, 0.8);
}

.leaderboard-card.first-place:hover {
    border-color: rgba(255, 211, 122, 0.7);
    box-shadow:
        0 24px 60px -15px rgba(255, 211, 122, 0.7),
        0 0 80px -20px rgba(255, 211, 122, 0.5);
}

/* Rank 2 */
.leaderboard-card.sec-place {
    background:
        radial-gradient(120% 130% at 50% 0%, rgba(226, 232, 240, 0.12), transparent 60%),
        linear-gradient(160deg, #1a2530 0%, #0a1724 100%);
    border-color: rgba(226, 232, 240, 0.25);
}

.leaderboard-card.sec-place::before {
    background: linear-gradient(90deg, transparent, #E2E8F0, transparent);
}

/* Rank 3 */
.leaderboard-card.third-place {
    background:
        radial-gradient(120% 130% at 50% 0%, rgba(251, 146, 60, 0.15), transparent 60%),
        linear-gradient(160deg, #251a12 0%, #0a1724 100%);
    border-color: rgba(251, 146, 60, 0.3);
}

.leaderboard-card.third-place::before {
    background: linear-gradient(90deg, transparent, #FB923C, transparent);
}

/* ============================================================
   PLACE BADGE
============================================================ */
.leaderboard-card .place img {
    width: 32px;
    height: 32px;
    -webkit-filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.6));
            filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.6));
    animation: place-float 3s ease-in-out infinite;
}

@keyframes place-float {
    0%, 100% { transform: translateY(0) rotate(-8deg); }
    50%      { transform: translateY(-4px) rotate(-8deg); }
}

/* ============================================================
   AVATAR
============================================================ */
.leaderboard-image {
    position: relative;
    width: 88px;
    height: 88px;
    margin: 0 auto;
}

.leaderboard-image img:first-child {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #54F39A;
    box-shadow:
        0 0 0 4px rgba(84, 243, 154, 0.15),
        0 8px 24px rgba(84, 243, 154, 0.4);
    transition: transform 0.3s ease;
    -webkit-backface-visibility: hidden;
            backface-visibility: hidden;
}

.leaderboard-card:hover .leaderboard-image img:first-child {
    transform: scale(1.08);
}

.leaderboard-card.first-place .leaderboard-image img:first-child {
    border-color: #FFD37A;
    box-shadow:
        0 0 0 4px rgba(255, 211, 122, 0.2),
        0 8px 24px rgba(255, 211, 122, 0.5);
}

.leaderboard-card.sec-place .leaderboard-image img:first-child {
    border-color: #E2E8F0;
}

.leaderboard-card.third-place .leaderboard-image img:first-child {
    border-color: #FB923C;
}

/* ============================================================
   CROWN
============================================================ */
.leaderboard-image .crown {
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
    width: 48px;
    height: 48px;
    animation: crown-bounce 2.5s ease-in-out infinite;
    -webkit-filter: drop-shadow(0 4px 12px rgba(255, 211, 122, 0.8));
            filter: drop-shadow(0 4px 12px rgba(255, 211, 122, 0.8));
    z-index: 2;
}

@keyframes crown-bounce {
    0%, 100% { transform: translateX(-50%) translateY(0) rotate(-5deg); }
    50%      { transform: translateX(-50%) translateY(-6px) rotate(5deg); }
}

/* ============================================================
   USERNAME & POINTS
============================================================ */
.leaderboard-card .f-md.text-break {
    color: #ffffff !important;
    font-weight: 700 !important;
    font-size: 15px !important;
    margin-top: 14px !important;
}

.leaderboard-card .text-primary.f-md {
    color: #54F39A !important;
    font-weight: 800 !important;
    font-size: 17px !important;
    text-shadow: 0 0 16px rgba(84, 243, 154, 0.5);
    font-variant-numeric: tabular-nums;
}

.leaderboard-card.first-place .text-primary.f-md {
    color: #FFD37A !important;
    text-shadow: 0 0 16px rgba(255, 211, 122, 0.6);
}

/* ============================================================
   PRIZE BADGE
============================================================ */
.leaderboard-card .badge.bg-dark {
    background: rgba(0, 0, 0, 0.4) !important;
    border: 1px solid rgba(84, 243, 154, 0.15);
    border-radius: 12px !important;
    padding: 6px 12px !important;
    margin-top: 12px;
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    transition: all 0.25s ease;
}

.leaderboard-card:hover .badge.bg-dark {
    border-color: rgba(84, 243, 154, 0.4);
    background: rgba(84, 243, 154, 0.08) !important;
}

/* ============================================================
   TABLE
============================================================ */
.table-responsive {
    background: linear-gradient(160deg, #0f1420 0%, #0a1724 100%);
    border: 1px solid rgba(84, 243, 154, 0.1);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 8px 32px -12px rgba(0, 0, 0, 0.5);
    -webkit-overflow-scrolling: touch;
}

.table {
    margin: 0 !important;
    color: rgba(255, 255, 255, 0.85) !important;
}

.table thead {
    background: rgba(84, 243, 154, 0.05);
}

.table thead th {
    color: #54F39A !important;
    font-weight: 700 !important;
    font-size: 12px !important;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 18px 20px !important;
    border-bottom: 1px solid rgba(84, 243, 154, 0.15) !important;
    white-space: nowrap;
}

.table tbody td {
    padding: 16px 20px !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04) !important;
    vertical-align: middle;
    color: rgba(255, 255, 255, 0.8);
}

.table tbody tr {
    transition: all 0.2s ease;
}

.table tbody tr:hover {
    background: linear-gradient(90deg, rgba(84, 243, 154, 0.06), transparent) !important;
}

.table tbody tr:hover td {
    color: #ffffff !important;
}

.table tbody tr:last-child td {
    border-bottom: none !important;
}

/* Table avatars */
.table tbody img[style*="width: 24px"] {
    border: 2px solid #54F39A !important;
    border-radius: 50% !important;
    box-shadow: 0 0 8px rgba(84, 243, 154, 0.4);
    object-fit: cover;
    vertical-align: middle;
}

/* Table rank badges */
.table .badge.bg-label-primary {
    background: linear-gradient(135deg, rgba(84, 243, 154, 0.2), rgba(84, 243, 154, 0.05)) !important;
    color: #54F39A !important;
    border: 1px solid rgba(84, 243, 154, 0.3);
    font-weight: 700 !important;
    padding: 6px 12px !important;
    font-size: 12px !important;
    border-radius: 8px !important;
}

/* Points cell */
.table td.text-primary {
    color: #54F39A !important;
    font-weight: 800 !important;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 12px rgba(84, 243, 154, 0.3);
}

/* ============================================================
   INFO BADGES (You earned today, Ends in)
============================================================ */
.badge.bg-dark {
    background: linear-gradient(135deg, rgba(84, 243, 154, 0.08), rgba(84, 243, 154, 0.02)) !important;
    border: 1px solid rgba(84, 243, 154, 0.2);
    border-radius: 14px !important;
    padding: 10px 18px !important;
    color: rgba(255, 255, 255, 0.85) !important;
    font-weight: 600 !important;
    font-size: 13px !important;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
}

.badge.bg-dark:hover {
    border-color: rgba(84, 243, 154, 0.4);
    box-shadow: 0 6px 20px -8px rgba(84, 243, 154, 0.5);
}

.badge.bg-dark svg.text-primary {
    color: #54F39A !important;
    -webkit-filter: drop-shadow(0 0 6px rgba(84, 243, 154, 0.5));
            filter: drop-shadow(0 0 6px rgba(84, 243, 154, 0.5));
}

/* ============================================================
   BACKGROUND IMAGE
============================================================ */
.bg-b-csm {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.15;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 300px;
    z-index: -1;
    pointer-events: none;
    -webkit-filter: blur(2px);
            filter: blur(2px);
    -webkit-mask-image: linear-gradient(180deg, black 0%, transparent 100%);
            mask-image: linear-gradient(180deg, black 0%, transparent 100%);
}

/* ============================================================
   RESPONSIVE — TABLET
============================================================ */
@media (max-width: 991.98px) {
    .leaderboard-card {
        min-width: 160px;
        max-width: 200px;
        padding: 20px 16px;
    }
    .leaderboard-image,
    .leaderboard-image img:first-child {
        width: 72px;
        height: 72px;
    }
    .leaderboard-image .crown {
        width: 40px;
        height: 40px;
        top: -20px;
    }
}

/* ============================================================
   RESPONSIVE — MOBILE
============================================================ */
@media (max-width: 767.98px) {
    .leaderboard-container {
        padding: 20px 0 40px;
    }
    .leaderboard-card {
        min-width: 140px;
        max-width: 180px;
        padding: 18px 12px;
        border-radius: 20px;
    }
    .leaderboard-image,
    .leaderboard-image img:first-child {
        width: 64px;
        height: 64px;
    }
    .leaderboard-image .crown {
        width: 36px;
        height: 36px;
        top: -16px;
    }
    .leaderboard-card.first-place {
        padding-top: 32px;
        transform: scale(1.02);
    }
    .leaderboard-card .f-md.text-break {
        font-size: 13px !important;
    }
    .leaderboard-card .text-primary.f-md {
        font-size: 15px !important;
    }
    .table thead th,
    .table tbody td {
        padding: 12px 14px !important;
        font-size: 12px !important;
    }
    .badge.bg-dark {
        padding: 8px 14px !important;
        font-size: 12px !important;
    }
}

/* ============================================================
   RESPONSIVE — SMALL MOBILE
============================================================ */
@media (max-width: 575.98px) {
    .leaderboard-card {
        min-width: 110px;
        max-width: 140px;
        padding: 14px 10px;
    }
    .leaderboard-image,
    .leaderboard-image img:first-child {
        width: 54px;
        height: 54px;
    }
    .leaderboard-image .crown {
        width: 30px;
        height: 30px;
        top: -14px;
    }
    .leaderboard-card .f-md.text-break {
        font-size: 11.5px !important;
    }
    .leaderboard-card .text-primary.f-md {
        font-size: 13px !important;
    }
    .leaderboard-card .badge.bg-dark {
        font-size: 10px !important;
        padding: 4px 8px !important;
    }
    .table thead th,
    .table tbody td {
        padding: 10px 10px !important;
        font-size: 11px !important;
    }
}

/* ============================================================
   iOS SAFE AREA
============================================================ */
@supports (padding: max(0px)) {
    .leaderboard-container {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
}

/* ============================================================
   iOS SPECIFIC
============================================================ */
@supports (-webkit-touch-callout: none) {
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }
    .leaderboard-card {
        -webkit-appearance: none;
        appearance: none;
    }
}

/* ============================================================
   REDUCED MOTION
============================================================ */
@media (prefers-reduced-motion: reduce) {
    .leaderboard-card .place img,
    .leaderboard-image .crown {
        animation: none !important;
    }
    .leaderboard-card,
    .leaderboard-card * {
        transition-duration: 0.01ms !important;
    }
}