/* Per-frame sky updates stay on composited layers, separate from the HUD. */
#sun{will-change:transform,opacity}
.landscape:after{will-change:opacity;transition:none}
.earth{filter:none!important;transition:none}
.earth:before{content:'';position:absolute;inset:0;background:#080a20;opacity:calc(var(--night,0)*.45);pointer-events:none;will-change:opacity;z-index:1}
/* Mirror only the portrait surface. The sprite strip still plays in authored frame order. */
#minerCompanion .miner-portrait,#mobileRoll .miner-portrait{scale:-1 1;transform-origin:center}

/* Stable manager cards; the containing panel grows only with unlocked rows. */
#managerPanel{--manager-panel-width:min(1180px,calc(100vw - clamp(280px,25vw,400px) - 24px));--manager-card-height:clamp(140px,calc((100dvh - 128px)/4),205px);width:var(--manager-panel-width);height:auto;bottom:auto!important;max-height:calc(100dvh - 24px);overflow:auto;scrollbar-gutter:stable}
#managerOptions{min-height:0;height:auto;grid-auto-rows:var(--manager-card-height);align-content:start}
#managerPanel .manager-card{height:var(--manager-card-height);min-height:0;align-items:center;overflow:auto}
#managerPanel[data-count="1"]{width:calc((100vw - clamp(280px,25vw,400px) - 24px)/2 + 20.5px);max-width:610.5px}
#managerPanel[data-count="1"] #managerOptions{grid-template-columns:1fr}
#managerPanel[data-count="0"]{width:320px}
#managerOptions:empty:after{content:'Meet your first manager through the Blacksmith upgrades.';color:#d0e4c9;font-size:15px;line-height:1.5}

.sr-only{position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}
.gold-word,.vendor-word,.level-word{display:inline-block;background-position:center;background-size:contain;background-repeat:no-repeat;font-size:0;flex-shrink:0}
.gold-word{width:48px;height:20px;background-image:url('./assets/v20-gold.webp')}
.wallet>.gold-word{width:88px;height:30px;align-self:flex-start}
.cost-gold{display:flex;align-items:center;justify-content:center;gap:6px;flex-wrap:wrap;border:1px solid #ba873c;background:linear-gradient(#473725,#2e241b)!important}
.cost-gold .cost-amount,.gold-total #gold{color:#f5d270;text-shadow:0 1px 1px #352819,1px 0 #584727,-1px 0 #584727}
.coin{color:#e2ab45}
#vendorLevel{display:flex;align-items:center;justify-content:center;gap:7px;min-height:28px;padding:3px 0}
.vendor-word{width:112px;height:24px}
.word-smith{background-image:url('./assets/v20-blacksmith.webp')}
.word-jeweler{background-image:url('./assets/v20-jeweler.webp')}
.word-acolyte{background-image:url('./assets/v20-acolyte.webp')}
.word-excavator{background-image:url('./assets/v20-excavator.webp')}
.level-value{display:flex;align-items:center;gap:1px}
.level-word{width:48px;height:21px;margin-right:3px;background-image:url('./assets/v20-level.webp')}
.level-digit{display:block;width:15px;height:23px;background:url('./assets/v20-digits.webp') var(--digit-x) var(--digit-y)/500% 200% no-repeat;flex-shrink:0}
@media(min-width:761px){
 .blacksmith{position:relative}
 .forge-brand{height:104px;min-height:104px;width:calc(100% - 104px);flex-shrink:0}
 .forge-brand a{width:100%;height:100%;max-width:230px}
 .blacksmith .smith-scene{position:absolute;top:12px;right:0;width:114px;height:104px;min-height:0;justify-content:flex-end}
 .blacksmith .smith-scene:after{width:114px;height:104px}
}
@media(min-width:761px) and (max-height:650px){
 .forge-brand{height:74px;min-height:74px;display:flex}
 .blacksmith .smith-scene{display:flex;height:74px;top:6px}
 .blacksmith .smith-scene:after{height:74px;width:94px}
}
@media(max-width:760px){
 #managerPanel,#managerPanel[data-count="0"],#managerPanel[data-count="1"]{--manager-card-height:160px;inset:70px 5px auto!important;width:auto;max-width:none;height:auto;max-height:calc(100dvh - 134px)}
 #managerOptions{grid-template-columns:1fr;min-height:0}
 #managerPanel .manager-card{height:160px}
 #managerPanel .manager-card b{font-size:16px}
 #managerPanel .manager-card p{font-size:12px}
 #managerPanel .manager-card small{font-size:11px}
 #forgePanel:not(.mobile-vendor) .forge-brand a{height:36px}
 #forgePanel:not(.mobile-vendor) .smith-scene:after{left:calc(50% + 5px)}
 #forgePanel #vendorLevel{flex-wrap:wrap;gap:0;min-height:30px;padding:2px 0}
 #forgePanel:not(.mobile-vendor) .vendor-word{width:80px;height:13px}
 #forgePanel:not(.mobile-vendor) .level-word{width:29px;height:12px;margin-right:2px}
 #forgePanel:not(.mobile-vendor) .level-digit{width:8px;height:13px}
 #forgePanel:not(.mobile-vendor) .cost-gold{gap:2px;padding:3px 2px;min-height:32px}
 #forgePanel:not(.mobile-vendor) .cost-gold .gold-word{width:34px;height:13px}
 .player-info .wallet{display:grid;grid-template-columns:auto 1fr;gap:3px;align-items:center}
 .player-info .wallet>.gold-word{display:block;width:42px;height:19px;align-self:center}
 .player-info .gold-total{font-size:18px}
 .gold-total .coin{display:none}
 body.motherlode-view #forgePanel #vendorLevel{min-height:16px;flex-wrap:nowrap;gap:5px}
 body.motherlode-view #forgePanel .next-upgrade em{flex-wrap:nowrap;min-height:24px}
}
@media(max-width:760px) and (max-height:600px){
 #forgePanel:not(.mobile-vendor) .forge-brand a{height:24px}
 #forgePanel:not(.mobile-vendor) .next-upgrade b{font-size:11px!important}
 #forgePanel:not(.mobile-vendor) .next-upgrade strong{font-size:10px!important}
}
@media(prefers-reduced-motion:reduce){#sun{will-change:auto}}

/* Relics remain inspectable after the keeper consumes the waiting queue. */
#bagDialog{width:min(560px,calc(100vw - 20px));max-height:calc(100dvh - 24px);overflow:auto}
#bagSummary{font-size:13px;line-height:1.5;margin:10px 0;color:#5d476c}
.bag-tabs{display:flex;gap:8px;margin:12px 0}
.bag-tabs button{flex:1;min-height:44px;padding:8px;border:1px solid #647c6e;border-radius:7px;background:#d4e1d8;font-weight:700}
.bag-tabs button[aria-selected=true]{background:#28483b;color:#fff0c4;border-color:#b49353}
#bagCaption{font-size:13px;line-height:1.5;margin:10px 0}
#bagItems .bag-item.legendary{border-color:#a268c7;background:#f0e4f8}
#bagItems .bag-item span{min-width:0;overflow-wrap:anywhere}
#bagItems .bag-item small{display:block;margin-top:5px;line-height:1.35}
#bagItems .legendary-name{color:#694080;font-weight:700}
.bag-empty{font-size:14px;line-height:1.5;padding:10px 0}
#bagDialog .relic-area{display:block}
#bagDialog .relic-area h2{color:#f3dfb4}
#settingsActions #relicsBtn{display:block!important}
@media(max-width:760px){#bagItems{grid-template-columns:1fr}#bagItems .bag-item{min-height:88px}#bagDialog .relic-area .relic-rack{width:100%;max-width:none}#bagSummary{font-size:12px}}
#chatBtn{display:inline-flex;align-items:center;justify-content:center;min-width:42px;height:34px;flex:none;padding:0 7px;border:1px solid #a7bcb6;border-radius:9px;background:#213c42;color:#fff3ce;font:700 14px/1 system-ui;cursor:pointer}
.gold-total #chatBtn{margin-left:auto}.gold-total #settingsBtn{margin-left:3px}
#chatDialog{width:min(430px,calc(100vw - 24px));max-height:90dvh;overflow:auto;padding:22px;border:1px solid #ac8c53;border-radius:14px;background:#182824;color:#f7ead3}
#chatDialog h2{padding-right:38px;color:#f7d88e;font-size:22px}#chatDialog .chat-caption{font-size:13px;color:#c0cfc4;margin:4px 0 14px}
#chatLog{max-height:42dvh;min-height:90px;overflow-y:auto;overscroll-behavior:contain;background:#101c1a;border-radius:8px;padding:0 12px}
#chatLog article{padding:9px 0;border-bottom:1px solid #30413a;line-height:1.35}#chatLog article:last-child{border:0}#chatLog b{color:#e7c889;font-size:13px}#chatLog time{margin-left:8px;color:#b3c3ba;font-size:11px}#chatLog span{display:block;overflow-wrap:anywhere;font-size:15px}
#chatForm{margin-top:12px;display:flex;gap:7px}#chatInput{min-width:0;flex:1;border:1px solid #8d9c8e;border-radius:6px;padding:8px;font:16px system-ui;background:#f8f3e5;color:#182824}#chatSend{padding:8px 14px;min-height:44px;border:0;border-radius:6px;background:#e4c67d;color:#142720;font-weight:750}#chatConnection,#chatStatus{color:#d5dfcd;font-size:13px;margin-top:8px}#chatConnection:empty,#chatStatus:empty{display:none}
@media(max-width:760px){.player-info #chatBtn{height:38px;min-width:38px;font-size:12px}}
@media(max-width:760px){.player-column .player-info{padding-right:92px}}

#nicknameForm{margin:0 0 12px}
#nicknameForm label{display:block;margin-bottom:4px;font-size:14px;font-weight:700;color:#ebd9ad}
.nickname-controls{display:flex;align-items:stretch;gap:7px}
#chatNickname{flex:1;min-width:0;padding:7px 9px;border:1px solid #889d8e;border-radius:6px;background:#11201c;color:#fff1ce;font:16px system-ui}
#nicknameForm button{min-height:44px;padding:6px 14px;border:1px solid #9fae98;border-radius:6px;background:#30453b;color:#fff1ce;font-weight:700}
#nicknameStatus:not(:empty){display:block;margin-top:5px;color:#e8dbbc}
#chatLog b{overflow-wrap:anywhere;unicode-bidi:isolate}
