/* 排行页：我的排名 + 排行榜列表 */

.tab-page-rank {
    padding: 0;
}

.rank-page {
    padding: 12px 12px calc(16px + var(--safe-bottom));
}

.rank-my-card {
    position: relative;
    display: block;
    padding: 16px;
    margin-bottom: 16px;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(201, 162, 39, 0.16), rgba(26, 26, 32, 0.95));
    background-size: cover;
    background-position: center;
    border: 1px solid rgba(201, 162, 39, 0.25);
    border-radius: 14px;
}

.rank-my-card.has-bg,
.rank-mushroom-card.has-bg,
.rank-item.has-bg,
.rank-user-sheet.has-bg,
.rank-podium-slot.has-bg {
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center;
    border-color: rgba(255, 255, 255, 0.16);
}

.rank-card-veil {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(12, 12, 16, 0.32), rgba(12, 12, 16, 0.1));
    pointer-events: none;
    z-index: 0;
}

.rank-my-card > *:not(.rank-card-veil),
.rank-mushroom-card > *:not(.rank-card-veil),
.rank-item > *:not(.rank-card-veil),
.rank-user-sheet > *:not(.rank-card-veil):not(.rank-user-close),
.rank-podium-slot > *:not(.rank-card-veil) {
    position: relative;
    z-index: 1;
}

.rank-my-top {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.rank-score-line {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
}

.rank-tier-tag {
    flex-shrink: 0;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.4;
    color: #f5d76e;
    background: rgba(245, 215, 110, 0.16);
    border: 1px solid rgba(245, 215, 110, 0.28);
}

.rank-my-score-block .rank-score-line {
    justify-content: flex-start;
}

.rank-my-score {
    font-size: 36px;
    font-weight: 800;
    color: var(--color-primary);
    line-height: 1.1;
}

.rank-my-score-label,
.rank-my-place-label {
    margin-top: 4px;
    font-size: 13px;
    color: var(--color-text-muted);
}

.rank-my-place {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    text-align: right;
    line-height: 1.2;
}

.rank-my-place-block {
    text-align: right;
}

.rank-my-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid rgba(201, 162, 39, 0.18);
}

.rank-my-stat {
    text-align: center;
    min-width: 0;
}

.rank-my-stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1.2;
}

.rank-my-stat-label {
    margin-top: 4px;
    font-size: 12px;
    color: var(--color-text-muted);
}

.rank-my-hint {
    margin-top: 12px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--color-text-muted);
    opacity: 0.9;
}

.rank-my-login-tip {
    font-size: 16px;
    color: var(--color-text-muted);
    line-height: 1.6;
    text-align: center;
    padding: 8px 0;
}

.rank-section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin: 16px 0 10px;
}

.rank-section-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--color-text);
}

.rank-section-sub {
    font-size: 13px;
    color: var(--color-text-muted);
}

.rank-me-tag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    color: #1a1408;
    background: var(--color-primary);
    vertical-align: middle;
}

.rank-privacy-agree {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0 auto 20px;
    max-width: 320px;
    cursor: pointer;
    user-select: none;
}

.rank-privacy-checkbox {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1px solid rgba(201, 162, 39, 0.45);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #0f0f12;
    box-sizing: border-box;
}

.rank-privacy-checkbox.checked {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.rank-privacy-agree-text {
    font-size: 13px;
    line-height: 1.5;
    color: var(--color-text-muted);
    text-align: left;
}

.rank-privacy-link {
    color: var(--color-primary);
    font-weight: 600;
    text-decoration: none;
}

.rank-privacy-modal {
    position: fixed;
    inset: 0;
    z-index: 400;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.rank-privacy-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.rank-privacy-modal-sheet {
    position: relative;
    width: 100%;
    max-width: 480px;
    max-height: 72vh;
    background: var(--color-surface);
    border-radius: 16px 16px 0 0;
    border: 1px solid rgba(201, 162, 39, 0.22);
    border-bottom: none;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.rank-privacy-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.rank-privacy-modal-title {
    font-size: 17px;
    font-weight: 700;
}

.rank-privacy-modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.rank-privacy-modal-body {
    overflow-y: auto;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
}

.rank-privacy-modal-content {
    font-size: 14px;
    line-height: 1.7;
    color: var(--color-text-muted);
    white-space: pre-wrap;
    word-break: break-word;
}

.rank-podium {
    display: grid;
    grid-template-columns: 1fr 1.15fr 1fr;
    gap: 8px;
    align-items: end;
    margin-bottom: 14px;
}

.rank-podium-slot {
    position: relative;
    overflow: hidden;
    background: var(--color-surface);
    background-size: cover;
    background-position: center;
    border: 1px solid rgba(201, 162, 39, 0.25);
    border-radius: 14px;
    padding: 12px 8px 14px;
    text-align: center;
}

.rank-podium-1 {
    padding-top: 22px;
    padding-bottom: 20px;
    border-color: rgba(201, 162, 39, 0.45);
    background: linear-gradient(180deg, rgba(201, 162, 39, 0.18), var(--color-surface));
}

.rank-podium-1.has-bg,
.rank-podium-2.has-bg,
.rank-podium-3.has-bg {
    background-color: #141418;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center;
}

.rank-podium-2 {
    border-color: rgba(192, 192, 192, 0.35);
}

.rank-podium-3 {
    border-color: rgba(205, 127, 50, 0.35);
}

.rank-podium-place {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 8px;
    color: var(--color-primary);
}

.rank-podium-2 .rank-podium-place { color: #b8b8b8; }
.rank-podium-3 .rank-podium-place { color: #cd7f32; }

.rank-podium-avatar-wrap {
    position: relative;
    width: 68px;
    height: 68px;
    margin: 0 auto 8px;
}

.rank-podium-1 .rank-podium-avatar-wrap {
    width: 82px;
    height: 82px;
}

.rank-podium-avatar {
    position: absolute;
    left: 15.5%;
    top: 15.5%;
    width: 69%;
    height: 69%;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #222;
    border: 2px solid rgba(201, 162, 39, 0.35);
    color: var(--color-primary);
    font-weight: 700;
    box-sizing: border-box;
}

.rank-podium-avatar.has-frame,
.rank-avatar.has-frame {
    border-color: transparent;
}

.rank-podium-avatar.is-empty {
    opacity: 0.35;
}

.rank-podium-avatar img,
.rank-podium-avatar .app-avatar-fallback {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.rank-avatar-frame {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
    object-fit: contain;
}

.rank-podium-name {
    font-size: 16px;
    font-weight: 700;
    margin: 6px 0 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rank-podium-name-1 { color: #a855f7; }
.rank-podium-name-2 { color: #f5d76e; }
.rank-podium-name-3 { color: #3b82f6; }

.rank-mushroom-name {
    font-size: 16px;
    font-weight: 700;
    color: #ef4444;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rank-podium-stats {
    display: flex;
    width: 100%;
    gap: 4px;
    margin: 6px 0 4px;
    padding: 0 2px;
    box-sizing: border-box;
}

.rank-podium-stat {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.rank-podium-stat-val {
    max-width: 100%;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rank-podium-stat-lab {
    font-size: 11px;
    color: var(--color-text-muted);
    line-height: 1.2;
}

.rank-podium-score {
    margin-top: 4px;
    justify-content: center;
    font-size: 15px;
    color: var(--color-primary);
    font-weight: 700;
}

.rank-podium-score-num {
    font-size: 15px;
    font-weight: 800;
    color: var(--color-primary);
    line-height: 1.1;
}

.rank-podium-empty {
    font-size: 15px;
    color: var(--color-text-muted);
    padding: 24px 0;
}

.rank-mushroom-card {
    position: relative;
    padding: 12px 14px;
    margin-bottom: 4px;
    overflow: hidden;
    border-radius: 12px;
    border: 1px solid rgba(245, 158, 11, 0.28);
    background: rgba(245, 158, 11, 0.08);
    background-size: cover;
    background-position: center;
}

.rank-mushroom-label {
    font-size: 15px;
    color: #f59e0b;
    font-weight: 700;
    margin-bottom: 8px;
}

.rank-mushroom-body {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rank-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rank-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    overflow: hidden;
    background: var(--color-surface);
    background-size: cover;
    background-position: center;
    border: 1px solid rgba(201, 162, 39, 0.25);
    border-radius: 12px;
}

.rank-item.is-me {
    border-color: rgba(201, 162, 39, 0.35);
    /* 只用 background-color，避免 background 简写清掉装扮背景图 */
    background-color: rgba(201, 162, 39, 0.06);
}

.rank-item.is-me.has-bg {
    background-color: #141418;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center;
}

.rank-no {
    flex-shrink: 0;
    width: 28px;
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text-muted);
}

.rank-no.rank-no-top1 {
    color: #ffd700;
}

.rank-no.rank-no-top2 {
    color: #c0c0c0;
}

.rank-no.rank-no-top3 {
    color: #cd7f32;
}

.rank-avatar-wrap {
    position: relative;
    flex-shrink: 0;
    width: 52px;
    height: 52px;
}

.rank-avatar {
    position: absolute;
    left: 15.5%;
    top: 15.5%;
    width: 69%;
    height: 69%;
    border-radius: 50%;
    background: linear-gradient(135deg, #2a2418, #1a1a20);
    border: 1px solid rgba(201, 162, 39, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    font-weight: 700;
    color: var(--color-primary);
    overflow: hidden;
    box-sizing: border-box;
}

.rank-avatar img,
.rank-avatar .app-avatar-fallback {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.rank-body {
    flex: 1;
    min-width: 0;
}

.rank-name {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rank-meta {
    font-size: 14px;
    color: var(--color-text-muted);
    line-height: 1.5;
}

.rank-score {
    flex-shrink: 0;
    text-align: right;
}

.rank-score .rank-score-line {
    justify-content: flex-end;
}

.rank-score-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1.2;
}

.rank-user-place .rank-score-line,
.rank-user-score-inline {
    display: inline-flex;
    vertical-align: middle;
}

.rank-user-score-num {
    font-size: inherit;
    font-weight: 700;
    color: var(--color-primary);
}

.rank-score-label {
    margin-top: 2px;
    font-size: 14px;
    color: var(--color-text-muted);
}

.rank-loading,
.rank-empty,
.rank-error {
    text-align: center;
    padding: 40px 16px;
    font-size: 17px;
    color: var(--color-text-muted);
}

.rank-error {
    color: #f87171;
}

.rank-podium-slot.is-clickable,
.rank-mushroom-card.is-clickable,
.rank-item.is-clickable {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.rank-podium-slot.is-clickable:active,
.rank-mushroom-card.is-clickable:active,
.rank-item.is-clickable:active {
    opacity: 0.88;
}

body.rank-modal-open {
    overflow: hidden;
}

.rank-user-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 20px calc(24px + var(--safe-bottom));
    box-sizing: border-box;
}

.rank-user-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.62);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.rank-user-sheet {
    position: relative;
    width: 100%;
    max-width: 320px;
    padding: 24px 18px 20px;
    overflow: hidden;
    border-radius: 18px;
    background: linear-gradient(165deg, #22222a 0%, #16161c 100%);
    background-size: cover;
    background-position: center;
    border: 1px solid rgba(201, 162, 39, 0.28);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
    box-sizing: border-box;
    text-align: center;
}

.rank-user-close {
    position: absolute;
    top: 10px;
    right: 12px;
    z-index: 2;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    color: var(--color-text-muted);
    font-size: 20px;
    line-height: 32px;
    padding: 0;
    cursor: pointer;
}

.rank-user-avatar-wrap {
    position: relative;
    width: 88px;
    height: 88px;
    margin: 8px auto 0;
}

.rank-user-avatar {
    position: absolute;
    left: 15.5%;
    top: 15.5%;
    width: 69%;
    height: 69%;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #222;
    border: 2px solid rgba(201, 162, 39, 0.4);
    box-sizing: border-box;
}

.rank-user-avatar.has-frame {
    border-color: transparent;
}

.rank-user-avatar img,
.rank-user-avatar .app-avatar-fallback {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.rank-user-name {
    margin-top: 12px;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rank-user-id {
    margin-top: 8px;
    padding: 5px 12px;
    border-radius: 999px;
    background: rgba(201, 162, 39, 0.12);
    border: 1px solid rgba(201, 162, 39, 0.32);
    box-sizing: border-box;
    font-size: 13px;
    color: var(--color-text-muted);
    line-height: 1.3;
}

.rank-user-id span {
    color: var(--color-primary);
    font-weight: 700;
    letter-spacing: 0.3px;
}

.rank-user-place {
    margin-top: 6px;
    font-size: 14px;
    color: var(--color-primary);
}

.rank-user-stats {
    display: flex;
    flex-wrap: wrap;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid rgba(201, 162, 39, 0.18);
}

.rank-user-stat {
    width: 33.33%;
    padding: 10px 4px;
    box-sizing: border-box;
}

.rank-user-stat-val {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}

.rank-user-stat-lab {
    margin-top: 4px;
    font-size: 12px;
    color: var(--color-text-muted);
}
