/* Keep information at the edges; the centre belongs to the arena. */
body.playing .scoreboard { top: 14px; filter: none; }
body.playing .team-score {
  min-width: 0; flex-direction: row; justify-content: center; gap: 8px;
  padding: 7px 12px; border-bottom-width: 2px; background: #0a1220bb;
}
body.playing .team-score span { font-size: 12px; letter-spacing: .04em; }
body.playing .team-score strong { font-size: 23px; line-height: 1.2; }
body.playing .clock {
  min-width: 94px; padding: 5px 12px; display: flex; align-items: center;
  justify-content: center; border: 0; background: #0a1220bb;
}
body.playing .clock strong { margin: 0; font-size: 23px; line-height: 1.2; }
body.playing .clock span, body.playing .clock small { display: none; }
body.playing .objective-panel {
  top: 65px; bottom: auto; padding: 5px 10px; width: max-content;
  max-width: 420px; background: #09111a80; border: 0;
  text-shadow: 0 1px 3px #000;
}
body.playing .objective-panel .eyebrow { display: none; }
body.playing .objective-panel strong { margin: 0; font: bold 16px/1.35 Arial, sans-serif; }
body.playing .objective-panel > span { font-size: 13px; }
.objective-brief { display: none !important; }
body.playing .objective-progress { height: 2px; margin-top: 4px; }
body.playing .minimap-panel { width: 168px; bottom: 20px; }
body.playing .minimap-label { padding: 6px 8px; }
body.playing .minimap-label span + span { display: none; }
body.playing .toast { top: 122px; padding: 6px 10px; font-size: 14px; }
.pause-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 16px 0; }
.pause-options button { min-height: 44px; padding: 8px; margin: 0; font-size: 14px; }
#hud-detail { display: none; }
#pause-mode { color: var(--orange); margin: -10px 0 16px; }

/* Include short landscape windows: a phone's browser chrome can leave
   only 270px of usable height even when its width looks like a tablet. */
@media (max-width: 700px), (max-height: 550px) and (orientation: landscape), (pointer: coarse) {
  :root {
    --hud-left: max(12px, env(safe-area-inset-left));
    --hud-right: max(12px, env(safe-area-inset-right));
    --hud-top: max(8px, env(safe-area-inset-top));
    --hud-bottom: max(12px, env(safe-area-inset-bottom));
  }
  body.playing .brand, body.playing .player-badge, body.playing .key-hints,
  body.playing .minimap-panel, body.playing .speed-panel { display: none; }
  body.playing .vignette { opacity: .35; }
  body.playing .topbar {
    padding: 0; top: var(--hud-top); left: auto; right: var(--hud-right);
    width: 44px; z-index: 4;
  }
  body.playing .top-actions { gap: 0; }
  body.playing .top-actions .icon-button { display: none; }
  body.playing .top-actions #pause {
    display: block; width: 44px; height: 44px; min-height: 44px;
    padding: 0; font-size: 0; background: #0a122099;
  }
  body.playing #pause kbd { display: none; }
  body.playing #pause::before { content: 'Ⅱ'; font: bold 22px Arial, sans-serif; }
  body.playing .scoreboard {
    top: var(--hud-top); left: var(--hud-left); transform: none;
    width: min(282px, calc(100% - var(--hud-left) - var(--hud-right) - 54px));
    min-height: 40px; display: grid; grid-template-columns: 1fr auto 1fr;
  }
  body.playing .team-score { min-width: 0; padding: 5px 6px; gap: 5px; }
  body.playing .team-score span { font-size: 12px; letter-spacing: 0; }
  body.playing .team-score strong { font-size: 20px; }
  body.playing .clock { min-width: 74px; padding: 5px 6px; }
  body.playing .clock strong { font-size: 20px; }
  body.playing .objective-panel {
    top: calc(var(--hud-top) + 48px); bottom: auto; left: var(--hud-left);
    right: var(--hud-right); width: auto; max-width: none; transform: none;
    padding: 4px 8px; text-align: left; background: transparent;
    pointer-events: none;
  }
  body.playing .objective-panel strong { font: bold 14px/1.3 Arial, sans-serif; }
  body.playing .objective-panel #objective-detail { display: none; }
  body.playing .objective-panel .objective-brief {
    display: block !important; color: #d3deed; font: 12px/1.35 Arial, sans-serif;
  }
  body.playing .objective-progress { max-width: 180px; }
  body.playing #touch-controls {
    left: var(--hud-left); right: var(--hud-right); bottom: var(--hud-bottom);
    gap: 10px; align-items: end;
  }
  body.playing .touch-steer, body.playing .touch-pedals { gap: 6px; }
  body.playing #touch-controls button {
    width: 52px; min-width: 52px; min-height: 56px; padding: 8px 2px; font-size: 14px;
    background: #0d182966; border-color: #d9e8ff66; border-radius: 12px;
    text-shadow: 0 1px 2px #000;
  }
  body.playing #touch-controls button[data-control=forward] {
    width: 60px; min-width: 60px; background: #ff951bc4; text-shadow: none;
  }
  body.playing #touch-controls button.pressed { background: #c7d6efdd; color: #101725; text-shadow: none; }
  body.playing .toast {
    top: auto; bottom: calc(var(--hud-bottom) + 66px); font-size: 13px;
    padding: 5px 8px; max-width: min(360px, calc(100vw - 32px));
    width: max-content; background: #0a1220b3;
  }
  body.playing .countdown { font-size: 56px; }
  #hud-detail { display: block; }
  body.playing.hud-details .minimap-panel {
    display: block; top: auto; bottom: calc(var(--hud-bottom) + 72px);
    left: auto; right: var(--hud-right); width: 112px;
  }
  body.playing.hud-details .minimap-label { display: none; }
  body.playing.hud-details .speed-panel {
    display: block; top: auto; left: var(--hud-left);
    bottom: calc(var(--hud-bottom) + 72px); width: 90px;
  }
  body.playing.hud-details .speed-label, body.playing.hud-details .speed-track { display: none; }
  body.playing.hud-details .speed-panel strong { font-size: 28px; }
  #pause-panel { padding: 22px; }
  #pause-panel h2 { margin: 8px 0 16px; }
  #pause-panel > p:last-child { display: none; }
}

@media (orientation: landscape) and (max-height: 550px) and (min-width: 600px) {
  body.playing .scoreboard { width: 282px; }
  body.playing .objective-panel {
    top: var(--hud-top); left: calc(var(--hud-left) + 294px);
    right: calc(var(--hud-right) + 56px); padding-top: 3px;
  }
}

/* Keep the team names readable in especially narrow portrait windows. */
@media (max-width: 360px) {
  body.playing .team-score { flex-direction: column; gap: 0; padding: 3px 4px; }
  body.playing .team-score strong { font-size: 18px; }
}
