.rating-wrapper {
    max-width: 950px;
    margin: 20px auto;
    background: var(--surface-glass);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    padding: 24px;
}

.rating-header {
    text-align: center;
    margin-bottom: 24px;
}

.rating-title {
    display: block;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.rating-subtitle {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.rating-table {
    width: 100%;
    border-collapse: collapse;
    color: var(--text-secondary);
}

.rating-table thead {
    border-bottom: 2px solid var(--border-color);
}

.rating-table th {
    padding: 12px 10px;
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
}

.rating-table td {
    padding: 16px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.rank-cell {
    font-weight: 800;
    color: var(--text-primary);
}

.nick-cell {
    font-weight: 600;
    color: var(--primary-color);
}

.exp-main {
    font-weight: 700;
    color: var(--text-primary);
}

.val-positive {
    color: var(--success-color);
}

.val-negative {
    color: var(--error-color);
}

.val-new {
    color: var(--text-muted);
    font-style: italic;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.rating-footer {
    margin-top: 25px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
}

.legend-group {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.btn-history {
    background: var(--surface-color);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: var(--border-radius-sm);
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-history:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-light);
}

.rating-tabs {
    display: flex;
    width: fit-content;
    margin: 0 auto 12px auto;
    background: var(--surface-glass);
    border: 1px solid var(--border-color);
    padding: 4px;
    border-radius: var(--border-radius-lg);
    gap: 4px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 24px;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
    background: var(--primary-color);
    color: #fff;
}

.rating-table-container {
    display: none;
}

.rating-table-container.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-hover-card {
    position: relative;
    display: inline-block;
    cursor: pointer;
    font-weight: 600;
    color: var(--primary-color);
    transition: color 0.15s ease;
    padding: 6px 0;
}

.user-hover-card:hover {
    color: #fff;
}

.user-hover-card::before {
    content: '';
    position: absolute;
    top: 100%;
    left: -20px;
    width: calc(100% + 40px);
    height: 24px;
    background: transparent;
    pointer-events: auto;
    z-index: 999;
}

.hover-popup {
    position: absolute;
    top: calc(100%);
    left: 50%;
    transform: translateX(-50%) translateY(-6px) scale(0.95);
    z-index: 1000;
    min-width: 200px;
    background: var(--surface-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    background-color: rgba(30, 41, 59, 0.96);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 6px 0;
    box-shadow: var(--shadow-heavy);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    transform-origin: top center;
    pointer-events: none;
}

.user-hover-card:hover .hover-popup {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0) scale(1);
    pointer-events: auto;
}

.hover-popup-item {
    display: block;
    padding: 10px 18px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
    background: transparent;
    border: none;
    width: 100%;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    white-space: nowrap;
    position: relative;
    z-index: 1001;
    border-radius: var(--border-radius);
    margin: 2px 6px;
    width: calc(100% - 12px);
}

.hover-popup-item:first-child {
    margin-top: 4px;
}

.hover-popup-item:last-child {
    margin-bottom: 4px;
}

.hover-popup-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.hover-popup-item:active {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(0.98);
}

.hover-popup-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 14px;
}

.hover-popup-item.copied {
    color: var(--success-color);
    pointer-events: none;
}

@media (pointer: coarse) {
    .user-hover-card::before {
        display: none;
    }

    .hover-popup {
        position: absolute;
        top: calc(100% + 8px);
        left: 55%;
        transform: translateX(-50%) translateY(-6px) scale(0.92);
        width: auto;
        min-width: 180px;
        max-width: 260px;
        background: rgba(30, 41, 59, 0.98);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-radius: var(--border-radius-lg);
        padding: 4px 0;
        box-shadow: var(--shadow-heavy);
        transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.25s;
        border: 1px solid var(--border-color);
    }

    .user-hover-card.active .hover-popup {
        opacity: 1;
        visibility: visible;
        transform: translateX(-50%) translateY(0) scale(1);
        pointer-events: auto;
    }

    .user-hover-card.active::after {
        display: none;
    }

    .user-hover-card.active .hover-popup {
        z-index: 1000;
    }

    .hover-popup-item {
        padding: 10px 14px;
        font-size: 0.8rem;
        margin: 1px 4px;
        width: calc(100% - 8px);
        border-radius: var(--border-radius);
    }

    .hover-popup-divider {
        margin: 2px 10px;
    }

    .hover-popup {
        min-width: 150px;
        max-width: 220px;
    }
}

@media (max-width: 650px) {
    .rating-wrapper {
        padding: 16px;
    }

    .rating-table thead {
        display: none;
    }

    .rating-table tr {
        display: block;
        padding: 15px 0;
        border-bottom: 1px solid var(--border-color);
    }

    .rating-table tr:last-child {
        border-bottom: none;
    }

    .rating-table td:not(.rank-cell) {
        display: block;
        text-align: right;
        padding: 8px 0;
        border: none;
        position: relative;
        min-height: 32px;
    }

    .rating-table td:not(.rank-cell)::before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        color: var(--text-muted);
        font-size: 0.75rem;
        font-weight: 600;
        text-transform: uppercase;
    }

    .rating-table td.rank-cell {
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 1.1rem;
        font-weight: 700;
        color: var(--text-primary);
        background: rgba(255, 255, 255, 0.03);
        border-radius: var(--border-radius-sm);
        margin-bottom: 12px;
        padding: 10px 0;
        border: none;
    }

    .rating-table td.rank-cell::before {
        content: "Место №";
        color: var(--text-primary);
        margin-right: 4px;
    }

    .rating-table td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 0.75rem;
        font-weight: 600;
        text-transform: uppercase;
    }

    .rating-footer {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .legend-group {
        justify-content: center;
        margin-bottom: 10px;
    }

    .btn-history {
        display: block;
        width: 100%;
        text-align: center;
    }

    .hover-popup {
        min-width: 140px;
        max-width: 200px;
    }

    .hover-popup-item {
        padding: 8px 12px;
        font-size: 0.75rem;
    }
}