/* One final responsive layer owns the mobile HUD in both orientations. */
@media(max-width:700px),(max-width:1400px) and (any-pointer:coarse){
 :root{--safe-top:env(safe-area-inset-top,0px);--safe-right:env(safe-area-inset-right,0px);--safe-bottom:env(safe-area-inset-bottom,0px);--safe-left:env(safe-area-inset-left,0px);--screen-h:var(--visible-height,100dvh);--screen-w:var(--visible-width,100vw);--ui-top:calc(var(--safe-top) + var(--visible-top,0px));--ui-bottom:calc(var(--safe-bottom) + max(0px,100dvh - var(--screen-h) - var(--visible-top,0px)));--ui-left:calc(var(--safe-left) + 10px);--ui-right:calc(var(--safe-right) + 10px);--hud-bottom:calc(var(--ui-top) + 92px);--dock-size:clamp(54px,15.6vw,68px);--dock-height:calc(var(--dock-size) + 22px)}
 html,body{overscroll-behavior:none;-webkit-text-size-adjust:100%;text-size-adjust:100%}
 #game{height:var(--screen-h);width:100%;min-height:0}
 #viewport{position:fixed;inset:0;top:var(--visible-top,0px);height:var(--screen-h);width:100%;overflow:hidden}
 .scene-vignette{background:linear-gradient(#062c3b65,transparent 22%,transparent 77%,#082d3860);opacity:1}
 .topbar{inset:calc(var(--ui-top) + 6px) var(--ui-right) auto var(--ui-left);display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:42px 36px;gap:4px;height:auto;direction:ltr;align-items:center;pointer-events:none}
 .brand{width:min(180px,47vw);height:42px;min-width:0;max-width:100%;justify-self:start;flex:none;filter:drop-shadow(0 2px 3px #002b3666)}
 .brand strong{max-width:100%;overflow:hidden;text-overflow:ellipsis;font-size:20px;line-height:1.2}.brand-level{font-size:16px;border-width:1px}.profile-avatar{right:-1%}.profile-xp{height:3px}
 .wallet{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;width:100%;height:36px;padding:0;flex:none;direction:ltr}
 .resource{height:36px;width:100%;grid-template-columns:24px minmax(0,1fr);padding:0;gap:1px;background:none}
 .resource-symbol,.resource.gems .resource-symbol{width:26px;height:28px;grid-column:1;left:auto;bottom:auto}.resource.gems .resource-symbol{width:21px;height:26px}.gold-symbol{font-size:25px}
 .resource>div,.resource.gold>div,.resource.gems>div{height:32px;padding:3px 6px;background:linear-gradient(140deg,#164e59f2,#092e3ceb);border:1px solid #99d6d1ba;border-radius:10px;box-shadow:inset 0 1px 0 #e2fff433,0 2px 5px #00242c30}
 .resource.gold>div{border-color:#d6c280;background:linear-gradient(140deg,#5b562cf0,#293e32ed)}.resource.gems>div{border-color:#d78be1;background:linear-gradient(140deg,#673b70f0,#382647eb)}
 .resource strong{font:700 clamp(16px,4.6vw,20px)/1.2 Tahoma,Arial,sans-serif;letter-spacing:0;white-space:nowrap;text-shadow:none;font-variant-numeric:tabular-nums}
 .island-quick{inset:calc(var(--ui-top) + 7px) var(--ui-right) auto auto;transform:none;width:min(142px,38vw);max-width:none;min-height:40px;height:40px;padding:5px 10px;font:14px/1.5 Swissra,Tahoma,sans-serif;border-radius:15px;border-color:#b5e1d18c;background:#103e46e6;overflow:hidden;text-overflow:ellipsis;box-shadow:0 3px 12px #062d3933}
 .left-actions{left:var(--ui-left);top:calc(var(--hud-bottom) + 4px);bottom:auto;display:flex;flex-direction:row;gap:6px}
 .left-actions button{width:44px;height:44px;padding:4px;border-radius:14px;border:1px solid #d9f3cf55;background:#123f487d;box-shadow:0 3px 9px #052f3922}.left-actions img{width:100%;height:100%}
 #open-messages .notification-badge{right:-3px;top:-3px;min-width:19px;height:19px;padding:0 3px;font-size:11px;line-height:15px;border-width:2px}
 .mobile-tools-toggle{display:flex;align-items:center;justify-content:center;inset:calc(var(--hud-bottom) + 4px) var(--ui-right) auto auto;min-width:44px;min-height:44px;height:44px;padding:6px 10px;gap:6px;border-radius:14px;font:14px/1.4 Swissra,Tahoma,sans-serif;background:#123f48df;border:1px solid #c1e6cf8c;z-index:30}
 .mobile-tools-toggle[aria-expanded=true] span{display:inline}
 .toolbar{inset:calc(var(--hud-bottom) + 56px) var(--ui-right) auto auto;display:grid;grid-template-columns:repeat(2,58px);gap:7px;padding:9px;border:1px solid #b7e8d077;border-radius:19px;background:#103a42ed;box-shadow:0 8px 28px #0827314d;width:auto;max-width:none}
 .mobile-tools-collapsed .toolbar{padding:0;border:0;background:none;box-shadow:none}
 .toolbar .tool-divider{display:none}.toolbar .tool:not(#open-shop),.toolbar #open-inventory{position:relative;display:flex;flex-direction:column;justify-content:center;align-items:center;width:58px;height:62px;min-height:44px;padding:3px;gap:2px;background:#ccebd612;border-radius:12px}
 .toolbar .tool:not(#open-shop)>img{width:34px;height:34px}.toolbar #open-inventory .inventory-art{width:34px;height:34px}
 .toolbar .tool:not(#open-shop)>span:not(.inventory-art),.toolbar #open-collections>span{position:static!important;display:block;width:auto!important;height:auto!important;overflow:visible!important;clip:auto!important;padding:0;background:none;font:12px/16px Tahoma,sans-serif;color:#f0ffe6}
 .mobile-tools-collapsed .toolbar .tool:not(#open-shop){display:none}
 #open-shop{position:fixed;inset:auto auto calc(var(--ui-bottom) + var(--dock-height) + 14px) var(--ui-left);width:76px;height:76px;min-height:44px;padding:0;background:none;border:0;filter:drop-shadow(0 3px 5px #003b3880)}
 #open-shop>span{display:none} /* The supplied Build artwork already contains its label. */
 .camera-controls{inset:calc(var(--hud-bottom) + 206px) var(--ui-right) auto auto;display:flex;flex-direction:row;gap:5px}
 .camera-controls button,.camera-controls #recenter{width:44px;height:44px;min-width:44px;min-height:44px;font-size:24px;border-radius:13px;background:#123f48ee;border:1px solid #abd7c877}.camera-controls img{width:27px;height:27px}
 .mobile-tools-collapsed .camera-controls{display:none}
 .dhikr-dock{inset:auto auto calc(var(--ui-bottom) + 4px) 50%;transform:translateX(-50%);width:min(390px,calc(var(--screen-w) - var(--safe-left) - var(--safe-right) - 20px));max-width:none;height:var(--dock-height);padding:0 6px;border:1px solid #c4e6cb55;border-radius:24px;background:linear-gradient(#0b394b9c,#092b37e8);box-shadow:0 7px 25px #00312f55;overflow:visible}
 .dhikr-buttons{height:var(--dock-size);gap:0;align-items:center}.dhikr,.dhikr:nth-child(n+4),.dhikr-3,.dhikr-4{width:auto!important;height:var(--dock-size);min-width:44px;min-height:44px;flex:1;background:none}
 .dhikr-orb{width:146%;height:146%}.dhikr small{display:none}.dock-note{display:block;width:100%;max-width:100%;height:18px;margin:0;padding:0;font:12px/18px Tahoma,sans-serif;background:none;color:#def4df;white-space:nowrap}
 .garden-stats,.save-status{display:none}.shop-open :is(.mobile-tools-toggle,.toolbar,.left-actions,.dhikr-dock),.placing .mobile-tools-toggle{visibility:hidden;pointer-events:none}
 .selected-panel{inset:auto auto calc(var(--ui-bottom) + var(--dock-height) + 10px) 50%;transform:translateX(-50%);width:min(420px,calc(var(--screen-w) - var(--safe-left) - var(--safe-right) - 20px));max-width:none;max-height:calc(var(--screen-h) - var(--safe-top) - var(--safe-bottom) - var(--dock-height) - 112px);padding:12px 14px;border:1px solid #d6f5dc;border-radius:21px;background:linear-gradient(135deg,#e1f5eaf7,#a7d7d9fa);overflow:auto}
 .selected-panel .selected-heading h2{font:700 18px/1.4 Swissra,Tahoma,sans-serif}.selected-panel .selected-heading .icon-button{width:44px;height:44px}.selected-panel .selected-image{width:72px;height:90px}.selected-panel .item-description{font:14px/1.6 Tahoma,sans-serif}.selected-panel .primary{font-size:14px;min-height:44px}
 .selected-panel .selected-actions{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}.selected-panel .selected-actions:has(#rotate-selected){grid-template-columns:repeat(2,minmax(0,1fr))}.selected-panel .selected-actions button{font-size:14px;min-height:44px;padding:5px}.selected-panel .action-icon{width:24px;height:26px}
 .placement-bar{inset:auto auto calc(var(--ui-bottom) + 6px) 50%;transform:translateX(-50%);width:min(520px,calc(var(--screen-w) - var(--safe-left) - var(--safe-right) - 20px));max-height:calc(var(--screen-h) - var(--safe-top) - var(--safe-bottom) - 108px);max-width:none;overflow:auto;padding:10px 12px;gap:6px 10px;border-radius:20px;background:#123f4af5}
 .placement-bar>div:first-child{flex-basis:100%}.placement-bar strong{font-size:16px}.placement-bar>div>span{font-size:14px;line-height:1.5}.placement-bar .placement-option{font:14px/1.4 Tahoma,sans-serif;min-height:44px;flex:1}.placement-bar .art-confirm{min-height:44px;min-width:132px;max-width:100%;margin:0;flex:1}.placement-bar .art-confirm span{font-size:14px}.placement-bar #rotate-place{min-height:44px}.placement-bar .art-cancel{margin:0;width:44px;height:44px}.placing .camera-controls{top:auto;bottom:calc(var(--ui-bottom) + 205px)}
 body:has(.mobile-tools-toggle[aria-expanded=true]) .garden-guide{display:none}
 .garden-guide{inset:calc(var(--hud-bottom) + 58px) auto auto 50%;transform:translateX(-50%);width:min(260px,calc(var(--screen-w) - 100px));padding:12px 14px}.garden-guide p{font-size:14px}.garden-guide strong{font-size:16px}
 .shop{--shop-page-size:4;inset:calc(var(--ui-top) + 10px) auto auto calc(var(--safe-left) + 10px);transform:none;width:calc(var(--screen-w) - var(--safe-left) - var(--safe-right) - 20px);height:calc(var(--screen-h) - var(--safe-top) - var(--safe-bottom) - 20px);max-height:none;max-width:none;padding:12px;grid-template-rows:44px 60px minmax(0,1fr) 44px;gap:8px;border-radius:24px}
 .shop .panel-heading h1{font-size:21px}.shop .category-tabs{height:60px}.shop .category-tabs button{min-height:52px}.shop .category-tabs span{font-size:14px}.shop .shop-list,.shop[data-page-size='4'] .shop-list{grid-template-columns:repeat(2,minmax(0,1fr));grid-template-rows:repeat(2,minmax(0,1fr));gap:8px}.shop .shop-card,.shop[data-page-size='4'] .shop-card{min-height:132px;padding:7px;gap:4px}.shop .shop-card>img{min-height:50px}.shop .shop-card h2{font-size:14px}.shop .shop-card button{min-height:44px;height:44px;font-size:16px}.shop .category-tabs img{height:32px;width:36px}.shop .shop-list{overflow:auto}
 .shop-controls{gap:8px}.shop .shop-pagination button,.shop #shop-previous,.shop #shop-next,.shop-inventory{height:44px;min-height:44px}.shop::before,.shop::after{background-size:100% 100%;opacity:.65}
 dialog,#castle-dialog,.feature-dialog,.garden-detail-dialog,.community-dialog{max-height:calc(var(--screen-h) - var(--safe-top) - var(--safe-bottom) - 20px);width:calc(var(--screen-w) - var(--safe-left) - var(--safe-right) - 20px);max-width:720px;top:var(--ui-top);bottom:var(--ui-bottom);overflow-y:auto;overscroll-behavior:contain;scroll-padding:16px;margin:auto;padding:48px 18px 20px;border-radius:23px}
 .community-dialog input,.community-dialog textarea,dialog input,dialog select{font-size:16px;min-height:44px}.community-dialog p,.garden-detail-dialog p{font-size:14px;line-height:1.7}.detail-build{position:sticky;bottom:0;z-index:2;box-shadow:0 2px 12px #204c3f33;font-size:14px;min-height:44px}.detail-stages{gap:7px;margin:14px 0}.detail-stages img{height:clamp(100px,25vw,180px)}.detail-stages figcaption{font-size:14px}.detail-facts{font-size:14px}.collection-pages{grid-template-columns:1fr}.collection-page>button{font-size:14px}.collection-page p,.collection-reward span{font-size:14px}
 #toast{top:calc(var(--hud-bottom) + 4px);max-width:calc(var(--screen-w) - 24px);font-size:14px}
 .photo-controls{bottom:calc(var(--ui-bottom) + 10px);width:calc(var(--screen-w) - var(--safe-left) - var(--safe-right) - 24px)}
}
@media(max-width:700px) and (max-height:580px) and (orientation:portrait){
 .shop{--shop-page-size:2}.shop .shop-list,.shop[data-page-size='2'] .shop-list{grid-template-rows:minmax(0,1fr)}
}
@media(max-width:700px) and (max-height:650px) and (orientation:landscape),(max-width:1400px) and (any-pointer:coarse) and (max-height:650px) and (orientation:landscape){
 :root{--hud-bottom:calc(var(--ui-top) + 54px);--dock-size:52px;--dock-height:70px}
 .topbar{display:grid;grid-template-columns:minmax(144px,1fr) minmax(260px,340px);grid-template-rows:42px;gap:12px;height:42px;align-items:center}
 .brand{width:164px;height:40px}.brand strong{font-size:19px}.brand-level{font-size:16px}.wallet{width:100%;height:36px}.resource strong{font-size:18px}
 .island-quick{inset:calc(var(--hud-bottom) + 4px) auto auto calc(var(--ui-left) + 54px);width:142px;height:36px;min-height:36px;font-size:13px;border-radius:13px}
 .left-actions{top:calc(var(--hud-bottom) + 4px);flex-direction:column;gap:6px}.left-actions button{width:44px;height:44px}
 .mobile-tools-toggle{top:calc(var(--hud-bottom) + 4px);height:44px;min-height:44px}
 .toolbar{top:calc(var(--hud-bottom) + 56px);grid-template-columns:repeat(4,54px);gap:6px;padding:8px;width:auto;max-width:none}.toolbar .tool:not(#open-shop){width:54px;height:60px}.camera-controls{top:calc(var(--hud-bottom) + 140px);right:var(--ui-right)}
 #open-shop{width:66px;height:66px;bottom:calc(var(--ui-bottom) + 6px)}
 .dhikr-dock{left:50%;right:auto;bottom:calc(var(--ui-bottom) + 4px);width:310px;height:70px;max-width:calc(var(--screen-w) - var(--safe-left) - var(--safe-right) - 176px);border-radius:22px}.dhikr-buttons,.dhikr,.dhikr:nth-child(n+4),.dhikr-3,.dhikr-4{height:52px}.dock-note{font-size:12px;height:16px;line-height:16px}
 .shop{--shop-page-size:4;left:calc(var(--safe-left) + 12px);top:calc(var(--ui-top) + 8px);width:calc(var(--screen-w) - var(--safe-left) - var(--safe-right) - 24px);height:calc(var(--screen-h) - var(--safe-top) - var(--safe-bottom) - 16px);padding:10px 12px;grid-template-columns:64px minmax(0,1fr);grid-template-rows:44px minmax(0,1fr) 44px;grid-template-areas:'heading heading' 'categories items' 'categories controls';gap:6px 10px;direction:ltr}
 .shop .panel-heading{direction:rtl}.shop .panel-heading h1{font-size:19px}.shop .category-tabs{display:flex;flex-direction:column;justify-content:flex-start;align-items:stretch;height:auto;min-height:0;overflow-y:auto;overflow-x:hidden;gap:6px;direction:rtl}.shop .category-tabs button{flex:0 0 52px;min-height:52px;min-width:0;width:100%;flex-direction:column;padding:3px;gap:0}.shop .category-tabs img{width:30px;height:28px}.shop .category-tabs span{font-size:12px;line-height:18px}.shop .shop-list,.shop[data-page-size='4'] .shop-list{grid-template-columns:repeat(4,minmax(0,1fr));grid-template-rows:minmax(0,1fr);gap:7px;direction:rtl}.shop .shop-card,.shop[data-page-size='4'] .shop-card{padding:6px;min-height:126px;gap:3px}.shop .shop-card>img{min-height:45px}.shop .shop-card h2{font-size:13px;line-height:18px}.shop .shop-card button{height:44px;min-height:44px}.shop-controls{direction:rtl}.shop .collection-badge{font-size:12px}
 .selected-panel{inset:calc(var(--hud-bottom) + 5px) var(--ui-right) auto auto;transform:none;width:min(320px,44vw);max-width:none;max-height:calc(var(--screen-h) - var(--safe-top) - var(--safe-bottom) - 70px);padding:10px 12px}.selected-panel .selected-image{width:60px;height:76px}.selected-panel .selected-heading h2{font-size:17px}.selected-panel .item-description{font-size:14px}.selected-panel .selected-actions{grid-template-columns:repeat(2,minmax(0,1fr));margin-top:6px;padding-top:5px}.selected-panel .selected-actions button:last-child:nth-child(3){grid-column:1/-1}
 body:has(.selected-panel:not([hidden])) .mobile-tools-toggle,body:has(.selected-panel:not([hidden])) .toolbar,body:has(.selected-panel:not([hidden])) .camera-controls{visibility:hidden;pointer-events:none}
 .placement-bar{left:calc(var(--ui-left) + 50px);right:calc(var(--ui-right) + 50px);bottom:calc(var(--ui-bottom) + 5px);transform:none;width:auto;max-width:760px;max-height:calc(var(--screen-h) - var(--safe-top) - var(--safe-bottom) - 80px);padding:8px 12px;gap:5px 10px}.placement-bar>div:first-child{flex-basis:100%;display:flex;align-items:center;justify-content:space-between;gap:14px;text-align:right}.placement-bar strong{font-size:15px}.placement-bar>div>span{font-size:13px;max-width:65%}.placement-bar .placement-option{flex:0 1 auto;font-size:14px}.placement-bar .art-confirm{flex:1;margin:0}.placing .camera-controls{display:none}
 .garden-guide{top:calc(var(--hud-bottom) + 48px);left:calc(var(--ui-left) + 54px);transform:none;width:240px;max-height:calc(var(--screen-h) - var(--safe-top) - var(--safe-bottom) - 125px);overflow:auto}.garden-guide strong{font-size:15px}.garden-guide p{font-size:14px;margin:5px 0}
 .garden-detail-dialog .detail-stages img{height:clamp(72px,calc(var(--screen-h) - 220px),150px)}.garden-detail-dialog{padding:30px 20px 12px}.garden-detail-dialog h2{font-size:21px;margin:4px 0}.detail-description{margin:6px 0}.detail-stages{margin:8px 0}.detail-stages figcaption{font-size:13px}.detail-facts{font-size:14px;padding:6px}.detail-build{margin-top:8px}.collection-pages{grid-template-columns:repeat(3,minmax(0,1fr))}.collection-miniatures{grid-template-columns:repeat(4,minmax(0,1fr))}.collection-page{padding:12px 8px}
 .community-dialog,.feature-dialog{padding:44px 22px 18px}.feature-dialog h2{font-size:23px}.hub-grid{grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}.hub-grid button{padding:8px;min-height:70px}.hub-grid span:last-child{font-size:14px}.hub-grid img,.hub-symbol{width:32px;height:32px;font-size:28px}.feature-dialog .focus-tap{width:110px;height:110px}.feature-dialog .focus-tap span{font-size:22px}.session-options{gap:8px}
 #toast{top:calc(var(--hud-bottom) + 4px);max-width:46vw}
}
@media(max-width:359px){
 .brand{width:150px}.brand strong{font-size:18px}.island-quick{width:130px;font-size:13px}.dhikr-dock{padding:0 4px}.resource strong{font-size:16px}.resource{grid-template-columns:21px minmax(0,1fr)}.resource-symbol{width:23px}.selected-panel .selected-actions button{font-size:13px}
}
