/* Phone layout (pointer:coarse), landscape only: in portrait a "turn your phone" screen covers the game. Every touch control's size
   and position lives here; the slot map and the reasons are in ZombieGame/touch-controls.md. Thumb-cluster offsets are measured from
   the stick centres, so change --stick and those offsets together.
   Rules: targets are at least 44 px; a control never moves while you play; a control with nothing to do is hidden. */
#touch-build,#touch-view,.stick-zone,.phone-note,#rotate-note{display:none}
@media(pointer:coarse){
:root{--el:max(14px,env(safe-area-inset-left));--er:max(14px,env(safe-area-inset-right));--eb:max(20px,env(safe-area-inset-bottom));--et:max(6px,env(safe-area-inset-top));--stick:132px;--row1:calc(var(--eb) + var(--stick) + 14px);--chip:clamp(100px,calc(100vw - 600px),128px)}
.desktop-hint,#crosshair,.desktop-note,.dodge-panel,.lobby-controls,#world-seed{display:none}.phone-note{display:block}.touch-note{color:#9eb4a5}
body.playing #world{cursor:default}

/* one look for every button a thumb presses */
#hud #touch-sneak,#hud #touch-dodge,#hud #touch-mark,#hud #touch-emote,#hud #touch-map,#hud #touch-view,#hud #touch-scope,#hud #touch-fire,#hud #touch-build,#hud #cam-left,#hud #cam-right,#hud #pickup-button,#hud #quick-heal,#hud #inventory-toggle,#hud #chat-toggle,#hud #build-place,#hud #build-rotate{position:absolute;align-items:center;justify-content:center;text-align:center;pointer-events:auto;touch-action:manipulation;border:1px solid #8af0c355;border-radius:12px;background:#12302acc;color:var(--mint);font:10px/1.2 var(--mono);letter-spacing:.5px;padding:2px;margin:0;min-height:0;white-space:normal;float:none;-webkit-tap-highlight-color:transparent}
#hud button:active{filter:brightness(1.5)}

/* sticks: a touch on the base works like a fixed stick; a touch elsewhere in the zone brings the base under the thumb */
#touch-controls{display:block}
.stick-zone{display:block;position:absolute;bottom:0;width:40vw;height:64vh;pointer-events:auto;touch-action:none}
#move-zone{left:0}#aim-zone{right:0}
.stick{width:var(--stick);height:var(--stick);bottom:var(--eb)}
#move-stick{left:calc(var(--el) + 6px)}#aim-stick{right:calc(var(--er) + 6px)}
.stick-knob{width:52px;height:52px;left:calc(50% - 26px);top:calc(50% - 26px)}
.stick>span{bottom:9px;font-size:7px;letter-spacing:.3px;opacity:.8}
.stick.held{background:#0a191388;border-color:#8af0c3aa}.stick.held>span{opacity:0}
#aim-stick.held{border-color:#eacb86aa}
#move-stick.sprinting{border-color:#e8c46a;box-shadow:0 0 0 3px #e8c46a44}#move-stick.sprinting .stick-knob{background:#e8c46a66;border-color:#e8c46a}
#aim-stick.firing{border-color:#ff8a7a;box-shadow:0 0 0 3px #ff8a7a44}#aim-stick.firing .stick-knob{background:#ff8a7a66;border-color:#ff8a7a}

/* left hand, movement, the view and the squad: SNEAK and HEAL above the stick; turn left, turn right, MARK and EMOTE beside it on the
   bottom edge; above them the minimap, VIEW (top-down or first person) and, when open, the emote menu */
#hud #touch-sneak{display:flex;left:var(--el);bottom:var(--row1);width:60px;height:60px;border-radius:50%}
#hud #touch-sneak[aria-pressed=true]{background:#8af0c3;color:#14241c}
#hud #quick-heal{display:flex;left:calc(var(--el) + 70px);bottom:var(--row1);width:60px;height:60px;border-radius:50%;border-color:#f18e7388;background:#3a1a16cc;color:#ffb19d;z-index:3}
#hud #quick-heal:disabled{display:none}
#cam-rotate{display:contents}
#hud #cam-left,#hud #cam-right{display:flex;width:48px;height:48px;bottom:var(--eb);font-size:22px;touch-action:none;z-index:3}
#hud #cam-left{left:calc(var(--el) + 146px)}#hud #cam-right{left:calc(var(--el) + 200px)}
#hud #touch-view{display:flex;width:52px;height:48px;left:calc(var(--el) + 238px);bottom:calc(var(--eb) + 58px);font-size:9px;z-index:3}#hud #touch-view[hidden]{display:none}#hud #touch-view[aria-pressed="true"]{background:#1d5a49;border-color:var(--mint)}
/* first person: no aim stick. The right side is a look pad (drag to look), FIRE is a button where the thumb rests, and a crosshair marks
   the centre. The turn buttons and EMOTE (you cannot see your own emote) are hidden */
body.first-person #hud #cam-left,body.first-person #hud #cam-right,body.first-person #hud #touch-emote,body.first-person #hud #emote-menu,body.first-person #aim-stick{display:none}
body.first-person #aim-zone{width:55vw;height:100vh}
body.first-person #crosshair{display:block}
body.first-person:not(.building) #hud #touch-fire{display:flex;right:calc(var(--er) + 28px);bottom:calc(var(--eb) + 22px);width:88px;height:88px;font-size:13px;border-color:#e86a6a88;background:#3a1616cc;color:#ff8a7a;touch-action:none}
#hud #touch-mark{display:flex;left:calc(var(--el) + 254px);bottom:var(--eb);width:48px;height:48px}
#hud #touch-emote{display:flex;left:calc(var(--el) + 308px);bottom:var(--eb);width:52px;height:48px;font-size:9px}
#hud #touch-emote[aria-expanded=true]{background:#8af0c3;color:#14241c}
#hud #emote-menu:not([hidden]){display:grid;grid-template-columns:repeat(2,46px);gap:4px;pointer-events:auto;position:absolute;z-index:30;left:calc(var(--el) + 294px);bottom:calc(var(--eb) + 58px)}   /* CA-4: 2x2 so SIT fits clear of DODGE at 667x375 */
#hud #emote-menu button{min-width:46px;height:48px;padding:2px 4px;border:1px solid #8af0c366;border-radius:12px;background:#12302af0;color:var(--mint);font:10px var(--mono);touch-action:manipulation}
#minimap{width:84px;height:84px;left:calc(var(--el) + 146px);right:auto;top:auto;bottom:calc(var(--eb) + 58px)}
#hud #touch-map{display:flex;align-items:flex-end;left:calc(var(--el) + 146px);bottom:calc(var(--eb) + 58px);width:84px;height:84px;border-radius:50%;background:transparent;border-color:transparent;font-size:8px;padding-bottom:6px;text-shadow:0 0 4px #000,0 0 2px #000;z-index:3}
#hud:has(#minimap[hidden]) #touch-map{align-items:center;padding:2px;background:#12302acc;border-color:#8af0c355}

/* right hand, fighting and handling: DODGE and the main action on an arc around the stick. The main action is whatever is nearest
   (pick up, search, open, drive); it becomes FIRE while the scope is up and PLACE while building. The weapon chip (tap to switch)
   sits beside the stick, and a modifier slot on the screen edge holds SCOPE with the rifle and ROTATE while building */
#hud #touch-dodge{display:flex;flex-direction:column;right:calc(var(--er) + 134px);bottom:calc(var(--eb) + 88px);width:64px;height:64px;border-radius:50%;font-size:20px;gap:0}
#hud #touch-dodge span{font:8px var(--mono)}
#hud #pickup-button{display:flex;right:calc(var(--er) + 57px);bottom:calc(var(--eb) + 142px);width:68px;height:68px;border-radius:50%;border-color:#e8c46a;background:#2e2814e6;color:#f3dc9a;font-size:9px;z-index:4;overflow:hidden}
#hud #pickup-button:disabled{display:none}
/* FB-62b: with 2+ actions in reach a small chip above the main action button cycles them */
#hud #pickup-next{display:flex;position:absolute;align-items:center;justify-content:center;right:calc(var(--er) + 63px);bottom:calc(var(--eb) + 214px);min-width:56px;height:24px;padding:0 8px;margin:0;border:1px solid #e8c46a;border-radius:12px;background:#2e2814e6;color:#f3dc9a;font:9px/1 var(--mono);letter-spacing:.5px;pointer-events:auto;touch-action:manipulation;-webkit-tap-highlight-color:transparent;z-index:4}
#hud #pickup-next[hidden],body.scope-held #hud #pickup-next,body.building #hud #pickup-next{display:none}
/* CA-4: with 2+ actions on the selected object, its other actions stack above the gold button (above the NEXT chip while it shows).
   44 px rows; the stack scrolls past two rows so it never leaves the screen. */
#hud #pickup-panel{display:flex;flex-direction:column;gap:4px;position:absolute;right:calc(var(--er) + 57px);bottom:calc(var(--eb) + 214px);width:112px;max-height:96px;overflow-y:auto;z-index:4;pointer-events:auto;touch-action:manipulation}
#hud:has(#pickup-next:not([hidden])) #pickup-panel{bottom:calc(var(--eb) + 242px)}
#hud #pickup-panel[hidden],body.scope-held #hud #pickup-panel,body.building #hud #pickup-panel{display:none}
#hud .pickup-option{display:flex;align-items:center;justify-content:center;flex:none;width:100%;height:44px;min-height:44px;margin:0;padding:2px 4px;border:1px solid #e8c46a;border-radius:12px;background:#2e2814e6;color:#f3dc9a;font:9px/1.2 var(--mono);text-align:center;touch-action:manipulation;-webkit-tap-highlight-color:transparent}
#hud .pickup-option:disabled{opacity:.45;border-color:#8a7d55}
#hud #touch-fire,#hud #build-place{right:calc(var(--er) + 57px);bottom:calc(var(--eb) + 142px);width:68px;height:68px;border-radius:50%;font-size:11px;z-index:31}
body.scope-held #hud #touch-fire{display:flex;border-color:#e86a6a88;background:#3a1616e6;color:#ff8a7a;touch-action:none}
body.scope-held #hud #pickup-button,body.building #hud #pickup-button,body.building #hud #touch-fire{display:none}
body.building #hud #build-place{display:flex;position:fixed;border-color:#8af0c3;background:#16302ae6;color:var(--mint)}
#weapon-panel{position:fixed;right:calc(var(--er) + 148px);bottom:var(--eb);width:var(--chip);height:48px;padding:5px 8px;border:1px solid #8af0c355;border-radius:12px;background:#0d1716e6;pointer-events:auto;touch-action:manipulation;cursor:pointer;align-items:center;gap:0;z-index:3}
#weapon-panel .weapon-icon{display:none}#weapon-panel .weapon-switch{position:absolute;top:-9px;right:-7px;width:22px;height:22px;display:flex;align-items:center;justify-content:center;border:1px solid #8af0c3aa;border-radius:50%;background:#12302af0;color:var(--mint);pointer-events:none}#weapon-panel .weapon-switch svg{width:13px;height:13px}#weapon-panel>div{gap:3px;width:100%;min-width:0}
#weapon-panel b{font-size:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}#weapon-panel div>span{gap:6px;justify-content:space-between;font-size:7px}#weapon-panel em{font-size:15px;line-height:1}
#hud #touch-scope,#hud #build-rotate{right:var(--er);bottom:calc(var(--eb) + 152px);width:48px;height:48px;font-size:9px}
body.rifle-active #hud #touch-scope{display:flex;z-index:30}
body.building #hud #touch-scope{display:none}
body.building #hud #build-rotate{display:flex;position:fixed}#build-rotate b{display:none!important}
#hud #touch-scope[aria-pressed=true]{background:#8af0c3;color:#14241c}
/* looking down the scope: only the sticks, DODGE, SCOPE and FIRE stay, drawn above the scope mask, and what is hidden cannot be pressed */
body.scoped #hud{z-index:21}
body.scoped #hud>:not(#touch-controls):not(#touch-scope):not(#touch-fire):not(.stick-zone),body.scoped #hud #cam-left,body.scoped #hud #cam-right,body.scoped #survival-ui>*,body.scoped #weapon-panel{pointer-events:none}
body.scoped #hud #cam-left,body.scoped #hud #cam-right,body.scoped #survival-ui>*{opacity:0;transition:opacity .15s}

/* top of the screen: things you read, and the three menus you open rarely */
#compass{top:var(--et);width:min(250px,calc(100vw - 480px));height:26px}
body.playing .topbar{padding:0;pointer-events:none}body.playing .brand,body.playing #network-label,body.playing .network>i{display:none}
body.playing .network{position:fixed;top:var(--et);right:calc(var(--er) + 174px)}
body.playing #sound{display:none} /* on a phone SOUND lives in the settings menu */
body.playing #sound,body.playing #settings-btn{pointer-events:auto;min-width:48px;height:44px;margin:0;padding:0 5px;border:1px solid #ffffff22;border-radius:10px;background:#0d1716cc;font-size:8px;line-height:1.3}
body #objective-line{top:calc(var(--et) + 30px);padding:3px 8px;font-size:10px;letter-spacing:.5px;max-width:calc(100vw - 400px);overflow:hidden;text-overflow:ellipsis}
#survival-ui{display:contents}
#hud #survival-hunger,#hud #survival-thirst{position:absolute;top:var(--et);width:84px;height:44px;min-height:0;font-size:9px;line-height:1.3;border-radius:10px;pointer-events:auto;touch-action:manipulation;cursor:pointer;text-align:center;z-index:3}
#hud #survival-hunger{left:var(--el)}#hud #survival-thirst{left:calc(var(--el) + 90px)}
#hud #quick-food,#hud #quick-water{display:none}
#hud #inventory-toggle,#hud #touch-build,#hud #chat-toggle{display:flex;top:var(--et);width:52px;height:44px;font-size:9px;z-index:3}
#hud #inventory-toggle{right:var(--er)}#hud #touch-build{right:calc(var(--er) + 58px)}#hud #chat-toggle{position:fixed;right:calc(var(--er) + 116px)}
#hud #touch-build[aria-pressed=true],#hud #inventory-toggle[aria-expanded=true]{background:#8af0c3;color:#14241c}
.bottom-hud{display:block;top:calc(var(--et) + 50px);left:var(--el);bottom:auto;padding:7px 10px;border-radius:10px}
.vitals{width:150px}.vital-title{font-size:10px}.vital-title>span{max-width:80px}.vital-title>b{font-size:12px}.vital-caption{display:none}
.health-track{margin:6px 0 5px}.stamina-track{margin:0}#status-chips{margin:6px 0 0}
.run-stats,body.playing .run-stats{left:calc(var(--el) + 184px);right:auto;top:calc(var(--et) + 60px);gap:10px;align-items:baseline}
.run-stats>div{flex-direction:row;gap:5px;align-items:baseline}.run-stats b{font-size:13px}.run-stats .threat-stat,.run-stats>div:first-child>span{display:none}
.run-stats>div:nth-child(2)>span{font-size:0}.run-stats>div:nth-child(2)>span::after{content:'KILLS';font-size:7px}
.squad{right:var(--er);top:calc(var(--et) + 50px);width:150px;max-height:76px;overflow:hidden}.squad>.eyebrow{display:none}
.roster-player{padding:3px 0;font-size:10px;justify-content:flex-end}.roster-player b{display:inline;margin-left:6px}
body #beacon-hud{right:auto;left:calc(var(--el) + 184px);top:calc(var(--et) + 84px)}
#survival-message,#car-hud{top:calc(var(--et) + 60px)}#car-hud{bottom:auto!important}
#hud #window-progress{position:absolute;left:50%;top:calc(50% + 84px);translate:-50% 0;width:150px}
body #beacon-progress{bottom:auto;top:calc(50% + 84px)}
#world-info{bottom:auto;top:calc(50% + 60px);right:50%;transform:translateX(50%);max-width:70%;align-items:center;font-size:8px;text-shadow:0 0 4px #000}
#chat-root{top:calc(var(--et) + 54px);left:auto;right:calc(var(--er) + 160px);width:min(220px,calc(100vw - 500px))}
#chat-panel:not([hidden]){padding:6px;background:#111d1bcc}#chat-log{max-height:44px;font-size:11px}

/* build tray: opened by BUILD, a row of pieces under the objective; PLACE takes the main action slot and ROTATE the modifier slot */
#build-controls{display:none;left:calc(var(--el) + 184px);right:calc(var(--er) + 172px);bottom:auto;top:calc(var(--et) + 58px);flex-direction:row;flex-wrap:wrap;gap:6px;padding:6px;border-radius:12px;z-index:5}
body.build-open #build-controls,body.building #build-controls{display:flex}
body.build-open .run-stats,body.building .run-stats,body.build-open #beacon-hud,body.building #beacon-hud{display:none}
#build-controls>span{display:none}
#hud #build-controls button:not(.build-only){flex:1 1 44px;min-width:44px;height:48px;padding:2px;font-size:9px;border-radius:10px;touch-action:manipulation}
#build-status{right:auto;left:0;bottom:auto;top:calc(100% + 6px);min-width:150px}

/* loot window (LT-D5): the same middle sheet as the bag, with 44 px buttons */
#hud #loot-window{left:calc(var(--el) + 146px);right:calc(var(--er) + 206px);top:calc(var(--et) + 50px);bottom:auto;max-height:calc(100vh - var(--et) - var(--eb) - 110px);width:auto;max-width:none;transform:none;padding:12px;border-radius:12px}
#hud #loot-window h3{min-height:44px;margin:0 52px 6px 0;display:flex;align-items:center}#hud #loot-window .loot-close{width:44px;height:44px;padding:0;top:12px;right:12px;font-size:18px}#hud #loot-window .loot-take,#hud #loot-window .loot-take-all{min-height:44px}

/* bag: a sheet in the middle, between the thumb clusters and above the bottom row, so every thumb control stays usable (K4) */
#hud #inventory-panel{position:fixed;left:calc(var(--el) + 146px);right:calc(var(--er) + 206px);top:calc(var(--et) + 50px);bottom:calc(var(--eb) + 56px);width:auto;max-width:none;padding:12px;overflow:auto;border-radius:12px;z-index:8}
#inventory-panel .tab-bar{margin:0 52px 10px 0}#hud #inventory-panel .tab-btn{min-height:44px;padding:4px}
#hud #inventory-panel>button{right:8px;top:12px;width:44px;height:44px;padding:0}
#inventory-panel .slots-container{grid-template-columns:repeat(auto-fill,minmax(48px,1fr));justify-content:stretch}#inventory-panel .slot{width:auto;min-height:48px;height:auto;aspect-ratio:1}#inventory-panel .back-slot{aspect-ratio:auto;height:48px}
#hud #inventory-panel .slot-detail button{min-height:44px;font-size:10px}
#hud #craft-panel .craft-btn{min-height:44px}
#fullmap .fullmap-bar span{display:none}.fullmap-bar button{min-height:44px}
}
@media(pointer:coarse) and (max-width:760px){#weapon-panel #weapon-mode{display:none}}

/* portrait: the game is landscape only on a phone. The lobby still works, so a name can be typed; play is covered by this screen */
@media(pointer:coarse) and (orientation:portrait){
body.playing #rotate-note{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;position:fixed;inset:0;z-index:100;padding:30px;background:#0b1413f7;color:var(--text);text-align:center;font:700 15px/1.5 var(--mono);letter-spacing:1.5px;pointer-events:auto;touch-action:none}
#rotate-note i{font-style:normal;font-size:54px;color:var(--mint);line-height:1}#rotate-note small{font-weight:400;font-size:11px;letter-spacing:.5px;color:var(--muted)}
}
/* NPC-1: the conversation scrolls between the thumb clusters; the passive shared log stays above them. */
@media(pointer:coarse){
#npc-dialogue{position:fixed;left:calc(var(--el) + 146px);right:calc(var(--er) + 146px);top:calc(var(--et) + 45px);bottom:calc(var(--eb) + 12px);padding:12px;overflow:auto;overscroll-behavior:contain;touch-action:pan-y;font-size:14px}
#npc-dialogue .npc-choices{display:flex;flex-direction:column;gap:6px}#npc-dialogue button{min-height:44px;padding:8px 12px;width:100%;touch-action:manipulation}#npc-dialogue .npc-choices+button{margin-top:8px}
#npc-quest-log{position:fixed;left:calc(var(--el) + 146px);right:calc(var(--er) + 206px);top:calc(var(--et) + 50px);max-height:92px;padding:6px 8px;overflow:auto;font-size:12px;pointer-events:auto;touch-action:pan-y}#npc-quest-log article{padding:3px 0}
}
/* FT-5: the report form is a modal, no fixed control; its fields stay thumb-sized and it scrolls in the short landscape height */
@media(pointer:coarse){#report-form{padding:12px 14px;gap:5px}#report-form textarea{height:44px;min-height:44px;resize:none}#report-form label{gap:3px}#report-form input:not([type=checkbox]),#report-form select,#report-form textarea{min-height:44px}#report-form .row button,#report-open{min-height:44px}#report-toast{top:calc(var(--et) + 52px)}}

@media(pointer:coarse){
/* Keep clear of the left vitals and minimap, the right actions and the bottom row. */
#hud #inventory-panel{left:calc(var(--el) + 238px);right:calc(var(--er) + 206px);bottom:calc(var(--eb) + 56px);padding:6px;max-height:none;overflow:hidden}
/* the bag takes the height down to the bottom row, so VIEW (which sat under it) is hidden while the bag is open */
body:has(#inventory-panel:not([hidden])) #hud #touch-view{display:none}
#inventory-panel .tab-bar{margin:0 46px 4px 0;gap:2px}
#hud #inventory-panel .tab-btn{font-size:7px;letter-spacing:0;padding:2px;min-width:0}
#hud #inventory-panel>button{top:6px;right:6px}
#inventory-panel #tabpanel-inventory:not([hidden]){display:grid;grid-template-columns:120px minmax(0,1fr);grid-template-rows:minmax(44px,1fr) auto;gap:4px;flex:1}
#inventory-panel .slots-container{grid-column:1/-1;grid-row:1;grid-template-columns:repeat(auto-fill,minmax(44px,1fr));gap:4px}
#inventory-panel .slot{height:44px;min-height:44px;aspect-ratio:auto}
#inventory-panel .back-row{grid-column:1;grid-row:2;margin:0;align-self:end;gap:4px}   /* CL-1: four cells (BACK, HEAD, TORSO, BODY) wrap two by two, each keeping the 44px tap size */
#inventory-panel .back-slot{width:58px;height:44px;padding:2px;gap:2px;grid-auto-flow:row}
#inventory-panel .back-slot .icon{width:22px;height:22px}
#inventory-panel .back-tag{font-size:8px}
#inventory-panel .slot-detail{grid-column:2;grid-row:2;margin:0;padding:2px;gap:2px}
#inventory-panel .detail-name{font-size:9px;flex-basis:100%}
#hud #inventory-panel .slot-detail button{padding:2px 4px;min-width:44px}
}
/* PT-2: the playtest panel (client/playtest-client.js). Opened from SETTINGS > PLAYTEST; a landscape phone gives it the right half so the game stays visible, and nothing scrolls the page. */
@media(pointer:coarse){#playtest{top:6px;right:6px;bottom:6px;width:min(420px,58vw)}#playtest-body button,#playtest-body select,#playtest-body input,#playtest-body textarea{min-height:40px}#playtest-body textarea{min-height:56px}#playtest-open{min-height:40px}}
