/**
 * =======================================
 * Leaderboard Styling
 * =======================================
 **/

/* Overlay: Full Screen Backdrop */
.lb-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 20000;
    /* Above Monogatari UI & Ending Screen */
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.lb-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
}

/* Card: Main Container */
.lb-card {
    background-color: rgba(0, 0, 0, 0.85);
    /* Deep dark semi-transparent */
    color: #ffffff;
    width: 95%;
    /* Mobile First */
    max-width: 500px;
    /* Desktop Limit */
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Microsoft JhengHei', 'PingFang TC', 'Noto Sans TC', sans-serif;
    animation: lbPopup 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes lbPopup {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Header */
.lb-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(to right, rgba(91, 255, 91, 0.05), transparent);
}

.lb-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: #5bff5b;
    /* Accent Color */
    text-shadow: 0 0 10px rgba(91, 255, 91, 0.3);
}

.lb-close-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 8px;
    transition: color 0.2s;
}

.lb-close-btn:hover {
    color: #ffffff;
}

/* Content: Scrollable Area */
.lb-content {
    padding: 0;
    max-height: 50vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #5bff5b rgba(255, 255, 255, 0.1);
}

/* Custom Scrollbar for Webkit */
.lb-content::-webkit-scrollbar {
    width: 6px;
}

.lb-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.lb-content::-webkit-scrollbar-thumb {
    background-color: #5bff5b;
    border-radius: 3px;
}

/* Table Styling */
.lb-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.lb-table th {
    position: sticky;
    top: 0;
    background-color: rgba(20, 20, 20, 0.95);
    padding: 12px 16px;
    font-size: 0.9rem;
    color: #aaaaaa;
    text-transform: uppercase;
    font-weight: 600;
    z-index: 10;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1);
}

.lb-table td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 1rem;
}

.lb-table tr:last-child td {
    border-bottom: none;
}

.lb-rank {
    width: 15%;
    font-weight: bold;
    color: #5bff5b;
}

.lb-name {
    width: 55%;
}

.lb-score {
    width: 30%;
    text-align: right;
    font-family: 'Courier New', monospace;
    /* Monospace for alignment */
    font-weight: bold;
}

/* Highlight User Row */
.lb-row-me {
    background-color: rgba(91, 255, 91, 0.15) !important;
    position: relative;
}

.lb-row-me td {
    color: #ffffff;
    font-weight: bold;
    border-bottom: 1px solid rgba(91, 255, 91, 0.3);
    border-top: 1px solid rgba(91, 255, 91, 0.3);
}

.lb-row-me::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: #5bff5b;
}

/* Input Group */
.lb-input-group {
    padding: 20px;
    display: flex;
    gap: 10px;
    background-color: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.lb-input {
    flex: 1;
    padding: 10px 12px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.lb-input:focus {
    border-color: #5bff5b;
}

.lb-submit-btn {
    background-color: #5bff5b;
    color: #000;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.1s, background-color 0.2s;
}

.lb-submit-btn:hover {
    background-color: #4ce64c;
    transform: translateY(-1px);
}

.lb-submit-btn:active {
    transform: translateY(1px);
}

.lb-submit-btn:disabled {
    background-color: #555;
    color: #888;
    cursor: not-allowed;
    transform: none;
}

/* Loading State */
.lb-loading {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    /* Placeholder height */
    color: rgba(255, 255, 255, 0.6);
}

.lb-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #5bff5b;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Empty State / Message */
.lb-message {
    padding: 30px;
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
}

/* Tabs */
.lb-tabs {
    display: flex;
    justify-content: space-around;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.lb-tab {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    padding: 8px 12px;
    font-size: 0.95rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.lb-tab:hover {
    color: #ffffff;
}

.lb-tab.active {
    color: #5bff5b;
    border-bottom-color: #5bff5b;
    font-weight: bold;
}

/* Teaser Card (in Ending Screen) */
.lb-teaser-card {
    background: rgba(91, 255, 91, 0.1);
    border: 1px solid rgba(91, 255, 91, 0.3);
    border-radius: 8px;
    padding: 8px 15px;
    /* Reduced padding */
    margin: 8px 0;
    /* Reduced margin */
    width: 90%;
    /* Widen slightly */
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    animation: teaserFadeIn 0.8s ease-out 0.5s forwards;
    opacity: 0;
    transform: translateY(10px);
    flex-shrink: 0;
    /* Prevent shrinking too much */
}

.lb-teaser-card:hover {
    background: rgba(91, 255, 91, 0.2);
    transform: translateY(10px) scale(1.02);
    box-shadow: 0 0 15px rgba(91, 255, 91, 0.2);
}

@keyframes teaserFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.lb-teaser-title {
    font-size: 0.9rem;
    color: #5bff5b;
    font-weight: bold;
    margin-bottom: 4px;
}

.lb-teaser-text {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.9);
}

.lb-teaser-loading {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
}