/* Nối Từ Việt v3.9.43 — universal frame and VIP-title safe areas.
 * Loaded after legacy game, sprite, leaderboard, mobile and wardrobe styles.
 * Admin calibration is preserved; each component caps its own visible frame
 * to prevent overlaps, even for a 195% frame or uploaded artwork.
 */

/* Shared geometry: all sprite frames (ordinary, VIP, or uploaded). */
#ntv-game-root :is(.ntv-profile-avatar,.ntv-profile-pic,.ntv-person-avatar-wrap,.ntv-chat-avatar,.ntv-roster-avatar,.ntv-lb-portrait,.ntv-character-portrait){
  --ntv-safe-frame-limit:138%;
  --ntv-safe-face-inset:12%;
  isolation:isolate;min-width:0;
}
#ntv-game-root :is(.ntv-profile-avatar,.ntv-profile-pic,.ntv-person-avatar-wrap,.ntv-chat-avatar,.ntv-roster-avatar,.ntv-lb-portrait,.ntv-character-portrait)>.ntv-sprite-391{
  --ntv-safe-frame-render:min(var(--ntv-frame-size,100%),var(--ntv-safe-frame-limit,138%));
  display:block;max-width:100%;max-height:100%;aspect-ratio:1 / 1;
}
#ntv-game-root :is(.ntv-profile-avatar,.ntv-profile-pic,.ntv-person-avatar-wrap,.ntv-chat-avatar,.ntv-roster-avatar,.ntv-lb-portrait,.ntv-character-portrait)>.ntv-sprite-391>img[data-ntv-part="frame"]{
  inset:calc((100% - var(--ntv-safe-frame-render))/2)!important;
  width:var(--ntv-safe-frame-render)!important;
  height:var(--ntv-safe-frame-render)!important;
  max-width:none!important;max-height:none!important;object-fit:contain!important;
  transform:translate(clamp(-5%,var(--ntv-frame-x,0%),5%),clamp(-5%,var(--ntv-frame-y,0%),5%))!important;
  pointer-events:none;
}
#ntv-game-root :is(.ntv-profile-avatar,.ntv-profile-pic,.ntv-person-avatar-wrap,.ntv-chat-avatar,.ntv-roster-avatar,.ntv-lb-portrait,.ntv-character-portrait)>.ntv-sprite-391>.ntv-sprite-art{
  inset:var(--ntv-safe-face-inset,12%)!important;overflow:hidden!important;border-radius:50%!important;
}

/* Photo avatars never get a second overlay when the sprite engine renders a frame. */
#ntv-game-root :is(.ntv-profile-avatar,.ntv-profile-pic,.ntv-person-avatar-wrap,.ntv-chat-avatar,.ntv-roster-avatar,.ntv-lb-portrait,.ntv-character-portrait):is([class*="ntv-frame-vip_"],.ntv-frame-custom):not(:has(>.ntv-sprite-391)){
  --ntv-safe-photo-frame:min(var(--ntv-frame-size,145%),var(--ntv-safe-frame-limit,138%));
  overflow:visible!important;position:relative;isolation:isolate;
}
#ntv-game-root :is(.ntv-profile-avatar,.ntv-profile-pic,.ntv-person-avatar-wrap,.ntv-chat-avatar,.ntv-roster-avatar,.ntv-lb-portrait,.ntv-character-portrait):is([class*="ntv-frame-vip_"],.ntv-frame-custom):not(:has(>.ntv-sprite-391))::after{
  content:""!important;position:absolute!important;pointer-events:none!important;
  inset:calc((100% - var(--ntv-safe-photo-frame))/2)!important;
  width:var(--ntv-safe-photo-frame)!important;height:var(--ntv-safe-photo-frame)!important;
  background:var(--ntv-vip-art) center/contain no-repeat!important;
  transform:translate(clamp(-5%,var(--ntv-frame-x,0%),5%),clamp(-5%,var(--ntv-frame-y,0%),5%))!important;
  filter:drop-shadow(0 1px 2px #44302533);z-index:3;
}
#ntv-game-root :is(.ntv-profile-avatar,.ntv-profile-pic,.ntv-roster-avatar,.ntv-chat-avatar,.ntv-lb-portrait,.ntv-character-portrait):is([class*="ntv-frame-vip_"],.ntv-frame-custom):not(:has(>.ntv-sprite-391))>img{
  width:78%!important;height:78%!important;min-width:0;object-fit:cover!important;border-radius:50%!important;position:relative;z-index:1;
}
#ntv-game-root .ntv-person-avatar-wrap:is([class*="ntv-frame-vip_"],.ntv-frame-custom):not(:has(>.ntv-sprite-391))>.ntv-person-avatar{
  width:78%!important;height:78%!important;object-fit:cover!important;border-radius:50%!important;
}

/* Titles reserve real space in layout, not floating on top of labels/cups. */
#ntv-game-root .ntv-vip-title{
  --ntv-safe-title-height:28px;
  display:block!important;box-sizing:border-box;
  position:relative;z-index:4;flex:0 0 auto;min-width:0;min-height:0!important;
  width:min(100%,var(--ntv-safe-title-width,120px))!important;
  max-width:100%!important;height:var(--ntv-safe-title-height)!important;
  margin:3px auto 0!important;overflow:hidden!important;pointer-events:none;
}
#ntv-game-root .ntv-vip-title>img{
  display:block!important;width:100%!important;height:var(--ntv-safe-title-height,28px)!important;
  max-width:100%!important;max-height:var(--ntv-safe-title-height,28px)!important;
  object-fit:contain!important;object-position:center!important;
  border:0!important;border-radius:0!important;box-shadow:none!important;
}
#ntv-game-root :is(.ntv-home-avatar-stack,.ntv-profile-avatar-stack,.ntv-room-avatar-stack,.ntv-lb-avatar-stack){
  box-sizing:border-box;min-width:0;max-width:100%;overflow:visible;
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  flex-shrink:0;gap:0;
}

/* Home account strip: 43–46px portrait inside a protected 68px column. */
#ntv-game-root .ntv-home-avatar-stack{width:70px!important;min-width:70px!important;padding:9px 1px 0}
#ntv-game-root .ntv-home-avatar-stack>.ntv-profile-avatar{width:44px;height:44px;--ntv-safe-frame-limit:138%;--ntv-safe-face-inset:12%;margin:0 auto 9px}
#ntv-game-root .ntv-home-avatar-stack>.ntv-vip-title{--ntv-safe-title-width:68px;--ntv-safe-title-height:30px}
#ntv-game-root .ntv-profile-card{min-width:0;gap:7px;overflow:hidden}
#ntv-game-root .ntv-profile-card .ntv-profile-text{min-width:0;overflow:hidden}

/* Public profile popup; title is a separate row beneath the portrait. */
#ntv-game-root .ntv-profile-avatar-stack{width:132px!important;min-width:120px!important;padding:16px 3px 0}
#ntv-game-root .ntv-profile-avatar-stack>.ntv-profile-pic{width:82px;height:82px;flex:0 0 82px;--ntv-safe-frame-limit:140%;margin:0 auto 15px}
#ntv-game-root .ntv-profile-avatar-stack>.ntv-vip-title{--ntv-safe-title-width:125px;--ntv-safe-title-height:48px}
#ntv-game-root .ntv-profile-hero{min-width:0;gap:10px;overflow:hidden}
#ntv-game-root .ntv-profile-hero>:not(.ntv-profile-avatar-stack){min-width:0}

/* Room roster and active players: reserve crown and bottom ribbon space. */
#ntv-game-root .ntv-room-avatar-stack{width:92px!important;min-width:86px!important;padding:10px 0 0}
#ntv-game-root .ntv-room-avatar-stack>.ntv-roster-avatar{width:54px;height:54px;--ntv-safe-frame-limit:136%;margin:0 auto 12px;flex:0 0 54px}
#ntv-game-root .ntv-room-avatar-stack>.ntv-vip-title{--ntv-safe-title-width:88px;--ntv-safe-title-height:36px}
#ntv-game-root .ntv-roster-card{overflow:hidden;min-width:0;align-items:center}
#ntv-game-root .ntv-roster-card>span:nth-child(2){min-width:0;overflow:hidden}
#ntv-game-root .ntv-person:has(>.ntv-vip-title){min-height:193px!important;padding-top:18px!important;overflow:hidden}
#ntv-game-root .ntv-person-avatar-wrap{--ntv-safe-frame-limit:130%;margin:12px auto 13px}
#ntv-game-root .ntv-person>.ntv-vip-title{--ntv-safe-title-width:92px;--ntv-safe-title-height:37px;margin:0 auto 3px!important}
#ntv-game-root .ntv-person .ntv-person-name{max-width:100%;overflow:hidden;text-overflow:ellipsis}
#ntv-game-root .ntv-chat-avatar{--ntv-safe-frame-limit:123%;--ntv-safe-face-inset:10%;flex-shrink:0}

/* Leaderboard: individual cards reserve space above and below the avatar. */
#ntv-game-root .ntv-lb-podium{max-width:100%;gap:clamp(4px,1vw,12px);padding-top:36px}
#ntv-game-root .ntv-lb-podium-card{max-width:100%;min-width:0;overflow:hidden;padding:44px 7px 14px;gap:4px}
#ntv-game-root .ntv-lb-podium-card.ntv-lb-gold{padding-top:48px}
#ntv-game-root .ntv-lb-podium-card>.ntv-lb-portrait{--ntv-safe-frame-limit:128%;--ntv-safe-face-inset:9%;width:72px;height:72px;margin:5px auto 13px;flex:0 0 72px}
#ntv-game-root .ntv-lb-gold>.ntv-lb-portrait{width:86px;height:86px;flex-basis:86px}
#ntv-game-root .ntv-lb-podium-card>.ntv-vip-title{--ntv-safe-title-width:132px;--ntv-safe-title-height:44px;margin:0 auto 4px!important}
#ntv-game-root .ntv-lb-podium-card>.ntv-lb-name,#ntv-game-root .ntv-lb-podium-card>.ntv-lb-score{max-width:100%;min-width:0}
#ntv-game-root .ntv-lb-avatar-stack{width:76px!important;min-width:70px!important;padding:7px 0 0}
#ntv-game-root .ntv-lb-avatar-stack>.ntv-lb-portrait{--ntv-safe-frame-limit:130%;--ntv-safe-face-inset:10%;width:50px;height:50px;margin:0 auto 9px;flex:0 0 50px}
#ntv-game-root .ntv-lb-avatar-stack>.ntv-vip-title{--ntv-safe-title-width:76px;--ntv-safe-title-height:34px}
#ntv-game-root .ntv-lb-entry{overflow:hidden;min-width:0}
#ntv-game-root .ntv-lb-entry-score{overflow:hidden;text-overflow:ellipsis;min-width:0}

/* Character preview in the older game wardrobe (not the fullscreen wardrobe). */
#ntv-game-root .ntv-character-portrait{--ntv-safe-frame-limit:135%;margin:10px 10px 12px;overflow:visible}
#ntv-game-root .ntv-character-portrait img{max-width:100%;max-height:100%}

/* All 12 titles and any future custom title: bounded thumbnails. */
#ntv-game-root .ntv-vip-title-grid{min-width:0;max-width:100%;grid-template-columns:repeat(auto-fit,minmax(min(100%,130px),1fr))}
#ntv-game-root .ntv-vip-title-choice{overflow:hidden;min-width:0;max-width:100%;overflow-wrap:anywhere}
#ntv-game-root .ntv-vip-title-choice>img{display:block!important;width:100%!important;height:58px!important;max-width:100%!important;object-fit:contain!important}

@media(max-width:620px){
  #ntv-game-root .ntv-profile-avatar-stack{width:99px!important;min-width:92px!important;padding-top:12px}
  #ntv-game-root .ntv-profile-avatar-stack>.ntv-profile-pic{width:64px;height:64px;flex-basis:64px;margin-bottom:12px}
  #ntv-game-root .ntv-profile-avatar-stack>.ntv-vip-title{--ntv-safe-title-width:95px;--ntv-safe-title-height:39px}
  #ntv-game-root .ntv-room-avatar-stack{width:83px!important;min-width:78px!important}
  #ntv-game-root .ntv-room-avatar-stack>.ntv-vip-title{--ntv-safe-title-width:80px;--ntv-safe-title-height:33px}
  #ntv-game-root .ntv-lb-avatar-stack{width:68px!important;min-width:65px!important}
  #ntv-game-root .ntv-lb-avatar-stack>.ntv-lb-portrait{width:44px;height:44px;flex-basis:44px}
  #ntv-game-root .ntv-lb-avatar-stack>.ntv-vip-title{--ntv-safe-title-width:64px;--ntv-safe-title-height:28px}
  #ntv-game-root .ntv-lb-podium-card{padding:35px 4px 11px}
  #ntv-game-root .ntv-lb-podium-card.ntv-lb-gold{padding-top:40px}
  #ntv-game-root .ntv-lb-podium-card>.ntv-lb-portrait{width:49px;height:49px;flex-basis:49px;margin-bottom:9px;--ntv-safe-frame-limit:125%}
  #ntv-game-root .ntv-lb-gold>.ntv-lb-portrait{width:60px;height:60px;flex-basis:60px}
  #ntv-game-root .ntv-lb-podium-card>.ntv-vip-title{--ntv-safe-title-width:96px;--ntv-safe-title-height:35px}
  #ntv-game-root .ntv-person:has(>.ntv-vip-title){min-height:179px!important}
}
@media(max-width:390px){
  #ntv-game-root .ntv-home-avatar-stack{width:62px!important;min-width:62px!important}
  #ntv-game-root .ntv-home-avatar-stack>.ntv-profile-avatar{width:40px;height:40px}
  #ntv-game-root .ntv-home-avatar-stack>.ntv-vip-title{--ntv-safe-title-width:61px;--ntv-safe-title-height:27px}
  #ntv-game-root .ntv-lb-podium-card>.ntv-lb-portrait{width:43px;height:43px;flex-basis:43px}
  #ntv-game-root .ntv-lb-gold>.ntv-lb-portrait{width:53px;height:53px;flex-basis:53px}
}

/* Full-screen wardrobe uses a square art anchor. Frame image may exceed the
 * character, but NEVER the preview stage or profile column. */
#ntv-wardrobe-layer .ntv-wardrobe .ntv-profile-top{min-width:0;gap:10px}
#ntv-wardrobe-layer .ntv-wardrobe .ntv-wardrobe-avatar-stack{
  box-sizing:border-box;width:132px;min-width:112px;max-width:100%;padding:18px 1px 0;
  display:flex;flex-direction:column;align-items:center;justify-content:center;overflow:visible;
}
#ntv-wardrobe-layer .ntv-wardrobe .ntv-profile-portrait{
  box-sizing:border-box;width:94px!important;height:94px!important;flex:0 0 94px;
  margin:0 auto 17px!important;position:relative;isolation:isolate;overflow:visible!important;
}
#ntv-wardrobe-layer .ntv-wardrobe .ntv-profile-portrait>.ntv-sprite-391{
  --ntv-safe-frame-render:min(var(--ntv-frame-size,100%),136%);
  max-width:100%;max-height:100%;
}
#ntv-wardrobe-layer .ntv-wardrobe .ntv-profile-portrait>.ntv-sprite-391>.ntv-sprite-art{
  inset:13%!important;overflow:hidden!important;border-radius:50%!important;
}
#ntv-wardrobe-layer .ntv-wardrobe .ntv-profile-portrait>.ntv-sprite-391>img[data-ntv-part="frame"]{
  inset:calc((100% - var(--ntv-safe-frame-render))/2)!important;
  width:var(--ntv-safe-frame-render)!important;height:var(--ntv-safe-frame-render)!important;
  max-width:none!important;max-height:none!important;object-fit:contain!important;
  transform:translate(clamp(-5%,var(--ntv-frame-x,0%),5%),clamp(-5%,var(--ntv-frame-y,0%),5%))!important;
}
#ntv-wardrobe-layer .ntv-wardrobe .ntv-wardrobe-avatar-stack>.ntv-vip-title-image{
  box-sizing:border-box;width:126px!important;max-width:100%!important;height:42px!important;max-height:42px!important;
  margin:0!important;display:block!important;object-fit:contain!important;object-position:center!important;
}
#ntv-wardrobe-layer .ntv-wardrobe .ntv-profile-info{min-width:0;max-width:100%;overflow-wrap:anywhere}
#ntv-wardrobe-layer .ntv-wardrobe .ntv-profile-info h3{max-width:100%;overflow-wrap:anywhere}

/* The old stage was 90% wide and let a 180% frame escape into buttons.
 * A centered 55% square with a capped 135% frame fits even narrow stages. */
#ntv-wardrobe-layer .ntv-wardrobe .ntv-stage{position:relative;overflow:hidden!important;isolation:isolate}
#ntv-wardrobe-layer .ntv-wardrobe .ntv-character-canvas{
  position:absolute!important;inset:auto!important;top:44%!important;left:50%!important;
  width:min(55%,182px)!important;height:auto!important;aspect-ratio:1/1!important;
  max-width:55%!important;transform:translate(-50%,-50%)!important;
  overflow:visible!important;isolation:isolate;z-index:2;
}
#ntv-wardrobe-layer .ntv-wardrobe .ntv-character-canvas .ntv-sprite[data-sprite="frame"]{
  --ntv-safe-frame-render:min(var(--ntv-frame-size,100%),135%);
  inset:calc((100% - var(--ntv-safe-frame-render))/2)!important;
  width:var(--ntv-safe-frame-render)!important;height:var(--ntv-safe-frame-render)!important;
  max-width:none!important;max-height:none!important;object-fit:contain!important;
  transform:translate(clamp(-5%,var(--ntv-frame-x,0%),5%),clamp(-5%,var(--ntv-frame-y,0%),5%))!important;
}
#ntv-wardrobe-layer .ntv-wardrobe .ntv-stage-status{z-index:5}

/* The frame grid and title grid must not borrow size from the actual PNG. */
#ntv-wardrobe-layer .ntv-wardrobe .ntv-item-grid{min-width:0;max-width:100%;}
#ntv-wardrobe-layer .ntv-wardrobe .ntv-item{min-width:0;max-width:100%;overflow:hidden;}
#ntv-wardrobe-layer .ntv-wardrobe .ntv-item-media{width:100%;max-width:100%;overflow:hidden!important;}
#ntv-wardrobe-layer .ntv-wardrobe .ntv-item-media>.ntv-item-img{
  display:block!important;max-width:100%!important;max-height:100%!important;
  width:100%!important;height:100%!important;object-fit:contain!important;object-position:center!important;
}
#ntv-wardrobe-layer .ntv-wardrobe .ntv-vip-title-grid{min-width:0;max-width:100%;grid-template-columns:repeat(auto-fit,minmax(min(100%,120px),1fr));}
#ntv-wardrobe-layer .ntv-wardrobe .ntv-vip-title-choice{min-width:0;max-width:100%;overflow:hidden;overflow-wrap:anywhere}
#ntv-wardrobe-layer .ntv-wardrobe .ntv-vip-title-choice>.ntv-vip-title-image{
  display:block!important;width:100%!important;height:70px!important;
  max-width:100%!important;max-height:70px!important;object-fit:contain!important;
}

@media(max-width:900px){
  #ntv-wardrobe-layer .ntv-wardrobe .ntv-wardrobe-avatar-stack{width:120px;min-width:110px;padding-top:14px}
  #ntv-wardrobe-layer .ntv-wardrobe .ntv-profile-portrait{width:86px!important;height:86px!important;flex-basis:86px;margin-bottom:14px!important}
  #ntv-wardrobe-layer .ntv-wardrobe .ntv-wardrobe-avatar-stack>.ntv-vip-title-image{width:116px!important;height:36px!important;max-height:36px!important}
}
@media(max-width:430px){
  #ntv-wardrobe-layer .ntv-wardrobe .ntv-wardrobe-avatar-stack{width:104px;min-width:104px}
  #ntv-wardrobe-layer .ntv-wardrobe .ntv-profile-portrait{width:75px!important;height:75px!important;flex-basis:75px;margin-bottom:11px!important}
  #ntv-wardrobe-layer .ntv-wardrobe .ntv-wardrobe-avatar-stack>.ntv-vip-title-image{width:101px!important;height:32px!important;max-height:32px!important}
  #ntv-wardrobe-layer .ntv-wardrobe .ntv-character-canvas{width:min(55%,155px)!important}
}
