/* ==============================
   ТЕМЫ (используем CSS-переменные)
   ============================== */

:root {
    --bg-body: radial-gradient(circle at center, #eef2ff 0%, #d7dbec 60%, #c3c8d8 100%);
    --bg-card: rgba(255, 255, 255, 0.7);
    --bg-container: rgba(255, 255, 255, 0.55);
    --border-container: rgba(255, 255, 255, 0.7);
    --border-card: rgba(255, 255, 255, 0.85);
    --text-main: #1b2140;
    --text-secondary: rgba(0, 0, 0, 0.6);
    --text-muted: rgba(0, 0, 0, 0.45);
    --accent: #6284ff;
    --accent2: #7f5dff;
    --shadow-container: 0 10px 28px rgba(0, 0, 0, 0.08);
    --shadow-card: 0 6px 14px rgba(0, 0, 0, 0.06);
    --role-bg: rgba(70, 70, 120, 0.18);
    --loader-border: #d2d5e9;
    --loader-border-top: #7f5dff;
}

body[data-theme="dark"] {
    --bg-body: radial-gradient(circle at top, #181b2b 0%, #111320 40%, #080916 100%);
    --bg-container: rgba(17, 19, 32, 0.9);
    --bg-card: rgba(16, 19, 34, 0.98);
    --border-container: rgba(117, 130, 190, 0.5);
    --border-card: rgba(117, 130, 190, 0.6);
    --text-main: #f7f7ff;
    --text-secondary: rgba(255, 255, 255, 0.75);
    --text-muted: rgba(255, 255, 255, 0.5);
    --accent: #7f8bff;
    --accent2: #c47fff;
    --shadow-container: 0 12px 30px rgba(0, 0, 0, 0.6);
    --shadow-card: 0 10px 20px rgba(0, 0, 0, 0.6);
    --role-bg: rgba(122, 108, 255, 0.25);
    --loader-border: #343854;
    --loader-border-top: #c47fff;
}

/* ==========
   GLOBAL
   ========== */

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Inter", system-ui, sans-serif;
    background: var(--bg-body);
    display: flex;
    justify-content: center;
    padding: 20px 12px 32px;
    min-height: 100vh;
    color: var(--text-main);
    transition: background 0.3s ease;
}

/* ==========
   CONTAINER
   ========== */

.container {
    width: 100%;
    max-width: 430px;
    padding: 24px 20px 20px;
    background: var(--bg-container);
    backdrop-filter: blur(30px);
    border-radius: 24px;
    border: 1px solid var(--border-container);
    box-shadow: var(--shadow-container);
}

/* ==========
   HEADER
   ========== */

.header {
    margin-bottom: 18px;
}

.header h1 {
    margin: 0;
    font-weight: 700;
    font-size: 22px;
    color: var(--text-main);
}

.header-sub {
    margin-top: 4px;
    font-size: 14px;
    color: var(--text-secondary);
}

.header-top-row {
    margin-top: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.counter {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ==========
   THEME TOGGLE
   ========== */

.theme-toggle {
    padding: 7px 14px;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

/* ==========
   REFRESH
   ========== */

.refresh {
    text-align: center;
    margin-top: 10px;
}

.refresh button {
    padding: 10px 22px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.8);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: 0.2s;
}

body[data-theme="dark"] .refresh button {
    background: rgba(22, 25, 42, 0.9);
    border-color: rgba(129, 140, 248, 0.6);
    color: var(--text-secondary);
}

.refresh button:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}

/* ==========
   USER LIST
   ========== */

.user-list {
    margin-top: 18px;
}

/* ==========
   USER CARD
   ========== */

.user-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 15px;
    margin-bottom: 12px;

    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border-card);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow-card);
    transition: transform 0.15s ease-out, box-shadow 0.15s ease-out, background 0.15s;
}

.user-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 9px 20px rgba(0, 0, 0, 0.12);
    background: rgba(255, 255, 255, 0.92);
}

body[data-theme="dark"] .user-card:hover {
    background: rgba(33, 36, 64, 0.98);
}

/* LEFT BLOCK */

.user-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Position bubble */

.position {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: white;
    font-weight: 600;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.position-1 {
    background: #ffd35a;
}

.position-2 {
    background: #d1d1d1;
}

.position-3 {
    background: #cf9b64;
}

.position-default {
    background: #a3a8b8;
}

/* Avatar */

.avatar-wrapper {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.9);
    flex-shrink: 0;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.16);
    background: radial-gradient(circle at 30% 20%, #ffffff 0%, #c3d0ff 40%, #9097ff 100%);
}

body[data-theme="dark"] .avatar-wrapper {
    border-color: rgba(148, 163, 255, 0.9);
    background: radial-gradient(circle at 30% 20%, #353a7a 0%, #11152f 50%, #050614 100%);
}

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

.avatar-placeholder {
    width: 100%;
    height: 100%;
    font-size: 16px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

/* Text block */

.user-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
}

.stats {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Activity bar */

.activity {
    margin-top: 4px;
}

.activity-track {
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.07);
    overflow: hidden;
}

body[data-theme="dark"] .activity-track {
    background: rgba(255, 255, 255, 0.08);
}

.activity-bar {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    width: var(--fill, 0%);
    transition: width 0.4s ease-out;
}

/* Role badge */

.role {
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--role-bg);
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* ==========
   LOADER
   ========== */

.loader-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 24px 0 8px;
    color: var(--text-muted);
    font-size: 13px;
}

.loader {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 3px solid var(--loader-border);
    border-top-color: var(--loader-border-top);
    animation: spin 0.8s linear infinite;
}

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

/* ==========
   FOOTER
   ========== */

.footer {
    text-align: center;
    margin-top: 16px;
    opacity: 0.45;
    font-size: 12px;
}

/* ==========
   RESPONSIVE
   ========== */

@media (max-width: 480px) {
    .container {
        padding: 18px 14px 16px;
        max-width: 100%;
    }

    .header h1 {
        font-size: 20px;
    }

    .header-top-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .user-card {
        padding: 12px 12px;
    }
}

.avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 12px;
    border: 2px solid rgba(255, 255, 255, 0.15);
}

#chartTooltip {
    position: absolute;
    display: none;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12px;
    background: rgba(30, 30, 60, 0.92);
    color: #fff;
    pointer-events: none;
    transform: translate(-50%, -120%);
    white-space: nowrap;
    z-index: 20;
}

#monthChart {
    width: 100%;
    height: 240px;
    display: block;
}

#chartTooltip {
    position: absolute;
    pointer-events: none;
    white-space: nowrap;
    transform: translate(-50%, -100%);
}

/* ==========
   HALL OF FAME
   ========== */

.hall-grid {
    display: grid;
    gap: 14px;
}

.hall-card {
    padding: 14px 14px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.08);
}

body[data-theme="dark"] .hall-card {
    background: rgba(25, 28, 50, 0.75);
    border-color: rgba(255, 255, 255, 0.06);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.25);
}

.hall-title {
    font-weight: 700;
    margin-bottom: 10px;
}

.hall-user {
    display: flex;
    gap: 12px;
    align-items: center;
}

.hall-avatar {
    width: 54px; /* крупнее чем в рейтинге */
    height: 54px;
    border-radius: 50%;
}

.hall-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.hall-name {
    font-weight: 700;
}

.hall-value {
    font-size: 14px;
    opacity: 0.9;
}

.hall-date {
    font-size: 12px;
    opacity: 0.65;
}

.hall-link {
    display: inline-block;
    margin-top: 6px;
    font-weight: 600;
    text-decoration: none;
    color: var(--accent);
}

.hall-link:hover {
    text-decoration: underline;
}

.hall-error {
    padding: 12px 0;
    opacity: 0.8;
}

