/* Clean enhanced Rankings & Events Section */
.rankings {
    padding: 2.4rem 0 3.2rem;
    position: relative;
    overflow: hidden;
}

.rankings__container {
    position: relative;
    z-index: 1;
}

.rankings__layout {
    --rank-event-width: 340px;
    /* fixed width for event column */
    --rank-ratio-left: 2fr;
    /* left side share when room > event fixed */
    display: grid;
    grid-template-columns: minmax(0, var(--rank-ratio-left)) var(--rank-event-width);
    gap: 1.4rem;
    align-items: start;
    /* prevent vertical stretch; ranking card keeps natural height */
}

/* Global var for ranking row height so we can compute reserved heights */
:root {
    --ranking-row-h: 56px;
}

/* Card wrapper for tabs + panels */
.rankings__card {
    background: linear-gradient(170deg, #221935 0%, #2d1e4f 55%, #1a1830 100%);
    border: 1px solid var(--color-purple-light);
    border-radius: 20px;
    padding: 0.9rem 0.9rem 1rem;
    /* slightly smaller horizontal padding */
    box-shadow: 0 18px 40px -14px rgba(92, 54, 150, 0.55), 0 0 0 3px rgba(124, 58, 237, 0.15) inset;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    position: relative;
    max-width: 100%;
}

.rankings__heading {
    margin: 0 auto 1.2rem;
    height: 130px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    display: block;
    animation: glow 3s ease-in-out infinite, float 4s ease-in-out infinite;
}

.rankings__heading::after {
    content: '';
    display: block;
    margin-top: .55rem;
    width: 110px;
    height: 4px;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--color-purple) 0%, var(--color-gold-bright) 55%, var(--color-purple-light) 100%);
    box-shadow: 0 0 10px -2px var(--color-gold-bright);
}

@keyframes glow {

    0%,
    100% {
        filter: brightness(1);
    }

    50% {
        filter: brightness(1.3);
    }
}

/* Tabs */
.rankings__tabs {
    display: flex;
    flex-wrap: nowrap;
    /* single row */
    gap: 0.55rem;
    margin: 0;
    position: relative;
    padding-bottom: .45rem;
    overflow: visible;
    z-index: 2;
    /* ensure clickable above panels */
}

.rankings__tab {
    background: rgba(60, 40, 100, 0.35);
    border: 1px solid var(--color-purple-light);
    color: var(--color-silver);
    padding: 0.5rem 0.7rem;
    /* reduce width usage */
    border-radius: 11px;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    cursor: pointer;
    white-space: nowrap;
    transition: background .25s, box-shadow .25s, color .25s;
}

.rankings__tab.is-active {
    background: var(--gradient-brand);
    color: #fff;
    box-shadow: 0 0 0 2px rgba(255, 215, 0, 0.55);
}

.rankings__tab:focus {
    outline: none;
    /* Remove default focus outline */
}

.rankings__tab {
    /* ... existing styles ... */
    scroll-margin: 0;
    /* Prevent scroll jump when focused */
}

.rankings__tab-indicator {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 120px;
    background: var(--gradient-brand);
    border-radius: 999px;
    box-shadow: 0 0 10px -2px var(--color-gold-bright);
    transition: transform .35s ease, width .3s ease;
    pointer-events: none;
}

/* Panels */
.rankings__content {
    position: relative;
}

.rankings__content {
    flex: 1;
}

.rankings__panel {
    display: none;
    animation: fadeIn .35s ease;
}

.rankings__panel.is-visible {
    display: block;
}


@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

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

/* Table */
.rankings__table {
    max-height: calc(var(--ranking-row-h) * 5 + 1px);
    /* 1px buffer for borders */
}

/* Reserve vertical space for the entire rankings content so panels switching
   doesn't change page layout (prevents jumping when switching tabs) */
.rankings__content {
    min-height: calc(var(--ranking-row-h) * 5 + 140px);
    /* header + controls buffer */
}

.rankings__table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    /* prevent widening */
    font-size: 0.9rem;
    background: rgba(28, 20, 44, 0.65);
    border: 1px solid var(--color-purple-light);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 10px 24px -6px rgba(92, 54, 150, 0.45);
}

.rankings__table thead th {
    text-align: left;
    padding: 0.75rem 0.6rem;
    /* narrower sides keep height */
    background: linear-gradient(95deg, #2d1b69 0%, #5b2ca2 40%, #7c3aed 70%, #5b2ca2 90%, #2d1b69 100%);
    color: #ffffff;
    font-weight: 700;
    letter-spacing: 0.05em;
    font-size: 0.78rem;
    text-shadow: 0 0 6px rgba(0, 0, 0, 0.5);
    border-right: 1px solid rgba(255, 255, 255, 0.2);
}

.rankings__table thead th:last-child {
    border-right: none;
}

.rankings__table tbody td {
    padding: 0.75rem 0.6rem;
    /* reduce horizontal padding */
    color: var(--color-silver);
    border-top: 1px solid rgba(124, 58, 237, 0.18);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rankings__table tbody tr {
    transition: all 0.3s ease;
}

/* Ensure table reserves vertical space for exactly 5 rows so the card height is stable
   - Each row has a fixed min-height so missing rows (placeholders) keep layout consistent */
.rankings__table tbody tr {
    min-height: 56px;
    /* adjust if needed to match your visual design */
    height: 56px;
}

/* Reserve total height for 5 rows (5 * 56px + borders). This keeps the card height fixed
   so panels with fewer items don't collapse. */
.rankings__table {
    --row-h: 56px;
    max-height: calc(var(--row-h) * 5 + 1px);
    /* 1px buffer for borders */
}

/* Placeholder styling for empty cells */
.rankings__table tbody tr td {
    color: var(--color-silver);
}

.rankings__table tbody tr td:empty {
    opacity: 0.55;
}

.guild-logo-placeholder {
    opacity: 0.6;
}

.rankings__table tbody tr:hover {
    background: rgba(92, 54, 150, 0.25);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(92, 54, 150, 0.3);
    border-left: 3px solid var(--color-purple-light);
    transition: all 0.3s ease;
}

.rankings__table tbody tr:hover td {
    color: #ffffff;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.rankings__table tbody tr:nth-child(odd) td {
    background: rgba(255, 255, 255, 0.02);
}

.rankings__table tbody tr:first-child td {
    border-top: none;
}

/* Removed rank-specific first column styling since rank column no longer displayed */

.guild-logo {
    width: 30px;
    height: 30px;
    width: 46px;
    height: 46px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18), 0 4px 8px -2px rgba(0, 0, 0, 0.55);
    transition: all 0.3s ease;
}

.rankings__table tbody tr:hover .guild-logo {
    transform: scale(1.1);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3), 0 6px 12px -2px rgba(0, 0, 0, 0.7);
}

.guild-logo-placeholder {
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
}

/* Events */
.events {
    background: linear-gradient(170deg, #221935 0%, #2d1e4f 55%, #1a1830 100%);
    border: 1px solid var(--color-purple-light);
    border-radius: 20px;
    padding: 0.85rem 0.95rem 1rem;
    /* slightly tighter to visually match new ratio */
    box-shadow: 0 18px 40px -14px rgba(92, 54, 150, 0.55), 0 0 0 3px rgba(124, 58, 237, 0.15) inset;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    width: var(--rank-event-width);
    max-width: 100%;
    /* remove forced full height so ranking card determines natural height */
}

.events__title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: 0.06em;
}

.events__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow-y: auto;
    scrollbar-width: thin;
    /* height now controlled dynamically via JS syncEventHeight */
    --scrollbar-track: linear-gradient(180deg, #3d246e 0%, #2b1d52 100%);
    --scrollbar-thumb: linear-gradient(180deg, #b983ff 0%, #6f33d5 100%);
    --scrollbar-thumb-hover: linear-gradient(180deg, #c89dff 0%, #8a54ff 100%);
    --scrollbar-thumb-active: linear-gradient(180deg, #dab8ff 0%, #9a64ff 100%);
    scrollbar-color: #9a64ff rgba(50, 32, 90, 0.42);
    /* Firefox */
}

/* WebKit custom scrollbar (Chrome/Edge/Safari) */
.events__list::-webkit-scrollbar {
    width: 10px;
}

.events__list::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    background-color: #2b1d52;
    /* fallback solid */
    border-radius: 8px;
    box-shadow: inset 0 0 0 1px rgba(155, 88, 255, 0.45), inset 0 0 6px -2px rgba(124, 58, 237, 0.55);
}

.events__list::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    background-color: #7a3fe6;
    /* fallback solid */
    border-radius: 8px;
    box-shadow: 0 2px 6px -2px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.25);
    position: relative;
}

.events__list::-webkit-scrollbar-thumb:before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(circle at 40% 30%, rgba(255, 255, 255, 0.25), transparent 70%);
    pointer-events: none;
}

.events__list::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
    background-color: #8a54ff;
}

.events__list::-webkit-scrollbar-thumb:active {
    background: var(--scrollbar-thumb-active);
    background-color: #9a64ff;
}

.events__list::-webkit-scrollbar-corner {
    background: #2b1d52;
}

/* Fallback enforcement: some Windows + Chromium setups keep native colors unless !important used */
@supports selector(::-webkit-scrollbar) {
    .events__list::-webkit-scrollbar-track {
        background-color: #2b1d52 !important;
    }

    .events__list::-webkit-scrollbar-thumb {
        background-color: #7a3fe6 !important;
    }

    .events__list::-webkit-scrollbar-thumb:hover {
        background-color: #8a54ff !important;
    }

    .events__list::-webkit-scrollbar-thumb:active {
        background-color: #9a64ff !important;
    }

    /* Mirror styles for .events container if it becomes scrollable */
    .events {
        scrollbar-color: #9a64ff #2b1d52;
        scrollbar-width: thin;
    }

    .events::-webkit-scrollbar {
        width: 10px;
        background: transparent;
    }

    .events::-webkit-scrollbar-track {
        background: #2b1d52 !important;
        border-radius: 8px;
    }

    .events::-webkit-scrollbar-thumb {
        background: #7a3fe6 !important;
        border-radius: 8px;
        box-shadow: 0 2px 6px -2px rgba(0, 0, 0, .6), inset 0 0 0 1px rgba(255, 255, 255, .25);
    }

    .events::-webkit-scrollbar-thumb:hover {
        background: #8a54ff !important;
    }

    .events::-webkit-scrollbar-thumb:active {
        background: #9a64ff !important;
    }
}

.event {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.8rem;
    background: linear-gradient(150deg, #3a2a5e 0%, #2d1e4f 60%, #1a1830 100%);
    border: 1px solid rgba(124, 58, 237, 0.35);
    border-radius: 14px;
    position: relative;
    box-shadow: 0 10px 24px -10px rgba(0, 0, 0, 0.55);
    font-size: 0.75rem;
    overflow: visible;
    /* tránh cắt mất status pill ở mép phải */
    min-width: 0;
    /* cho phép thu gọn bên trong khi container hẹp */
}

.event::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(circle at 20% 25%, rgba(124, 58, 237, 0.35), transparent 70%);
    opacity: .65;
}

.event__name {
    font-weight: 600;
    color: var(--color-silver);
    letter-spacing: 0.05em;
    flex: 1 1 auto;
    min-width: 0;
    /* để text có thể ellipsis nếu quá dài */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.event__countdown {
    font-family: monospace;
    color: var(--color-gold-bright);
    font-weight: 600;
    letter-spacing: 0.08em;
    flex: 0 0 auto;
}

.event__status {
    padding: 0.4rem 0.65rem;
    border-radius: 10px;
    background: rgba(92, 54, 150, 0.35);
    color: var(--color-silver);
    font-weight: 600;
    font-size: 0.67rem;
    letter-spacing: 0.07em;
    backdrop-filter: blur(3px);
    flex: 0 0 auto;
    white-space: nowrap;
}

.event__status.is-active {
    background: var(--gradient-brand);
    color: #fff;
}

.event__status.is-soon {
    background: linear-gradient(90deg, #f59e0b, #ffb347);
    /* warm warning */
    color: #221935;
    font-weight: 700;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.35);
}

/* Tooltip popup for event times */
.event-times-pop {
    position: fixed;
    /* bám theo viewport để tính trực tiếp tọa độ chuột */
    z-index: 999;
    min-width: 220px;
    max-width: 400px;
    background: rgba(34, 25, 53, 0.92);
    border: 1px solid var(--color-purple-light);
    border-radius: 14px;
    padding: 0.7rem 0.75rem 0.75rem;
    box-shadow: 0 14px 38px -10px rgba(0, 0, 0, 0.6), 0 0 0 2px rgba(124, 58, 237, 0.35) inset;
    backdrop-filter: blur(6px);
    font-size: 0.8rem;
    color: var(--color-silver);
    display: none;
    pointer-events: none;
    /* không chặn chuột khi sát trỏ */
}

.event-times-pop.is-visible {
    display: block;
    animation: fadeIn .25s ease;
}

.event-times-pop__title {
    font-weight: 700;
    font-size: 0.78rem;
    margin: 0 0 0.4rem;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: .05em;
}

.event-times-pop__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 0.35rem;
}

.event-times-pop__list li {
    background: rgba(92, 54, 150, 0.25);
    border: 1px solid rgba(124, 58, 237, 0.35);
    border-radius: 8px;
    padding: 0.35rem 0.3rem;
    text-align: center;
    font-family: monospace;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.event-times-pop__dropsTitle {
    margin: 0.6rem 0 0.35rem;
    font-weight: 700;
    font-size: 0.7rem;
    letter-spacing: .07em;
    text-transform: uppercase;
    opacity: .85;
    color: var(--color-silver);
    position: relative;
}

.event-times-pop__dropsTitle:before {
    content: '';
    position: absolute;
    left: 0;
    bottom: -4px;
    height: 2px;
    width: 42px;
    background: var(--gradient-brand);
    border-radius: 2px;
}

.event-times-pop__drops {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 0.45rem;
}

.event-times-pop__drops li {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(34, 25, 53, 0.55);
    border: 1px solid rgba(124, 58, 237, 0.35);
    border-radius: 10px;
    padding: 0.35rem 0.3rem 0.4rem;
    gap: 0.3rem;
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: .04em;
    color: var(--color-silver);
}

.event-times-pop__drops li img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    filter: drop-shadow(0 0 6px rgba(124, 58, 237, 0.45));
    border-radius: 6px;
}

.event-times-pop__meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.63rem;
    background: rgba(124, 58, 237, 0.15);
    padding: 0.35rem 0.5rem;
    border: 1px solid rgba(124, 58, 237, 0.35);
    border-radius: 8px;
    margin: 0.2rem 0 0.35rem;
    letter-spacing: .05em;
}

.event-times-pop__metaLabel {
    font-weight: 700;
    opacity: .85;
}

.event-times-pop__metaValue {
    font-weight: 600;
}

.event-times-pop__note {
    font-size: 0.6rem;
    line-height: 1.25;
    background: rgba(92, 54, 150, 0.25);
    padding: 0.4rem 0.55rem 0.45rem;
    border: 1px solid rgba(124, 58, 237, 0.3);
    border-radius: 8px;
    margin: 0 0 0.55rem;
    color: var(--color-silver);
}

.event-times-pop__reward {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.15), rgba(255, 183, 0, 0.25));
    border: 1px solid rgba(255, 193, 7, 0.45);
    padding: 0.45rem 0.7rem;
    border-radius: 10px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: .05em;
    color: #ffd666;
    margin: 0.5rem 0 0.65rem;
    box-shadow: 0 0 0 1px rgba(255, 193, 7, 0.3), 0 4px 12px -4px rgba(0, 0, 0, 0.5);
}

.event-times-pop__rewardIcon {
    width: 22px;
    height: 22px;
    object-fit: contain;
    filter: drop-shadow(0 0 6px rgba(255, 193, 7, 0.6));
}

.event-times-pop__rewardIcon.big {
    width: 46px;
    height: 46px;
}

.event-times-pop__reward.is-bottom {
    margin-top: 0.65rem;
}

.event-times-pop__rewardVal {
    font-weight: 700;
}

/* Top Rankings Styling */
.rankings__table tbody tr:nth-child(1) {
    background: url('/images/Top2.png') center center / cover no-repeat;
    animation: pulse 2s ease-in-out infinite;
}

.rankings__table tbody tr:nth-child(1) td {
    background: transparent !important;
    color: var(--color-gold-bright);
    font-size: 1.2rem;
    font-weight: 900;
    text-shadow: 0 0 4px rgba(39, 1, 61, 0.8), 0 0 15px #23012799;
}

/* Override hover effects for top rankings to preserve background */
.rankings__table tbody tr:nth-child(1):hover {
    background: url('/images/Top2.png') center center / cover no-repeat !important;
    transform: none;
}

@keyframes pulse {

    0%,
    100% {
        filter: brightness(1.2);
    }

    50% {
        filter: brightness(0.7);
    }
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-8px);
    }
}
