/* 48.5: touch presentation only; desktop selectors and simulation stay intact. */
.touch-only{display:none!important}
body.touch-play{--touch-dock:105px;--touch-head:76px;--touch-right:0px;-webkit-text-size-adjust:100%;text-size-adjust:100%}
.touch-play .touch-only{display:flex!important}.touch-play .touch-only[hidden]{display:none!important}
.touch-play button{touch-action:manipulation;-webkit-tap-highlight-color:transparent;min-height:48px}
.touch-play input,.touch-play select{font-size:16px;min-height:44px}
.touch-play #world{position:fixed;inset:0;width:100%;height:100dvh}
.touch-play header{position:fixed;inset:0 0 auto;display:grid;grid-template-columns:minmax(0,1fr) 46px 46px;align-items:center;gap:6px;min-height:0;padding:calc(5px + env(safe-area-inset-top)) max(8px,env(safe-area-inset-right)) 6px max(8px,env(safe-area-inset-left));background:#223f31f5;z-index:12}
.touch-play header .brand,.touch-play header #music,.touch-play header #voice,.touch-play header #help,.touch-play header #gameMenuButton,.touch-play #treasuryButton,.touch-play #housingAvailability{display:none!important}
.touch-play header .stats{order:0;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:2px;width:100%;min-width:0;margin:0;padding:0;background:none;border:0;box-shadow:none;backdrop-filter:none}
.touch-play header .stats>div{min-width:0;padding:2px;text-align:center;border:0;border-radius:10px;background:#ffffff08}
.touch-play header .stats>div:nth-child(4){display:none}
.touch-play header .stats span{display:block;font-size:20px;line-height:24px;color:#ffe2a5}
.touch-play header .stats b{display:block;white-space:nowrap;font-size:14px;line-height:21px;font-weight:750}
.touch-play header #touchSound,.touch-play header #pause{display:flex;align-items:center;justify-content:center;width:46px;min-width:46px;height:48px;min-height:48px;margin:0;padding:0;border:1px solid #dbd5a440;border-radius:14px;background:#456344;color:#ffedc8;font-size:22px}
.touch-play .speed-controls,.touch-play #weatherStatus{display:none!important}
.touch-play #bearStatus:not(.bear-danger){display:none!important}
.touch-play #bearStatus.bear-danger{position:fixed;top:calc(var(--touch-head) + 8px);left:10px;right:auto;max-width:calc(100% - 70px);font-size:13px;border-radius:12px;z-index:18}
.touch-play #hungerAlert,.touch-play #prisonAlert,.touch-play #deathNotice{position:fixed;top:calc(var(--touch-head) + 8px);left:10px;right:10px;bottom:auto;transform:none;max-width:none;padding:9px 12px;font-size:14px;z-index:20}
.touch-play footer#commandDock,.touch-play.kids footer#commandDock{position:fixed;inset:auto 0 0;transform:none;filter:none;display:flex!important;flex-direction:column;gap:0;width:100%;max-width:none;height:auto;min-height:0;max-height:56dvh;padding:4px max(8px,env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left));border:0;border-top:2px solid #d4ca96;border-radius:20px 20px 0 0;background:linear-gradient(#36563d,#243f30);box-shadow:0 -4px 22px #1233213d;z-index:15;overflow:hidden}
.touch-play #commandDock .dock-tabs{order:30;flex:0 0 66px;display:grid;grid-template-columns:repeat(5,minmax(0,1fr));width:100%;gap:5px;align-items:stretch;overflow:visible;margin:0;padding:4px 0 0;border:0;border-radius:0;background:none}
.touch-play #commandDock .dock-tabs>button{display:none!important}
.touch-play #commandDock .dock-tabs #tabBuild,.touch-play #commandDock .dock-tabs #tabUnits,.touch-play #commandDock .dock-tabs #demolishTool,.touch-play #commandDock .dock-tabs #minimapToggle,.touch-play #commandDock .dock-tabs #touchMore{display:flex!important;flex-direction:column;align-items:center;justify-content:center;gap:2px;min-width:0;width:auto;min-height:60px;height:62px;padding:4px 2px;margin:0;border:1px solid #b9c69b55;border-radius:14px;background:#456344;color:#fff0cb;font-size:12px;font-weight:750;line-height:1.2}
.touch-play #commandDock .dock-tabs #demolishTool{background:#705538;border-color:#d0b67a;color:#ffe9b9}
.touch-play #commandDock .dock-tabs button[aria-pressed=true]{background:#ffe2a1!important;border-color:#fff1c9!important;color:#29462d!important;box-shadow:inset 0 -3px #dfba68}
.touch-play #commandDock .dock-tabs #demolishTool[aria-pressed=true]{background:#ffd0a8!important;border-color:#ffd9b6!important;color:#5c311d!important}
.touch-play #commandDock .touch-nav-icon{display:block;width:33px;height:31px;min-height:0;object-fit:contain;margin:0;font-size:28px;line-height:30px;filter:drop-shadow(0 2px 1px #13281333)}
.touch-play #commandDock #dockPopulation{display:none}
.touch-play #touchDockMeta{order:0;flex:0 0 auto;display:flex;align-items:center;gap:7px;min-height:40px;padding:0 3px 4px;color:#ecdfb3}
.touch-play #touchDrawerTitle{flex:1;min-width:0;font-size:14px;font-weight:700}
.touch-play #touchDockMeta #year{font-size:11px;white-space:nowrap;font-weight:550;color:#ced8b5}
.touch-play #touchCloseDrawer{flex:0 0 44px;width:44px;min-height:44px;height:44px;padding:0;border-radius:12px;background:#ffffff12;font-size:20px}
.touch-play #touchCloseDrawer[hidden]{display:none!important}
.touch-play #commandDock.dock-collapsed #touchDockMeta{min-height:22px;padding-bottom:0}
.touch-play #commandDock.dock-collapsed #touchDrawerTitle{font-size:11px;color:#d6dfbf;font-weight:500}
.touch-play #commandDock .dock-context,.touch-play #commandDock .footnote,.touch-play #commandDock .timeline{display:none!important}
.touch-play #commandDock .buildbar,.touch-play #commandDock .unitbar,.touch-play #commandDock .chiefbar{order:10;flex:1 1 auto;min-height:0!important;height:auto!important;max-height:none!important;width:100%;padding:0!important;margin:0;border:0;border-radius:0;background:none;box-shadow:none;overflow-x:hidden;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}
.touch-play #commandDock[data-panel=build] .buildbar{display:flex!important;flex-direction:column;gap:4px}
.touch-play #commandDock[data-panel=build] .unitbar,.touch-play #commandDock[data-panel=build] .chiefbar,.touch-play #commandDock[data-panel=units] .buildbar,.touch-play #commandDock[data-panel=units] .chiefbar,.touch-play #commandDock[data-panel=commands] .buildbar,.touch-play #commandDock[data-panel=commands] .unitbar{display:none!important}
.touch-play #commandDock[data-panel=units] .unitbar{display:flex!important;flex-direction:column;gap:7px}
.touch-play #commandDock[data-panel=commands] .chiefbar{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px}
.touch-play #commandDock .chiefbar>button{min-height:54px!important;padding:10px!important;font-size:14px!important}
.touch-play #commandDock.dock-collapsed .buildbar,.touch-play #commandDock.dock-collapsed .unitbar,.touch-play #commandDock.dock-collapsed .chiefbar{display:none!important}
.touch-play #commandDock .categories{display:flex!important;flex:0 0 46px;gap:5px;min-height:46px;overflow-x:auto;overflow-y:hidden;padding:0 0 3px;white-space:nowrap;scrollbar-width:none;touch-action:pan-x}
.touch-play #commandDock .categories button{flex:0 0 auto;min-height:44px;padding:6px 11px;font-size:13px;border-radius:11px;background:#29472f;border:1px solid #d8cba140}
.touch-play #commandDock .categories button.active{background:#e3ebc2;color:#2a432c}
.touch-play #commandDock .categories #cancel,.touch-play #commandDock .categories #economyButton{display:none}
.touch-play #commandDock #buildings{display:flex;flex:0 0 auto;align-items:stretch;justify-content:flex-start;gap:8px;min-height:126px;padding:2px 0 6px;overflow-x:auto;overflow-y:hidden;scroll-snap-type:x proximity;scrollbar-width:none;touch-action:pan-x}
.touch-play #commandDock #buildings button,.touch-play.kids #commandDock #buildings button{flex:0 0 118px;min-width:118px;max-width:118px;height:auto;min-height:120px;max-height:none;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;gap:4px;padding:8px 5px;border:2px solid #aebc83;border-radius:15px;background:#e8edcf!important;color:#2b472f;text-align:center;scroll-snap-align:start;transform:none;box-shadow:none}
.touch-play #commandDock #buildings button.active{background:#ffe2a1!important;border-color:#ffcb66}
.touch-play #commandDock #buildings button.locked{background:#b9c7ac!important;opacity:1;border-style:dashed}
.touch-play #commandDock #buildings img{width:58px!important;height:53px!important;object-fit:contain}
.touch-play #commandDock #buildings button:nth-child(n) strong{font-size:14px!important;font-weight:750!important;line-height:1.2}
.touch-play #commandDock #buildings button small{display:block;font-size:12px!important;line-height:1.25;color:#405f38!important;margin:3px 0 0}
.touch-play #commandDock .build-scroll,.touch-play #commandDock #hint{display:none!important}
.touch-play #touchBuildPager{display:flex;flex:0 0 48px;align-items:center;justify-content:space-between;gap:8px;padding-bottom:4px;font-size:12px;color:#e6e6c7}
.touch-play #touchBuildPager button{width:48px;min-height:44px;height:44px;font-size:19px;border-radius:11px;background:#456344}
.touch-play #commandDock #armyRecruitBar:not([hidden]){display:flex;flex:0 0 auto;gap:6px;overflow:auto;padding:5px 0}
.touch-play #armyRecruitBar button{min-height:48px;font-size:13px;padding:8px 12px;border-radius:11px}
.touch-play #touchMinimap{display:none!important;position:fixed;top:calc(var(--touch-head) + 8px);left:max(10px,env(safe-area-inset-left));bottom:auto;width:242px;height:auto;max-height:calc(100dvh - var(--touch-head) - var(--touch-dock) - 22px);gap:7px;padding:10px;border:2px solid #d9cf9d;border-radius:17px;background:#294633fa;z-index:24;box-shadow:0 8px 25px #142b2955;overflow:auto}
.touch-play.touch-map-open #touchMinimap{display:flex!important;flex-direction:column}
.touch-play #touchMinimap .map-heading{display:flex;align-items:center;gap:4px;font-size:10px;white-space:nowrap}
.touch-play #touchMinimap .map-heading button{flex:0 0 44px;width:44px;height:44px;min-height:44px;padding:0;border-radius:10px;font-size:19px}
.touch-play #touchMinimap #miniHome{margin-left:auto}
.touch-play #touchMinimap #minimap{width:100%;height:auto;max-height:none;aspect-ratio:1.5}
.touch-play #touchMinimap small{display:block;font-size:11px;text-align:center}
.touch-play #touchMapTools{position:fixed;left:max(10px,env(safe-area-inset-left));bottom:calc(var(--touch-dock) + 10px);z-index:10}
.touch-play #touchMapTools button{min-height:46px;max-width:170px;padding:9px 12px;background:#2b4a35ed;color:#ffedca;border:1px solid #d6cc9c;border-radius:14px;font-size:13px;font-weight:650}
.touch-play .zoom,body.touch-play:has(#selectionPanel:not([hidden])) .zoom{position:fixed;top:auto;right:calc(var(--touch-right) + max(10px,env(safe-area-inset-right)));bottom:calc(var(--touch-dock) + 10px)!important;display:grid;grid-template-columns:1fr;gap:5px;z-index:10}
.touch-play .zoom button{width:44px!important;height:44px!important;min-height:44px!important;border-radius:13px;font-size:23px;background:#2b4a35ed}
.touch-play .zoom #overview{display:none}
.touch-play #touchModeBar{position:fixed;left:max(10px,env(safe-area-inset-left));right:calc(var(--touch-right) + 64px);bottom:calc(var(--touch-dock) + 10px);display:flex;align-items:center;gap:8px;padding:7px 8px 7px 12px;border:2px solid #ffde93;border-radius:16px;background:#fff0c5;color:#29432e;box-shadow:0 4px 12px #16372633;z-index:12}
.touch-play #touchModeLabel{flex:1;font-size:13px;line-height:1.35;font-weight:700}
.touch-play #touchModeBar[data-kind=demolish],.touch-play #touchModeBar[data-kind=fire]{background:#ffe0be;border-color:#f5b77d;color:#693b22}
.touch-play #touchCancel{flex:0 0 auto;min-height:44px;padding:8px;border:0;border-radius:11px;background:#376b43;color:#fff9dd;font-size:13px;font-weight:750}
.touch-play #joystickWrap{display:none}.touch-play.touch-joystick #joystickWrap{display:flex;position:fixed;bottom:calc(var(--touch-dock) + 65px);left:10px;z-index:10}
.touch-play #cameraJoystick{width:88px;height:88px}
.touch-play #notification{position:fixed;top:calc(var(--touch-head) + 9px);bottom:auto!important;left:calc((100% - var(--touch-right))/2);transform:translateX(-50%);width:max-content;max-width:calc(100% - var(--touch-right) - 20px);font-size:14px;line-height:1.4;padding:9px 13px;border-radius:13px;background:#294633f5;z-index:23;box-shadow:0 4px 14px #17362333;pointer-events:none}
.touch-play #commandDock .resident-toolbar{display:flex!important;flex:0 0 auto;flex-wrap:wrap;gap:5px;grid-column:auto;grid-row:auto}
.touch-play .resident-toolbar button{min-height:44px!important;padding:7px 10px!important;font-size:13px!important}
.touch-play #unitHousing{width:100%;font-size:12px!important;line-height:1.4}
.touch-play #recruitmentConditions{max-height:none;font-size:12px;overflow:visible;flex-shrink:0}
.touch-play #recruitmentPane{min-height:210px;flex:0 0 auto}
.touch-play #quickResidents{min-height:170px;scroll-snap-type:x proximity}
.touch-play #quickResidents .recruit-card-wrap{flex:0 0 152px}
.touch-play #quickResidents .recruit-card-wrap .recruit-card{height:auto;min-height:132px;grid-template-rows:42px auto auto;padding:7px}
.touch-play #quickResidents .recruit-help{min-height:44px;flex-basis:44px;font-size:13px}
.touch-play #recruitmentStatus{max-height:none;white-space:normal;font-size:12px}
.touch-play #residentRosterPane{min-height:180px;flex-shrink:0}
.touch-play #unitRoster button{min-width:88px;min-height:100px!important;font-size:14px}
.touch-play #selectionGroupPane{min-height:235px;flex:0 0 auto}
.touch-play #selectionGroupRoster{min-height:100px;flex:1 0 100px;grid-template-columns:repeat(auto-fill,minmax(170px,1fr))}
.touch-play #selectionProfessions button,.touch-play .selection-filter-scroll>button{min-height:44px;font-size:13px}
.touch-play .selection-filter-scroll{flex-basis:46px}
.touch-play dialog{width:min(660px,calc(100vw - 20px));max-width:calc(100vw - 20px);max-height:calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px);padding:20px 16px;border-radius:20px;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}
.touch-play dialog button{min-height:48px;font-size:16px;line-height:1.35}
.touch-play dialog input,.touch-play dialog select{font-size:16px}
.touch-play dialog h2{font-size:25px}
.touch-play #stockDialog,.touch-play #recoveryDialog,.touch-play #residentsDialog{max-height:calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px)}
.touch-play #touchMoreDialog .touch-more-grid{display:grid;grid-template-columns:1fr 1fr;gap:9px}
.touch-play #touchMoreDialog .touch-more-grid button{min-height:68px;padding:10px 7px;font-size:15px;background:#e3eac8;color:#29432f;border:1px solid #b1ba90}
.touch-play .touch-dialog-heading{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:16px}
.touch-play .touch-dialog-heading h2{margin:0}
.touch-play .touch-dialog-heading button{width:48px;flex:0 0 48px;padding:0;font-size:25px}
.touch-play #touchWelcome{padding:26px 22px;text-align:center;width:min(440px,calc(100vw - 28px));border:2px solid #e7d49b;background:linear-gradient(145deg,#fff8df,#e3eccb);color:#2d472f}
.touch-play #touchWelcome::backdrop{background:#17362bbf;backdrop-filter:blur(7px)}
.touch-play .touch-welcome-art{height:132px;display:flex;align-items:flex-end;justify-content:center;gap:2px;margin:0 0 10px}
.touch-play .touch-welcome-art img{width:62px;height:91px;object-fit:contain;filter:drop-shadow(0 5px 2px #67784533)}
.touch-play .touch-welcome-art img:first-child{width:142px;height:132px}
.touch-play .touch-welcome-art img:last-child{width:42px;height:55px}
.touch-play #touchWelcome h2{font:700 32px Georgia,serif;margin:10px 0}
.touch-play #touchWelcome p{font-size:16px;line-height:1.45;margin:10px 0 16px}
.touch-play #touchPlay{min-height:68px;width:100%;font-size:25px;border-radius:18px;background:#427844;border:0;color:#fff9db;box-shadow:0 5px 0 #254c2a}
.touch-play #touchPlay:disabled{box-shadow:none;background:#ccd4ba;color:#506342;font-size:19px}
.touch-play .touch-sound-choice{display:flex;align-items:center;justify-content:center;gap:12px;min-height:52px;margin-top:13px;font-size:16px;font-weight:650}
.touch-play .touch-sound-choice input{width:24px;height:24px;min-height:24px;accent-color:#477641}
.touch-play #touchWelcome small{display:block;font-size:12px;color:#61714d}

@media(min-width:768px) and (min-height:541px){
 .touch-play header{grid-template-columns:minmax(0,560px) 48px 48px;justify-content:center;gap:10px}
 .touch-play header .stats b{font-size:19px}.touch-play header .stats span{font-size:22px}
 .touch-play footer#commandDock{max-height:46dvh;padding-left:max(18px,env(safe-area-inset-left));padding-right:max(18px,env(safe-area-inset-right))}
 .touch-play #commandDock .dock-tabs{grid-template-columns:repeat(5,minmax(70px,120px));justify-content:center}
 .touch-play #commandDock #buildings button{flex-basis:136px;min-width:136px;max-width:136px}
}
@media(max-height:540px) and (min-width:600px){
 .touch-play header{right:var(--touch-right);grid-template-columns:minmax(0,1fr) 44px 44px;gap:4px;padding-top:max(4px,env(safe-area-inset-top))}
 .touch-play header .stats b{font-size:13px}.touch-play header .stats span{font-size:17px;line-height:20px}
 .touch-play header #touchSound,.touch-play header #pause{width:44px;min-width:44px;height:44px;min-height:44px}
 .touch-play footer#commandDock,.touch-play.kids footer#commandDock{inset:0 0 0 auto;width:clamp(248px,34vw,310px);max-height:none;height:100dvh;border-top:0;border-left:2px solid #d4ca96;border-radius:16px 0 0 16px;padding-top:max(6px,env(safe-area-inset-top));padding-right:max(8px,env(safe-area-inset-right))}
 .touch-play #commandDock.dock-collapsed{width:88px;justify-content:space-between}
 .touch-play #commandDock .dock-tabs{flex:0 0 61px;grid-template-columns:repeat(5,minmax(0,1fr));gap:3px}
 .touch-play #commandDock .dock-tabs #tabBuild,.touch-play #commandDock .dock-tabs #tabUnits,.touch-play #commandDock .dock-tabs #demolishTool,.touch-play #commandDock .dock-tabs #minimapToggle,.touch-play #commandDock .dock-tabs #touchMore{height:56px;min-height:56px;font-size:10px;border-radius:10px}
 .touch-play #commandDock .touch-nav-icon{width:27px;height:27px;font-size:24px;line-height:25px}
 .touch-play #commandDock.dock-collapsed .dock-tabs{flex:1;display:flex;flex-direction:column;gap:5px;padding-top:6px;justify-content:center}
 .touch-play #commandDock.dock-collapsed .dock-tabs>button{flex:1;max-height:64px;width:100%!important;min-height:46px!important}
 .touch-play #commandDock.dock-collapsed #touchDockMeta{min-height:15px;padding:0;justify-content:center}
 .touch-play #commandDock.dock-collapsed #touchDrawerTitle{display:none}.touch-play #commandDock.dock-collapsed #year{font-size:8px}
 .touch-play #touchDrawerTitle{font-size:12px}.touch-play #touchDockMeta #year{font-size:9px}
 .touch-play #commandDock #buildings{display:grid;grid-template-columns:1fr 1fr;overflow:visible;gap:7px}
 .touch-play #commandDock #buildings button{width:100%;min-width:0!important;max-width:none!important;min-height:112px}
 .touch-play #touchBuildPager{display:none}
 .touch-play #notification{max-width:calc(100% - var(--touch-right) - 20px)}
 .touch-play #hungerAlert,.touch-play #prisonAlert,.touch-play #deathNotice{right:calc(var(--touch-right) + 10px)}
 .touch-play #touchWelcome{max-height:calc(100dvh - 20px);padding:16px 22px}
 .touch-play .touch-welcome-art{display:none}.touch-play #touchWelcome h2{font-size:28px;margin:0 0 6px}
 .touch-play #touchWelcome p{margin:6px 0 12px}.touch-play #touchPlay{min-height:58px}
}

.touch-play #touchMapTools{flex-direction:column;align-items:flex-start;gap:6px}
.touch-play #touchMapTools button[hidden]{display:none!important}
.touch-play #touchSelected{background:#ffe1a2!important;color:#29432d!important}
