/* UI language follows the player; world coordinates and calligraphy do not. */
html[data-game-language] dialog,html[data-game-language] .panel,html[data-game-language] .garden-guide,html[data-game-language] #item-hover-tip,html[data-game-language] #garden-editor,html[data-game-language] .placement-bar,html[data-game-language] .placement-option{direction:var(--ui-direction,rtl)}
html[data-game-language] #shop :is(.panel-heading,.category-tabs,.shop-list,.shop-controls),html[data-game-language] #placement-bar :is(.placement-option,#confirm-place),html[data-game-language] #placement-bar>div:first-child{direction:var(--ui-direction,rtl)}
html[data-game-language] dialog:not(.focus-dialog):not(#castle-dialog),html[data-game-language] .session-options,html[data-game-language] .shadow-style-options button,html[data-game-language] .goal-card,html[data-game-language] .garden-guide,html[data-game-language] #placement-bar>div:first-child{text-align:start}
html[data-game-language] .dhikr-dock{direction:rtl}
/* Terrain is a physical left-to-right tile atlas, independent of UI reading order. */
html[data-game-language] #world{direction:ltr}
html[data-game-language] .placement-nudges{direction:ltr}
html[data-game-language] .build-time{direction:var(--ui-direction,rtl)}
html[data-game-language] #focus-arabic,html[data-game-language] #session-dhikr{direction:rtl;font-family:Swissra,Tahoma,sans-serif}
html[data-game-language] #focus-translation{direction:var(--ui-direction,rtl)}
html[data-game-language]:not([lang=ar]) body,html[data-game-language]:not([lang=ar]) button,html[data-game-language]:not([lang=ar]) input,html[data-game-language]:not([lang=ar]) select,html[data-game-language]:not([lang=ar]) dialog h2,html[data-game-language]:not([lang=ar]) .garden-guide,html[data-game-language]:not([lang=ar]) #item-hover-tip{font-family:system-ui,'Segoe UI',Tahoma,Arial,sans-serif}
html[data-game-language]:is([lang=ur],[lang=fa]) body{font-family:Tahoma,'Noto Naskh Arabic',Arial,sans-serif}
html[data-game-language] [data-no-i18n]{unicode-bidi:plaintext}
.language-setting{display:grid;gap:8px;margin:12px 0 4px;font-size:15px;text-align:left}
.language-setting,.language-field,.language-status{direction:ltr;text-align:left}
.welcome-dialog .language-field{text-align:left}
html[data-game-language] [data-language-select],html[data-game-language] [data-language-select] option{direction:ltr;text-align:left;unicode-bidi:isolate}
.language-setting select,.welcome-dialog select{width:100%;max-width:100%;min-height:48px;padding:10px 12px;border:1px solid #75aca6;border-radius:12px;background:#f3fff4;color:#164b51;font:16px/1.6 system-ui,Tahoma,sans-serif;box-sizing:border-box}
.language-status{min-height:1.5em;font-size:13px;margin:4px 0}
.welcome-dialog{width:min(470px,calc(100vw - 24px));max-height:calc(100dvh - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px) - 24px);padding:26px 30px 24px;background:linear-gradient(145deg,#ecfff4,#b1dbd8);border:1px solid #efffde;border-radius:26px;overscroll-behavior:contain}
.welcome-dialog .welcome-emblem{display:block;text-align:center;font:54px/1 Georgia,serif;color:#a98239;margin-bottom:10px}
.welcome-dialog h2{font-size:24px;text-align:center;margin:0 0 6px;line-height:1.5}
.welcome-dialog>p{text-align:center;margin:0 0 20px;font-size:14px}
.welcome-dialog label{display:grid;gap:5px;margin:10px 0;font-size:14px;text-align:start}
.welcome-dialog input{margin:0;min-height:48px;font-size:16px}
.welcome-dialog button[type=submit]{width:100%;font-size:16px;min-height:48px;background:#21665f;color:#f4ffe6}
.welcome-dialog small{display:block;text-align:center;margin-top:14px;font-size:12px}
.welcome-dialog .community-error{font-size:13px;margin:8px 0;min-height:0}
.welcome-dialog .community-error:empty{display:none}
.welcome-dialog .welcome-close{position:absolute;inset-inline-end:12px;top:14px;margin:0}
.welcome-dialog .welcome-close[hidden]{display:none}
html[data-game-language] #shop #categories button span{max-width:100%;white-space:normal;line-height:1.25;overflow-wrap:anywhere;text-align:center;font-family:inherit}
html[data-game-language] #shop #categories button{min-width:0;flex-shrink:0}
html[data-game-language]:not([lang=ar]) .hub-grid button span:last-child{overflow-wrap:anywhere;line-height:1.35}
html[data-game-language]:not([lang=ar]) .studio-tabs button{white-space:normal;line-height:1.3}
html[data-game-language]:not([lang=ar]) .toolbar .tool:not(#open-shop)>span:not(.inventory-art){font-size:12px;line-height:1.3;white-space:normal;overflow-wrap:anywhere;max-width:100%;text-align:center}
html[data-game-language] .island-quick{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
html[data-game-language] .goal-card>div{min-width:0;overflow-wrap:break-word}
@media(max-width:700px){html[data-game-language] .island-card{text-align:start}.welcome-dialog{padding:22px}.welcome-dialog h2{font-size:21px}}
@media(max-height:500px) and (orientation:landscape){.welcome-dialog{width:min(660px,calc(100vw - 40px));padding:14px 26px}.welcome-dialog .welcome-emblem{display:none}.welcome-dialog>p{margin-bottom:8px}.welcome-dialog form{display:grid;grid-template-columns:1fr 1fr;gap:8px 16px}.welcome-dialog label{margin:2px 0}.welcome-dialog form button,.welcome-dialog .community-error{grid-column:1/-1}.welcome-dialog small{margin-top:8px}}

/* Long translations get space without reversing physical camera/grid controls. */
html[data-game-language] :is(.selected-heading h2,.detail-facts,.detail-description,#garden-editor header){min-width:0;overflow-wrap:anywhere}
@media(max-width:700px),(max-width:1400px) and (any-pointer:coarse){
 html[data-game-language] #shop{grid-template-rows:minmax(44px,auto) 76px minmax(0,1fr) 44px}
 html[data-game-language] #shop .panel-heading>div{min-width:0}
 html[data-game-language] #shop .panel-heading h1{font-size:18px;line-height:1.3;overflow-wrap:anywhere}
 html[data-game-language] #shop .shop-inventory{white-space:normal;overflow-wrap:anywhere;line-height:1.25}
 html[data-game-language] #shop #categories{height:76px}
 html[data-game-language] #shop #categories button{min-height:70px;flex-basis:84px;padding:4px}
 html[data-game-language] #shop #categories button span{font-size:12px;line-height:15px}
 html[data-game-language] .toolbar .tool:not(#open-shop){height:auto;min-height:68px}
 html[data-game-language] .toolbar .tool:not(#open-shop)>span:not(.inventory-art){position:static}
 html[data-game-language] #garden-editor{left:var(--ui-left,10px);right:var(--ui-right,10px);bottom:calc(var(--ui-bottom,10px) + 68px);width:auto;max-height:calc(var(--screen-h,100dvh) * .48)}
 html[data-game-language] .photo-controls{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));width:calc(var(--screen-w,100vw) - var(--safe-left,0px) - var(--safe-right,0px) - 24px);max-width:560px}
 html[data-game-language] .photo-controls>span{grid-column:1/-1;min-width:0;overflow-wrap:anywhere}
 html[data-game-language] .photo-controls button{min-width:0;white-space:normal;overflow-wrap:anywhere;font:14px/1.4 system-ui,Tahoma,sans-serif}
 html[data-game-language] .dock-note{white-space:normal;height:auto;line-height:15px;min-height:30px;overflow-wrap:break-word}
 html[data-game-language] .dhikr-dock{height:auto;min-height:calc(var(--dock-size) + 32px)}
 html[data-game-language]{--dock-height:calc(var(--dock-size) + 32px)}
}
@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){
 html[data-game-language] #shop{direction:ltr;grid-template-columns:84px minmax(0,1fr);grid-template-rows:minmax(44px,auto) minmax(0,1fr) 44px}
 html[data-game-language] #shop #categories{height:auto}
 html[data-game-language] #shop #categories button{flex-basis:auto;min-height:66px}
 html[data-game-language] #garden-editor{left:auto;right:var(--ui-right,10px);top:calc(var(--hud-bottom,54px) + 8px);bottom:calc(var(--ui-bottom,0px) + 8px);width:min(300px,45vw);max-height:none}
}
@media(max-width:1400px) and (max-height:350px) and (orientation:landscape){
 body:not(.mobile-tools-collapsed) .toolbar{height:auto;min-height:90px;align-items:stretch}
}
