/* Touch layout owns its control space in both orientations, including notches.
   Keep this last: chapter-specific presentation must not cover the controls. */
:root{--safe-top:env(safe-area-inset-top,0px);--safe-bottom:env(safe-area-inset-bottom,0px);--safe-left:env(safe-area-inset-left,0px);--safe-right:env(safe-area-inset-right,0px)}
body.touch-mode{height:100dvh;overscroll-behavior:none;-webkit-tap-highlight-color:transparent}
body.touch-mode #world,body.touch-mode #hud{touch-action:none}
body.touch-mode button{touch-action:manipulation}
body.touch-mode #interact{touch-action:none;transition:none;animation:none;min-height:56px;min-width:0;width:max-content;max-width:min(400px,calc(100vw - 32px));bottom:calc(228px + var(--safe-bottom));padding:10px 16px;border-radius:14px;border-color:#d9dcad99;background:#10362af5;box-shadow:0 4px 18px #041d2a50;gap:10px}
body.touch-mode #interact-text{font-size:calc(12px * var(--text-scale,1));line-height:1.35;white-space:normal}
body.touch-mode .interact-ring{flex-shrink:0;width:32px;height:32px}
body.first-bloom.touch-mode #interact .interact-ring{display:none}
body.touch-mode .touch-stick{bottom:calc(82px + var(--safe-bottom));width:132px;height:132px;border-radius:50%}
body.touch-mode .touch-stick.move{left:max(14px,var(--safe-left))}
body.touch-mode .touch-stick.aim{right:max(14px,var(--safe-right))}
body.touch-mode .stick-base{width:94px;height:94px;background:#123a2b88;border:1px solid #e1e6bc70;box-shadow:inset 0 0 24px #0c262549,0 3px 16px #071c2330}
body.touch-mode .stick-base i{width:38px;height:38px;background:#c6d6b8d6;box-shadow:0 2px 8px #0c262580}
body.touch-mode .touch-stick.held .stick-base{border-color:#f4e8b9;background:#1d503cd9}
body.touch-mode .touch-stick>span{bottom:1px;font-size:9px;letter-spacing:.12em}
body.touch-mode .hud-bottom{left:max(14px,var(--safe-left));right:max(14px,var(--safe-right));bottom:calc(12px + var(--safe-bottom));height:60px}
body.touch-mode .vitals,body.first-bloom.touch-mode .vitals{width:142px;max-width:40%;height:58px;padding:8px 10px}
body.touch-mode .abilities{left:auto;right:0;transform:none;gap:7px;bottom:0}
body.touch-mode .ability{width:52px;height:58px;border-radius:12px;min-height:44px}
body.touch-mode .ability b{font-size:8px}
body.touch-mode .ability kbd{display:none}
body.touch-mode #touch-swap{bottom:calc(135px + var(--safe-bottom));width:64px;min-height:58px;padding:8px 4px;border-radius:12px}
body.touch-mode #touch-swap small{font-size:8px;line-height:1.2;white-space:normal}
body.touch-mode .hud-top{top:calc(8px + var(--safe-top));left:max(14px,var(--safe-left));right:max(14px,var(--safe-right))}
body.touch-mode #pause-btn{min-width:44px;min-height:44px}
body.touch-mode .hud-top-right{gap:10px}
body.touch-mode #hud .objective{top:calc(70px + var(--safe-top))!important;left:max(14px,var(--safe-left));max-width:230px}
body.touch-mode #tutorial{bottom:calc(230px + var(--safe-bottom));max-width:calc(100vw - 32px)}
body.touch-mode #boss-hud,body.touch-mode #boss-hud.sovereign{top:calc(140px + var(--safe-top));left:50%;transform:translateX(-50%);width:min(360px,calc(100vw - 32px));max-width:none}
body.touch-mode #toasts{top:calc(72px + var(--safe-top));right:14px;width:min(250px,calc(100vw - 28px));pointer-events:none}
body.first-bloom.touch-mode .bloom-chapter{top:calc(70px + var(--safe-top));left:max(14px,var(--safe-left));width:min(330px,calc(100vw - 28px));padding:12px 15px;border-radius:0 12px 12px 0}
body.first-bloom.touch-mode .bloom-chapter h2{font-size:22px;margin:4px 34px 6px 0}
body.first-bloom.touch-mode .bloom-chapter p{font-size:calc(12px * var(--text-scale,1));line-height:1.4;margin:8px 0 0}
body.first-bloom.touch-mode #bloom-journal-button{position:absolute;right:2px;top:0;margin:0;min-width:44px;min-height:44px;font-size:0}
body.first-bloom.touch-mode #bloom-journal-button:after{content:'✎';font-size:23px}
body.first-bloom.touch-mode #bloom-steps{margin-top:8px}
body.first-bloom.touch-mode #bloom-caption{bottom:calc(300px + var(--safe-bottom));width:min(420px,calc(100vw - 28px));padding:10px 14px}
body.first-bloom.touch-mode #bloom-caption p{font-size:calc(15px * var(--text-scale,1));line-height:1.35;margin-top:4px}
body.first-bloom.touch-mode #bloom-breath{top:auto;bottom:calc(232px + var(--safe-bottom));max-width:calc(100vw - 32px);font-size:11px}
body.first-bloom.touch-mode:has(#interact:not(.hidden)) #bloom-breath{bottom:calc(295px + var(--safe-bottom))}
body.touch-mode .input-hint{font-size:0}
body.touch-mode .input-hint:after{content:'LEFT STICK  MOVE     ·     RIGHT STICK  AIM / WATER';font-size:9px;letter-spacing:.08em}
@media(max-width:1024px),(pointer:coarse){
 #menu{height:100%;height:100dvh;overflow-y:auto;overflow-x:hidden;justify-content:flex-start;padding:0 max(20px,var(--safe-left)) max(16px,var(--safe-bottom));-webkit-overflow-scrolling:touch;touch-action:pan-y}
 #menu header{flex-shrink:0;min-height:72px;padding-top:var(--safe-top);gap:16px}
 #menu nav{overflow-x:auto;flex-shrink:1;touch-action:pan-x}
 #menu .nav{min-height:44px;flex-shrink:0}
 #home-panel{flex:1 0 auto;min-height:0;padding:24px 0;gap:30px}
 #menu footer{position:relative;flex-shrink:0;padding:16px 0;height:auto;min-height:48px}
 #menu .start-row button{min-height:48px}
 #overlay{padding:max(12px,var(--safe-top)) max(12px,var(--safe-right)) max(12px,var(--safe-bottom)) max(12px,var(--safe-left))}
 #modal{max-height:calc(100dvh - max(24px,var(--safe-top)) - var(--safe-bottom));overscroll-behavior:contain;touch-action:pan-y}
 #modal input,#modal select,#modal textarea{font-size:16px}
}
@media(max-width:600px){
 #menu header{display:flex;flex-direction:column;align-items:flex-start;gap:6px;padding:18px 0 0}
 #menu nav{width:100%;display:flex;gap:17px;order:2}
 #menu .brand{font-size:18px}
 #menu .version,#menu .hero-copy,#menu .chapter-preview{display:none}
 #home-panel{display:block;padding-top:20px}
 #menu .intro{max-width:100%}
 #menu .garden-title{font-size:clamp(52px,15vw,78px);margin:14px 0}
 #menu .hero-sub{font-size:24px;margin:14px 0 22px}
 #menu .start-row{display:grid;grid-template-columns:1fr;gap:10px;width:100%;max-width:420px}
 #menu .start-row button{width:100%;justify-content:space-between;margin:0}
 #menu .input-hint{margin-top:20px}
 #menu footer .weather,#menu footer .build-note{font-size:8px}
}
@media(orientation:landscape) and (max-height:600px){
 body.touch-mode .touch-stick{bottom:calc(12px + var(--safe-bottom));width:132px;height:132px}
 body.touch-mode .hud-bottom{left:160px;right:160px}
 body.touch-mode .abilities{left:50%;right:auto;transform:translateX(-50%)}
 body.touch-mode .vitals,body.first-bloom.touch-mode .vitals{position:fixed;top:calc(10px + var(--safe-top));left:50%;transform:translateX(-50%);width:150px;height:40px;max-width:none;padding:7px 10px}
 body.touch-mode .vitals .ranger-label,body.touch-mode .vitals .xp-line{display:none}
 body.touch-mode .vitals .health-track{margin-top:3px}
 body.touch-mode #touch-swap{left:auto;right:max(154px,calc(var(--safe-right) + 140px));bottom:calc(18px + var(--safe-bottom));transform:none}
 body.touch-mode #interact{bottom:calc(90px + var(--safe-bottom));max-width:min(360px,calc(100vw - 330px));min-height:48px;padding:9px 13px}
 body.touch-mode #tutorial{bottom:calc(95px + var(--safe-bottom));max-width:calc(100vw - 350px);font-size:11px}
 body.touch-mode #hud .objective{top:calc(62px + var(--safe-top))!important;max-width:220px}
 body.touch-mode #boss-hud,body.touch-mode #boss-hud.sovereign{top:calc(60px + var(--safe-top));left:auto;right:max(14px,var(--safe-right));transform:none;width:240px}
 body.first-bloom .bloom-chapter{top:calc(62px + var(--safe-top));width:min(270px,38vw);padding:9px 12px}
 body.first-bloom .bloom-kicker,body.first-bloom #bloom-steps{display:none}
 body.first-bloom .bloom-chapter h2{font-size:19px;margin:0 24px 4px 0}
 body.first-bloom .bloom-chapter p{font-size:calc(11px * var(--text-scale,1));margin-top:4px;line-height:1.35}
 body.first-bloom #bloom-caption{top:calc(62px + var(--safe-top));bottom:auto;left:auto;right:max(14px,var(--safe-right));transform:none;width:min(280px,35vw);padding:9px 12px;text-align:left}
 body.first-bloom #bloom-caption p{font-size:calc(13px * var(--text-scale,1))}
 body.first-bloom #bloom-breath,body.first-bloom.touch-mode:has(#interact:not(.hidden)) #bloom-breath{bottom:calc(155px + var(--safe-bottom));max-width:calc(100vw - 330px);padding:6px 12px}
 body.touch-mode #toasts{top:auto;bottom:calc(155px + var(--safe-bottom));right:50%;transform:translateX(50%);width:260px}
 #menu header{min-height:56px;padding-top:var(--safe-top)}
 #menu .brand{font-size:17px;white-space:nowrap}
 #menu nav{gap:14px}#menu .version{display:none}
 #home-panel{padding:8px 0 20px;display:block}
 #menu .intro{max-width:100%;width:100%}
 #menu .garden-title{font-size:49px;line-height:.95;margin:8px 0}
 #menu .hero-sub{font-size:19px;margin:10px 0 16px}
 #menu .hero-copy,#menu .chapter-preview{display:none}
 #menu .eyebrow{font-size:8px}
 #menu .start-row{display:flex;flex-wrap:wrap;gap:8px;margin:0}
 #menu .start-row button{min-height:46px;padding:12px 17px;font-size:11px}
 #menu .input-hint{margin-top:14px}
 #menu footer{padding:8px 0}
 #modal{padding:20px}
}

@media(orientation:landscape) and (max-height:600px) and (max-width:660px){body.touch-mode .abilities{left:calc(50% - 30px)}}
@media(max-width:370px) and (orientation:portrait){body.touch-mode .vitals,body.first-bloom.touch-mode .vitals{width:calc(100vw - 220px);max-width:none}body.touch-mode .ranger-label{font-size:9px}}
@media(max-height:700px) and (orientation:portrait){body.first-bloom.touch-mode .bloom-kicker,body.first-bloom.touch-mode #bloom-steps{display:none}body.first-bloom.touch-mode .bloom-chapter{padding:9px 12px}body.first-bloom.touch-mode .bloom-chapter h2{font-size:19px}body.first-bloom.touch-mode .bloom-chapter p{font-size:calc(11px * var(--text-scale,1));margin-top:4px}body.first-bloom.touch-mode #bloom-caption{padding:8px 12px}body.first-bloom.touch-mode #bloom-caption p{font-size:calc(13px * var(--text-scale,1))}}
