/* ============================================================
   LEADERBOARD SCREEN
   Romantic Twin Pieces aesthetic: deep crimson base,
   gold accents, glassmorphism cards, green "you" highlight.
   ============================================================ */

/* ── layout shell ── */
.leaderboard-screen {
    display: none;                      /* toggled to flex on show() */
    flex-direction: column;
    align-items: center;
    width: 100%;
    min-height: 100vh;
    padding: 28px 20px 32px;
    box-sizing: border-box;
    gap: 0;                             /* controlled per-child */
}

/* ── header ── */
.lb-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}

.lb-trophy {
    font-size: 2.2rem;
    filter: drop-shadow(0 4px 8px rgba(255, 215, 0, 0.5));
    animation: lb-trophy-bounce 2s ease-in-out infinite;
}

@keyframes lb-trophy-bounce {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-6px); }
}

.lb-title {
    font-family: 'Georgia', serif;
    font-size: 2.4rem;
    font-weight: bold;
    color: #fff;
    margin: 0;
    text-shadow: 0 3px 12px rgba(0, 0, 0, 0.6),
                 0 0 24px rgba(255, 71, 87, 0.25);
    letter-spacing: 1px;
}

/* ── podium wrapper ── */
.lb-podium-wrap {
    width: 100%;
    max-width: 560px;
    margin-bottom: 8px;
}

/* ── podium row (3 slots) ── */
.lb-podium {
    display: flex;
    justify-content: center;
    align-items: flex-end;             /* bars grow upward */
    gap: 16px;
    width: 100%;
}

/* ── single podium slot ── */
.lb-podium-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 1;
    max-width: 150px;
    position: relative;
}

/* badge (medal emoji) */
.lb-podium-badge {
    font-size: 1.8rem;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.4));
    position: relative;
    z-index: 2;
}

/* avatar circle */
.lb-podium-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: 4px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 6px 20px rgba(0,0,0,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
    position: relative;
    z-index: 2;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.lb-podium-slot.rank-1 .lb-podium-avatar {
    width: 88px;
    height: 88px;
    font-size: 1.8rem;
    border-color: #ffd700;
    box-shadow: 0 0 24px rgba(255, 215, 0, 0.5),
                0 6px 20px rgba(0,0,0,0.35);
    background: linear-gradient(135deg, #ff6b7a, #ff4757);
}

.lb-podium-slot.rank-2 .lb-podium-avatar {
    background: linear-gradient(135deg, #a8a8a8, #c0c0c0);
    border-color: #c0c0c0;
}

.lb-podium-slot.rank-3 .lb-podium-avatar {
    background: linear-gradient(135deg, #cd7f32, #dea060);
    border-color: #cd7f32;
}

/* highlight current pair on podium */
.lb-podium-slot.current .lb-podium-avatar {
    border-color: #4cd137 !important;
    box-shadow: 0 0 20px rgba(76, 209, 55, 0.6),
                0 6px 20px rgba(0,0,0,0.35) !important;
}

/* name */
.lb-podium-name {
    font-size: 0.88rem;
    font-weight: bold;
    color: #fff;
    text-align: center;
    text-shadow: 0 1px 6px rgba(0,0,0,0.6);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 4px;
    position: relative;
    z-index: 2;
}

/* time beneath name */
.lb-podium-time {
    font-size: 0.82rem;
    color: #ffd700;
    font-weight: bold;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
    position: relative;
    z-index: 2;
}

/* coloured bar at bottom */
.lb-podium-bar {
    width: 100%;
    border-radius: 12px 12px 0 0;
    position: relative;
    z-index: 1;
}

.lb-podium-slot.rank-1 .lb-podium-bar {
    height: 80px;
    background: linear-gradient(180deg, #ffd700 0%, #ffaa00 100%);
    box-shadow: 0 -4px 16px rgba(255, 215, 0, 0.4);
}

.lb-podium-slot.rank-2 .lb-podium-bar {
    height: 56px;
    background: linear-gradient(180deg, #c0c0c0 0%, #a0a0a0 100%);
    box-shadow: 0 -4px 12px rgba(192, 192, 192, 0.3);
}

.lb-podium-slot.rank-3 .lb-podium-bar {
    height: 40px;
    background: linear-gradient(180deg, #cd7f32 0%, #a0602a 100%);
    box-shadow: 0 -4px 12px rgba(205, 127, 50, 0.3);
}

/* ── divider between podium and list ── */
.lb-divider {
    width: 100%;
    max-width: 520px;
    height: 2px;
    margin: 18px 0 16px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255, 71, 87, 0.5) 20%,
        rgba(255, 215, 0, 0.6) 50%,
        rgba(255, 71, 87, 0.5) 80%,
        transparent 100%
    );
}

/* ── scrollable list wrapper ── */
.lb-list-wrap {
    width: 100%;
    max-width: 520px;
    max-height: 340px;
    overflow-y: auto;
    /* hide default scrollbar on webkit */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 71, 87, 0.4) transparent;
}

.lb-list-wrap::-webkit-scrollbar        { width: 6px; }
.lb-list-wrap::-webkit-scrollbar-track  { background: transparent; }
.lb-list-wrap::-webkit-scrollbar-thumb  {
    background: rgba(255, 71, 87, 0.4);
    border-radius: 3px;
}

/* ── list ── */
.lb-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 4px 2px;
}

/* ── single list row ── */
.lb-list-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: rgba(0, 0, 0, 0.38);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    transition: background 0.25s, border-color 0.25s, transform 0.2s;
}

.lb-list-row:hover {
    background: rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 71, 87, 0.35);
    transform: translateX(4px);
}

/* green highlight for the pair that just finished */
.lb-list-row.current {
    background: rgba(76, 209, 55, 0.18);
    border-color: #4cd137;
    box-shadow: 0 0 18px rgba(76, 209, 55, 0.25);
}

.lb-list-row.current:hover {
    background: rgba(76, 209, 55, 0.26);
    border-color: #4cd137;
}

/* rank number */
.lb-list-rank {
    min-width: 32px;
    font-size: 1.1rem;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.55);
    text-align: center;
    font-family: 'Courier New', monospace;
    flex-shrink: 0;
}

.lb-list-row:nth-child(1) .lb-list-rank { color: #ffd700; }
.lb-list-row:nth-child(2) .lb-list-rank { color: #c0c0c0; }
.lb-list-row:nth-child(3) .lb-list-rank { color: #cd7f32; }

/* small avatar in list */
.lb-list-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: 2px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: bold;
    color: #fff;
    flex-shrink: 0;
    text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.lb-list-row.current .lb-list-avatar {
    border-color: #4cd137;
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    box-shadow: 0 0 10px rgba(76, 209, 55, 0.4);
}

/* details wrapper (name + date) */
.lb-list-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

/* name (grows to fill) */
.lb-list-name {
    font-size: 1.05rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* date/time beneath name */
.lb-list-date {
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.6);
    font-weight: normal;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.lb-list-row.current .lb-list-date {
    color: rgba(255, 255, 255, 0.75);
}

/* time (right side) */
.lb-list-time {
    font-size: 1.1rem;
    font-weight: bold;
    color: #ffd700;
    font-family: 'Courier New', monospace;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
    flex-shrink: 0;
    min-width: 60px;
    text-align: right;
}

.lb-list-row.current .lb-list-time {
    color: #fff;
}

/* ── current player footer (when rank > 5) ── */
.lb-current-separator {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px 0;
    margin-top: 8px;
}

.lb-separator-dots {
    font-size: 1.5rem;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 4px;
}

.lb-current-footer {
    margin-top: 8px;
    animation: currentPlayerPulse 2s ease-in-out infinite;
}

@keyframes currentPlayerPulse {
    0%, 100% {
        box-shadow: 0 0 18px rgba(76, 209, 55, 0.25);
    }
    50% {
        box-shadow: 0 0 28px rgba(76, 209, 55, 0.5);
    }
}

/* empty state */
.lb-empty {
    text-align: center;
    color: rgba(255,255,255,0.55);
    font-size: 1.1rem;
    padding: 48px 20px;
    font-style: italic;
}

/* ── back button row ── */
.lb-back-row {
    width: 100%;
    max-width: 520px;
    margin-top: 20px;
}

.lb-back-btn {
    width: 100%;
}

/* ── leaderboard button on victory screen ── */
.btn-leaderboard {
    background: linear-gradient(135deg, #ffd700 0%, #ffaa00 100%);
    color: #333;
    border: 3px solid rgba(255, 215, 0, 0.5);
    font-weight: bold;
    font-size: 1.1rem;
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.4);
}

.btn-leaderboard:hover {
    background: linear-gradient(135deg, #ffdd00 0%, #ffbb00 100%);
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(255, 215, 0, 0.6);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* ── large desktop (1200+) – keep it centred & comfortable ── */
@media (min-width: 1200px) {
    .leaderboard-screen { padding-top: 40px; }
    .lb-title           { font-size: 2.8rem; }
    .lb-podium-wrap     { max-width: 620px; }
    .lb-list-wrap       { max-width: 600px; max-height: 380px; }
    .lb-back-row        { max-width: 600px; }
    .lb-divider         { max-width: 600px; }
}

/* ── tablet landscape (900-1199) ── */
@media (max-width: 1199px) and (min-width: 900px) {
    .lb-podium-wrap { max-width: 540px; }
    .lb-list-wrap   { max-width: 500px; max-height: 340px; }
    .lb-back-row    { max-width: 500px; }
    .lb-divider     { max-width: 500px; }
}

/* ── tablet portrait / small laptop (650-899) ── */
@media (max-width: 899px) and (min-width: 650px) {
    .leaderboard-screen { padding: 22px 24px 28px; }
    .lb-title           { font-size: 2rem; }
    .lb-podium-slot.rank-1 .lb-podium-avatar { width: 78px; height: 78px; }
    .lb-podium-avatar   { width: 64px; height: 64px; }
    .lb-podium-slot.rank-1 .lb-podium-bar { height: 68px; }
    .lb-podium-slot.rank-2 .lb-podium-bar { height: 48px; }
    .lb-podium-slot.rank-3 .lb-podium-bar { height: 34px; }
    .lb-list-wrap       { max-height: 300px; }
}

/* ── mobile (< 650) ── */
@media (max-width: 649px) {
    .leaderboard-screen { padding: 20px 14px 28px; gap: 0; }

    .lb-header          { margin-bottom: 20px; gap: 10px; }
    .lb-trophy          { font-size: 1.8rem; }
    .lb-title           { font-size: 1.7rem; }

    /* shrink podium avatars & bars */
    .lb-podium          { gap: 10px; }
    .lb-podium-slot     { max-width: 110px; }

    .lb-podium-avatar           { width: 54px; height: 54px; font-size: 1.1rem; }
    .lb-podium-slot.rank-1 .lb-podium-avatar { width: 68px; height: 68px; font-size: 1.4rem; }

    .lb-podium-slot.rank-1 .lb-podium-bar { height: 56px; }
    .lb-podium-slot.rank-2 .lb-podium-bar { height: 40px; }
    .lb-podium-slot.rank-3 .lb-podium-bar { height: 28px; }

    .lb-podium-badge    { font-size: 1.4rem; }
    .lb-podium-name     { font-size: 0.78rem; }
    .lb-podium-time     { font-size: 0.76rem; }

    /* list */
    .lb-list-wrap       { max-height: 260px; }
    .lb-list-row        { padding: 12px 14px; gap: 10px; border-radius: 12px; }
    .lb-list-avatar     { width: 36px; height: 36px; font-size: 0.88rem; }
    .lb-list-name       { font-size: 0.95rem; }
    .lb-list-date       { font-size: 0.75rem; }
    .lb-list-time       { font-size: 1rem; min-width: 50px; }
    .lb-list-rank       { min-width: 26px; font-size: 1rem; }

    .lb-divider         { margin: 14px 0 12px; }
    .lb-back-row        { margin-top: 16px; }
    .lb-current-separator { padding: 12px 0; }
}

/* ── very small mobile (< 380) ── */
@media (max-width: 379px) {
    .lb-title           { font-size: 1.45rem; }
    .lb-podium-avatar           { width: 46px; height: 46px; font-size: 1rem; }
    .lb-podium-slot.rank-1 .lb-podium-avatar { width: 58px; height: 58px; font-size: 1.2rem; }
    .lb-podium-slot.rank-1 .lb-podium-bar { height: 46px; }
    .lb-podium-slot.rank-2 .lb-podium-bar { height: 32px; }
    .lb-podium-slot.rank-3 .lb-podium-bar { height: 22px; }
    .lb-list-row        { padding: 10px 10px; }
    .lb-list-avatar     { width: 32px; height: 32px; font-size: 0.8rem; }
    .lb-list-name       { font-size: 0.85rem; }
    .lb-list-date       { font-size: 0.7rem; }
    .lb-list-time       { font-size: 0.9rem; min-width: 45px; }
}

/* ── landscape on short screens (phones sideways) ── */
@media (max-height: 500px) and (orientation: landscape) {
    .leaderboard-screen { padding: 10px 18px 14px; min-height: auto; }
    .lb-header          { margin-bottom: 10px; }
    .lb-trophy          { font-size: 1.4rem; }
    .lb-title           { font-size: 1.4rem; }

    .lb-podium          { gap: 8px; }
    .lb-podium-avatar           { width: 42px; height: 42px; font-size: 0.9rem; }
    .lb-podium-slot.rank-1 .lb-podium-avatar { width: 52px; height: 52px; font-size: 1.1rem; }
    .lb-podium-badge    { font-size: 1.1rem; }
    .lb-podium-name     { font-size: 0.7rem; }
    .lb-podium-time     { font-size: 0.68rem; }

    .lb-podium-slot.rank-1 .lb-podium-bar { height: 38px; }
    .lb-podium-slot.rank-2 .lb-podium-bar { height: 26px; }
    .lb-podium-slot.rank-3 .lb-podium-bar { height: 18px; }

    .lb-list-wrap       { max-height: 160px; }
    .lb-list-row        { padding: 8px 12px; gap: 8px; }
    .lb-list-avatar     { width: 30px; height: 30px; font-size: 0.8rem; }
    .lb-list-name       { font-size: 0.82rem; }
    .lb-list-date       { font-size: 0.68rem; }
    .lb-list-time       { font-size: 0.85rem; }

    .lb-divider         { margin: 8px 0 6px; }
    .lb-back-row        { margin-top: 10px; }
    .lb-current-separator { padding: 8px 0; }
}