.history-popup {
    position: fixed;
    inset: 0;
    z-index: 22000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.history-popup.is-open {
    display: flex;
}

.history-popup-overlay {
    position: absolute;
    inset: 0;
    background: rgb(4 8 18 / .72);
    backdrop-filter: blur(8px);
}

.history-popup-card {
    position: relative;
    z-index: 1;
    width: min(680px, 100%);
    max-height: min(84vh, 760px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: #f8fafc;
    background:
        radial-gradient(120% 80% at 0% 0%, rgb(255 196 72 / .16), transparent 46%),
        linear-gradient(180deg, #1a2438 0%, #121a2b 100%);
    border: 1px solid rgb(255 213 106 / .28);
    border-radius: 20px;
    box-shadow:
        0 0 0 1px rgb(255 255 255 / .04) inset,
        0 24px 70px rgb(0 0 0 / .5);
}

.history-popup.is-open .history-popup-card {
    animation: historyPopupIn 220ms ease-out;
}

.history-popup-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 18px 14px;
    border-bottom: 1px solid rgb(255 255 255 / .08);
}

.history-popup-heading {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 0;
}

.history-popup-icon {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: linear-gradient(180deg, #ffd56a, #ff9a1f);
    color: #3b2500;
    font-size: 1.15rem;
    box-shadow: 0 8px 18px rgb(255 154 31 / .28);
}

.history-popup-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: 0.01em;
    color: #fff;
}

.history-popup-subtitle {
    margin: 4px 0 0;
    color: #cbd5e1;
    font-size: 0.86rem;
    line-height: 1.4;
}

.history-popup-close {
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 12px;
    background: rgb(255 255 255 / .08);
    color: #fff;
    font-size: 1.7rem;
    line-height: 1;
    cursor: pointer;
}

.history-popup-close:hover,
.history-popup-close:focus-visible {
    background: rgb(255 255 255 / .16);
    outline: 2px solid #ffd56a;
    outline-offset: 2px;
}

.history-popup-body {
    padding: 14px 18px 18px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.history-popup-table-wrap {
    overflow: auto;
    min-height: 220px;
    border: 1px solid rgb(255 255 255 / .08);
    border-radius: 14px;
    background: rgb(8 12 22 / .35);
}

.history-popup-table {
    width: 100%;
    border-collapse: collapse;
    color: #f8fafc;
}

.history-popup-table th,
.history-popup-table td {
    padding: 12px 14px;
    text-align: left;
    font-size: 0.92rem;
    vertical-align: middle;
}

.history-popup-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #1c2740;
    color: #ffd56a;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.history-popup-table tbody tr {
    border-top: 1px solid rgb(255 255 255 / .06);
}

.history-popup-table tbody tr:nth-child(even) {
    background: rgb(255 255 255 / .03);
}

.history-popup-user-cell {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.history-popup-avatar {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: linear-gradient(180deg, #2a3854, #1a2438);
    border: 1px solid rgb(255 213 106 / .28);
    color: #ffe08a;
    font-size: 0.72rem;
    font-weight: 800;
}

.history-popup-user {
    font-weight: 700;
    word-break: break-word;
}

.history-popup-prize-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-popup-prize {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    max-width: 100%;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgb(255 213 106 / .14);
    border: 1px solid rgb(255 213 106 / .22);
    color: #ffe08a;
    font-weight: 700;
    font-size: 0.84rem;
}

.history-popup-prize-value {
    color: #e2e8f0;
    font-size: 0.8rem;
}

.history-popup-date {
    color: #94a3b8;
    white-space: nowrap;
    font-size: 0.84rem;
}

.history-popup-empty,
.history-popup-loading {
    text-align: center;
    color: #94a3b8;
    padding: 42px 16px !important;
}

.history-popup-empty-icon,
.history-popup-loading-icon {
    display: block;
    margin: 0 auto 10px;
    font-size: 1.6rem;
    color: #ffd56a;
}

.history-popup-pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 14px;
}

.history-popup-page-info {
    color: #cbd5e1;
    font-size: 0.88rem;
    font-weight: 700;
    text-align: center;
}

.history-popup-pager-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 0 14px;
    border: 0;
    border-radius: 12px;
    background: rgb(255 255 255 / .1);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.history-popup-pager-btn:hover:not(:disabled),
.history-popup-pager-btn:focus-visible:not(:disabled) {
    background: rgb(255 213 106 / .22);
    outline: 2px solid #ffd56a;
    outline-offset: 2px;
}

.history-popup-pager-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

body.history-popup-open {
    overflow: hidden;
}

@keyframes historyPopupIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 640px) {
    .history-popup-card {
        max-height: 88vh;
        border-radius: 16px;
    }

    .history-popup-table th:nth-child(3),
    .history-popup-table td:nth-child(3) {
        display: none;
    }

    .history-popup-date-mobile {
        display: block;
        margin-top: 4px;
        color: #94a3b8;
        font-size: 0.76rem;
        font-weight: 500;
    }

    .history-popup-pager {
        flex-wrap: wrap;
        justify-content: center;
    }

    .history-popup-page-info {
        order: -1;
        width: 100%;
    }
}

@media (min-width: 641px) {
    .history-popup-date-mobile {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .history-popup.is-open .history-popup-card {
        animation: none;
    }
}
