/* Consistent room between independent controls and cards. */
#quests-dialog #quest-list{display:flex;flex-direction:column;gap:16px!important;padding:5px 3px 12px;overflow-y:auto;min-height:0}
#quests-dialog #quest-list .quest-card{flex:none;min-height:128px;margin:0;padding:12px;overflow:hidden}
#quests-dialog .dialog-content{padding-top:28px!important}
#quests-dialog h2{margin:0 42px 14px!important}
#quests-dialog .quest-tabs{margin-top:8px;margin-bottom:8px;gap:12px}
#quests-dialog .close{top:7px!important;right:7px!important}
#achievement-list{gap:14px!important;padding:6px!important}
#profile-dialog .profile-cosmetics{gap:12px!important}
#level-objectives{display:flex;flex-direction:column;gap:10px}
#level-objectives li{border-radius:10px;background:#dcf8f888;padding:8px}
#leaderboard-personal[hidden]{display:none!important}
.profile-tabs{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px;margin:12px 0 16px;flex-shrink:0}
.profile-tabs button{padding:8px 2px;min-height:42px;font:900 12px Nunito,sans-serif;border:1px solid #41aec5;border-radius:10px;background:#d6f8ff;color:#164b63}
.profile-tabs button[aria-selected=true]{background:#ffe589;border-color:#cc9a22;color:#69420e}
#profile-dialog .profile-tab-panel[hidden]{display:none!important}
#profile-dialog .profile-tab-panel{min-height:190px;padding:4px 0 12px}
#profile-dialog #avatar-presets{margin:12px 0}
#profile-dialog .dialog-content{gap:10px}
#app[data-screen=home] .home-tools #achievements-open>img{width:38px!important;height:38px!important;min-height:0!important;margin:3px auto;object-fit:contain}
/* Reserve a real header band, so the Beacon never overlays a level node. */
#adventure-map .map-header{height:62px!important;margin-bottom:-62px!important;background:none!important}
#adventure-map{scroll-padding-top:145px}
#map-landscape{margin-top:0!important;border-top:0;box-sizing:content-box}
#living-water{position:absolute;inset:0;width:100%;height:100%;pointer-events:none;z-index:0}
#home>h1,#home>.tagline,#home>.mode-carousel,#home>#mode-dots{position:relative;z-index:1}
#home>.home-actions{z-index:1}
#home h1[role=button]{cursor:pointer}
#discovery-notice{position:absolute;bottom:23%;left:50%;transform:translateX(-50%);z-index:8;max-width:90%;padding:9px 15px;border:1px solid #fff2a7;border-radius:18px;background:#164b5ef2;color:#fff2a7;font:900 14px Nunito,sans-serif;pointer-events:none;white-space:nowrap}
.mode-card[data-position='-2'],.mode-card[data-position='2']{visibility:hidden;pointer-events:none}
@media(max-width:360px){.profile-tabs{gap:4px}.profile-tabs button{font-size:11px}#quests-dialog #quest-list{gap:12px!important}}
@media(prefers-reduced-motion:reduce){#living-water{display:none}}
.reduce-motion #living-water{display:none}

/* One illustrated frame for every popup. Nine-slicing preserves square corners
   and the same rim thickness when the content needs a short or tall panel.
   Fullscreen scenes keep their scenery; their popup cards use this frame. */
html body dialog:not(#story-scene):not(#adventure-victory):not(#ability-guide):not(#piano-flow):not(#shape-drop[data-view="play"]):not(#shape-slice[data-view="play"]),
html body :is(#shape-drop,#shape-slice,#piano-flow) .drop-panel,
html body #ability-guide section {
 border:0 solid transparent!important;
 border-image:url('assets/menu-panel-v240.webp') 96 fill / 32px / 0 stretch!important;
 border-radius:24px!important;
 background:none!important;
 box-shadow:0 16px 54px #001f4770!important;
}
/* Retire the old independently stretched top and bottom frame layers. */
html body dialog:not(#story-scene):not(#adventure-victory):not(#ability-guide):not(#piano-flow):not(#shape-drop[data-view="play"]):not(#shape-slice[data-view="play"])::before,
html body dialog:not(#story-scene):not(#adventure-victory):not(#ability-guide):not(#piano-flow):not(#shape-drop[data-view="play"]):not(#shape-slice[data-view="play"])::after {
 content:none!important;display:none!important;
}
/* Keep content inside the illustrated rim on panels formerly using thin CSS borders. */
html body :is(#quests-dialog,#achievements-dialog) .dialog-content{padding-left:24px!important;padding-right:24px!important}
html body #terms-dialog .terms-shell{margin:16px;height:calc(100% - 32px);background:transparent}
html body :is(#games-hub,#shape-drop[data-view="menu"],#shape-slice[data-view="menu"]){padding:24px 22px!important}
html body #ability-guide section{padding:28px}
html body :is(#shape-drop,#shape-slice,#piano-flow) .drop-panel.drop-pause-panel{padding:32px 26px!important}

/* Consistent close control, header clearance, and popup rhythm. */
html body dialog:not(#story-scene):not(#adventure-victory):not(#piano-flow) > .close {
 top:8px!important;right:8px!important;left:auto!important;bottom:auto!important;
 width:48px!important;height:48px!important;min-width:48px!important;min-height:48px!important;
 max-width:48px!important;max-height:48px!important;margin:0!important;padding:0!important;
 transform:none!important;z-index:20;
}
html body dialog:not(#story-scene):not(#adventure-victory):has(> .close) > .dialog-content {
 padding-top:24px!important;padding-left:24px!important;padding-right:24px!important;padding-bottom:20px!important;gap:12px;
}
html body dialog:not(#story-scene):not(#adventure-victory):has(> .close) > .dialog-content > h2 {
 flex:none;margin:0 36px 12px!important;padding:0!important;line-height:1.2;
}
html body dialog .dialog-content > p:empty{display:none}
html body #achievement-detail-popup #achievement-detail{padding-top:56px;gap:12px}
html body #coin-help-dialog .coin-help-heading{margin:0 34px 16px 0}
/* Match the size of the shop and leaderboard circles. */
html body #app[data-screen=home] .home-tools #achievements-open>img{width:44px!important;height:44px!important;min-height:44px!important;margin:0!important;object-fit:contain}
/* The controls stay outside the flexible card area. */
html body #home .home-actions :is(#play,#view-map){margin:0!important}
html body #home>.home-actions{position:absolute;bottom:max(8px,env(safe-area-inset-bottom));left:50%;right:auto;transform:translateX(-50%);width:76%;max-width:350px;align-items:center}
html body #home .home-actions #play{width:100%;max-width:280px}
html body #home{padding-bottom:158px}
html body #home .mode-carousel{flex:1;min-height:150px}
@media(max-height:680px){html body #home{padding-bottom:130px}html body #home .mode-carousel{min-height:120px}}
/* Profile categories fit the viewport; collections use explicit pages. */
html body #app #profile-dialog{width:min(440px,calc(100vw - 16px));height:min(690px,calc(100dvh - 20px));max-height:calc(100dvh - 20px)}
html body #app #profile-dialog .dialog-content{display:flex;flex-direction:column;overflow:hidden;gap:10px}
html body #profile-dialog .profile-tabs{grid-template-columns:repeat(4,minmax(0,1fr));margin:0;gap:8px}
html body #profile-dialog .profile-tab-panel{flex:1;min-height:0;padding:0;display:flex;flex-direction:column;gap:10px;overflow:hidden}
html body #profile-dialog .profile-tab-panel[hidden],html body #profile-dialog [hidden],html body #profile-dialog #profile-shop{display:none!important}
html body #profile-dialog .profile-tab-panel h3{margin:0;font-size:16px;flex:none}
html body #profile-dialog .profile-cosmetics{flex:1;min-height:0;grid-template-columns:repeat(3,minmax(0,1fr));grid-auto-rows:1fr;gap:12px;overflow:hidden}
html body #profile-dialog .profile-cosmetic{min-height:0;max-height:210px;gap:6px;padding:10px 5px;justify-content:center}
html body #profile-dialog .profile-cosmetic .background-preview{height:65px;max-height:40%}
html body #profile-dialog .profile-cosmetic small{margin-top:0}
html body #profile-dialog .profile-pages{display:flex;align-items:center;justify-content:center;gap:12px;flex:none;margin-top:4px}
html body #profile-dialog .profile-pages button{height:40px;min-height:40px;padding:6px 12px;border:1px solid #25879d;border-radius:12px;background:#d3f6fc;color:#12556c;font:900 13px Nunito,sans-serif}
html body #profile-dialog .profile-pages span{font-size:13px;white-space:nowrap}
html body #profile-dialog #profile-preview{line-height:0}
html body #profile-dialog #profile-preview .avatar-shell{width:76px;height:76px}
html body #profile-dialog #profile-preview>.avatar{width:68px;height:68px}
html body #profile-dialog :is(.name-label,#player-id-status,#profile-message,#profile-lock-message){margin:0;min-height:0}
html body #profile-dialog .name-label{font-size:12px}
html body #profile-dialog .name-row input{padding:9px;height:44px}
html body #profile-dialog .name-row button{min-height:44px;padding:8px}
html body #profile-dialog .menu-input-hint{display:none}
html body #profile-dialog #avatar-presets{grid-template-columns:repeat(4,minmax(0,1fr));margin:4px 0 0;gap:10px;flex:none}
html body #profile-dialog #avatar-presets button{width:52px;height:52px;min-height:52px}
html body #profile-dialog #avatar-presets .avatar{width:44px;height:44px}
html body #profile-dialog #avatar-presets #choose-photo{margin:0}
@media(max-height:699px){
 html body #profile-dialog .profile-tab-panel{gap:7px}
 html body #profile-dialog #profile-preview .avatar-shell{width:56px;height:56px}
 html body #profile-dialog #profile-preview>.avatar{width:52px;height:52px}
 html body #profile-dialog #avatar-presets{gap:7px;margin-top:2px}
 html body #profile-dialog #avatar-presets button{width:46px;height:46px;min-height:46px}
 html body #profile-dialog #avatar-presets .avatar{width:40px;height:40px}
 html body #profile-dialog .profile-cosmetic{max-height:none}
}
@media(orientation:landscape) and (max-height:500px){
 html body #app #profile-dialog{width:min(740px,calc(100vw - 20px))}
 html body #app #profile-dialog .dialog-content{gap:6px;padding-top:16px!important;padding-bottom:12px!important}
 html body #app #profile-dialog .dialog-content>h2{margin-bottom:4px!important;font-size:22px}
 html body #profile-dialog .profile-tabs button{min-height:34px;padding:5px}
 html body #profile-dialog #profile-panel-identity{display:grid;grid-template-columns:100px 1fr;grid-template-rows:auto 44px 1fr;gap:6px 14px;align-items:center}
 html body #profile-dialog #profile-preview{grid-column:1;grid-row:1/4}
 html body #profile-dialog #player-id-row{grid-column:2;grid-row:1}
 html body #profile-dialog .name-label{display:none}
 html body #profile-dialog .name-row{grid-column:2;grid-row:2}
 html body #profile-dialog #avatar-presets{grid-column:2;grid-row:3;grid-template-columns:repeat(7,minmax(0,1fr));gap:4px}
 html body #profile-dialog .profile-tab-panel h3{display:none}
 html body #profile-dialog .profile-cosmetic{flex-direction:row;flex-wrap:wrap;padding:5px;gap:3px}
 html body #profile-dialog .profile-cosmetic .avatar-shell{width:40px;height:40px}
 html body #profile-dialog .profile-cosmetic .background-preview{width:64px;height:44px;max-height:none}
 html body #profile-dialog .profile-cosmetic small{width:100%}
 html body #profile-dialog .profile-pages button{height:34px;min-height:34px}
}
/* Quest meters use the same painted gold fill and dark ink as player XP. */
html body #quests-dialog .quest-progress{height:30px;min-height:30px;border:3px solid var(--ui-ink,#075570);background:var(--ui-track,#bfdfeb);box-shadow:0 2px 0 #07395326;border-radius:22px}
html body #quests-dialog .quest-progress-fill{display:block;height:100%;border:0;border-radius:0 18px 18px 0;box-shadow:none;background:#f5c638 url('assets/xp-gold-painted-v335.webp') center/150% 620% no-repeat}
html body #quests-dialog .quest-progress strong{font:1000 15px/1 Nunito,sans-serif;color:var(--ui-dark,#073e62);text-shadow:0 1px 1px #ffffffcc}
html body #quests-dialog #quests-collect-all{flex:none;min-height:48px;height:48px;margin:8px auto 0}
html body #quests-dialog #quests-collect-all:disabled{opacity:.55;filter:saturate(.6)}
html body #quests-dialog #quest-list{gap:14px!important;padding:4px 2px 10px;scrollbar-width:none}
html body #quests-dialog .quest-card{gap:8px;min-height:128px}
html body #quests-dialog .quest-tabs{margin:0 0 4px}
html body #quests-dialog .quest-tabs button{min-height:40px}
/* A short panel is enough for one level and its meter. */
html body #app #xp-help-dialog{width:min(380px,calc(100vw - 20px));height:auto;max-height:calc(100dvh - 20px)}
html body #xp-help-dialog .dialog-content{height:auto;margin:16px 0;display:flex;flex-direction:column;gap:16px;overflow:auto}
html body #xp-help-dialog #xp-help-level{margin:0;font-size:25px}
html body #xp-help-dialog .xp-help-meter{margin:0 auto}
html body #xp-help-dialog p{margin:0;font-size:14px}
html body #xp-help-dialog .primary{margin:0 auto}
@media(max-height:500px){html body #xp-help-dialog .dialog-content{gap:8px;padding-top:16px!important;padding-bottom:12px!important}html body #xp-help-dialog .dialog-content>h2{font-size:22px;margin-bottom:4px!important}html body #xp-help-dialog .primary{min-height:44px;height:44px}}

html body #app #xp-help-dialog{height:fit-content!important;min-height:0!important}
html body #app #xp-help-dialog>.dialog-content{height:auto!important}
#home>.menu-keyboard-hint{position:relative;z-index:1}
@media(min-width:600px) and (max-height:500px){
 html body #home{display:grid;grid-template-columns:40% 60%;grid-template-rows:minmax(0,1fr) 25px;padding:56px 0 8px;gap:8px 0}
 html body #home h1{grid-column:1;grid-row:1;width:78%;height:100px;min-height:0;max-height:100px;align-self:start;margin:10px auto 0}
 html body #home .tagline,html body #home .menu-keyboard-hint{display:none}
 html body #home .mode-carousel{grid-column:2;grid-row:1;min-height:0;height:100%;margin:0}
 html body #home .mode-card{width:calc((100dvh - 100px)*.563);left:calc(50% - (100dvh - 100px)*.2815);top:0;height:100%}
 html body #home #mode-dots{grid-column:2;grid-row:2;align-self:center}
 html body #home .home-actions{left:20%;bottom:25px;width:210px;gap:3px}
 html body #home .home-actions #play{height:56px;font-size:23px}
 html body #home .home-actions #view-map{height:36px}
 html body #home .home-bottom,html body #home #home-level{left:8px}
}
@media(max-width:599px) and (max-height:500px){
 html body #home{padding-top:46px;padding-bottom:105px;gap:3px}
 html body #home h1{height:50px;min-height:50px;max-height:50px}
 html body #home .tagline,html body #home .menu-keyboard-hint{display:none}
 html body #home .mode-carousel{min-height:90px;margin:0}
 html body #home .mode-card{width:calc((100dvh - 225px)*.563);left:calc(50% - (100dvh - 225px)*.2815);padding-top:5px;border-radius:14px}
 html body #home .mode-card>strong{font-size:17px;padding:4px}
 html body #home .mode-card>small{font-size:10px;padding:4px;bottom:4px}
 html body #home .home-actions{gap:0}
 html body #home .home-actions #play{height:50px;font-size:21px}
 html body #home .home-actions #view-map{height:32px;font-size:13px}
}

html body #achievement-detail-popup{padding:56px 24px 22px;overflow:hidden}
html body #achievement-detail-popup #achievement-detail{padding:0;gap:10px;max-height:calc(100dvh - 110px);overflow-y:auto;overscroll-behavior:contain}
@media(max-height:500px){
 html body #story-library>.dialog-content{gap:6px!important;padding-top:24px!important;padding-bottom:16px!important}
 html body #story-library>.dialog-content>h2{margin-bottom:6px!important}
}

/* Short portrait browser panes still keep name, ID, and avatar choices on one page. */
@media(max-width:599px) and (max-height:500px){
 html body #app #profile-dialog .dialog-content{padding:16px 18px 12px!important;gap:6px}
 html body #app #profile-dialog .dialog-content>h2{font-size:18px;margin:0 24px 6px!important}
 html body #profile-dialog .profile-tabs{gap:4px}
 html body #profile-dialog .profile-tabs button{font-size:10px;min-height:32px;padding:4px 0}
 html body #profile-dialog #profile-panel-identity{gap:6px}
 html body #profile-dialog #profile-preview,html body #profile-dialog .name-label{display:none}
 html body #profile-dialog #player-id-row{font-size:11px;margin:0;min-height:28px}
 html body #profile-dialog #copy-player-id{height:28px;min-height:28px;width:28px;padding:3px}
 html body #profile-dialog .name-row input{height:36px;padding:6px;font-size:14px}
 html body #profile-dialog .name-row button{min-height:36px;padding:5px;font-size:11px}
 html body #profile-dialog #avatar-presets{gap:6px}
 html body #profile-dialog #avatar-presets button{width:40px;height:40px;min-height:40px}
 html body #profile-dialog #avatar-presets .avatar{width:34px;height:34px}
 html body #profile-dialog .profile-pages{gap:6px}
 html body #profile-dialog .profile-pages button{min-height:32px;height:32px;padding:4px 8px;font-size:11px}
 html body #profile-dialog .profile-cosmetics{gap:6px}
 html body #profile-dialog .profile-cosmetic{padding:5px 3px;gap:4px}
 html body #profile-dialog .profile-cosmetic .avatar-shell{width:40px;height:40px}
 html body #profile-dialog .profile-cosmetic strong{font-size:10px}
}

/* Keep the avatar collection label visible in every Player layout. */
html body #profile-dialog #player-id-status:empty{display:none!important}
html body #profile-dialog #profile-avatar-heading{display:block;font-size:15px;line-height:1.2;margin:2px 0 0;text-align:left}
@media(orientation:landscape) and (max-height:500px){
 html body #profile-dialog #profile-panel-identity{grid-template-rows:auto 44px auto 1fr}
 html body #profile-dialog #player-id-row{min-height:28px;margin:0;font-size:12px}
 html body #profile-dialog #copy-player-id{height:28px;min-height:28px;width:28px;padding:3px}
 html body #profile-dialog .name-label{display:none!important}
 html body #profile-dialog #profile-preview{grid-row:1/5}
 html body #profile-dialog #profile-avatar-heading{grid-column:2;grid-row:3;font-size:13px;margin:0}
 html body #profile-dialog #avatar-presets{grid-row:4;align-self:start}
}
@media(max-width:599px) and (max-height:500px){
 html body #profile-dialog .name-label{display:none!important}
 html body #profile-dialog #profile-avatar-heading{font-size:13px;margin:0}
}


/* Every popup category uses the Shop's rounded tray and gold selected tab.
   Border space is reserved on every button, so selection never moves labels. */
html body #app dialog :is(.shop-tabs,.profile-tabs,#achievement-tabs,.quest-tabs){
 display:grid;grid-template-columns:none;grid-auto-flow:column;grid-auto-columns:minmax(0,1fr);
 position:relative;top:auto;flex:0 0 auto;box-sizing:border-box;width:100%;min-width:0;min-height:0;
 gap:8px;margin:0;padding:4px;border:1px solid #3199b4;border-radius:14px;background:#86cbdc;box-shadow:inset 0 1px 0 #e1ffff88;
}
html body #app dialog :is(.shop-tabs,.profile-tabs,#achievement-tabs,.quest-tabs)>button{
 position:relative;box-sizing:border-box;min-width:0;min-height:44px;margin:0;padding:5px 2px;
 border:2px solid transparent;border-radius:10px;background:transparent;
 color:var(--ui-text,#12536c);font:900 clamp(10px,3.2vw,13px)/1.15 Nunito,sans-serif;
 text-align:center;white-space:nowrap;text-shadow:none;box-shadow:none;
}
html body #app dialog :is(.shop-tabs,.profile-tabs,#achievement-tabs,.quest-tabs)>button[aria-selected=true]{
 border-color:#9b6817;background:var(--ui-selected,linear-gradient(#fff2a4,#ffd159));
 color:var(--ui-gold-ink,#674414);text-shadow:0 1px #fff7cf;
 box-shadow:inset 0 1px 0 #fff8d5,0 2px var(--ui-gold-shadow,#cb9428);
}
html body #app dialog :is(.shop-tabs,.profile-tabs,#achievement-tabs,.quest-tabs)>button:focus-visible{
 outline:2px solid var(--ui-ink,#075570);outline-offset:1px;
}
html body #app dialog :is(.shop-tabs,.profile-tabs,#achievement-tabs,.quest-tabs) :is(.achievement-tab-dot,.quest-tab-dot){
 top:-3px;right:-3px;left:auto;width:9px;height:9px;
}
@media(max-width:360px){
 html body #app dialog :is(.shop-tabs,.profile-tabs,#achievement-tabs,.quest-tabs){gap:6px;padding:3px}
}
@media(max-width:300px){
 html body #app dialog :is(.shop-tabs,.profile-tabs,#achievement-tabs,.quest-tabs){gap:4px}
 html body #app dialog :is(.shop-tabs,.profile-tabs,#achievement-tabs,.quest-tabs)>button{padding-inline:0;font-size:10px}
}
@media(max-height:500px){
 html body #app dialog :is(.shop-tabs,.profile-tabs,#achievement-tabs,.quest-tabs){padding:3px}
 html body #app dialog :is(.shop-tabs,.profile-tabs,#achievement-tabs,.quest-tabs)>button{min-height:32px;padding-block:4px}
}

/* Unselected choices remain text on the panel, without a tinted tile. */
html body #app :is(#language-dialog .language-option,#difficulty-dialog .difficulty-option):not([aria-pressed=true]){background:transparent;border-color:transparent;box-shadow:none}

/* Water follows the card artwork, beneath its text and inside its rounded edge. */
.mode-card>.card-water{position:absolute;inset:0;width:100%;height:100%;z-index:0;pointer-events:none;border-radius:inherit}
.mode-card>.card-water[hidden]{display:none}
.mode-card>strong,.mode-card>span{position:relative;z-index:1}
.mode-card>em,.mode-card>small{z-index:1}

/* Pre-filtered, density-aware frame art avoids aliasing when a detailed atlas is
   reduced to a small badge. Use the same opening alignment in every context. */
html body .frame-art{background-size:100% 100%;background-repeat:no-repeat;background-position:center;image-rendering:auto}
html body .avatar-shell{--portrait-x:50%;--portrait-y:48%}
html body .avatar-shell>.avatar,
html body #shop-dialog .frame-preview:not([data-cosmetic="none"])>.avatar{
 position:absolute;width:70%!important;height:70%!important;left:var(--portrait-x,50%);top:var(--portrait-y,48%);
 transform:translate(-50%,-50%);border:0;box-shadow:none;
}
html body .avatar-shell:has(>.frame-gold),html body #shop-dialog .frame-preview[data-cosmetic="gold"]{--portrait-x:52%;--portrait-y:47%}
html body .frame-gold{background-image:url("assets/avatar-frame-gold-2x-v49462.webp");background-image:image-set(url("assets/avatar-frame-gold-1x-v49462.webp") 1x,url("assets/avatar-frame-gold-2x-v49462.webp") 2x,url("assets/avatar-frame-gold-3x-v49462.webp") 3x,url("assets/avatar-frame-gold-4x-v49462.webp") 4x);}
html body .avatar-shell:has(>.frame-ice),html body #shop-dialog .frame-preview[data-cosmetic="ice"]{--portrait-x:48.5%;--portrait-y:48%}
html body .frame-ice{background-image:url("assets/avatar-frame-ice-2x-v49462.webp");background-image:image-set(url("assets/avatar-frame-ice-1x-v49462.webp") 1x,url("assets/avatar-frame-ice-2x-v49462.webp") 2x,url("assets/avatar-frame-ice-3x-v49462.webp") 3x,url("assets/avatar-frame-ice-4x-v49462.webp") 4x);}
html body .avatar-shell:has(>.frame-blossom),html body #shop-dialog .frame-preview[data-cosmetic="blossom"]{--portrait-x:52%;--portrait-y:48.5%}
html body .frame-blossom{background-image:url("assets/avatar-frame-blossom-2x-v49462.webp");background-image:image-set(url("assets/avatar-frame-blossom-1x-v49462.webp") 1x,url("assets/avatar-frame-blossom-2x-v49462.webp") 2x,url("assets/avatar-frame-blossom-3x-v49462.webp") 3x,url("assets/avatar-frame-blossom-4x-v49462.webp") 4x);}
html body .avatar-shell:has(>.frame-cosmic),html body #shop-dialog .frame-preview[data-cosmetic="cosmic"]{--portrait-x:48.5%;--portrait-y:47%}
html body .frame-cosmic{background-image:url("assets/avatar-frame-cosmic-2x-v49462.webp");background-image:image-set(url("assets/avatar-frame-cosmic-1x-v49462.webp") 1x,url("assets/avatar-frame-cosmic-2x-v49462.webp") 2x,url("assets/avatar-frame-cosmic-3x-v49462.webp") 3x,url("assets/avatar-frame-cosmic-4x-v49462.webp") 4x);}

/* Reserve room for the complete ring when a frame has two purchase actions. */
html body #shop-dialog #frame-items .cosmetic-card:has(.frame-upgrade){justify-content:flex-start;gap:3px;padding:7px 4px}
html body #shop-dialog #frame-items .cosmetic-card:has(.frame-upgrade) .cosmetic-preview{width:36px;height:36px;min-width:36px;min-height:36px;max-height:36px;flex:0 0 36px}
html body #shop-dialog #frame-items .cosmetic-card:has(.frame-upgrade)>strong{min-height:24px;font-size:11px;flex-shrink:0}
html body #shop-dialog #frame-items .cosmetic-card:has(.frame-upgrade) .shop-buy{height:44px;min-height:44px;max-height:44px;flex:0 0 44px;font-size:12px;padding:2px}

/* Make the Player portrait a focal point without growing the dialog. */
html body #profile-dialog #profile-preview{flex:none}
html body #profile-dialog #profile-preview .avatar-shell{width:112px;height:112px}
html body #profile-dialog #profile-preview>.avatar{width:100px;height:100px}
@media(max-height:699px){
 html body #profile-dialog #profile-preview .avatar-shell{width:80px;height:80px}
 html body #profile-dialog #profile-preview>.avatar{width:72px;height:72px}
}
@media(max-height:599px){
 html body #profile-dialog #profile-preview .avatar-shell{width:72px;height:72px}
 html body #profile-dialog #profile-preview>.avatar{width:64px;height:64px}
}
@media(orientation:landscape) and (min-width:600px) and (max-height:500px){
 html body #profile-dialog #profile-preview .avatar-shell{width:96px;height:96px}
 html body #profile-dialog #profile-preview>.avatar{width:86px;height:86px}
}

/* Reward redemption: soft light and tiny sparkles replace the flat green wipe. */
#quests-dialog .quest-card.quest-redeeming{border-color:#8ae5ba;box-shadow:inset 0 0 16px #a4f7d233,0 0 8px #6ee5b333}
#quests-dialog .quest-card.quest-redeeming::after{content:none;animation:none}
.quest-finish-light{position:absolute;inset:0;overflow:hidden;border-radius:inherit;pointer-events:none;z-index:2}
.quest-finish-glow{position:absolute;inset:0;background:radial-gradient(ellipse at 45% 55%,#fff1a94d 0%,#86efbc38 50%,transparent 85%)}
.quest-finish-shine{position:absolute;inset:-20% auto -20% 0;width:32%;background:linear-gradient(105deg,transparent,#fffbea80,transparent);filter:blur(3px)}
.quest-finish-spark{position:absolute;border-radius:50%;background:#fffbe3;box-shadow:0 0 4px 1px #fff3a8,0 0 8px #a1f8cb;pointer-events:none}
#quests-dialog .quest-card.quest-redeeming-reduced{box-shadow:inset 0 0 10px #a4f7d222}

/* Local preview v2: trace, pulse and embers survive the card's final dissolve. */
.quest-ending-layer{position:fixed;inset:0;width:100vw;height:100dvh;max-width:none;max-height:none;margin:0;padding:0;border:0;background:transparent;overflow:visible;pointer-events:none;z-index:210}
.quest-ending-layer::backdrop{background:transparent;pointer-events:none}
.quest-ending-rim{position:absolute;overflow:visible;filter:drop-shadow(0 0 3px #ffe784) drop-shadow(0 0 7px #7fe6ba);transform-origin:center}
.quest-ending-ember{position:absolute;width:4px;height:4px;border-radius:50%;background:#ffd65a;box-shadow:0 0 2px #fffde7,0 0 6px 1px #ffd65a,0 0 10px #85eec4;pointer-events:none}

/* Preview v3: concise general quests, compact cards and clear separation. */
html body #quests-dialog #quest-list{gap:24px!important;padding:7px 4px 12px}
html body #quests-dialog #quest-list .quest-card{flex:0 0 auto;min-height:112px;padding:12px 14px;gap:8px}
html body #quests-dialog .quest-card h3{font-size:16px;line-height:1.25;margin:0;min-height:0}
html body #quests-dialog .quest-objectives{display:none}
html body #quests-dialog .quest-progress{height:24px;min-height:24px}
html body #quests-dialog .quest-progress strong{font-size:13px;line-height:18px}
#app #quests-dialog .quest-progress-fill{background:#f5c638 url('assets/xp-gold-painted-v335.webp') center/150% 620% no-repeat}
html body #quests-dialog .quest-footer{flex-direction:row;justify-content:center;align-items:center;gap:12px}
html body #quests-dialog .quest-reward{font-size:15px;line-height:22px}
html body #quests-dialog .quest-reward img{width:22px;height:22px}
html body #quests-dialog .quest-collect{min-height:40px;height:40px;padding:4px 10px}
.quest-finish-fill{position:absolute;inset:-8% auto -8% 0;width:52%;background:linear-gradient(90deg,transparent 0%,#f7b50055 20%,#ffd21be6 55%,#fff9b8ff 75%,#ffda3799 88%,transparent 100%);filter:blur(3px) drop-shadow(0 0 9px #ffd32a);pointer-events:none}
@media(max-height:650px){
 html body #quests-dialog #quest-list{gap:18px!important}
 html body #quests-dialog #quest-list .quest-card{min-height:96px;padding:8px 10px;gap:6px}
 html body #quests-dialog .quest-card h3{font-size:14px}
 html body #quests-dialog .quest-collect{min-height:36px;height:36px}
}

/* Local preview: one claim action, compact cards, safe bottom spacing. */
html body #quests-dialog .dialog-content{padding-bottom:38px!important;overflow:hidden}
html body #quests-dialog #quest-list{gap:16px!important;padding:5px 4px 8px}
html body #quests-dialog #quest-list .quest-card{min-height:96px;padding:9px 12px;gap:6px}
html body #quests-dialog .quest-footer{margin-top:2px;min-height:22px}
.quest-completed-label{font-size:13px;font-weight:900;color:#126251}
html body #quests-dialog #quests-collect-all{margin:12px auto 0;min-height:44px;height:44px}
@media(max-height:720px){
 html body #quests-dialog .dialog-content{padding-bottom:30px!important}
 html body #quests-dialog #quest-list{gap:10px!important}
 html body #quests-dialog #quest-list .quest-card{min-height:80px;padding:6px 10px;gap:4px}
 html body #quests-dialog .quest-card h3{font-size:14px}
 html body #quests-dialog .quest-progress{height:22px;min-height:22px}
 html body #quests-dialog #quests-collect-all{margin-top:8px;min-height:40px;height:40px}
}
html body #quests-dialog #quests-collect-all{margin-bottom:18px}
@media(max-height:650px){
 html body #quests-dialog #quest-list{gap:8px!important;padding-top:2px;padding-bottom:2px}
 html body #quests-dialog #quest-list .quest-card{min-height:66px;padding:5px 9px;gap:3px}
 html body #quests-dialog .quest-card h3{font-size:13px;line-height:16px}
 html body #quests-dialog .quest-progress{height:20px;min-height:20px}
 html body #quests-dialog .quest-footer{min-height:18px;margin:0}
 html body #quests-dialog .quest-reward{font-size:13px;line-height:18px}
 html body #quests-dialog .quest-reward img{width:18px;height:18px}
 html body #quests-dialog #quest-cycle-status{margin:5px 0;font-size:11px}
 html body #quests-dialog .dialog-content{padding-top:20px!important;padding-bottom:26px!important}
 html body #quests-dialog #quests-collect-all{margin-bottom:14px;min-height:36px;height:36px}
}

/* Center the sole claim action in the remaining panel space. */
html body #quests-dialog .dialog-content{padding-bottom:20px!important}
html body #quests-dialog #quest-list{flex:0 1 auto;padding-bottom:0}
html body #quests-dialog .quest-claim-area{flex:1 0 76px;display:flex;align-items:center;justify-content:center;min-height:76px}
html body #quests-dialog #quests-collect-all{margin:0;width:82%;max-width:320px;height:54px;min-height:54px;font-size:18px}
.quest-finish-fill{inset:0;width:100%;filter:none;background:linear-gradient(90deg,#ffd02a99,#ffe44dbb 65%,#fff3a4dd);border-radius:inherit}
@media(max-height:650px){html body #quests-dialog .quest-claim-area{flex-basis:64px;min-height:64px}html body #quests-dialog #quests-collect-all{height:46px;min-height:46px;font-size:16px}}
html body #quests-dialog .quest-claim-area{position:relative;top:4px}

/* A brief star shimmer marks the moment the light fills the card. */
.quest-finish-twinkle{position:absolute;width:10px;height:10px;background:#fffbe2;clip-path:polygon(50% 0,60% 38%,100% 50%,60% 62%,50% 100%,40% 62%,0 50%,40% 38%);filter:drop-shadow(0 0 3px #ffd45a);pointer-events:none}
