/* Phone gameplay: reserve the centre for Scout, with full details one tap away.
   Loaded last so these rules own the mobile HUD without changing desktop cards. */
@media(max-width:600px),(max-height:560px) and (orientation:landscape){
  body.started .footer{display:none}
  body.started:not(.fullscreen-mode) #game-shell{margin-bottom:max(6px,env(safe-area-inset-bottom))}
  .top-hud{top:8px;left:8px;right:8px;bottom:174px;display:grid;grid-template-columns:minmax(0,1fr) 65px;gap:8px;align-items:start}
  .top-hud>.quest:not(.compact){display:grid;grid-template-columns:minmax(0,1fr) 44px 44px;column-gap:8px;align-content:start;padding:8px}
  .quest:not(.compact)>*{grid-column:1/-1}
  .quest:not(.compact)>.eyebrow{grid-column:1;grid-row:1;padding:0;align-self:center}
  .quest:not(.compact)>#mission-hear{position:sticky;top:0;right:auto;grid-column:2;grid-row:1;align-self:start;z-index:2}
  .quest:not(.compact)>#quest-toggle{position:sticky;top:0;right:auto;grid-column:3;grid-row:1;align-self:start;z-index:2;background:#eff3e7}
  .top-hud>.quest.compact,body.driving .top-hud>.quest.compact{display:grid;grid-template-columns:minmax(0,1fr) 44px 44px;grid-template-rows:44px 44px 14px;gap:8px;width:100%;max-width:260px;height:124px;min-height:0;padding:2px;overflow:hidden;border-radius:12px}
  .quest.compact>.eyebrow,.quest.compact #compact-icon,.quest.compact .compact-why,.quest.compact .compact-meter{display:none}
  .quest.compact .compact-mission,body.driving .quest.compact .compact-mission{display:contents;margin:0}
  .quest.compact #compact-step,body.driving .quest.compact #compact-step{grid-column:1;grid-row:1;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;align-self:center;margin:0;overflow:hidden;font-size:14px;line-height:1.25;font-weight:600}
  .quest.compact #mission-hear,body.driving .quest.compact #mission-hear{position:static;grid-column:2;grid-row:1;width:44px;min-width:44px;height:44px;margin:0}
  .quest.compact #quest-toggle,body.driving .quest.compact #quest-toggle{position:static;grid-column:3;grid-row:1;width:44px;min-width:44px;height:44px;margin:0;font-size:12px}
  .quest.compact .mission-actions,body.driving .quest.compact .mission-actions{grid-column:1/-1;grid-row:2;display:grid;grid-template-columns:1fr 1fr;gap:8px;margin:0}
  .quest.compact .mission-actions button{width:100%;min-width:44px;min-height:44px;height:44px;padding:4px;font-size:12px;line-height:1.1;gap:4px}
  .quest.compact .mission-actions svg{width:17px;height:17px;flex:none}
  .quest.compact #compact-progress,body.driving .quest.compact #compact-progress{grid-column:1/-1;grid-row:3;display:block;margin:0;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;font-size:11px;line-height:14px;color:var(--label-green)}
  .top-hud>.status-column,.quest.compact~.status-column{position:static;display:flex;flex-direction:column;align-items:center;gap:8px;width:65px;margin:0}
  .status-column #stealth-pill{width:44px;height:44px;padding:10px}
  .status-column #stealth-text,.status-column .status-dot{display:none}
  .top-hud>.status-column #energy-status.picture-energy{height:58px;min-height:58px;padding:2px;gap:0}
  .top-hud>.status-column #energy-status.picture-energy>.picture-energy-disc{width:30px;height:30px;flex-basis:30px}
  .top-hud>.status-column #energy-status.picture-energy .picture-energy-copy strong{font-size:11px;min-height:22px}
  .status-column>.view-toggle{width:65px;height:44px;min-height:44px;padding:3px;gap:2px;font-size:10px;flex-direction:column}
  .status-column>.view-toggle svg{width:17px;height:17px}
  .location-tag,.mini-tip{display:none}
  .bottom-hud,#game-shell:has(#toast.visible) .bottom-hud,body.driving .bottom-hud{top:auto;left:10px;right:auto;bottom:112px}
  .map-button,#game-shell:has(#toast.visible) .map-button{display:flex;justify-content:center;align-items:center;width:56px;height:52px;min-height:52px;padding:4px;border-radius:10px}
  .map-button canvas,#game-shell:has(#toast.visible) .map-button canvas{display:none}
  .map-button>span,#game-shell:has(#toast.visible) .map-button>span{display:flex;flex-direction:column;gap:3px;font-size:0;padding:0}
  .map-button>span:after{content:'Map';font-size:11px;line-height:1}
  .map-button>span svg{width:20px;height:20px}
  .camera-toolbar,.camera-toolbar.playing-only,body.driving .camera-toolbar{top:auto;bottom:112px;left:74px;right:10px;transform:none;display:flex;flex-wrap:nowrap;justify-content:stretch;gap:8px;max-width:none;width:auto}
  .camera-toolbar button{flex:1;min-width:44px;min-height:52px;height:52px;padding:4px;flex-direction:column;gap:3px;font-size:11px;line-height:1.1;white-space:normal}
  .camera-toolbar button svg{width:18px;height:18px;flex:none}
  .camera-toolbar button b,.camera-toolbar button kbd{display:none}
  #touch-controls{left:12px;right:12px;bottom:12px}
  #joystick{width:80px;height:80px}
  #joystick-knob{width:40px;height:40px}
  .touch-actions{gap:8px}
  .touch-actions button{width:56px;height:56px;min-width:56px}
  #touch-interact{width:68px;height:68px;min-width:68px}
}
@media(max-width:600px) and (orientation:portrait){
  #game-shell:has(#toast.visible) .top-hud{bottom:232px}
  #toast{bottom:174px;left:10px;width:calc(100% - 92px);max-width:calc(100% - 92px)}
  body.driving .car-controls{bottom:174px;left:10px;transform:none;width:calc(100% - 92px);max-width:calc(100% - 92px);padding:4px;gap:4px}
  body.driving .car-controls>span{display:none}
  .car-controls .secondary-button{min-height:44px}
}
@media(max-height:560px) and (orientation:landscape){
  .top-hud{grid-template-columns:minmax(0,260px) 236px;bottom:106px;gap:12px}
  .top-hud>.quest.compact,body.driving .top-hud>.quest.compact{grid-template-rows:44px 44px;gap:8px;height:100px;padding:1px;width:260px;max-width:100%}
  .quest.compact #compact-progress,body.driving .quest.compact #compact-progress{display:none}
  .top-hud>.status-column,.quest.compact~.status-column{display:grid;grid-template-columns:44px 58px 58px 58px;grid-template-rows:58px 3px;gap:6px;width:236px;align-items:center;justify-items:center}
  .status-column #stealth-pill{grid-column:1;grid-row:1;width:44px;height:44px;padding:10px}
  .status-column #coin-wallet{grid-column:2;grid-row:1;width:58px}
  .status-column #energy-status{grid-column:3;grid-row:1}
  .top-hud>.status-column #energy-status.picture-energy{width:58px;max-width:58px;height:58px;min-height:58px}
  .top-hud>.status-column #energy-status.picture-energy>.picture-energy-copy{width:52px}
  .top-hud>.status-column #energy-status.picture-energy .picture-energy-copy strong{max-width:52px}
  .status-column>.view-toggle{grid-column:4;grid-row:1;width:58px}
  .status-column>.alert-track{grid-column:1/-1;grid-row:2;width:100%}
  .camera-toolbar,.camera-toolbar.playing-only,body.driving .camera-toolbar{top:auto;bottom:10px;left:50%;right:auto;transform:translateX(-50%);width:250px;max-width:calc(100% - 240px);gap:6px}
  .camera-toolbar button{height:48px;min-height:48px}
  .bottom-hud,#game-shell:has(#toast.visible) .bottom-hud,body.driving .bottom-hud{top:auto;bottom:90px;left:auto;right:14px;transform:none}
  .map-button,#game-shell:has(#toast.visible) .map-button{height:44px;min-height:44px}
  #touch-controls{bottom:10px}
  #game-shell:has(#toast.visible) .top-hud{bottom:128px}
  #game-shell:has(#toast.visible) .bottom-hud{left:calc(100% - 198px);right:auto;bottom:70px;transform:none}
  #toast{bottom:70px;left:110px;width:calc(100% - 318px);max-width:calc(100% - 318px)}
  body.driving .car-controls{bottom:68px;left:50%;transform:translateX(-50%);max-width:calc(100% - 250px);width:auto;padding:4px 8px;gap:5px}
  body.driving .car-controls>span{display:none}
  body.driving .camera-toolbar{left:12px;bottom:110px;transform:none;width:auto}
  body.driving .bottom-hud{left:auto;right:14px;bottom:110px;transform:none}
  body.driving #touch-interact{display:none}
}
@media(max-width:600px) and (max-height:560px) and (orientation:landscape){
  .top-hud{grid-template-columns:minmax(0,220px) 236px}
  .top-hud>.quest.compact,body.driving .top-hud>.quest.compact{width:220px}
}

@media(max-width:350px){
  .header .brand-mark{display:none}
  .header nav{gap:8px}
  .header .pause-button{min-width:44px;min-height:44px}
}

/* The challenge picker is a menu, so all three choices should read as one
   set on a phone instead of leaving the last choice behind the fixed action. */
@media(max-width:600px) and (orientation:portrait){
  .dialog-card:has(.challenge-choice-grid) .challenge-choice-grid{gap:6px}
  .dialog-card:has(.challenge-choice-grid) .challenge-choice-card{grid-template-columns:64px minmax(0,1fr) 44px;grid-template-rows:44px 44px;gap:3px;padding:3px}
  .dialog-card:has(.challenge-choice-grid) .challenge-choice-art{grid-column:1;grid-row:1/3}
  .dialog-card:has(.challenge-choice-grid) .challenge-choice-art>svg{width:62px;height:62px}
  .dialog-card:has(.challenge-choice-grid) .challenge-choice-copy{grid-column:2;grid-row:1/3;gap:2px}
  .dialog-card:has(.challenge-choice-grid) .challenge-choice-copy strong{font-size:15px;line-height:1.08}
  .dialog-card:has(.challenge-choice-grid) .challenge-choice-copy span{font-size:11px;line-height:1.12}
  .dialog-card:has(.challenge-choice-grid) .challenge-choice-copy small{display:none}
  .dialog-card:has(.challenge-choice-grid) .challenge-choice-speaker{grid-column:3;grid-row:1;height:44px}
  .dialog-card:has(.challenge-choice-grid) .challenge-choice-button{grid-column:3;grid-row:2;height:44px;font-size:12px}
}
