#mobile-menu {display:none}
@media (max-width:700px), (pointer:coarse) and (max-width:1100px), (orientation:landscape) and (max-height:500px) {
  :root {
    --edge-top:max(6px,env(safe-area-inset-top));
    --edge-right:max(9px,env(safe-area-inset-right));
    --edge-bottom:max(9px,env(safe-area-inset-bottom));
    --edge-left:max(9px,env(safe-area-inset-left));
  }
  html,body {overflow:hidden;overscroll-behavior:none}
  #stage {inset:0 0 auto;height:100vh;height:100dvh;overflow:hidden}
  #canvas,.hud {position:absolute;inset:0}
  .hud {display:block;padding:0;background:none}
  .hud header {
    position:absolute;inset:0 0 auto;min-height:54px;z-index:4;gap:8px;
    padding:var(--edge-top) var(--edge-right) 5px var(--edge-left);
    background:linear-gradient(#08131bed,#08131b00);
  }
  .hud header .game-wordmark {width:clamp(68px,18vw,110px)}
  .hud header h1 {font-size:clamp(.95rem,4vw,1.3rem);white-space:nowrap}
  .hud header p.eyebrow {font-size:.6rem;white-space:nowrap;margin-bottom:4px}
  .header-right {gap:5px}
  .header-right .mode {display:none}
  #mobile-menu,#sound-toggle {display:grid;place-items:center;padding:0;width:44px;min-width:44px}
  #reset {display:none}
  .hud.menu-open #reset {
    display:block;position:absolute;top:calc(var(--edge-top) + 49px);right:var(--edge-right);
  }
  .hud .panel {position:static;width:auto;padding:0;border:0;background:none;box-shadow:none}
  .hud #mission-details {display:none}
  .hud.menu-open #mission-details {
    display:block;pointer-events:auto;position:absolute;z-index:3;
    left:var(--edge-left);top:calc(var(--edge-top) + 54px);right:calc(var(--edge-right) + 76px);
    width:auto;max-width:360px;max-height:calc(100dvh - var(--edge-top) - var(--edge-bottom) - 158px);
    overflow:auto;overscroll-behavior:contain;touch-action:pan-y;
    padding:12px;background:#0a1820f3;border:1px solid #87c7c780;border-radius:12px;
    box-shadow:0 6px 28px #07111899;
  }
  .hud #mission-details #copy {display:block}
  .hud #parts {margin-bottom:0;gap:6px}
  .hud button {font-size:.885rem;min-height:44px}
  .hud #action-dock {
    position:absolute;z-index:2;bottom:var(--edge-bottom);left:50%;transform:translateX(-50%);
    display:flex;align-items:center;justify-content:center;gap:6px;width:max-content;
    max-width:calc(100% - var(--edge-left) - var(--edge-right));
  }
  #action-dock button {min-width:0;margin:0;white-space:nowrap;padding-inline:10px}
  #action-dock .primary {padding-inline:13px}
  .hud[data-driving="true"] #action-dock {bottom:calc(var(--edge-bottom) + 52px)}
  .hud #drive {
    position:absolute;z-index:2;bottom:var(--edge-bottom);left:var(--edge-left);right:var(--edge-right);
    display:grid;grid-template-columns:repeat(2, max-content) 1fr repeat(2, max-content);
    gap:5px;margin:0;align-items:center;justify-content:stretch;
  }
  #drive button {min-width:46px;min-height:48px;padding-inline:9px;background:#102632e9}
  #drive button.held,#drive button:active {background:#41686b}
  #drive [data-key=left] {grid-column:1;grid-row:1}
  #drive [data-key=right] {grid-column:2;grid-row:1}
  #drive [data-key=brake] {grid-column:4;grid-row:1}
  #drive [data-key=boost] {grid-column:5;grid-row:1}
  .hud aside {
    position:absolute;top:calc(var(--edge-top) + 48px);left:var(--edge-left);right:auto;
    width:max-content;max-width:calc(100% - var(--edge-right) - var(--edge-left));
    align-items:center;gap:7px;padding:5px 8px;background:#0a1820c9;border-radius:7px;
  }
  .hud.menu-open aside,.hud[data-state=inspect] aside,.hud footer {display:none}
  .hud aside div {display:flex;gap:4px;align-items:baseline;min-width:0}
  .hud aside div:first-child small {display:none}
  .hud aside small {font-size:.6rem;letter-spacing:.03em}
  .hud aside strong {font-size:.75rem;margin:0}
  .hud #victory-banner,.hud #victory-banner.settled {top:calc(var(--edge-top) + 86px)}
}
@media (orientation:landscape) and (max-height:500px) {
  .hud[data-driving="true"] #action-dock {bottom:var(--edge-bottom);max-width:calc(100% - var(--edge-left) - var(--edge-right) - 288px)}
  .hud.menu-open #mission-details {max-height:calc(100dvh - var(--edge-top) - var(--edge-bottom) - 109px)}
  .hud header .game-wordmark {width:104px}
  .hud header h1 {font-size:1.16rem}
}
@media (max-width:370px) and (orientation:portrait) {
  .hud header h1 {font-size:.9rem}
  .hud header .game-wordmark {width:60px}
  .hud header {gap:5px}
  #action-dock button {font-size:.78rem;padding-inline:8px}
}
