/* The profile slot keeps the accepted framed dimensions before and after
   equipping a frame. Artwork openings remain owned by their frame styles. */
#matching-screen .v167-match-portrait {
    box-sizing:border-box;
    width:min(23vw,214px) !important;
    height:auto !important;
    min-height:0 !important;
    max-height:none !important;
    aspect-ratio:1 / 1 !important;
    flex:none;
}

/* Room portraits use the same square source/profile-frame artwork. */
#v186-online-root .v186-person > .v191-room-profile-portrait {
    box-sizing:border-box;
    width:54px !important;
    height:54px !important;
    min-height:0;
    aspect-ratio:1 / 1 !important;
}

/* v360: use the accepted Riana frame's actual portrait opening for a plain
   icon too. A square wrapper alone left the plain photo at almost 100%,
   while that frame's photo occupies 67.94258% of the same slot.
   Existing artwork keeps its own measured opening in v348. */
#matching-screen .v167-match-portrait:not(:has(> :is(.v197-mastery-profile-frame,.v175-illustrated-profile-frame,.v160-generated-profile-frame,.v161-pass-profile-frame))),
#v186-online-root .v191-room-profile-portrait:not(:has(> :is(.v197-mastery-profile-frame,.v191-room-profile-frame))),
body:not([data-v137-profile-frame]) :is(#v105-home-profile-button,#v105-profile-preview)[data-v105-frame="none"]:not([data-v197-mastery-frame]) > .v105-profile-emblem {
    --v360-profile-photo-left:15.39075%;
    --v360-profile-photo-top:16.26794%;
    --v360-profile-photo-size:67.94258%;
    /* Alpha >= 32 bounds of the original 512px frame: (8,5)-(502,499). */
    --v360-profile-outer-left:1.5625%;
    --v360-profile-outer-top:.9765625%;
    --v360-profile-outer-size:96.484375%;
    position:relative !important;
    isolation:isolate;
    padding:0 !important;
    border:0 !important;
    clip-path:none !important;
    overflow:visible !important;
    background:none !important;
    box-shadow:none !important;
}

/* Keep a quiet, full-size backing behind the smaller photo, rather than
   shrinking the whole icon down to the frame's inner opening. */
#matching-screen .v167-match-portrait:not(:has(> :is(.v197-mastery-profile-frame,.v175-illustrated-profile-frame,.v160-generated-profile-frame,.v161-pass-profile-frame)))::before,
#v186-online-root .v191-room-profile-portrait:not(:has(> :is(.v197-mastery-profile-frame,.v191-room-profile-frame)))::before,
body:not([data-v137-profile-frame]) :is(#v105-home-profile-button,#v105-profile-preview)[data-v105-frame="none"]:not([data-v197-mastery-frame]) > .v105-profile-emblem::before {
    content:"";
    position:absolute;
    left:var(--v360-profile-outer-left);
    top:var(--v360-profile-outer-top);
    width:var(--v360-profile-outer-size);
    height:var(--v360-profile-outer-size);
    box-sizing:border-box;
    border-radius:7px;
    background:#08090a;
    z-index:0;
    pointer-events:none;
}

#matching-screen .v167-match-portrait:not(:has(> :is(.v197-mastery-profile-frame,.v175-illustrated-profile-frame,.v160-generated-profile-frame,.v161-pass-profile-frame))) > :is(img,.v167-match-image-shade,.v167-match-image-fallback),
#v186-online-root .v191-room-profile-portrait:not(:has(> :is(.v197-mastery-profile-frame,.v191-room-profile-frame))) > img,
body:not([data-v137-profile-frame]) :is(#v105-home-profile-button,#v105-profile-preview)[data-v105-frame="none"]:not([data-v197-mastery-frame]) > .v105-profile-emblem > img {
    position:absolute !important;
    inset:auto !important;
    left:var(--v360-profile-photo-left) !important;
    top:var(--v360-profile-photo-top) !important;
    width:var(--v360-profile-photo-size) !important;
    height:var(--v360-profile-photo-size) !important;
    box-sizing:border-box;
    object-fit:cover !important;
    object-position:50% 24% !important;
    clip-path:none !important;
    border-radius:7px !important;
}

#v186-online-root .v191-room-profile-portrait:not(:has(> :is(.v197-mastery-profile-frame,.v191-room-profile-frame))) > img,
body:not([data-v137-profile-frame]) :is(#v105-home-profile-button,#v105-profile-preview)[data-v105-frame="none"]:not([data-v197-mastery-frame]) > .v105-profile-emblem > img { z-index:1; }

body:not([data-v137-profile-frame]) :is(#v105-home-profile-button,#v105-profile-preview)[data-v105-frame="none"]:not([data-v197-mastery-frame]) > .v105-profile-emblem::after { display:none !important; }

/* A missing legacy frame uses its existing colored rail. Previously inset
   -6px made this rail wider than the original mastery artwork itself. */
#matching-screen .v167-match-portrait > .v167-match-frame-fallback {
    inset:auto !important;
    left:1.5625% !important;
    top:.9765625% !important;
    width:96.484375% !important;
    height:96.484375% !important;
    box-sizing:border-box;
    border-radius:7px;
    background:none;
}

@media(max-width:620px) {
    #matching-screen .v167-match-portrait { width:min(29vw,150px) !important; }
}

@media(orientation:landscape) and (max-height:520px) {
    /* Keep the native compact profile grid; its first column owns the width. */
    #matching-screen .v167-match-portrait { width:100% !important; }
}
