/* ==================== TOURNAMENT POPUP STYLES ==================== */
/* Theme: Dark-space fantasy + gold rank prestige */

.tournament-overlay {
    --tour-gold: #FFD66E;
    --tour-gold-soft: #ffef9f;
    --tour-violet-1: #1e2260;
    --tour-violet-2: #2f1b67;
    --tour-violet-3: #4a146e;
    --tour-cyan: #7cf2ff;
    --tour-text: #f4efff;
    --tour-text-muted: #c8bfdf;
    --tour-text-on-gold: #3f255d;
    --tour-text-strong: #fff9ea;
    --tour-text-accent: #f3d890;
    --tour-text-soft: #a79bbf;
    --tour-text-emerald: #9ce8cf;
    --tour-text-cool: #b8d9ff;

    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    opacity: 1;
    transition: opacity 0.25s ease;
}

.tournament-overlay.hidden {
    display: none;
    opacity: 0;
}

.tournament-container {
    position: relative;
    width: min(92vw, 460px);
    height: min(92vh, 850px);
    max-width: 95%;
    max-height: 95%;
    padding: 0 0 18px;
    border-radius: 30px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: 'Outfit', sans-serif;
    overflow: hidden;
    background:
        url('./assets/slots/common/tournament_character.png'),
        radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.14) 0%, rgba(255, 255, 255, 0) 34%),
        radial-gradient(circle at 100% 24%, rgba(196, 118, 255, 0.14) 0%, rgba(196, 118, 255, 0) 40%),
        linear-gradient(180deg, rgba(9, 8, 26, 0.14), rgba(9, 8, 26, 0.3)),
        linear-gradient(180deg, #5b356f 0%, #6a3f91 44%, #6433a4 100%);
    background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat;
    background-size: 125px auto, auto, auto, 100% 100%, 100% 100%;
    background-position: left 5px top 10px, center top, right top, center center, center center;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.5),
        0 0 0 2px rgba(255, 255, 255, 0.1) inset;
}

.tournament-container::before {
    content: '';
    position: absolute;
    inset: 10px;
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    pointer-events: none;
}

.tournament-container::after {
    content: '';
    position: absolute;
    top: 86px;
    left: 28px;
    right: 28px;
    height: 1px;
    background: linear-gradient(90deg, rgba(255, 214, 110, 0), rgba(255, 214, 110, 0.58), rgba(255, 214, 110, 0));
    pointer-events: none;
}

.tournament-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 20;
    width: 42px;
    height: 42px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 50%;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.08));
    box-shadow: 0 10px 14px rgba(0, 0, 0, 0.35);
    transition: transform 0.18s ease, filter 0.2s ease;
}

.tournament-close-btn:hover {
    transform: translateY(-1px) scale(1.03);
    filter: brightness(1.05);
}

.tournament-close-btn:active {
    transform: translateY(2px) scale(0.98);
}

.tournament-close-btn img {
    width: 16px;
    height: 16px;
}

.tournament-header {
    position: relative;
    margin-top: 24px;
    width: 100%;
    height: 72px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    overflow: visible;
}

.tournament-title-banner {
    margin-top: 12px;
    width: 288px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-left: 16px;
    margin-left: 110px;
    background: transparent;
    border: none;
    box-shadow: none;
    z-index: 11;
}

.tournament-title-text {
    font-family: 'Outfit', sans-serif;
    font-size: 23px;
    font-weight: 900;
    letter-spacing: 1.2px;
    text-align: left;
    color: #f3d890;
    text-shadow: none;
}

.tournament-timer-bar {
    position: relative;
    z-index: 5;
    width: min(88%, 320px);
    min-height: 42px;
    margin-top: 12px;
    margin-bottom: 16px;
    align-self: flex-end;
    margin-right: 28px;
    padding: 8px 12px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0)),
        rgba(15, 9, 29, 0.52);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.28) inset;
}

.tournament-timer-text {
    color: var(--tour-text-strong);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.45px;
    text-transform: uppercase;
}

.tournament-refresh-btn {
    min-height: 28px;
    border: 0;
    border-radius: 9px;
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: var(--tour-text-on-gold);
    cursor: pointer;
    background: linear-gradient(135deg, #FFD66E 0%, #FFBE3F 100%);
    box-shadow:
        0 4px 10px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.28) inset;
    transition: transform 0.15s ease, filter 0.18s ease, box-shadow 0.18s ease;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.28);
}

.tournament-refresh-btn::before {
    content: '';
    position: absolute;
    left: 3px;
    right: 3px;
    top: 2px;
    height: 45%;
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0));
    pointer-events: none;
}

.tournament-refresh-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    filter: brightness(1.06);
    box-shadow:
        0 6px 14px rgba(0, 0, 0, 0.36),
        0 0 0 1px rgba(255, 255, 255, 0.28) inset;
}

.tournament-refresh-btn:active:not(:disabled) {
    transform: translateY(2px);
    box-shadow: 0 3px 9px rgba(0, 0, 0, 0.3);
}

.tournament-refresh-btn:disabled {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
    box-shadow: none;
    color: #ecebf3;
    filter: saturate(0.2);
    cursor: wait;
}

.tournament-list-header {
    width: min(88%, 406px);
    height: 32px;
    margin-bottom: 7px;
    padding: 0 12px;
    box-sizing: border-box;
    display: grid;
    grid-template-columns: 44px 40px minmax(0, 1fr) 96px;
    gap: 10px;
    align-items: center;
}

.t-header-item {
    font-size: 11px;
    font-weight: 900;
    color: var(--tour-text-soft);
    letter-spacing: 0.9px;
    text-transform: uppercase;
}

.t-col-rank {
    width: 44px;
    grid-column: 1;
    text-align: center;
}

.t-col-name {
    width: auto;
    grid-column: 3;
    text-align: left;
    padding-left: 0;
}

.t-col-prize {
    width: 96px;
    grid-column: 4;
    text-align: right;
}

.tournament-list {
    width: min(88%, 406px);
    height: auto;
    max-height: min(54vh, 560px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 8px;
    padding-bottom: 0;
    margin-bottom: 8px;
}

.tournament-list::-webkit-scrollbar {
    width: 6px;
}

.tournament-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.tournament-list::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(255, 214, 110, 0.65), rgba(255, 190, 63, 0.42));
    border-radius: 8px;
}

.t-rank-row {
    position: relative;
    width: 100%;
    min-height: 60px;
    padding: 0 11px;
    box-sizing: border-box;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    display: grid;
    grid-template-columns: 44px 40px minmax(0, 1fr) 96px;
    align-items: center;
    gap: 10px;
    overflow: hidden;
    flex-shrink: 0;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01)),
        rgba(15, 9, 29, 0.52);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.24);
    transition: transform 0.18s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    position: relative;
}

.t-rank-row::before {
    content: '';
    position: absolute;
    top: 0;
    left: -120%;
    width: 66%;
    height: 100%;
    background: linear-gradient(95deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0));
    transform: skewX(-22deg);
    transition: left 0.45s ease;
    pointer-events: none;
}

.t-rank-row::after {
    content: '';
    position: absolute;
    left: 12px;
    right: 12px;
    top: 6px;
    height: 10px;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0));
    pointer-events: none;
}

.t-rank-row:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 214, 110, 0.35);
    box-shadow:
        0 12px 20px rgba(0, 0, 0, 0.3),
        0 0 14px rgba(255, 215, 0, 0.15);
}

.t-rank-row:hover::before {
    left: 145%;
}

.t-rank-row.rank-1,
.t-rank-row.rank-2,
.t-rank-row.rank-3 {
    background:
        linear-gradient(180deg, rgba(255, 214, 110, 0.08), rgba(255, 214, 110, 0.02)),
        rgba(15, 9, 29, 0.62);
    border: 1px solid rgba(255, 214, 110, 0.5);
    box-shadow:
        0 10px 18px rgba(0, 0, 0, 0.28),
        0 0 14px rgba(255, 215, 0, 0.2);
}

.t-rank-row.rank-normal {
    border-color: rgba(255, 255, 255, 0.09);
}

.t-rank-row--empty {
    min-height: 108px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.t-rank-row.t-rank-row--me {
    border: 2px solid #7cf2ff;
    box-shadow:
        0 0 0 1px rgba(124, 242, 255, 0.26) inset,
        0 10px 22px rgba(72, 218, 255, 0.24);
}

.t-rank-num {
    width: auto;
    text-align: center;
    font-size: 23px;
    font-weight: 900;
    color: var(--tour-text-accent);
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    z-index: 2;
}

.t-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    background: #cccccc;
    border: 1px solid rgba(255, 255, 255, 0.35);
    z-index: 2;
}

.t-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.t-name-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    z-index: 2;
}

.t-name {
    width: auto;
    font-size: 15px;
    font-weight: 800;
    color: var(--tour-text-strong);
    letter-spacing: 0.15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.t-score {
    font-size: 12px;
    font-weight: 700;
    color: var(--tour-text-cool);
    letter-spacing: 0.2px;
}

.t-tp {
    width: auto;
    margin-left: 0;
    text-align: right;
    font-size: 15px;
    font-weight: 900;
    color: var(--tour-text-emerald);
    letter-spacing: 0.2px;
    z-index: 2;
}

.t-rank-row.rank-1 .t-rank-num,
.t-rank-row.rank-2 .t-rank-num,
.t-rank-row.rank-3 .t-rank-num,
.t-rank-row.rank-1 .t-name,
.t-rank-row.rank-2 .t-name,
.t-rank-row.rank-3 .t-name,
.t-rank-row.rank-1 .t-score,
.t-rank-row.rank-2 .t-score,
.t-rank-row.rank-3 .t-score,
.t-rank-row.rank-1 .t-tp,
.t-rank-row.rank-2 .t-tp,
.t-rank-row.rank-3 .t-tp {
    color: var(--tour-text-strong);
    text-shadow: none;
}

.t-rank-row.rank-1 .t-rank-num,
.t-rank-row.rank-2 .t-rank-num,
.t-rank-row.rank-3 .t-rank-num {
    color: var(--tour-text-accent);
}

.tournament-user-footer {
    width: min(88%, 406px);
    min-height: 60px;
    margin-top: 5px;
    margin-bottom: 0;
    padding: 0 12px;
    box-sizing: border-box;
    display: grid;
    grid-template-columns: 44px 40px minmax(0, 1fr) 96px;
    align-items: center;
    gap: 10px;
    border-radius: 12px;
    border: 1px solid rgba(255, 214, 110, 0.5);
    background:
        linear-gradient(180deg, rgba(255, 214, 110, 0.18), rgba(255, 214, 110, 0.06)),
        rgba(15, 9, 29, 0.62);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.35);
    z-index: 10;
    position: relative;
    overflow: hidden;
}

.tournament-user-footer.is-disabled {
    opacity: 0.5;
    filter: grayscale(0.8);
    border-color: rgba(255, 255, 255, 0.22);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
        rgba(15, 9, 29, 0.45);
}

.tournament-user-footer::before {
    content: '';
    position: absolute;
    left: 12px;
    right: 12px;
    top: 6px;
    height: 10px;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0));
    pointer-events: none;
}

.tournament-user-footer .t-rank-num,
.tournament-user-footer .t-name,
.tournament-user-footer .t-score,
.tournament-user-footer .t-tp {
    color: var(--tour-text-strong);
}

.tournament-user-footer .t-rank-num {
    color: var(--tour-text-accent);
}

.tournament-user-footer .t-score {
    color: var(--tour-text-cool);
}

.tournament-user-footer .t-tp {
    color: var(--tour-text-emerald);
}

.t-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.12);
}

.t-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tournament-toast {
    position: absolute;
    left: 50%;
    bottom: 96px;
    transform: translateX(-50%) translateY(8px);
    min-width: 240px;
    padding: 10px 12px;
    border-radius: 10px;
    text-align: center;
    font-size: 13px;
    font-weight: 800;
    color: var(--tour-text-strong);
    background: rgba(18, 16, 29, 0.94);
    border: 1px solid rgba(255, 215, 0, 0.35);
    box-shadow: 0 10px 16px rgba(0, 0, 0, 0.32);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 30;
}

.tournament-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.tournament-toast.is-error {
    border-color: rgba(255, 96, 96, 0.72);
}

/* ==================== SIDEBAR ICON ==================== */
#tournament-icon-wrapper {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

#tournament-icon {
    width: 60px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#tournament-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.18s ease, filter 0.2s ease;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.35));
}

#tournament-icon-wrapper:hover #tournament-icon img {
    transform: scale(1.0);
    filter:
        drop-shadow(0 4px 8px rgba(0, 0, 0, 0.45)) drop-shadow(0 0 10px rgba(255, 215, 0, 0.58));
}

.tournament-rank-indicator {
    min-width: 51px;
    margin-top: -5px;
    padding: 3px 6px;
    border-radius: 999px;
    border: 1px solid rgba(210, 216, 228, 0.7);
    background: linear-gradient(180deg, rgba(96, 104, 120, 0.95), rgba(70, 78, 94, 0.92));
    color: #ffffff;
    font-size: 11px;
    line-height: 1.2;
    font-weight: 900;
    text-align: center;
    letter-spacing: 0.2px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.38);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
    z-index: 4;
}

.tournament-rank-indicator.hidden {
    display: none;
}

@media (max-width: 600px) {
    .tournament-container {
        width: min(95vw, 440px);
        height: min(92vh, 780px);
        border-radius: 22px;
        padding-bottom: 14px;
        background-size: 105px auto, auto, auto, 100% 100%, 100% 100%;
        background-position: left 6px top 12px, center top, right top, center center, center center;
    }

    .tournament-header {
        margin-top: 22px;
        height: 68px;
    }

    .tournament-title-banner {
        width: 252px;
        height: 48px;
        margin-top: 10px;
    }

    .tournament-title-text {
        font-size: 24px;
    }

    .tournament-list-header,
    .tournament-list,
    .tournament-user-footer {
        width: min(90%, 380px);
    }

    .tournament-timer-bar {
        width: min(88%, 320px);
        align-self: flex-end;
        margin-right: 28px;
    }

    .tournament-timer-text {
        font-size: 14px;
    }

    .tournament-list {
        max-height: min(50vh, 500px);
        margin-bottom: 8px;
    }

    .t-name {
        width: auto;
        font-size: 15px;
    }

    .t-score {
        font-size: 12px;
    }

    .t-tp {
        width: 86px;
        font-size: 15px;
    }

    .tournament-close-btn {
        width: 38px;
        height: 38px;
        top: 14px;
        right: 14px;
    }
}
