/* Guest profiles share the silver popup system; rank art is supplied by the user. */
.profile-badge{position:relative;display:inline-grid;place-items:center;flex:none;width:64px;height:64px;background-position:center;background-size:contain;background-repeat:no-repeat;isolation:isolate}
.profile-badge b{position:relative;z-index:1;font:700 20px/1 'Barlow Condensed',sans-serif;color:#fff!important;text-shadow:0 1px 2px #000,0 0 3px #000b;transform:translateY(-1px)}
.profile-badge[data-kind=elo] b{transform:translateY(-4px)}
.profile-badge[hidden]{display:none!important}
.profile-badge[data-inactive]{opacity:.45}
#snooker-preview #matchbar .profile-badges{display:flex;flex-direction:column;gap:1px;top:-2px;filter:drop-shadow(0 1px 1px #0008)}
#snooker-preview #matchbar .profile-badge{width:clamp(23px,3vw,36px);height:clamp(23px,3vw,36px);clip-path:none;background-size:contain;background-position:center;background-repeat:no-repeat}
#snooker-preview #matchbar .profile-badge::before{content:none}
#snooker-preview #matchbar .profile-badge b{font-size:clamp(10px,1.3vw,15px);letter-spacing:-.025em}
#snooker-preview #matchbar .profile-badge[data-kind=elo] b{transform:translateY(-2px)}
:root{--menu-profile-left:max(14px,env(safe-area-inset-left))}
#profileOpen{position:fixed;z-index:40;left:var(--menu-profile-left);top:max(10px,env(safe-area-inset-top));display:grid;grid-template-columns:42px minmax(0,1fr);align-items:center;column-gap:7px;box-sizing:border-box;width:min(167.4px,27.49vw);padding:5px 9px 5px 5px;overflow:visible;border:1px solid transparent;border-radius:999px;background:linear-gradient(160deg,#ffffff80,#eef3f680 34%,#dfe7ed80 67%,#cfd9e180) padding-box;-webkit-backdrop-filter:blur(16px);backdrop-filter:blur(16px);color:#262626;box-shadow:inset 0 1px 0 #ffffff66,0 3px 10px #0002;font:600 14px/1.15 'Barlow Condensed',sans-serif;cursor:pointer;text-align:left}
#profileOpen::after{content:'';position:absolute;inset:-1px;padding:1px;border-radius:inherit;background:linear-gradient(135deg,#fff,#8fa1ae 25%,#f6f9fb 49%,#7a8c99 73%,#e9eef2);-webkit-mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);-webkit-mask-composite:xor;mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);mask-composite:exclude;pointer-events:none}
#profileOpen .menu-profile-avatar{position:relative;display:block;width:42px;height:42px;margin-left:0}
#profileOpen .menu-profile-photo{display:block;width:42px;height:42px;object-fit:cover;border-radius:50%;box-shadow:0 0 0 1px #ffffffa6}
#profileOpen .menu-profile-badges{position:absolute;left:-13px;top:0;display:flex;flex-direction:column;gap:0;filter:drop-shadow(0 1px 1px #0008)}
#profileOpen .profile-badge{width:23.4px;height:23.4px}
#profileOpen .profile-badge b{font-size:10.8px;letter-spacing:-.025em}
#profileOpen .profile-badge[data-kind=elo] b{transform:translateY(-2px)}
#profileOpen .menu-profile-copy{display:grid;grid-template-rows:18px 14px 10px;min-width:0;gap:0}
#profileOpen .menu-profile-name{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13px;font-weight:700;line-height:18px}
#profileOpen .menu-profile-title{transform:translateY(-1px);display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:10.5px;font-weight:500;line-height:14px;letter-spacing:.035em;color:#3c4e5c}
#profileOpen .menu-profile-xp{width:92%;position:relative;display:grid;place-items:center;overflow:hidden;isolation:isolate;border-radius:3px;background:linear-gradient(#40586740,#6b829433);box-shadow:inset 0 1px 2px #1d344523,inset 0 -1px 0 #ffffff6b}
#profileOpen .menu-profile-xp-fill{position:absolute;inset:0 auto 0 0;width:100%;-webkit-mask-image:linear-gradient(90deg,#000 max(0px,calc(var(--menu-xp-progress,0%) - 1px)),transparent var(--menu-xp-progress,0%));mask-image:linear-gradient(90deg,#000 max(0px,calc(var(--menu-xp-progress,0%) - 1px)),transparent var(--menu-xp-progress,0%));filter:brightness(1.22) saturate(1.15);background:linear-gradient(90deg,#2cc9c0 0%,#2f7bf0 28%,#9b2fd8 58%,#e8264f 82%,#ff4a2e 100%);z-index:-1}
#profileOpen .menu-profile-xp-text{position:relative;font-size:8.5px;line-height:10px;letter-spacing:.05em;font-weight:700;color:#fff;text-shadow:0 1px 2px #17232d,0 0 2px #17232db3;font-variant-numeric:tabular-nums}
body.playing #profileOpen{display:none}
#profileOpen[data-profile-state=pending] .menu-profile-photo,#profileOpen[data-profile-state=pending] .menu-profile-badges,#profileOpen[data-profile-state=pending] .menu-profile-title,#profileOpen[data-profile-state=pending] .menu-profile-xp{visibility:hidden}
#profileOpen[data-profile-state=pending] .menu-profile-avatar{border-radius:50%;background:#ffffff35}
body #profileDialog{box-sizing:border-box;width:min(650px,calc(100vw - 28px));max-height:calc(100dvh - 24px);padding:18px 22px;font-family:'Barlow Condensed',sans-serif}
#profileDialog header{display:flex;justify-content:space-between;align-items:center;gap:15px}#profileDialog h2{margin:0;font-size:25px}#profileDialog header small{font-size:10px;letter-spacing:.14em}
#profileDialog button{cursor:pointer;padding:7px 12px;font:600 14px 'Barlow Condensed',sans-serif}
.profile-seats{display:flex;gap:8px;margin:12px 0}.profile-seats button{flex:1}
.profile-content{display:grid;grid-template-columns:115px minmax(0,1fr);gap:20px;max-height:calc(100dvh - 165px);overflow:auto;padding:1px 4px 3px 0}
.profile-identity{display:flex;flex-direction:column;align-items:center;gap:8px}#profilePortrait{width:92px;height:92px;object-fit:cover;border-radius:50%;border:1px solid #fff}
#profileBadges{display:flex;justify-content:center;gap:0}#profileBadges .profile-badge{width:56px;height:56px}
.profile-avatars{display:flex;gap:8px}.profile-avatars button{padding:3px!important;width:40px;height:40px;min-width:40px;min-height:40px;border-radius:50%!important;display:grid;place-items:center}.profile-avatars img{display:block;width:30px;height:30px;object-fit:cover;border-radius:50%}
.profile-details{min-width:0}.profile-choose{display:flex;align-items:center;gap:8px;margin-bottom:10px}.profile-choose select{min-width:0;flex:1}
#profileDialog :is(input,select){box-sizing:border-box;border:1px solid #fff;border-radius:7px;background:#f5f8fac9;color:#262626;padding:7px;font:500 14px 'Barlow',sans-serif}
#profileNameForm label{display:block;font-size:12px;margin-bottom:3px}#profileNameForm>div{display:flex;gap:8px}#guestName{min-width:0;flex:1}
.profile-xp{display:grid;grid-template-columns:1fr auto;gap:4px;margin-top:14px;font-size:14px}.profile-xp strong{font-size:19px}.profile-xp progress{grid-column:1/-1;width:100%;height:8px;appearance:none;border:0;border-radius:10px;overflow:hidden;background:#7c969549}
.profile-xp progress::-webkit-progress-bar{background:#7c969549}.profile-xp progress::-webkit-progress-value{background:linear-gradient(90deg,#258f82,#61b9a4)}.profile-xp progress::-moz-progress-bar{background:linear-gradient(90deg,#258f82,#61b9a4)}.profile-xp small{grid-column:1/-1;font-size:11px}
.profile-elo{margin:12px 0}.profile-elo strong{display:block;font-size:19px}.profile-elo small{display:block;font-size:11px;margin-top:2px}
#profileStats{display:grid;grid-template-columns:repeat(4,1fr);gap:7px}#profileStats>div{border-radius:8px;background:#ffffff3d;text-align:center;padding:6px 2px}#profileStats span{display:block;font-size:11px}#profileStats strong{display:block;font-size:21px;font-variant-numeric:tabular-nums}
#profileStorage{font:11px/1.4 'Barlow',sans-serif;margin-top:12px}
body #progressResult,body #concedeDialog{box-sizing:border-box;width:min(480px,calc(100vw - 32px));padding:22px;font-family:'Barlow Condensed',sans-serif}
#progressResult h2,#concedeDialog h2{margin:0;font-size:28px}.result-context{font-size:14px;margin:7px 0 15px}.result-rows{display:grid;grid-template-columns:1fr 1fr;gap:12px}.result-rows>div{display:flex;flex-direction:column;gap:5px;padding:12px;border-radius:12px;background:#ffffff40;min-width:0}.result-rows strong{font-size:18px;overflow-wrap:anywhere}.result-rows span{font-size:22px;font-weight:600}.result-rows small{font-size:13px}.result-storage{font-size:12px}.result-storage:empty{display:none}
.result-actions,#concedeDialog>div{display:flex;gap:10px;margin-top:18px}.result-actions button,#concedeDialog button{flex:1;min-height:38px;font:600 16px 'Barlow Condensed',sans-serif;cursor:pointer}
@media(max-height:390px){body #profileDialog{padding:12px 16px}.profile-seats{margin:8px 0}.profile-content{max-height:calc(100dvh - 140px)}#profileStorage{margin-top:8px}}

/* Online avatar profiles show only the identity/stat fields sent by the room. */
#profileDialog[data-online="true"] :is(.profile-seats,.profile-avatars,.profile-choose,#profileNameForm,#profileXP,#profileProgress,#profileTotalXP,.profile-elo){display:none!important}
#profileDialog[data-online] .profile-content{margin-top:14px}
#profileDialog[data-online] h2{overflow-wrap:anywhere}
#snooker-preview .hud-avatar[role=button]{pointer-events:auto;cursor:pointer;touch-action:manipulation;-webkit-tap-highlight-color:transparent}

#profileDialog[data-online="self"] :is(.profile-seats,.profile-choose){display:none!important}

/* Badges follow the circular portrait: level lower left, rank lower right. */
#profileOpen .menu-profile-badges [data-kind=level]{transform:translateY(-3px)}
#snooker-preview.snk-landscape #matchbar .hud-player .hud-level-wrap{inset:0;display:block;width:100%;height:100%}
#snooker-preview.snk-landscape #matchbar .hud-level-wrap .profile-badge{position:absolute;bottom:0}
#snooker-preview.snk-landscape #matchbar .hud-level-wrap [data-kind=level]{left:-10px;bottom:-1px}
#snooker-preview.snk-landscape #matchbar .hud-level-wrap [data-kind=elo]{right:-10px;bottom:-4px}
/* Freestanding menu identity: preserve the portrait, crests and progress bar. */
body #profileOpen,body #profileOpen:active,body #profileOpen.fcs-button-pressed{width:min(151px,25vw);padding:4px 0;background:none!important;border:0!important;border-radius:0;box-shadow:none!important;backdrop-filter:none;-webkit-backdrop-filter:none;color:#f4f7f9;text-shadow:0 1px 3px #101c29cc}
body #profileOpen::after,body #profileOpen::before{display:none!important}
#profileOpen .menu-profile-title{color:#e0e8ef;text-shadow:0 1px 3px #101c29cc}
#profileOpen .menu-profile-photo{box-shadow:0 0 0 1px #f2f8ffb0,0 3px 8px #10233355}
/* Restore the former card's 1px border + 5px inset without restoring its pill. */
body #profileOpen,body #profileOpen:active,body #profileOpen.fcs-button-pressed{padding-left:6px}
#profileOpen .menu-profile-xp{background:linear-gradient(#15212a9c,#2b3a4573);outline:none;border:0;box-shadow:inset 0 2px 3px #0610199c,inset 0 -1px 1px #19293638,0 1px 0 #edf4fa42}

/* Local/standalone fallback shares the public profile window controls. */
body #profileDialog{overflow:auto!important}
#profileDialog .profile-window-tools{display:flex;gap:3px;margin-left:auto}
body #profileDialog .profile-window-tools button{display:grid;place-items:center;width:32px;height:32px;min-height:32px;padding:7px;border:0!important;background:transparent!important;box-shadow:none!important}
#profileDialog .profile-window-tools svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round}
body #profileDialog[data-size=full]{width:100vw;height:100dvh;max-width:100vw;max-height:100dvh;border-radius:0!important}
body #profileDialog[data-size=table]{width:min(calc((100vw - 88px)*3569/3901),calc((100dvh - 4px)*3569/2110));height:min(calc((100vw - 88px)*1778/3901),calc((100dvh - 4px)*1778/2110))}
#snooker-preview .hud-name[role=button]{pointer-events:auto;cursor:pointer;touch-action:manipulation}

/* One anchor convention in every menu identity. */
body #profileOpen .menu-profile-badges{inset:0;display:block;pointer-events:none}
body #profileOpen .menu-profile-badges .profile-badge{position:absolute;left:0;top:auto;bottom:15%;transform:translate(-50%,50%);width:20px;height:23px}
body #profileOpen .menu-profile-badges [data-kind=elo]{left:100%}
#profileDialog .profile-identity{position:relative;width:100px;height:100px;margin:0 auto 18px}
#profileDialog #profileBadges{position:absolute;inset:0;pointer-events:none}
#profileDialog #profileBadges .profile-badge{position:absolute;left:0;bottom:15%;transform:translate(-50%,50%);width:44px;height:48px}
#profileDialog #profileBadges [data-kind=elo]{left:100%}

/* Leave the rank crest its half-width plus clear space before the XP bar. */
body #profileOpen{column-gap:18px}

/* Keep long level labels inside the crest face. */
.profile-badge[data-digits="3"] b{scale:.86}.profile-badge[data-digits="4"] b{scale:.7}
