/* Sequential roleplay statistics — flat dark-fantasy treatment. */

#tab-stats.roleplay-stats {
    --rp-stats-surface: #14151a;
    --rp-stats-surface-raised: #18191f;
    --rp-stats-surface-deep: #101116;
    --rp-stats-line: #2b2d36;
    --rp-stats-line-strong: #3f3943;
    --rp-stats-metal: #514c56;
    --rp-stats-ink: #e1dee6;
    --rp-stats-muted: #918c9a;
    --rp-stats-faint: #67636e;
    --rp-stats-accent: var(--c-rp, #7a5af8);
    width: min(100%, 760px);
    margin-inline: auto;
    padding: 4px 0 28px;
    color: var(--rp-stats-ink);
    box-sizing: border-box;
    min-width: 0;
}

.rp-stats-hero {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    margin: 4px 0 24px;
    padding: 0 16px;
    text-align: center;
}

.rp-stats-section__eyebrow {
    display: block;
    color: var(--rp-stats-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .14em;
    line-height: 1.4;
    text-transform: uppercase;
}

.rp-stats-hero h3 {
    margin: 0;
    color: var(--rp-stats-ink);
    font-size: clamp(28px, 5vw, 36px);
    font-weight: 750;
    letter-spacing: -.035em;
    line-height: 1.05;
    overflow-wrap: anywhere;
}

.rp-stats-stack {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
}

.rp-stats-section {
    position: relative;
    min-width: 0;
    padding: 20px;
    overflow: hidden;
    border: 1px solid var(--rp-stats-line);
    border-radius: 16px;
    background: var(--rp-stats-surface);
}

.rp-stats-section::before {
    position: absolute;
    top: 0;
    left: 22px;
    width: 38px;
    height: 2px;
    background: var(--rp-stats-metal);
    content: '';
}

.rp-stats-section::after {
    position: absolute;
    top: -3px;
    left: 38px;
    width: 7px;
    height: 7px;
    border: 1px solid var(--rp-stats-metal);
    background: var(--rp-stats-surface);
    content: '';
    transform: rotate(45deg);
}

.rp-stats-section__heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 17px;
}

.rp-stats-section__heading h4 {
    margin: 4px 0 0;
    color: var(--rp-stats-ink);
    font-size: 20px;
    font-weight: 720;
    letter-spacing: -.02em;
    line-height: 1.2;
}

.rp-stats-status {
    max-width: 240px;
    padding-top: 4px;
    color: var(--rp-stats-faint);
    font-size: 12px;
    line-height: 1.4;
    text-align: right;
}

.rp-stats-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-block: 1px solid var(--rp-stats-line);
}

.rp-stats-metric {
    display: flex;
    min-width: 0;
    min-height: 92px;
    align-items: flex-start;
    justify-content: center;
    flex-direction: column;
    padding: 14px 16px;
}

.rp-stats-metric + .rp-stats-metric {
    border-left: 1px solid var(--rp-stats-line);
}

.rp-stats-metric__value {
    max-width: 100%;
    overflow: hidden;
    color: var(--rp-stats-ink);
    font-variant-numeric: tabular-nums;
    font-size: clamp(23px, 4.5vw, 31px);
    font-weight: 760;
    letter-spacing: -.04em;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rp-stats-metric__value--compact {
    font-size: clamp(16px, 3vw, 22px);
    letter-spacing: -.02em;
}

.rp-stats-metric__label {
    margin-top: 6px;
    color: var(--rp-stats-muted);
    font-size: 12px;
    line-height: 1.35;
}

.rp-stats-trends {
    margin-top: 8px;
}

.rp-stats-trend {
    display: grid;
    grid-template-columns: minmax(150px, .72fr) minmax(0, 1.28fr);
    align-items: center;
    gap: 22px;
    min-height: 78px;
    padding: 14px 2px;
    border-bottom: 1px solid var(--rp-stats-line);
}

.rp-stats-trend:last-child {
    padding-bottom: 2px;
    border-bottom: 0;
}

.rp-stats-trend__label > span {
    display: block;
    color: var(--rp-stats-ink);
    font-size: 14px;
    font-weight: 680;
    line-height: 1.35;
}

.rp-stats-trend__label small,
.rp-stats-trend-share {
    display: block;
    margin-top: 3px;
    color: var(--rp-stats-faint);
    font-size: 11px;
    line-height: 1.35;
}

.rp-stats-trend__value {
    min-width: 0;
    text-align: right;
}

.rp-stats-trend-result {
    display: block;
    overflow: hidden;
    color: var(--rp-stats-ink);
    font-size: 15px;
    font-weight: 720;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rp-stats-empty {
    color: var(--rp-stats-faint);
    font-size: 12px;
    line-height: 1.4;
}

.rp-stats-traits {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
}

.rp-stats-trait-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 7px;
    max-width: 100%;
    min-width: 0;
    padding: 7px 9px;
    border: 1px solid var(--rp-stats-line-strong);
    border-radius: 8px;
    background: var(--rp-stats-surface-deep);
}

.rp-stats-trait-chip strong {
    min-width: 0;
    max-width: 180px;
    overflow: hidden;
    color: var(--rp-stats-ink);
    font-size: 12px;
    font-weight: 680;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rp-stats-trait-chip small {
    flex: 0 0 auto;
    color: var(--rp-stats-muted);
    font-size: 10px;
    font-variant-numeric: tabular-nums;
}

.rp-stats-plot-trends {
    padding-top: 8px;
}

.rp-stats-featured-tag {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 2px;
    border-bottom: 1px solid var(--rp-stats-line);
}

.rp-stats-featured-tag span {
    color: var(--rp-stats-muted);
    font-size: 12px;
}

.rp-stats-featured-tag strong {
    max-width: 65%;
    overflow: hidden;
    color: var(--rp-stats-ink);
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rp-stats-tags.stat-tags-cloud {
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 7px;
    padding: 15px 0 1px;
}

.roleplay-stats .tag-cloud-item {
    margin: 0;
    padding: 6px 9px;
    border: 1px solid var(--rp-stats-line);
    border-radius: 7px;
    background: var(--rp-stats-surface-deep);
    color: var(--rp-stats-muted);
    font-size: 11px;
    box-shadow: none;
}

.roleplay-stats .tag-cloud-item.empty-state {
    border-color: transparent;
    background: transparent;
    color: var(--rp-stats-faint);
}

.rp-stats-section__heading--boards {
    align-items: center;
}

.rp-stats-board-tabs {
    display: inline-flex;
    flex: 0 0 auto;
    padding: 3px;
    border: 1px solid var(--rp-stats-line);
    border-radius: 10px;
    background: var(--rp-stats-surface-deep);
}

.rp-stats-board-tab {
    min-height: 34px;
    padding: 0 11px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--rp-stats-muted);
    font: inherit;
    font-size: 11px;
    font-weight: 650;
    cursor: pointer;
}

.rp-stats-board-tab.is-active {
    background: var(--rp-stats-surface-raised);
    color: var(--rp-stats-ink);
}

.rp-stats-board-tab:focus-visible {
    outline: 2px solid var(--rp-stats-accent);
    outline-offset: 2px;
}

.rp-stats-board-panel[hidden] {
    display: none;
}

.roleplay-stats .leaderboard-list {
    display: grid;
    gap: 0;
}

.roleplay-stats .leaderboard-item {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 7px 2px;
    border-bottom: 1px solid var(--rp-stats-line);
    background: transparent;
}

.roleplay-stats .leaderboard-item:last-child {
    border-bottom: 0;
}

.roleplay-stats .leaderboard-rank {
    color: var(--rp-stats-faint);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

.roleplay-stats .leaderboard-name {
    min-width: 0;
    overflow: hidden;
    color: var(--rp-stats-ink);
    font-size: 13px;
    font-weight: 620;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.roleplay-stats .leaderboard-val {
    color: var(--rp-stats-muted);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.roleplay-stats .leaderboard-social-link {
    color: var(--rp-stats-muted);
}

.roleplay-stats .leaderboard-empty {
    padding: 18px 2px 4px;
    color: var(--rp-stats-faint);
    font-size: 12px;
    text-align: left;
}

.roleplay-stats .rp-stats-announcement {
    margin: 0 0 14px;
    border-color: var(--rp-stats-line-strong);
    border-radius: 14px;
    background: var(--rp-stats-surface);
    box-shadow: none;
}

.roleplay-stats .rp-stats-announcement::before {
    display: none;
}

html.telegram-mini-app #tab-stats.roleplay-stats {
    padding-bottom: max(28px, var(--tg-content-safe-area-inset-bottom, 0px));
}

@media (max-width: 640px) {
    #tab-stats.roleplay-stats {
        padding-inline: 0;
    }

    .rp-stats-hero {
        margin: 0 0 20px;
        padding-inline: 14px;
    }

    .rp-stats-stack {
        gap: 10px;
    }

    .rp-stats-section {
        padding: 17px 14px;
        border-radius: 13px;
    }

    .rp-stats-section__heading {
        gap: 10px;
    }

    .rp-stats-section__heading h4 {
        font-size: 18px;
    }

    .rp-stats-status {
        max-width: 150px;
        font-size: 10px;
    }

    .rp-stats-metric {
        min-height: 82px;
        padding: 12px 9px;
    }

    .rp-stats-metric__label {
        font-size: 10px;
    }

    .rp-stats-trend {
        grid-template-columns: minmax(116px, .75fr) minmax(0, 1.25fr);
        gap: 12px;
        min-height: 74px;
    }

    .rp-stats-traits {
        gap: 4px;
    }

    .rp-stats-trait-chip {
        padding: 6px 7px;
    }

    .rp-stats-section__heading--boards {
        align-items: flex-start;
        flex-direction: column;
    }

    .rp-stats-board-tabs {
        width: 100%;
    }

    .rp-stats-board-tab {
        flex: 1 1 50%;
    }
}

@media (max-width: 520px) {
    .rp-stats-metric__value {
        font-size: 21px;
    }

    .rp-stats-metric__value--compact {
        font-size: 14px;
    }

    .rp-stats-metrics {
        grid-template-columns: minmax(0, 1fr);
    }

    .rp-stats-metric {
        min-height: 62px;
        align-items: center;
        justify-content: space-between;
        flex-direction: row;
        gap: 12px;
    }

    .rp-stats-metric + .rp-stats-metric {
        border-top: 1px solid var(--rp-stats-line);
        border-left: 0;
    }

    .rp-stats-metric__label {
        margin-top: 0;
        text-align: right;
    }

    .rp-stats-trend {
        grid-template-columns: minmax(0, 1fr);
        gap: 8px;
    }

    .rp-stats-trend__value,
    .rp-stats-traits {
        justify-content: flex-start;
        text-align: left;
    }

    .rp-stats-trait-chip strong {
        max-width: 210px;
    }
}
