:root {
    --user-primary: #3f51b5;
    --user-primary-deep: #33439a;
    --user-primary-soft: #eef2ff;
    --user-accent-soft: #ecf8f1;
    --user-text: #1f2937;
    --user-muted: #64748b;
    --user-border: #dfe7e3;
    --user-surface: #ffffff;
}

body.user-page {
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    color: var(--user-text);
    background:
        radial-gradient(circle at 10% 8%, rgba(187, 225, 207, 0.32), transparent 30%),
        radial-gradient(circle at 90% 86%, rgba(199, 210, 254, 0.3), transparent 32%),
        #f5f8f6;
}

body.user-page #daily-start-overlay {
    align-items: flex-start;
    padding: clamp(20px, 5vh, 52px) 18px;
    overflow-y: auto;
    background: transparent;
    box-sizing: border-box;
}

body.user-page #daily-start-overlay .daily-box {
    width: min(820px, 100%);
    max-width: 820px;
    max-height: calc(100dvh - clamp(40px, 10vh, 104px)) !important;
    padding: clamp(22px, 4vw, 34px);
    border: 1px solid rgba(255, 255, 255, 0.92);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 22px 55px rgba(50, 75, 65, 0.13);
    box-sizing: border-box;
    scrollbar-gutter: stable;
}

body.user-page.profile-tab-active #daily-start-overlay,
body.user-page.profile-tab-active #daily-start-overlay .daily-box,
body.user-page #daily-start-overlay .daily-box.profile-scroll-locked {
    overflow: hidden !important;
    scrollbar-gutter: auto;
    overscroll-behavior: none;
}

body.user-page:not(.profile-tab-active) #daily-start-overlay {
    overflow-y: auto;
}

body.user-page:not(.profile-tab-active) #daily-start-overlay .daily-box {
    overflow-y: auto !important;
}

body.user-page .custom-tabs {
    position: sticky;
    top: 0;
    z-index: 8;
    gap: 8px;
    margin: -8px 0 26px;
    padding: 8px;
    border: 1px solid #e8eeeb;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 8px 18px rgba(51, 65, 85, 0.08);
    isolation: isolate;
}

body.user-page .custom-tab {
    min-height: 42px;
    flex: 1;
    justify-content: center;
    padding: 0 16px;
    border: 0;
    border-radius: 10px;
    color: var(--user-muted);
    font-weight: 600;
}

body.user-page .custom-tab:hover {
    color: var(--user-primary);
    background: rgba(63, 81, 181, 0.06);
}

body.user-page .custom-tab.active {
    border: 0;
    color: var(--user-primary);
    background: var(--user-primary-soft);
    box-shadow: inset 0 0 0 1px rgba(63, 81, 181, 0.08);
}

body.user-page .custom-tab .material-icons {
    font-size: 20px;
}

body.user-page #profile-card {
    position: relative;
    overflow: hidden;
    padding: clamp(20px, 4vw, 30px) !important;
    border: 1px solid #dce9e2;
    border-radius: 20px !important;
    background: linear-gradient(145deg, #f4fbf7 0%, #f2f5ff 100%) !important;
    box-shadow: 0 12px 30px rgba(51, 65, 85, 0.08);
}

body.user-page #profile-card > div:first-child {
    position: relative;
    z-index: 1;
}

body.user-page .profile-avatar {
    width: 88px;
    height: 88px;
    border: 4px solid #fff;
    box-shadow: 0 10px 24px rgba(30, 60, 114, 0.16);
}

body.user-page #profile-username {
    letter-spacing: -0.02em;
}

body.user-page #profile-level {
    min-height: 24px;
    padding: 3px 9px;
    border-radius: 999px;
    box-shadow: none;
}

body.user-page .edit-icon {
    width: 32px;
    height: 32px;
    margin-left: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.78);
    display: inline-grid;
    place-items: center;
    transition: transform 0.2s ease, background 0.2s ease;
}

body.user-page .edit-icon:hover {
    background: #fff;
    transform: translateY(-1px);
}

body.user-page .stat-grid {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    padding: 0;
    background: transparent !important;
}

body.user-page .stat-cell {
    min-width: 0;
    padding: 14px 8px;
    border: 1px solid rgba(221, 231, 226, 0.9);
    border-radius: 13px;
    background: rgba(255, 255, 255, 0.78);
}

body.user-page .stat-value {
    overflow: hidden;
    color: #294d69;
    font-size: clamp(1.3rem, 3vw, 1.75rem);
    line-height: 1.2;
    text-overflow: ellipsis;
}

body.user-page .stat-label {
    margin-top: 5px;
    color: #708078;
    font-size: 0.72rem;
    line-height: 1.35;
    letter-spacing: 0.04em;
}

body.user-page .setting-card {
    padding: clamp(18px, 3vw, 24px);
    border: 1px solid var(--user-border);
    border-radius: 17px;
    background: var(--user-surface);
    box-shadow: 0 8px 24px rgba(51, 65, 85, 0.055);
}

body.user-page .setting-title {
    margin-bottom: 18px;
    font-size: 1.02rem;
}

body.user-page .setting-title .material-icons {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--user-primary-soft);
    display: inline-grid;
    place-items: center;
    font-size: 20px;
}

body.user-page .avatar-preview {
    margin-left: 0;
    margin-bottom: 0;
    padding: 14px;
    border: 1px dashed #ccd9d2;
    border-radius: 14px;
    background: #fafcfb;
}

body.user-page .avatar-preview-img {
    width: 72px;
    height: 72px;
    border: 3px solid #fff;
    box-shadow: 0 5px 14px rgba(51, 65, 85, 0.12);
}

body.user-page mdui-text-field {
    --mdui-color-surface-container-highest: 255, 255, 255;
}

body.user-page mdui-button:not([variant]),
body.user-page mdui-button[variant="filled"] {
    background-color: var(--user-primary);
    color: #fff;
}

body.user-page mdui-button {
    border-radius: 14px;
}

body.user-page mdui-button:not([variant]):hover,
body.user-page mdui-button[variant="filled"]:hover {
    background-color: var(--user-primary-deep);
}

body.user-page mdui-button[variant="tonal"] {
    background-color: var(--user-primary-soft);
    color: var(--user-primary);
}

body.user-page #leaderboard-overlay {
    padding: 18px;
    background: rgba(30, 41, 59, 0.38);
    backdrop-filter: blur(8px);
    box-sizing: border-box;
}

body.user-page #leaderboard-overlay .leaderboard-box {
    width: min(720px, 100%);
    max-width: 720px;
    height: auto;
    max-height: min(82dvh, 760px);
    padding: clamp(22px, 4vw, 32px);
    border: 1px solid rgba(255, 255, 255, 0.86);
    border-radius: 22px;
    overflow-y: auto;
    background: #fff;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.2);
}

body.user-page .leaderboard-table {
    overflow: hidden;
    border: 1px solid #e5ebe8;
    border-radius: 14px;
}

body.user-page .leaderboard-table th {
    position: sticky;
    top: 0;
    background: #f3f7f5;
}

body.user-page .leaderboard-table tbody tr:hover {
    background: #f8fbf9;
}

body.user-page .leaderboard-table .current-user,
body.user-page .leaderboard-table tr.current-user {
    background: var(--user-primary-soft);
}

body.user-page #tools {
    position: fixed;
    top: auto !important;
    right: 4vw !important;
    bottom: calc(30px + env(safe-area-inset-bottom, 0px));
    left: auto;
    width: auto;
    height: auto;
    float: none !important;
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    background: transparent;
    border: 0;
    box-shadow: none;
}

body.user-page mdui-dialog {
    --mdui-color-surface: 255, 255, 255;
    --mdui-color-surface-container: 255, 255, 255;
    --mdui-color-surface-container-high: 255, 255, 255;
    --mdui-color-surface-container-highest: 252, 253, 252;
    --mdui-color-on-surface: 31, 41, 55;
    --mdui-shape-corner-extra-large: 1.25rem;
}

body.user-page mdui-dialog a {
    color: var(--user-primary);
    font-weight: 500;
    text-decoration: none;
}

body.user-page mdui-dialog > div {
    box-sizing: border-box;
}

@media (max-width: 700px) {
    body.user-page #daily-start-overlay {
        padding: 0;
    }

    body.user-page #daily-start-overlay .daily-box {
        width: 100%;
        min-height: 100dvh;
        max-height: 100dvh !important;
        padding: 18px 16px calc(24px + env(safe-area-inset-bottom));
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    body.user-page .custom-tabs {
        margin: -2px 0 20px;
    }

    body.user-page #profile-card {
        padding: 20px 16px !important;
    }

    body.user-page #profile-card > div:first-child {
        align-items: flex-start !important;
        gap: 14px !important;
    }

    body.user-page .profile-avatar {
        width: 72px;
        height: 72px;
    }

    body.user-page #profile-username {
        font-size: 1.25rem !important;
    }

    body.user-page .stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        margin-top: 14px !important;
    }

    body.user-page .stat-cell {
        padding: 12px 8px;
    }

    body.user-page .avatar-preview {
        align-items: flex-start;
        gap: 14px;
    }

    body.user-page #tools {
        right: calc(16px + env(safe-area-inset-right, 0px)) !important;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }

    body.user-page #leaderboard-overlay {
        align-items: flex-end;
        padding: 0;
    }

    body.user-page #leaderboard-overlay .leaderboard-box {
        width: 100%;
        max-height: 88dvh;
        padding: 22px 16px calc(18px + env(safe-area-inset-bottom));
        border-radius: 22px 22px 0 0;
    }
}

@media (max-width: 420px) {
    body.user-page .custom-tab {
        padding-inline: 10px;
        font-size: 0.9rem;
    }

    body.user-page .avatar-preview {
        flex-direction: column;
    }

    body.user-page #profile-card > div:first-child > div:last-child > div:last-child {
        flex-direction: column;
        gap: 3px !important;
    }
}
