/* V39.8: stable player identity above every game scene. */
#player-hud{position:absolute;left:16px;top:12px;width:240px;height:60px;z-index:16;pointer-events:auto}
#player-hud[hidden]{display:none}
.player-hud-button{width:100%;height:100%;display:flex;align-items:center;gap:10px;padding:6px 9px;color:#edf6fa;text-align:left;border:1px solid #b6d5e43a;border-radius:12px;background:linear-gradient(130deg,#102433ed,#081721ed);box-shadow:0 5px 20px #0003;backdrop-filter:blur(16px)}
.player-hud-button:hover{border-color:var(--accent);background:#173344f2}
.profile-avatar{position:relative;display:block;flex:0 0 46px;width:46px;height:46px;overflow:hidden;border:1px solid #87b6ce88;border-radius:9px;background:#142938}
.profile-avatar-art{position:absolute;inset:0;background-image:url('assets/unit_portraits.webp');background-size:512% 768%;background-position:3.8835% var(--portrait-row);background-repeat:no-repeat;display:none}
.profile-avatar.has-portrait .profile-avatar-art{display:block}.profile-avatar.has-portrait .profile-avatar-fallback{display:none}
.profile-avatar-fallback{display:grid;place-items:center;height:100%;font-size:22px;font-weight:700;color:var(--accent)}
.player-hud-copy{min-width:0;flex:1}.profile-name-line{display:flex;align-items:center;gap:6px;min-width:0}
.profile-race-emblem{width:23px;height:25px;object-fit:contain;flex:none;filter:drop-shadow(0 1px 3px #0009)}
.player-hud-copy [data-profile-name]{font-size:13px;font-weight:650;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.4}
.player-hud-power{display:flex;gap:6px;align-items:baseline;margin-top:3px;min-width:0;font-size:9px;color:#9db6c7;white-space:nowrap}.player-hud-power strong{font-size:12px;font-weight:650;color:#efcd86;font-variant-numeric:tabular-nums}
html[data-screen] .top .brand,html[data-screen] .top .topright{display:none}
html[data-screen] #resources{left:272px;right:20px;top:12px;width:auto;max-width:none;transform:none;grid-template-columns:repeat(7,minmax(108px,1fr));overflow-x:auto;scrollbar-width:thin}
html[data-hud="hidden"] #player-hud{visibility:hidden;pointer-events:none}
.player-profile-dialog{width:min(640px,calc(100vw - 32px));max-height:min(820px,90dvh);margin:auto;padding:0;border:1px solid #718d9b80;border-radius:16px;background:linear-gradient(140deg,#102431,#07151f);color:#e8f2f7;box-shadow:0 25px 100px #000a;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin}
.player-profile-dialog::backdrop{background:#020a12b8;backdrop-filter:blur(8px)}
.player-profile-heading{position:sticky;top:0;display:flex;align-items:center;justify-content:space-between;padding:18px 24px 10px;background:#10212ef5;z-index:2}
.profile-kicker{font-size:10px;letter-spacing:.18em;color:#e5c27a;font-weight:650}.profile-close{width:36px;height:36px;display:grid;place-items:center;border:1px solid #6e8c9d66;border-radius:7px;background:#0b1c28;color:#c3d9e7}
.profile-close:hover{background:#254251}
.player-profile-identity{display:flex;gap:18px;align-items:center;padding:12px 24px 24px;border-bottom:1px solid #47617066;margin-bottom:0}
.player-profile-identity .profile-avatar{width:84px;height:84px;flex-basis:84px;border-radius:14px}
.player-profile-title{min-width:0;flex:1}.player-profile-title h2{margin:0 0 8px;font-size:25px;line-height:1.3;letter-spacing:0}.player-profile-title [data-profile-name]{overflow-wrap:anywhere;min-width:0}.player-profile-title .profile-race-emblem{width:29px;height:32px}.player-profile-title p{margin:0;font-size:12px;color:#9fb7c8}.player-profile-title p strong{color:#dbeaf2;font-weight:500}
.player-profile-ratings{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin:0;padding:22px 24px 14px}
.profile-rating{padding:14px 16px;border:1px solid #6f92a533;border-radius:9px;background:#29455222;min-width:0}
.profile-rating[data-profile-category="overall"]{background:#b9a36b12;border-color:#d1b07155}
.profile-rating dt{display:flex;align-items:center;gap:7px;font-size:11px;color:#b2c8d6}.profile-rating-icon{width:18px;height:18px;display:inline-flex;color:#8bafc4}.profile-rating-icon svg{width:18px;height:18px}
.profile-rating dd{margin:8px 0 5px;font-size:23px;line-height:1.2;font-weight:650;font-variant-numeric:tabular-nums;overflow-wrap:anywhere;color:#edf5f8}.profile-rating[data-profile-category="overall"] dd{color:#f0cd87}
.profile-rating-hint{font-size:10px;color:#88a4b8;line-height:1.5}
#player-profile-explanation{margin:0;padding:0 24px 18px;color:#9db3c1;font-size:11px;line-height:1.6}
.player-profile-dialog footer{display:flex;justify-content:flex-end;padding:14px 24px 18px;border-top:1px solid #47617055}.player-profile-dialog footer .btn{min-width:110px}
@media(min-width:761px) and (max-width:1200px){#player-hud{left:12px;width:216px}.player-hud-button{gap:7px;padding:6px}.profile-avatar{width:42px;height:42px;flex-basis:42px}html[data-screen] #resources{left:240px;right:12px}.player-hud-power{font-size:8px}.player-hud-power strong{font-size:11px}}
@media(max-width:760px){
 #player-hud{top:7px;left:10px;width:calc(100% - 174px);height:45px}
 .player-hud-button{gap:6px;padding:3px 5px;border-radius:8px}.profile-avatar{width:35px;height:35px;flex-basis:35px;border-radius:6px}
 .player-hud-copy [data-profile-name]{font-size:11px}.profile-name-line{gap:4px}.profile-race-emblem{width:17px;height:19px}
 .player-hud-power{font-size:8px;gap:4px;margin-top:1px}.player-hud-power strong{font-size:10px}.player-hud-power>span{display:none}.player-hud-power:before{content:'Мощь';color:#9db6c7}
 html[data-screen] #resources{left:8px;right:8px;top:60px;width:auto;height:56px;transform:none;display:flex;overflow-x:auto;padding:0 5px;border-radius:10px;border:1px solid #bedfec33;background:#081923e8;scrollbar-width:none}
 html[data-screen] #resources .resource{min-width:104px;flex:0 0 auto}
 .player-profile-dialog{width:calc(100vw - 20px);max-height:calc(100dvh - 24px);border-radius:13px}
 .player-profile-heading{padding:12px 16px 8px}.player-profile-identity{padding:8px 16px 18px;gap:12px}.player-profile-identity .profile-avatar{width:64px;height:64px;flex-basis:64px;border-radius:10px}
 .player-profile-title h2{font-size:19px}.player-profile-title .profile-race-emblem{width:24px;height:27px}.player-profile-title p{font-size:11px}
 .player-profile-ratings{gap:8px;padding:16px 12px 12px}.profile-rating{padding:11px 10px}.profile-rating dt{font-size:10px;gap:5px}.profile-rating dd{font-size:20px}.profile-rating-hint{font-size:9px}
 #player-profile-explanation{padding:0 16px 14px;font-size:10px}.player-profile-dialog footer{padding:12px 16px}.player-profile-dialog footer .btn{min-height:42px}
}
@media(max-width:360px){.player-hud-button{gap:4px;padding:3px}.profile-avatar{width:30px;height:35px;flex-basis:30px}.player-hud-copy [data-profile-name]{font-size:10px}.profile-rating dt{min-height:28px}.profile-rating-icon{display:none}.player-profile-title h2{font-size:17px}}

@media(max-width:760px){
 html[data-screen] .hud-primary-actions{top:10px;right:10px;gap:6px}
 html[data-screen] .hud-primary-actions>button{width:32px;height:36px;padding:5px;gap:0;border-radius:7px}
 html[data-screen="planet"] .planet-head.scene-heading{top:126px}
}

/* V39.9: shared public player links and ranking cards. */
button.player-name-link{display:inline;padding:0;margin:0;border:0;border-radius:3px;background:none;box-shadow:none;min-width:0;min-height:0;width:auto;height:auto;font:inherit;line-height:inherit;letter-spacing:inherit;text-transform:none;color:inherit;text-align:inherit;vertical-align:baseline;cursor:pointer;text-decoration:underline;text-decoration-color:#94c5db66;text-underline-offset:3px;overflow-wrap:anywhere}
button.player-name-link:hover{color:#9ddbff;text-decoration-color:currentColor;background:none}
button.player-name-link:focus-visible,.player-profile-hit:focus-visible{outline:2px solid #8bd1ff;outline-offset:3px}
.player-profile-hit{cursor:pointer}
.player-name-svg[data-player-profile]{pointer-events:all;cursor:pointer;text-decoration:underline;text-decoration-color:#8abdd480;text-underline-offset:3px}
.player-name-svg:hover,.player-name-svg:focus{fill:#ace3ff;outline:0;text-decoration-thickness:2px}
button.ranking-row{width:100%;text-align:left;color:inherit;cursor:pointer;font:inherit;transition:background .15s,border-color .15s}
button.ranking-row:hover{background:#244356aa;border-color:#96c8df88}
button.ranking-row:focus-visible{outline:2px solid #8bd1ff;outline-offset:2px}
.ranking-player-identity{display:flex;gap:10px;align-items:center;min-width:0}
.ranking-player-identity>.profile-avatar{flex-basis:38px;width:38px;height:38px}
.ranking-player-identity>span:last-child{min-width:0}
.ranking-player-identity .profile-name-line{display:flex}
.ranking-player-identity .profile-name-line strong{overflow-wrap:anywhere;min-width:0}
.ranking-player-identity .profile-race-emblem{width:19px;height:22px}
.profile-request-state{padding:16px 24px 6px;font-size:12px;color:#adc7d8;min-height:80px}
.profile-request-state p{margin:0 0 12px;line-height:1.6}
.profile-request-state[hidden],.player-profile-dialog [hidden]{display:none!important}
@media(max-width:760px){.ranking-player-identity{gap:7px}.ranking-player-identity>.profile-avatar{flex-basis:30px;width:30px;height:34px}.ranking-player-identity .profile-race-emblem{width:16px;height:20px}.profile-request-state{padding:16px}.ranking-row em{overflow-wrap:anywhere;min-width:0}}

/* V39.10: personal images preserve the race portrait as a loading/error fallback. */
.profile-avatar-custom{display:none;position:absolute;inset:0;width:100%;height:100%;object-fit:cover}
.profile-avatar.has-custom .profile-avatar-custom{display:block}.profile-avatar.has-custom .profile-avatar-art,.profile-avatar.has-custom .profile-avatar-fallback{display:none}
.profile-avatar-controls{padding:13px 24px 15px;border-bottom:1px solid #47617066}
.profile-avatar-controls>div{display:flex;align-items:center;flex-wrap:wrap;gap:12px}
.profile-avatar-controls .btn{font-size:11px;padding:7px 12px}
.profile-avatar-controls .player-name-link{font-size:11px;color:#a2bfce}
.profile-avatar-controls small{display:block;color:#89a6b8;font-size:10px;margin-top:9px;line-height:1.5}
.profile-avatar-controls p{font-size:11px;line-height:1.5;color:#b5d8e9;margin:7px 0 0}
.profile-avatar-controls p:empty{display:none}
.avatar-editor-dialog{width:min(440px,calc(100vw - 24px));max-height:calc(100dvh - 24px);margin:auto;padding:20px;border:1px solid #718d9b80;border-radius:15px;background:linear-gradient(140deg,#102431,#07151f);color:#e8f2f7;overflow:auto;overscroll-behavior:contain;box-shadow:0 25px 100px #000a;scrollbar-width:thin}
.avatar-editor-dialog::backdrop{background:#020a12b8;backdrop-filter:blur(5px)}
.avatar-editor-dialog header{display:flex;justify-content:space-between;align-items:center;gap:16px}.avatar-editor-dialog header small{font-size:9px;letter-spacing:.15em;color:#e5c27a}.avatar-editor-dialog h2{font-size:20px;margin:5px 0 0}
.avatar-editor-intro{font-size:12px;line-height:1.5;color:#a4bfd0;margin:16px 0}
.avatar-crop-frame{width:256px;max-width:100%;margin:0 auto;border:1px solid #75a2b8;border-radius:10px;overflow:hidden;background:repeating-conic-gradient(#263e4c 0% 25%,#162b37 0% 50%) 50%/20px 20px}
.avatar-crop-frame canvas{display:block;width:100%;height:auto;touch-action:none;cursor:grab}.avatar-crop-frame canvas.dragging{cursor:grabbing}.avatar-crop-frame:focus-within{outline:2px solid #8bd1ff;outline-offset:3px}
.avatar-crop-sliders{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-top:16px}.avatar-crop-sliders label:first-child{grid-column:1/-1}.avatar-crop-sliders label{font-size:11px;color:#a8c1d0}.avatar-crop-sliders output{float:right;color:#e5c27a}.avatar-crop-sliders input{display:block;width:100%;min-height:24px;margin:5px 0 0;padding:0;accent-color:#82c9ef}
.avatar-editor-status{font-size:11px;line-height:1.5;min-height:32px;color:#b3cddb;margin:15px 0}
.avatar-editor-dialog footer{display:flex;justify-content:flex-end;gap:10px;border-top:1px solid #47617066;padding-top:16px}.avatar-editor-dialog footer .btn{font-size:12px;min-height:40px}.avatar-editor-dialog button:disabled{opacity:.55;cursor:wait}
@media(max-width:760px){.profile-avatar-controls{padding:12px 16px}.avatar-editor-dialog{padding:16px}.avatar-editor-dialog h2{font-size:18px}}

/* V39.11: private inventory below the owner's profile, in the same scroll area. */
.player-profile-dialog.is-own-profile{width:min(720px,calc(100vw - 32px));max-height:calc(100dvh - 32px)}
.is-own-profile .player-profile-ratings{grid-template-columns:repeat(3,minmax(0,1fr));gap:9px;padding:16px 24px 12px}
.is-own-profile .profile-rating{padding:12px}.is-own-profile .profile-rating dd{font-size:21px}
.is-own-profile .player-profile-identity{padding-bottom:16px}.is-own-profile .player-profile-identity .profile-avatar{width:72px;height:72px;flex-basis:72px}
.player-inventory{padding:17px 24px 19px;border-top:1px solid #647e9055;background:#0717205e}
.player-inventory>header{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:13px}
.player-inventory>header>div{display:flex;align-items:center;gap:9px;min-width:0}
.player-inventory h3{font-size:15px;line-height:1.4;margin:0;letter-spacing:.02em;color:#deedf5}
.inventory-symbol{display:inline-flex;width:21px;height:21px;color:#a2c7dc}.inventory-symbol svg{width:100%;height:100%}
.inventory-count{font-size:10px;color:#8da9bb;white-space:nowrap}
.inventory-empty-slots{display:grid;grid-template-columns:repeat(8,minmax(0,1fr));gap:8px}
.inventory-empty-slot{height:58px;border:1px dashed #5c80924d;border-radius:7px;background:linear-gradient(145deg,#23435528,#0d222c60);display:grid;place-items:center;color:#5b7e8c55}
.inventory-empty-slot>span{width:8px;height:1px;background:currentColor}.inventory-empty-message{text-align:center;margin-top:13px}
.inventory-empty-message strong{font-size:12px;font-weight:500;color:#c4d8e4}.inventory-empty-message p{margin:5px 0 0;font-size:11px;line-height:1.5;color:#829fb2}
.inventory-status{margin:15px 0;font-size:12px;line-height:1.6;color:#9ab5c6}
.inventory-items{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:9px;list-style:none;margin:0;padding:0}
.inventory-item{position:relative;min-width:0;border:1px solid #6b92a64d;border-radius:8px;padding:12px;background:#24425230}
.inventory-item-art{display:block;width:28px;height:28px;color:#93b9ce;margin-bottom:9px}.inventory-item-art svg{width:100%;height:100%}
.inventory-item-name{display:block;font-size:11px;line-height:1.4;overflow-wrap:anywhere;color:#d4e4ed}
.inventory-item-quantity{display:block;margin-top:6px;color:#e6c787;font-size:12px;font-variant-numeric:tabular-nums}
@media(max-width:760px){.player-profile-dialog.is-own-profile{width:calc(100vw - 20px);max-height:calc(100dvh - 24px)}.is-own-profile .player-profile-ratings{grid-template-columns:1fr 1fr;padding:14px 12px 12px;gap:8px}.is-own-profile .profile-rating{padding:11px 10px}.is-own-profile .profile-rating dd{font-size:20px}.is-own-profile .player-profile-identity .profile-avatar{width:64px;height:64px;flex-basis:64px}.player-inventory{padding:16px}.inventory-empty-slots{grid-template-columns:repeat(4,minmax(0,1fr));gap:7px}.inventory-empty-slot{height:48px}.inventory-items{grid-template-columns:repeat(3,minmax(0,1fr))}}
@media(max-width:360px){.inventory-items{grid-template-columns:repeat(2,minmax(0,1fr))}.player-inventory h3{font-size:14px}}
