/* Final ownership boundary for the personal center. Loaded after legacy UI CSS. */
.personal-center-layer {
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: hidden;
}

.personal-center-layer > .personal-center-modal {
    width: min(980px, calc(100vw - 40px));
    max-width: none;
    height: min(720px, calc(100dvh - 40px));
    max-height: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.personal-center-modal > .personal-center-heading {
    min-height: 78px;
}

.personal-center-modal > .personal-center-layout {
    height: calc(100% - 78px);
}

.personal-center-modal .personal-center-content {
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
}

.identity-avatar::after {
    content: "";
    position: absolute;
    inset: -18%;
    z-index: 2;
    pointer-events: none;
    background: var(--identity-frame-image, none) center / contain no-repeat;
}

.identity-trigger-copy,
.identity-menu-summary > span:last-child {
    gap: 8px;
}

/* Title and nickname rewards are two independent live-text nameplates. Their
   transparent canvases are fitted by visible pixels; text remains real DOM. */
.social-cosmetic-title,
[data-identity-title],
.reward-live-title {
    display: inline-grid;
    box-sizing: border-box;
    width: auto;
    min-width: 0;
    height: 30px;
    min-height: 30px;
    place-items: center;
    padding: 4px 10px;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, currentColor 32%, var(--shell-border));
    border-radius: 999px;
    background-color: color-mix(in srgb, var(--shell-surface-2) 88%, transparent);
    background-image: var(--cosmetic-title-image, none);
    background-position: var(--cosmetic-title-image-position, center);
    background-size: var(--cosmetic-title-image-size, 100% 100%);
    background-repeat: no-repeat;
    color: var(--shell-muted);
}

.social-cosmetic-title.has-title-artwork,
[data-identity-title].has-title-artwork,
.reward-live-title.has-title-artwork {
    width: min(100%, 130px);
    height: 40px;
    min-height: 40px;
    padding: 7px 18px;
    border: 0;
    border-radius: 0;
    background-color: transparent;
}

.social-title-copy {
    min-width: 0;
    overflow: hidden;
    color: #f8f4ff;
    font-size: 11px;
    font-weight: 900;
    line-height: 1.15;
    text-overflow: ellipsis;
    text-shadow: 0 1px 2px #17101d, 0 0 3px #17101d;
    white-space: nowrap;
}

.has-title-artwork > .social-title-copy {
    white-space: nowrap;
}

.personal-reward-filter {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    color: var(--shell-muted);
    font-size: 12px;
}

.personal-reward-filter select {
    min-height: 34px;
    padding: 0 28px 0 10px;
    border: 1px solid var(--shell-border);
    border-radius: 7px;
    background: var(--shell-surface-2);
    color: var(--shell-text);
}

.reward-card-preview {
    position: relative;
    display: grid;
    width: 120px;
    height: 56px;
    flex: 0 0 auto;
    place-items: center;
    overflow: hidden;
    border-radius: 8px;
    background: color-mix(in srgb, var(--shell-bg) 35%, transparent);
}

.reward-preview-art { position: absolute; z-index: 2; width: 100%; height: 100%; object-fit: contain; }
.reward-preview-art-normalized { max-width: none; max-height: none; }
.reward-preview-art-normalized.is-art-fallback { inset: 0; }
.reward-card-preview-avatar-frame { width: 64px; height: 64px; overflow: visible; border-radius: 50%; }
.reward-card-preview-avatar { width: 64px; height: 64px; overflow: hidden; border: 2px solid color-mix(in srgb, var(--shell-accent) 46%, var(--shell-border)); border-radius: 50%; background: var(--shell-surface-2); box-shadow: inset 0 0 0 2px color-mix(in srgb, white 10%, transparent); }
.reward-preview-avatar-portrait { width: 100%; height: 100%; object-fit: cover; }
.reward-preview-avatar-face { position: absolute; inset: 8px; z-index: 1; border-radius: 50%; background-position: center; background-size: cover; box-shadow: inset 0 0 0 1px color-mix(in srgb, white 32%, transparent); }
.reward-card-preview-title,
.reward-card-preview-font-color { aspect-ratio: 15 / 7; }
.reward-card-preview em { position: relative; z-index: 3; max-width: calc(100% - 24px); overflow: hidden; color: var(--shell-text); font-size: 10px; font-style: normal; font-weight: 800; line-height: 1; text-align: center; text-overflow: ellipsis; text-shadow: 0 1px 3px var(--shell-bg), 0 0 4px var(--shell-bg); white-space: nowrap; }
.reward-card-preview-font-color em { font-size: 12px; letter-spacing: .04em; }
.personal-reward-card { min-height: 86px; }
.personal-reward-group.is-avatar-group .personal-reward-grid { grid-template-columns: repeat(auto-fill, 68px); gap: 12px; }
.personal-avatar-card { position: relative; display: grid; width: 68px; height: 68px; padding: 0; place-items: center; border: 2px solid transparent; border-radius: 50%; background: transparent; cursor: pointer; transition: border-color .16s ease, opacity .16s ease, transform .16s ease, filter .16s ease; }
.personal-avatar-card .reward-card-preview-avatar { width: 60px; height: 60px; border: 0; }
.personal-avatar-card.is-owned { border-color: color-mix(in srgb, var(--shell-accent) 58%, var(--shell-border)); }
.personal-avatar-card.is-owned:not(:disabled):hover { transform: translateY(-2px) scale(1.04); border-color: var(--shell-accent); }
.personal-avatar-card.is-equipped { border-color: #ffd166; box-shadow: 0 0 0 2px color-mix(in srgb, #ffd166 25%, transparent), 0 0 16px color-mix(in srgb, #ffd166 35%, transparent); }
.personal-avatar-card.is-locked { opacity: .38; filter: grayscale(.82); cursor: not-allowed; }
.personal-reward-more { display: block; min-height: 36px; margin: 10px auto 0; padding: 0 18px; border: 1px solid var(--shell-border); border-radius: 999px; background: var(--shell-surface-2); color: var(--shell-text); cursor: pointer; }
.personal-reward-more:hover { border-color: var(--shell-accent); color: var(--shell-accent); }

.social-avatar { position: relative; }
.social-avatar::after {
    content: "";
    position: absolute;
    inset: -18%;
    z-index: 3;
    pointer-events: none;
    background: var(--cosmetic-avatar-image, none) center / contain no-repeat;
}

.social-name-copy {
    display: inline-grid;
    box-sizing: border-box;
    width: auto;
    min-width: 0;
    min-height: 34px;
    max-width: 100%;
    overflow: hidden;
    background-image: var(--cosmetic-name-image, none);
    background-position: var(--cosmetic-name-image-position, center);
    background-size: var(--cosmetic-name-image-size, 100% 100%);
    background-repeat: no-repeat;
    place-items: center;
    padding: 5px 18px;
    color: var(--social-name-color, inherit);
    text-overflow: ellipsis;
    vertical-align: middle;
    white-space: nowrap;
}

[data-identity-name],
.reward-live-name {
    display: inline-grid;
    box-sizing: border-box;
    min-width: 0;
    min-height: 34px;
    place-items: center;
    padding: 5px 18px;
    overflow: hidden;
    background-image: var(--cosmetic-name-image, none);
    background-position: var(--cosmetic-name-image-position, center);
    background-size: var(--cosmetic-name-image-size, 100% 100%);
    background-repeat: no-repeat;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.social-cosmetic-title {
    color: var(--social-name-color, var(--shell-muted));
}

/* Every live player identity uses one scan line on every product surface.
   The nickname is primary; the smaller title follows without changing height. */
.compact-social-identity {
    display: flex !important;
    box-sizing: border-box;
    min-width: 0;
    height: 44px;
    align-items: center;
    align-content: normal;
    justify-items: normal;
    gap: 4px;
    overflow: hidden;
}

.compact-social-identity > :is(.social-name-copy, [data-identity-name], .reward-live-name) {
    order: 0;
    flex: 1 1 auto;
    width: auto;
    max-width: none;
    min-width: 0;
    height: 32px;
    min-height: 32px;
    margin: 0;
    padding: 3px 6px;
    overflow: hidden;
    font-size: 15px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.compact-social-identity > :is(.social-cosmetic-title, [data-identity-title], .reward-live-title) {
    order: 1;
    flex: 0 1 42%;
    width: min(42%, 76px);
    min-width: 46px;
    max-width: 76px;
    height: 22px;
    min-height: 22px;
    margin: 0;
    padding: 2px 4px;
    overflow: hidden;
}

.compact-social-identity > :is(.social-cosmetic-title, [data-identity-title], .reward-live-title) .social-title-copy {
    font-size: 8px;
}

/* Waiting-room cards carry avatar, role, readiness and two live statistics in
   a narrow column. Reserve readable nickname space before distributing extras. */
.member-item[data-social-ready="true"] .member-identity {
    grid-template-columns: 32px minmax(100px, 1fr) 64px auto;
    gap: 2px;
}

.member-item[data-social-ready="true"] .member-avatar.social-avatar {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
}

.member-item[data-social-ready="true"] .compact-social-identity {
    min-width: 100px;
}

.member-item[data-social-ready="true"] .compact-social-identity > .social-name-copy {
    min-width: 58px;
    padding-inline: 4px;
    font-size: 14px;
}

.member-item[data-social-ready="true"] .compact-social-identity > .social-cosmetic-title {
    flex-basis: 38px;
    width: 38px;
    min-width: 38px;
    max-width: 50px;
    padding-inline: 2px;
}

.member-item[data-social-ready="true"] .social-vocabulary-chip {
    width: 64px;
    min-width: 64px;
    height: 28px;
}

/* Chat metadata has the same narrow-column pressure as room members. Keep the
   current nickname readable while fitting avatar, title, statistics and time. */
:is(.room-chat-panel, .game-chat-panel) .chat-message-meta {
    grid-template-columns: 32px minmax(90px, 1fr) 68px auto;
    gap: 4px;
}

:is(.room-chat-panel, .game-chat-panel) .chat-message-meta > .social-avatar {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
}

:is(.room-chat-panel, .game-chat-panel) .chat-message-meta > .compact-social-identity {
    min-width: 90px;
}

:is(.room-chat-panel, .game-chat-panel) .chat-message-meta > .compact-social-identity > .social-name-copy {
    min-width: 48px;
    padding-inline: 4px;
    font-size: 14px;
}

:is(.room-chat-panel, .game-chat-panel) .chat-message-meta > .compact-social-identity > .social-cosmetic-title {
    flex-basis: 38px;
    width: 38px;
    min-width: 38px;
    max-width: 48px;
    padding-inline: 2px;
}

:is(.room-chat-panel, .game-chat-panel) .chat-message-meta > .social-vocabulary-chip {
    width: 68px;
    min-width: 68px;
    height: 28px;
}

/* Ranking cards only own row density; identity hierarchy comes from the shared
   compact identity contract above, exactly like headers, chat and room members. */
#lobby-screen .leaderboard-workbench .leaderboard-row {
    min-height: 64px;
    grid-template-rows: 44px auto;
}

@media (max-width: 760px) {
    .personal-center-layer { padding: 8px; }
    .personal-center-layer > .personal-center-modal {
        width: calc(100vw - 16px);
        height: calc(100dvh - 16px);
    }
    .personal-center-modal > .personal-center-heading { min-height: 66px; }
    .personal-center-modal > .personal-center-layout { height: calc(100% - 66px); }
    .reward-card-preview { width: 108px; height: 50px; }
    .reward-card-preview-avatar,
    .reward-card-preview-avatar-frame { width: 58px; height: 58px; }
}
