/* css/style.css */
/* NYC HUD design system: quiet graphite glass in the corners of the screen, taxi yellow for whatever is active,
   NYC DOT green for street names, so that the city itself stays the star */

:root {
  /* Surfaces */
  --glass: rgba(18, 19, 22, 0.62);
  --glass-strong: rgba(16, 17, 20, 0.88);
  --glass-border: rgba(255, 255, 255, 0.09);
  --glass-highlight: rgba(255, 255, 255, 0.08);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.045 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --hover: rgba(255, 255, 255, 0.08);
  --divider: rgba(255, 255, 255, 0.1);

  /* Text */
  --text: #f6f5f2;
  --text-2: rgba(246, 245, 242, 0.68);
  --text-3: rgba(246, 245, 242, 0.44);

  /* Accents */
  --taxi: #ffc21a;
  --taxi-ink: #17140a;
  --sign-green: #0b6a46;
  --highway: #c08a3e;
  --ok: #5ee08f;
  --warn: #ffc857;
  --bad: #ff7a6b;

  /* Shape & motion */
  --edge: 20px;
  --bar-h: 50px;
  --r-panel: 16px;
  --r-ctl: 10px;
  --shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.7), 0 2px 8px rgba(0, 0, 0, 0.2);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  --font-sign: 'Overpass', 'Inter', 'Helvetica Neue', Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #0a0b0d;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: 2px;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-sm {
  width: 14px;
  height: 14px;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 5px;
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 650;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07), inset 0 -1px 0 rgba(0, 0, 0, 0.3);
}

#canvas-container {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  cursor: grab;
}

#canvas-container:active {
  cursor: grabbing;
}

/* Soft scrims behind the HUD: keep small type legible over a bright midday street */
body::before,
body::after {
  content: '';
  position: fixed;
  left: 0;
  right: 0;
  z-index: 5;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

body::before {
  top: 0;
  height: 120px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.22), rgba(0, 0, 0, 0));
}

body::after {
  bottom: 0;
  height: 210px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.36), rgba(0, 0, 0, 0));
}

/* ------------------------------------------------------------------------------------------------------------------
   Glass panel
   ------------------------------------------------------------------------------------------------------------------ */
.panel {
  background: var(--grain), var(--glass);
  -webkit-backdrop-filter: blur(22px) saturate(170%);
  backdrop-filter: blur(22px) saturate(170%);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-panel);
  box-shadow: inset 0 1px 0 var(--glass-highlight), var(--shadow);
}

/* ------------------------------------------------------------------------------------------------------------------
   Loading screen
   ------------------------------------------------------------------------------------------------------------------ */
#loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  /* same art as the title screen (already cached by its <img>), dimmed so the loader text reads over it */
  background:
    radial-gradient(60% 45% at 50% 50%, rgba(4, 9, 12, .62) 0%, rgba(4, 9, 12, .28) 100%),
    linear-gradient(0deg, rgba(3, 7, 9, .52), transparent 42%),
    #071016 url('../images/kaiju-home.webp?v=user1') 50% 40% / cover no-repeat;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.loader-title {
  text-shadow: 0 4px 24px rgba(0, 0, 0, .6);
}

/* hidden behind the title screen until Deploy is pressed (kaiju-launching) or a run is live */
#loading-overlay.hidden,
body:not(.kaiju-active):not(.kaiju-launching) #loading-overlay {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* appears at once on Deploy (a fade could stall while the city builds on the main thread); still fades out */
body.kaiju-launching #loading-overlay {
  transition: none;
}

.loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: rise-in 0.8s var(--ease-out) both;
}

.loader-title {
  font-size: 34px;
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.loader-track {
  position: relative;
  width: 240px;
  height: 3px;
  margin: 26px 0 14px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.loader-fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--taxi);
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

/* While the city is being built (main thread busy) the bar sweeps on the compositor; it fills once shaders compile */
.loader-track.is-indeterminate .loader-fill {
  width: 35%;
  transform: translateX(-100%);
  transition: none;
  animation: loader-sweep 1.5s cubic-bezier(0.45, 0, 0.25, 1) infinite;
  will-change: transform;
}

#loading-status {
  font-size: 12.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.loading-hint {
  max-width: 300px;
  margin-top: 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-3);
  opacity: 0.75;
  text-wrap: pretty;
}

@keyframes loader-sweep {
  from { transform: translateX(-100%); }
  to { transform: translateX(290%); }
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* Kaiju launch screen: a game title card over a living city, not a marketing page. */
.kaiju-home { position: fixed; inset: 0; z-index: 120; overflow: hidden; background: transparent; color: var(--text); transition: opacity 0.6s var(--ease-out), visibility 0.6s; }
.kaiju-home.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.kaiju-home-video, .kaiju-home-shade { position: absolute; inset: 0; width: 100%; height: 100%; }
.kaiju-home-video { display: block; object-fit: cover; object-position: 50% 40%; background: #071016; }
.kaiju-home-shade { background: linear-gradient(90deg, rgba(4, 9, 12, .72) 0%, rgba(4, 9, 12, .28) 45%, rgba(4, 9, 12, .03) 100%), linear-gradient(0deg, rgba(3, 7, 9, .52), transparent 42%); pointer-events: none; }
.kaiju-home-inner { position: absolute; left: clamp(20px, 7vw, 112px); right: clamp(20px, 7vw, 112px); bottom: clamp(64px, 13vh, 132px); display: flex; flex-direction: column; align-items: flex-start; max-width: 760px; }
.kaiju-eyebrow { color: var(--warn); font-family: var(--font-sign); font-size: 11px; font-weight: 700; letter-spacing: .22em; text-transform: uppercase; }
.kaiju-home h1 { max-width: 100%; color: #eef6f4; font-family: var(--font-sign); font-size: clamp(40px, min(9vw, 15vh), 128px); font-weight: 700; letter-spacing: .02em; line-height: .86; text-wrap: balance; text-shadow: 0 8px 40px rgba(0, 0, 0, .48); }
.kaiju-lede { max-width: 34ch; margin-top: clamp(12px, 2.4vh, 22px); color: rgba(238, 246, 244, .78); font-family: var(--font-sign); font-size: clamp(14px, min(1.6vw, 2.8vh), 19px); line-height: 1.45; letter-spacing: .03em; text-wrap: pretty; }
.kaiju-home .kaiju-lede-cite { margin-top: 6px; color: rgba(238, 246, 244, .6); font-size: clamp(12px, min(1.1vw, 2vh), 14px); }
.kaiju-home .kaiju-launch { margin-top: clamp(16px, 3.6vh, 32px); border-radius: 0; color: var(--warn); background: transparent; }
.kaiju-home .kaiju-launch:hover { background: rgba(255, 200, 87, .12); }
.kaiju-home .kaiju-launch:focus-visible { outline: 2px solid var(--warn); outline-offset: 3px; }
.kaiju-launch { display: inline-flex; align-items: center; gap: 34px; margin-top: 34px; padding: 16px 20px 16px 23px; border: 1px solid var(--warn); border-radius: 5px; color: var(--taxi-ink); background: var(--warn); font-family: var(--font-sign); font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; transition: transform .2s var(--ease-out), background .2s ease; }
.kaiju-launch:hover { transform: translateY(-3px); background: #ffd878; }
.kaiju-home-corner { position: absolute; right: 28px; bottom: 26px; display: flex; gap: 16px; color: rgba(238, 246, 244, .5); font-family: var(--font-sign); font-size: 9px; letter-spacing: .16em; text-transform: uppercase; }
.kaiju-home-corner span:first-child { color: var(--warn); }
.kaiju-mark { background: var(--warn); color: var(--taxi-ink); }
.kaiju-home-tools { display: flex; align-items: center; gap: 28px; margin-top: clamp(14px, 2.6vh, 22px); }
.kaiju-settings-button { padding: 8px 0; color: rgba(238,246,244,.72); font-family: var(--font-sign); font-size: 10px; letter-spacing: .16em; text-transform: uppercase; border-bottom: 1px solid rgba(238,246,244,.3); }
.kaiju-settings-button:hover { color: var(--warn); border-color: var(--warn); }
.kaiju-home-footer { position: absolute; right: 30px; bottom: 28px; display: flex; align-items: center; gap: 18px; color: rgba(238,246,244,.45); font-family: var(--font-sign); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; }
.kaiju-home-footer a { color: inherit; text-decoration: none; }
.kaiju-home-footer a:hover { color: var(--warn); }
.kaiju-settings[hidden] { display: none; }
.kaiju-settings { position: fixed; inset: 0; z-index: 130; display: grid; place-items: center; padding: 24px; background: rgba(2,6,8,.58); backdrop-filter: blur(10px); }
.kaiju-settings-card { width: min(440px, 100%); padding: 26px; border: 1px solid rgba(238,246,244,.16); background: rgba(8,16,20,.95); box-shadow: 0 24px 80px rgba(0,0,0,.5); }
.kaiju-settings-head { display: flex; align-items: flex-start; justify-content: space-between; padding-bottom: 22px; border-bottom: 1px solid rgba(238,246,244,.12); }
.kaiju-settings h2 { margin-top: 8px; color: #eef6f4; font-family: var(--font-sign); font-size: 26px; letter-spacing: .02em; }
.kaiju-settings-close { color: rgba(238,246,244,.62); font-size: 28px; line-height: 1; }
.kaiju-setting-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 20px 0; border-bottom: 1px solid rgba(238,246,244,.1); color: #eef6f4; }
.kaiju-setting-row strong, .kaiju-setting-row small { display: block; }
.kaiju-setting-row strong { font-size: 13px; letter-spacing: .04em; }
.kaiju-setting-row small { margin-top: 5px; color: rgba(238,246,244,.52); font-size: 11px; line-height: 1.4; }
.kaiju-setting-row select { padding: 8px 10px; border: 1px solid rgba(238,246,244,.2); border-radius: 3px; color: #eef6f4; background: #101d24; }
.kaiju-setting-row input { width: 18px; height: 18px; accent-color: var(--warn); }
.kaiju-setting-row input.kaiju-volume { flex: 0 0 150px; width: 150px; height: 18px; cursor: pointer; }
/* Range sliders get real width (the 18px rule above is for checkboxes; it made the shadow slider unusable) */
.kaiju-setting-row input.kaiju-range { flex: 0 0 170px; width: 170px; height: 18px; cursor: pointer; }
.kaiju-setting-row output { margin-left: 6px; color: var(--warn); font-variant-numeric: tabular-nums; font-weight: 600; }
.kaiju-settings-card { max-height: calc(100dvh - 48px); overflow-y: auto; overscroll-behavior: contain; }
.kaiju-settings-group { margin-top: 22px; color: rgba(238,246,244,.52); font-size: 11px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; }
.kaiju-pause-music { display: flex; flex-direction: column; gap: 8px; padding: 14px 0 16px; border-bottom: 1px solid rgba(238,246,244,.12); }
.kaiju-pause-music-label { color: rgba(238,246,244,.52); font-size: 11px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; }
.kaiju-pause-music-row { display: flex; align-items: center; gap: 8px; }
.kaiju-music-select { flex: 1 1 auto; min-width: 0; padding: 8px 10px; border: 1px solid rgba(238,246,244,.2); border-radius: 3px; color: #eef6f4; background: #101d24; font: inherit; font-size: 13px; }
.kaiju-mini-btn.kaiju-music-skip { display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; }
@media (max-width: 480px) {
  .kaiju-setting-row.kaiju-setting-slider { flex-direction: column; align-items: stretch; gap: 12px; }
  .kaiju-setting-row.kaiju-setting-slider input.kaiju-range { flex: 1 1 auto; width: 100%; }
}
.kaiju-settings-actions { display: flex; justify-content: flex-end; padding-top: 22px; }
.kaiju-settings-actions .kaiju-launch { margin-top: 0; border-radius: 0; color: var(--warn); background: transparent; }
.kaiju-settings-actions .kaiju-launch:hover { background: rgba(255,200,87,.12); }
.kaiju-settings-actions .kaiju-launch:focus-visible { outline: 2px solid var(--warn); outline-offset: 3px; }
.kaiju-settings-head .kaiju-eyebrow { margin-top: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Hangar ("Choose Assault Mech"): turntable preview beside the mech list, stacked on narrow screens */
.kaiju-hangar-card { display: flex; flex-direction: column; width: min(920px, 100%); max-height: calc(100dvh - 48px); overflow: auto; }
.kaiju-hangar-body { display: flex; flex-direction: column; gap: 22px; padding-top: 22px; }
.kaiju-hangar-stage { position: relative; height: min(46dvh, 420px); border: 1px solid rgba(238,246,244,.1); background: linear-gradient(to bottom, rgba(238,246,244,.035), rgba(238,246,244,0) 62%, rgba(255,200,87,.05)); }
.kaiju-hangar-canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.kaiju-hangar-canvas:active { cursor: grabbing; }
.kaiju-hangar-status { position: absolute; inset: auto 16px 50%; color: rgba(238,246,244,.72); font-family: var(--font-sign); font-size: 11px; letter-spacing: .16em; text-align: center; text-transform: uppercase; transform: translateY(50%); pointer-events: none; }
.kaiju-hangar-hint { position: absolute; left: 14px; bottom: 12px; color: rgba(238,246,244,.42); font-family: var(--font-sign); font-size: 10px; letter-spacing: .16em; text-transform: uppercase; pointer-events: none; }
.kaiju-hangar-side { display: flex; flex-direction: column; min-width: 0; }
.kaiju-hangar-list { display: flex; flex-direction: column; gap: 10px; min-width: 0; margin: 0; padding: 0; border: 0; }
.kaiju-hangar-option { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; border: 1px solid rgba(238,246,244,.12); color: #eef6f4; cursor: pointer; transition: border-color .15s, background .15s; }
.kaiju-hangar-option:hover { border-color: rgba(238,246,244,.3); }
.kaiju-hangar-option:has(:checked) { border-color: var(--warn); background: rgba(255,200,87,.08); }
.kaiju-hangar-option:has(:focus-visible) { outline: 2px solid var(--warn); outline-offset: 3px; }
.kaiju-hangar-radio { position: absolute; opacity: 0; pointer-events: none; }
.kaiju-hangar-option-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.kaiju-hangar-option-name { font-family: var(--font-sign); font-size: 15px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.kaiju-hangar-option:has(:checked) .kaiju-hangar-option-name { color: var(--warn); }
.kaiju-hangar-option-code { color: rgba(238,246,244,.5); font-family: var(--font-sign); font-size: 11px; letter-spacing: .14em; }
.kaiju-hangar-option-blurb { color: rgba(238,246,244,.6); font-size: 12px; line-height: 1.5; text-wrap: pretty; }
.kaiju-hangar-actions { margin-top: auto; }
@media (max-width: 719px) {
  .kaiju-settings.kaiju-hangar { padding: 12px; }
  .kaiju-hangar-card { max-height: calc(100dvh - 24px); padding: 20px; }
  .kaiju-hangar-actions .kaiju-launch { flex: 1; justify-content: space-between; }
}
@media (min-width: 720px) {
  .kaiju-hangar-body { flex-direction: row; gap: 28px; }
  .kaiju-hangar-stage { flex: 1.15 1 0; height: 460px; }
  .kaiju-hangar-side { flex: 1 1 0; }
}
/* Phones held sideways: side by side, the stage fits the height */
@media (max-height: 520px) and (orientation: landscape) {
  .kaiju-settings.kaiju-hangar { padding: 10px; }
  .kaiju-hangar-card { max-height: calc(100dvh - 20px); padding: 16px 20px; }
  .kaiju-hangar-card .kaiju-settings-head { padding-bottom: 12px; }
  .kaiju-hangar-card h2 { font-size: 20px; }
  .kaiju-hangar-body { flex-direction: row; gap: 18px; padding-top: 14px; }
  .kaiju-hangar-stage { flex: 1 1 0; height: calc(100dvh - 120px); }
  .kaiju-hangar-side { flex: 1 1 0; }
  .kaiju-hangar-option { padding: 10px 14px; }
  .kaiju-hangar-option-blurb { display: none; }
  .kaiju-hangar-actions { padding-top: 12px; }
}
@media (prefers-reduced-motion: reduce) { .kaiju-hangar-option { transition: none; } }

/* Pause menu (P): sits under Settings / Controls (earlier in the DOM, same z-index) so they open on top of it */
.kaiju-pause-card { width: min(380px, 100%); }
.kaiju-pause-actions { display: flex; flex-direction: column; padding-top: 10px; }
.kaiju-pause-btn { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 12px; width: 100%; padding: 16px 0; border-bottom: 1px solid rgba(238,246,244,.1); color: #eef6f4; background: transparent; text-align: left; cursor: pointer; transition: color .15s, padding-left .15s; }
.kaiju-pause-btn:last-child { border-bottom: 0; }
.kaiju-pause-btn span { font-family: var(--font-sign); font-size: 14px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.kaiju-pause-btn small { grid-column: 1; margin-top: 4px; color: rgba(238,246,244,.52); font-size: 11px; line-height: 1.4; }
.kaiju-pause-btn:hover, .kaiju-pause-btn:focus-visible { padding-left: 8px; color: var(--warn); }
.kaiju-pause-btn:focus-visible { outline: 2px solid var(--warn); outline-offset: 2px; }
.kaiju-pause-btn.is-primary span { color: var(--warn); }
.kaiju-pause-btn kbd { grid-row: 1; grid-column: 2; min-width: 24px; padding: 3px 7px; border: 1px solid rgba(255,200,87,.5); color: var(--warn); background: rgba(255,200,87,.12); font-family: var(--font-sign); font-size: 11px; text-decoration: none; }
@media (prefers-reduced-motion: reduce) { .kaiju-pause-btn { transition: none; } .kaiju-pause-btn:hover, .kaiju-pause-btn:focus-visible { padding-left: 0; } }

/* HUD note "P Menu" next to the fps readout: keyboard devices only, so touch layouts are unchanged */
.hud-menu-hint kbd { min-width: 0; margin-right: 4px; padding: 0 4px; border: 1px solid rgba(255,200,87,.45); color: var(--warn); font-family: var(--font-sign); font-size: 10px; line-height: 1.5; text-decoration: none; }
@media (hover: none), (pointer: coarse) { .hud-menu-hint { display: none; } }
.hud-mouselook-state { margin-left: 2px; color: var(--warn); font-weight: 700; letter-spacing: .08em; }
.hud-mouselook-state.is-off { color: var(--text-2); }
.kaiju-tip-item { display: inline-flex; align-items: center; gap: 8px; }
.kaiju-tip-sep { width: 1px; height: 14px; margin: 0 6px; background: var(--glass-border); }
.kaiju-mini-btn { flex: none; padding: 8px 14px; border: 1px solid rgba(238,246,244,.24); color: #eef6f4; background: transparent; font-family: var(--font-sign); font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; cursor: pointer; transition: color .15s, border-color .15s; }
.kaiju-mini-btn:hover { color: var(--warn); border-color: var(--warn); }
.kaiju-mini-btn:focus-visible { outline: 2px solid var(--warn); outline-offset: 2px; }

/* Controls modal: wider than Settings, capped to the viewport, key list scrolls between a fixed header and footer */
.kaiju-controls-card { display: flex; flex-direction: column; width: min(720px, 100%); max-height: calc(100dvh - 48px); }
.kaiju-controls-help { flex: none; padding-top: 16px; color: rgba(238,246,244,.6); font-size: 12px; line-height: 1.5; text-wrap: pretty; }
.kaiju-controls-body { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; gap: 22px 32px; margin: 16px -10px 0 0; padding: 4px 10px 4px 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(238,246,244,.24) transparent; }
.kaiju-keygroup { display: flex; flex-direction: column; min-width: 0; }
.kaiju-keygroup .kaiju-eyebrow { margin: 0 0 6px; font-size: 10px; }
.kaiju-keyrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 36px; border-bottom: 1px solid rgba(238,246,244,.08); }
.kaiju-keyname { min-width: 0; color: #eef6f4; font-size: 13px; line-height: 1.3; }
.kaiju-keycaps { display: flex; flex: none; gap: 6px; }
.kaiju-keycap { display: inline-flex; align-items: center; justify-content: center; width: 78px; height: 28px; padding: 0 6px; overflow: hidden; border: 1px solid rgba(238,246,244,.22); color: #eef6f4; background: rgba(238,246,244,.04); font-family: var(--font-sign); font-size: 11px; font-weight: 700; letter-spacing: .06em; white-space: nowrap; cursor: pointer; transition: color .15s, border-color .15s, background-color .15s; }
button.kaiju-keycap:hover { border-color: var(--warn); color: var(--warn); }
.kaiju-keycap:focus-visible { outline: 2px solid var(--warn); outline-offset: 2px; }
.kaiju-keycap.is-empty { border-style: dashed; color: rgba(238,246,244,.36); background: transparent; }
.kaiju-keycap.is-listening { border-color: var(--warn); color: var(--warn); background: rgba(255,200,87,.12); animation: kaiju-keycap-pulse 1s ease-in-out infinite; }
.kaiju-keycap.is-fixed { width: auto; padding: 0 10px; border-color: transparent; color: rgba(238,246,244,.6); background: rgba(238,246,244,.06); cursor: default; }
@keyframes kaiju-keycap-pulse { 50% { background: rgba(255,200,87,.24); } }
@media (prefers-reduced-motion: reduce) { .kaiju-keycap.is-listening { animation: none; } }
.kaiju-controls-status { flex: none; min-height: 18px; padding-top: 12px; color: var(--warn); font-size: 12px; line-height: 1.5; }
.kaiju-controls-actions { flex: none; justify-content: space-between; align-items: center; gap: 16px; margin-top: 4px; padding-top: 16px; border-top: 1px solid rgba(238,246,244,.12); }
@media (max-width: 640px) {
  .kaiju-controls { padding: 12px; }
  .kaiju-controls-card { max-height: calc(100dvh - 24px); padding: 18px; }
  .kaiju-controls-body { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .kaiju-keycap { width: 72px; }
}
.kaiju-launch-arrow { flex: none; }
/* Home screen: everything above scales fluidly; these only re-anchor the chrome on small or short screens. */
@media (max-width: 640px) {
  .kaiju-home-shade { background: linear-gradient(0deg, rgba(3, 7, 9, .82) 0%, rgba(3, 7, 9, .45) 45%, rgba(3, 7, 9, .1) 100%); }
  .kaiju-home-inner { bottom: max(72px, calc(env(safe-area-inset-bottom) + 64px)); }
  .kaiju-home h1 { font-size: clamp(40px, 14vw, 72px); }
  .kaiju-home .kaiju-launch { align-self: stretch; justify-content: space-between; }
  .kaiju-home-footer { left: 20px; right: 20px; bottom: max(20px, env(safe-area-inset-bottom)); justify-content: center; gap: 12px; font-size: 8px; }
  .kaiju-home-footer a:first-of-type { display: none; }
  .kaiju-home-tools { align-self: stretch; justify-content: center; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .kaiju-home-inner { bottom: 48px; max-width: 60vw; }
  .kaiju-home h1 { font-size: clamp(36px, 15vh, 64px); }
  .kaiju-home .kaiju-launch { align-self: flex-start; padding: 12px 16px; }
  .kaiju-home-tools { margin-top: 10px; }
  .kaiju-home-footer { bottom: 14px; }
}
.kaiju-combat-telemetry { position: fixed; z-index: 8; top: 78px; left: 50%; display: flex; align-items: stretch; transform: translateX(-50%); border: 1px solid var(--glass-border); border-radius: 6px; color: var(--text-1); background: rgba(12, 18, 22, 0.82); box-shadow: 0 14px 34px rgba(0, 0, 0, 0.18); backdrop-filter: blur(14px); }
.combat-readout { display: flex; min-width: 92px; flex-direction: column; gap: 3px; padding: 9px 13px 8px; }
.combat-label, .combat-sub { color: var(--text-3); font-family: var(--font-sign); font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; }
.combat-readout strong { color: var(--warn); font-family: var(--font-sign); font-size: 16px; letter-spacing: 0.04em; line-height: 1; }
.combat-sub { font-size: 8px; }
.combat-divider { width: 1px; margin: 9px 0; background: var(--glass-border); }
@media (max-width: 640px) { .kaiju-combat-telemetry { top: 68px; width: calc(100% - 32px); } .combat-readout { min-width: 0; flex: 1; padding: 8px 7px; } .combat-readout strong { font-size: 13px; } .combat-label, .combat-sub { font-size: 7px; } }
  .kaiju-class { color: var(--ok); }

  /* ---- Combat HUD (only while an Assault Mech is deployed) ---- */
  .kaiju-combat-telemetry, .kaiju-threat, .kaiju-vitals, .kaiju-reticle, .kaiju-lock, .kaiju-banner, .kaiju-boundary, .kaiju-touch { display: none; }
  body.kaiju-active .kaiju-combat-telemetry, body.kaiju-active .kaiju-vitals, body.kaiju-active .kaiju-reticle { display: flex; }
  body.kaiju-active.touch-enabled .kaiju-touch { display: flex; }
  body.kaiju-active .kaiju-threat, body.kaiju-active .kaiju-lock, body.kaiju-active .kaiju-banner, body.kaiju-active .kaiju-boundary { display: flex; }
  body.kaiju-active #mode-switch, body.kaiju-active #btn-teleport, body.kaiju-active .time-switch + .toolbar-divider { display: none; }
  body.kaiju-over .kaiju-vitals, body.kaiju-over .kaiju-reticle, body.kaiju-over .kaiju-touch { display: none; }
  body.hud-minimized .kaiju-vitals, body.hud-minimized .kaiju-combat-telemetry { visibility: hidden; }

  .kaiju-threat { position: fixed; z-index: 8; top: 140px; left: 50%; width: min(420px, calc(100% - 32px)); flex-direction: column; gap: 6px; transform: translate(-50%, -6px); opacity: 0; pointer-events: none; transition: opacity 0.3s ease, transform 0.3s ease; }
  .kaiju-threat.is-visible { opacity: 1; transform: translate(-50%, 0); }
  .threat-head { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--text); font-family: var(--font-sign); font-size: 12px; font-weight: 700; letter-spacing: 0.18em; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6); }
  .threat-tag { padding: 2px 5px; border-radius: 3px; color: var(--taxi-ink); background: var(--bad); font-size: 9px; }
  .threat-track { height: 6px; overflow: hidden; border: 1px solid rgba(255, 122, 107, 0.4); border-radius: 3px; background: rgba(12, 18, 22, 0.7); }
  .threat-track span { display: block; height: 100%; background: var(--bad); transform-origin: left; transition: transform 0.25s ease; }

  .kaiju-vitals { position: fixed; z-index: 8; bottom: calc(var(--edge) + 38px); left: 50%; align-items: center; gap: 14px; padding: 10px 12px; transform: translateX(-50%); border: 1px solid var(--glass-border); border-radius: 8px; background: rgba(12, 18, 22, 0.82); backdrop-filter: blur(14px); }
  .vital { display: flex; width: 132px; flex-direction: column; gap: 5px; }
  .vital-head { display: flex; justify-content: space-between; color: var(--text-3); font-family: var(--font-sign); font-size: 9px; font-weight: 700; letter-spacing: 0.14em; }
  .vital-head span:last-child { color: var(--text); }
  .vital-track { height: 5px; overflow: hidden; border-radius: 3px; background: rgba(246, 245, 242, 0.1); }
  .vital-track span { display: block; height: 100%; transform-origin: left; transition: transform 0.15s linear; }
  .vital-hull span { background: var(--ok); }
  .vital-hull.is-critical span { background: var(--bad); animation: kaiju-blink 0.6s steps(2) infinite; }
  .vital-energy span { background: #5ff4ff; }
  .weapon-rack { display: flex; gap: 4px; }
  .weapon-btn { position: relative; display: flex; min-width: 62px; flex-direction: column; align-items: flex-start; gap: 2px; padding: 6px 8px 7px; border: 1px solid transparent; border-radius: 5px; color: var(--text-3); background: rgba(246, 245, 242, 0.05); font-family: var(--font-sign); font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer; }
  .weapon-btn kbd { color: inherit; font-size: 8px; opacity: 0.7; }
  .weapon-btn.active { border-color: var(--warn); color: var(--warn); background: rgba(255, 200, 87, 0.1); }
  .weapon-ammo { position: absolute; top: 5px; right: 7px; color: var(--text); font-size: 9px; }
  .weapon-heat { position: absolute; left: 8px; right: 8px; bottom: 3px; height: 2px; overflow: hidden; background: rgba(246, 245, 242, 0.1); }
  .weapon-heat span { display: block; height: 100%; background: var(--warn); transform: scaleX(0); transform-origin: left; }
  .weapon-heat.is-hot span { background: var(--bad); }
  .weapon-ammo.is-low { color: var(--bad); }

  .kaiju-reticle { position: fixed; z-index: 7; top: 50%; left: 50%; width: 30px; height: 30px; align-items: center; justify-content: center; transform: translate(-50%, -50%); border: 1px solid rgba(246, 245, 242, 0.35); border-radius: 50%; pointer-events: none; }
  .kaiju-reticle span { width: 4px; height: 4px; border-radius: 50%; background: var(--text); }
  .kaiju-reticle.is-hit { border-color: var(--warn); }
  .kaiju-reticle.is-hit span { background: var(--warn); }
  .kaiju-lock { position: fixed; z-index: 7; top: 0; left: 0; width: 46px; height: 46px; opacity: 0; pointer-events: none; transition: opacity 0.15s ease; background:
    linear-gradient(var(--bad), var(--bad)) top left / 12px 2px no-repeat, linear-gradient(var(--bad), var(--bad)) top left / 2px 12px no-repeat,
    linear-gradient(var(--bad), var(--bad)) top right / 12px 2px no-repeat, linear-gradient(var(--bad), var(--bad)) top right / 2px 12px no-repeat,
    linear-gradient(var(--bad), var(--bad)) bottom left / 12px 2px no-repeat, linear-gradient(var(--bad), var(--bad)) bottom left / 2px 12px no-repeat,
    linear-gradient(var(--bad), var(--bad)) bottom right / 12px 2px no-repeat, linear-gradient(var(--bad), var(--bad)) bottom right / 2px 12px no-repeat; }
  .kaiju-lock.is-visible { opacity: 1; }

  .kaiju-vignette { position: fixed; z-index: 6; inset: 0; opacity: 0; pointer-events: none; box-shadow: inset 0 0 160px 30px rgba(255, 70, 40, 0.75); }
  body.kaiju-shielding .kaiju-vignette { box-shadow: inset 0 0 160px 30px rgba(95, 244, 255, 0.5); }

  .kaiju-banner { position: fixed; z-index: 9; top: 34%; left: 50%; flex-direction: column; align-items: center; gap: 8px; transform: translate(-50%, 10px); opacity: 0; pointer-events: none; text-align: center; transition: opacity 0.35s ease, transform 0.35s ease; }
  .kaiju-banner.is-visible { opacity: 1; transform: translate(-50%, 0); }
  .kaiju-banner strong { color: var(--text); font-family: var(--font-sign); font-size: clamp(30px, 6vw, 64px); font-weight: 700; letter-spacing: 0.08em; line-height: 1; text-shadow: 0 4px 30px rgba(0, 0, 0, 0.6); }
  .kaiju-banner span { color: var(--warn); font-family: var(--font-sign); font-size: 11px; font-weight: 700; letter-spacing: 0.24em; text-shadow: 0 1px 10px rgba(0, 0, 0, 0.8); }
  .kaiju-banner.is-small { top: 62%; }
  .kaiju-banner.is-small strong { font-size: 18px; letter-spacing: 0.16em; }
  .kaiju-banner.is-small span { color: var(--text-3); font-size: 9px; }

  .kaiju-boundary { position: fixed; z-index: 9; top: 50%; left: 50%; padding: 8px 14px; transform: translate(-50%, 46px); border: 1px solid var(--bad); border-radius: 5px; color: var(--bad); background: rgba(12, 18, 22, 0.82); font-family: var(--font-sign); font-size: 11px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; opacity: 0; pointer-events: none; transition: opacity 0.2s ease; }
  .kaiju-boundary.is-visible { opacity: 1; }

  .kaiju-gameover { position: fixed; z-index: 40; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(8, 11, 14, 0.72); backdrop-filter: blur(6px); transition: opacity 0.5s ease, visibility 0.5s ease; }
  .kaiju-gameover.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
  .gameover-card { display: flex; width: min(460px, 100%); flex-direction: column; gap: 18px; padding: 28px; border: 1px solid var(--glass-border); border-radius: 10px; background: rgba(12, 18, 22, 0.92); }
  .gameover-eyebrow { margin: 0; color: var(--bad); }
  .gameover-card h2 { color: var(--text); font-family: var(--font-sign); font-size: clamp(40px, 9vw, 64px); font-weight: 700; letter-spacing: 0.03em; line-height: 0.9; text-transform: uppercase; }
  .gameover-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; overflow: hidden; border-radius: 6px; background: var(--glass-border); }
  .gameover-stats div { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; background: rgba(12, 18, 22, 0.96); }
  .gameover-stats dt { color: var(--text-3); font-family: var(--font-sign); font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; }
  .gameover-stats dd { color: var(--warn); font-family: var(--font-sign); font-size: 24px; font-weight: 700; }
  .gameover-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
  .gameover-secondary { color: var(--text-2); background: none; border: 0; font-family: var(--font-sign); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; text-decoration: underline; text-underline-offset: 4px; cursor: pointer; }
  .gameover-secondary:hover { color: var(--text); }


  @keyframes kaiju-blink { 50% { opacity: 0.35; } }

  @media (max-width: 640px) {
    .kaiju-threat { top: 124px; }
    .kaiju-vitals { bottom: max(8px, env(safe-area-inset-bottom)); width: calc(100% - 16px); flex-wrap: wrap; gap: 6px 10px; padding: 7px 9px; }
    .vital { flex: 1; width: auto; min-width: 0; }
    .weapon-rack { width: 100%; }
    .weapon-btn { min-width: 0; flex: 1; flex-direction: row; align-items: center; gap: 4px; padding: 5px 6px; font-size: 9px; }
    .weapon-btn kbd { display: none; }
    .weapon-ammo { position: static; margin-left: auto; }
    body.kaiju-active #hud-controls-hint { display: none; }
  }

@media (max-width: 640px) {
  .kaiju-eyebrow { margin-top: 58px; }
  .kaiju-brief-grid { gap: 18px; margin-top: 58px; }
  .kaiju-brief-grid span { max-width: 82px; line-height: 1.35; }
}

/* ------------------------------------------------------------------------------------------------------------------
   HUD layout: four corners plus the bottom centre, the middle of the screen stays clear
   ------------------------------------------------------------------------------------------------------------------ */
.hud {
  position: fixed;
  z-index: 10;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.4s var(--ease-out);
  }

/* The homepage cinematic is a clean title screen; gameplay telemetry returns only after deployment. */
body:not(.kaiju-active) .hud,
body:not(.kaiju-active) .kaiju-threat,
body:not(.kaiju-active) .kaiju-lock,
/* Spawn hint for the cockpit toggle: keyboard players only, so touch/portrait layouts are untouched. */
.kaiju-tip { position: fixed; z-index: 9; bottom: calc(var(--edge) + 112px); left: 50%; display: flex; align-items: center; gap: 8px; padding: 8px 14px; transform: translate(-50%, 8px); border: 1px solid var(--glass-border); border-radius: 999px; background: rgba(12, 18, 22, 0.82); backdrop-filter: blur(14px); color: var(--text-2); font-family: var(--font-sign); font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; white-space: nowrap; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.35s ease, transform 0.35s var(--ease-out), visibility 0s linear 0.35s; }
.kaiju-tip.is-visible { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition: opacity 0.35s ease, transform 0.35s var(--ease-out), visibility 0s; }
.kaiju-tip kbd { min-width: 24px; padding: 3px 7px; border: 1px solid rgba(255, 200, 87, 0.5); border-radius: 6px; background: rgba(255, 200, 87, 0.12); color: var(--warn); font-family: var(--font-sign); font-size: 12px; text-align: center; }
@media (pointer: coarse), (max-width: 640px) { .kaiju-tip { display: none; } }

body:not(.kaiju-active) .kaiju-tip,
body:not(.kaiju-active) .kaiju-banner,
body:not(.kaiju-active) .kaiju-boundary {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.hud > * {
  pointer-events: auto;
}

.hud-top-left {
  top: max(var(--edge), env(safe-area-inset-top));
  left: max(var(--edge), env(safe-area-inset-left));
}

.hud-top-right {
  top: var(--edge);
  right: var(--edge);
}

.hud-bottom-left {
  left: var(--edge);
  bottom: var(--edge);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.hud-bottom-center {
  left: 50%;
  bottom: var(--edge);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.hud-bottom-right {
  right: var(--edge);
  bottom: var(--edge);
}

/* Clean view [H]: everything but the toggle itself steps out of the way */
body.hud-minimized::before,
body.hud-minimized::after {
  opacity: 0;
}

body.hud-minimized .hud:not(.hud-top-right) {
  opacity: 0;
}

body.hud-minimized .hud:not(.hud-top-right),
body.hud-minimized .hud:not(.hud-top-right) > * {
  pointer-events: none;
}

body.hud-minimized .hud-top-left { transform: translateY(-10px); }
body.hud-minimized .hud-bottom-left,
body.hud-minimized .hud-bottom-right { transform: translateY(12px); }
body.hud-minimized .hud-bottom-center { transform: translate(-50%, 12px); }

body.hud-minimized .toolbar > :not(#btn-toggle-hud) {
  display: none;
}

/* ------------------------------------------------------------------------------------------------------------------
   Top left: brand
   ------------------------------------------------------------------------------------------------------------------ */
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  height: var(--bar-h);
  padding: 0 18px 0 9px;
}

.mta-bullet {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--taxi);
  color: var(--taxi-ink);
  font-weight: 800;
  font-size: 12.5px;
  letter-spacing: -0.02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.18);
}

.brand-heading {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-titles h1 {
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.repo-link {
  flex: none;
  padding: 3px 0;
  color: var(--text-2);
  font-size: 11px;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.repo-link:hover,
.repo-link:focus-visible {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.brand-subtitle {
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#hud-fps {
  font-weight: 650;
  color: var(--text-2);
}

#hud-fps.fps-ok { color: var(--ok); }
#hud-fps.fps-warn { color: var(--warn); }
#hud-fps.fps-bad { color: var(--bad); }

/* ------------------------------------------------------------------------------------------------------------------
   Top right: toolbar (time of day, teleport, map, clean view)
   ------------------------------------------------------------------------------------------------------------------ */
.toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  height: var(--bar-h);
  padding: 0 5px;
}

.toolbar-divider {
  flex: none;
  width: 1px;
  height: 20px;
  margin: 0 5px;
  background: var(--divider);
}

.time-switch {
  display: flex;
  gap: 2px;
}

.time-btn {
  height: 36px;
  padding: 0 9px;
  border-radius: var(--r-ctl);
  display: inline-flex;
  align-items: center;
  gap: 0;
  color: var(--text-2);
  transition: background-color 0.2s ease, color 0.2s ease, gap 0.35s var(--ease-out), padding 0.35s var(--ease-out);
}

.time-btn:hover {
  color: var(--text);
  background: var(--hover);
}

/* The active time of day spells out its name */
.time-btn .seg-label {
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
  transition: max-width 0.4s var(--ease-out), opacity 0.25s ease;
}

.time-btn.active,
.time-btn.active:hover {
  gap: 7px;
  padding: 0 12px 0 10px;
  background: var(--text);
  color: #121314;
}

.time-btn.active .seg-label {
  max-width: 120px;
  opacity: 1;
}

.tool-btn {
  height: 36px;
  padding: 0 11px;
  border-radius: var(--r-ctl);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--text);
  transition: background-color 0.2s ease;
}

.tool-btn:hover,
.tool-btn.is-open {
  background: var(--hover);
}

.tool-btn .icon-sm {
  margin-left: -2px;
  color: var(--text-3);
  transition: transform 0.3s var(--ease-out);
}

.tool-btn.is-open .icon-sm {
  transform: rotate(180deg);
}

.tool-btn.icon-only {
  width: 36px;
  padding: 0;
  justify-content: center;
}

.icon-show {
  display: none;
}

body.hud-minimized .icon-hide {
  display: none;
}

body.hud-minimized .icon-show {
  display: block;
}

.tool-btn:active,
.time-btn:active,
.icon-btn:active,
.mode-btn:active,
.camera-current:active,
.pop-item:active {
  transform: scale(0.97);
}

/* ------------------------------------------------------------------------------------------------------------------
   Popovers (teleport destinations, cameras)
   ------------------------------------------------------------------------------------------------------------------ */
.popover {
  position: fixed;
  inset: auto;
  margin: 0;
  padding: 6px;
  min-width: 264px;
  max-height: calc(100vh - 2 * var(--edge) - 64px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  color: var(--text);
  background: var(--grain), var(--glass-strong);
  -webkit-backdrop-filter: blur(26px) saturate(170%);
  backdrop-filter: blur(26px) saturate(170%);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 28px 60px -22px rgba(0, 0, 0, 0.8), 0 4px 14px rgba(0, 0, 0, 0.3);
  transform-origin: top right;
  transition: opacity 0.18s ease, transform 0.26s var(--ease-out), overlay 0.26s allow-discrete, display 0.26s allow-discrete;
}

.popover[data-side='above'] {
  transform-origin: bottom right;
}

.popover:not(:popover-open) {
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
}

.popover[data-side='above']:not(:popover-open) {
  transform: translateY(4px) scale(0.98);
}

@starting-style {
  .popover:popover-open {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }

  .popover[data-side='above']:popover-open {
    transform: translateY(4px) scale(0.98);
  }
}

.pop-title {
  padding: 9px 10px 6px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}

.pop-title:not(:first-child) {
  margin-top: 5px;
  padding-top: 12px;
  border-top: 1px solid var(--divider);
}

.pop-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 10px;
  border-radius: 9px;
  text-align: left;
  font-size: 13px;
  font-weight: 550;
  color: var(--text);
  transition: background-color 0.15s ease;
}

.pop-item:hover {
  background: var(--hover);
}

.pop-item.active,
.pop-item.active:hover {
  background: var(--text);
  color: #121314;
}

.pop-item.active kbd {
  color: rgba(0, 0, 0, 0.55);
  background: rgba(0, 0, 0, 0.08);
  box-shadow: none;
}

.tp-btn {
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}

.pop-sub {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-3);
}

/* ------------------------------------------------------------------------------------------------------------------
   Bottom left: NYC street-name signs over the GPS radar
   ------------------------------------------------------------------------------------------------------------------ */
.location {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  pointer-events: none;
}

.location-place {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7), 0 0 14px rgba(0, 0, 0, 0.4);
  animation: rise-in 0.4s var(--ease-out) both;
}

.location-signs {
  display: flex;
  align-items: center;
  gap: 6px;
  animation: rise-in 0.4s var(--ease-out) both;
}

.location-near {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

/* Green blade, white inset border, Highway Gothic lettering: the sign on every Manhattan corner */
.street-sign {
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 9px 13px 7px;
  font-family: var(--font-sign);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: 0.01em;
  color: #ffffff;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0) 55%), var(--sign-green);
  border-radius: 6px;
  outline: 1.5px solid rgba(255, 255, 255, 0.92);
  outline-offset: -4px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35), 0 10px 22px -10px rgba(0, 0, 0, 0.75);
}

.radar {
  position: relative;
  width: 288px;
  height: 184px;
  overflow: hidden;
  border-radius: 18px;
  background: #0a1118;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  cursor: pointer;
  transition: transform 0.35s var(--ease-out);
}

.radar:hover {
  transform: translateY(-2px);
}

/* Inner rim: a soft vignette so the map sinks into the frame */
.radar::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), inset 0 0 30px rgba(0, 0, 0, 0.55);
}

#minimap-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.radar-north {
  position: absolute;
  top: 7px;
  left: 50%;
  transform: translateX(-50%);
  width: 17px;
  height: 17px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  color: #ffffff;
  background: rgba(10, 12, 15, 0.72);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
  pointer-events: none;
}

.radar-key {
  position: absolute;
  top: 9px;
  right: 9px;
  z-index: 1;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(10, 12, 15, 0.6);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.radar:hover .radar-key {
  color: var(--taxi-ink);
  background: var(--taxi);
  box-shadow: none;
}

/* ------------------------------------------------------------------------------------------------------------------
   Bottom centre: travel mode switcher & keyboard guide
   ------------------------------------------------------------------------------------------------------------------ */
.controls-hint {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 16px;
  max-width: 600px;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.88);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
  pointer-events: none;
}

.hint {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
  animation: rise-in 0.35s var(--ease-out) both;
}

.hint kbd {
  color: #ffffff;
  background: rgba(12, 13, 15, 0.55);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
  text-shadow: none;
}

.hint-label {
  margin-left: 4px;
}

.mode-switch {
  position: relative;
  display: flex;
  gap: 2px;
  padding: 5px;
}

/* The taxi-yellow pill glides to the selected mode (positioned by main.js) */
.mode-indicator {
  position: absolute;
  z-index: 0;
  top: 5px;
  bottom: 5px;
  left: 0;
  width: var(--ind-w, 0px);
  transform: translateX(var(--ind-x, 0px));
  border-radius: 12px;
  background: var(--taxi);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), inset 0 -1px 0 rgba(0, 0, 0, 0.12), 0 4px 12px -4px rgba(0, 0, 0, 0.5);
  transition: transform 0.45s var(--ease-out), width 0.45s var(--ease-out);
}

.mode-switch.no-anim .mode-indicator {
  transition: none;
}

.mode-btn {
  position: relative;
  z-index: 1;
  height: 42px;
  padding: 0 12px 0 11px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--text-2);
  transition: color 0.25s ease, background-color 0.2s ease;
}

.mode-btn:hover {
  color: var(--text);
  background: var(--hover);
}

.mode-btn.active,
.mode-btn.active:hover {
  color: var(--taxi-ink);
  background: transparent;
}

.mode-btn .icon {
  width: 20px;
  height: 20px;
  stroke-width: 1.7;
}

.mode-btn kbd {
  margin-left: 2px;
  transition: color 0.25s ease, background-color 0.25s ease;
}

.mode-btn.active kbd {
  color: rgba(23, 20, 10, 0.62);
  background: rgba(23, 20, 10, 0.1);
  box-shadow: none;
}

/* ------------------------------------------------------------------------------------------------------------------
   Bottom right: speed cluster & camera switcher
   ------------------------------------------------------------------------------------------------------------------ */
.cluster {
  width: 272px;
  overflow: hidden;
}

.gauge {
  padding: 13px 16px 15px;
}

.gauge-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.gauge-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}

.gauge-alt {
  flex: none;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.gauge-alt-label {
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}

.gauge-speed {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 5px;
}

#hud-speed {
  font-size: 42px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}

.gauge-unit {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}

.gauge-meter {
  position: relative;
  height: 4px;
  margin-top: 12px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

/* Speed as a share of the mode's top speed; it turns taxi yellow on boost */
#hud-speed-meter {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--text);
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 0.25s linear, background-color 0.2s ease;
}

body.is-boosting #hud-speed-meter {
  background: var(--taxi);
}

.camera-switch {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-top: 1px solid var(--divider);
}

.icon-btn {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: var(--r-ctl);
  display: inline-grid;
  place-items: center;
  color: var(--text-2);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
  color: var(--text);
  background: var(--hover);
}

.camera-current {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 8px;
  border-radius: var(--r-ctl);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  transition: background-color 0.15s ease;
}

.camera-current:hover,
.camera-current.is-open {
  background: var(--hover);
}

.camera-current .icon {
  color: var(--text-3);
}

#hud-active-camera {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------------------------------------------------------------------------
   Full-screen interactive street map ([M])
   ------------------------------------------------------------------------------------------------------------------ */
.fullmap-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: #0a1118;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.fullmap-modal.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.fullmap-canvas-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: crosshair;
}

.fullmap-canvas-wrap.is-panning {
  cursor: grabbing;
}

#fullmap-canvas {
  touch-action: none;
  display: block;
  width: 100%;
  height: 100%;
}

.fullmap-header {
  position: absolute;
  top: var(--edge);
  left: var(--edge);
  right: var(--edge);
  display: flex;
  align-items: stretch;
  gap: 10px;
  pointer-events: none;
}

.fullmap-header > * {
  pointer-events: auto;
}

.fullmap-modal:not(.hidden) .fullmap-header,
.fullmap-modal:not(.hidden) .map-controls,
.fullmap-modal:not(.hidden) .fullmap-footer {
  animation: rise-in 0.45s var(--ease-out) both;
}

.fullmap-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 9px 20px 9px 11px;
}

.fullmap-title h2 {
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.2;
  white-space: nowrap;
}

.fullmap-subtitle {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fullmap-search-wrap {
  flex: 0 1 440px;
  min-width: 180px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  color: var(--text-3);
  cursor: text;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.fullmap-search-wrap:focus-within {
  color: var(--text-2);
  border-color: rgba(255, 255, 255, 0.24);
  background: var(--grain), var(--glass-strong);
}

.fullmap-search {
  flex: 1;
  min-width: 0;
  height: 100%;
  background: none;
  border: 0;
  outline: none;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  user-select: text;
}

.fullmap-search::placeholder {
  color: var(--text-3);
}

.fullmap-close {
  margin-left: auto;
  height: auto;
  padding: 0 14px 0 12px;
  border-radius: var(--r-panel);
}

.fullmap-close:hover {
  background: var(--grain), var(--glass-strong);
}

/* (centred with `translate`, which the rise-in entrance animation on `transform` leaves alone) */
.map-controls {
  position: absolute;
  top: 50%;
  right: var(--edge);
  translate: 0 -50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.map-compass {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.map-compass svg {
  width: 44px;
  height: 44px;
}

.map-compass text {
  font: 800 7.5px var(--font-sans);
  fill: #ffffff;
}

.map-zoom {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px;
  border-radius: 14px;
}

.fullmap-footer {
  position: absolute;
  left: 50%;
  bottom: var(--edge);
  translate: -50% 0;
  display: flex;
  max-width: min(560px, calc(100% - 2 * var(--edge) - 2 * 200px));
}

.fullmap-status {
  min-width: 0;
  padding: 10px 16px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fullmap-legend {
  position: absolute;
  right: var(--edge);
  bottom: var(--edge);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
}

.fullmap-modal:not(.hidden) .fullmap-legend {
  animation: rise-in 0.45s var(--ease-out) both;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend-swatch {
  flex: none;
  display: inline-block;
}

.player-swatch {
  width: 10px;
  height: 11px;
  background: #ffffff;
  clip-path: polygon(50% 0, 100% 100%, 50% 78%, 0 100%);
}

.landmark-swatch {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 0 2px #0b0f14, 0 0 0 3px rgba(255, 255, 255, 0.35);
}

.gps-swatch,
.bridge-swatch {
  width: 16px;
  height: 4px;
  border-radius: 2px;
}

.gps-swatch { background: var(--taxi); }
.bridge-swatch { background: var(--highway); }

.legend-counts {
  padding-left: 14px;
  border-left: 1px solid var(--divider);
  color: var(--text-3);
}

/* ------------------------------------------------------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------------------------------------------------------ */
@media (max-width: 1800px) {
  .legend-counts { display: none; }
}

@media (max-width: 1360px) {
  .fullmap-legend { display: none; }
}

@media (max-width: 1240px) {
  .controls-hint { display: none; }
  .mode-btn kbd { display: none; }
}

@media (max-width: 1080px) {
  .mode-label,
  .tool-label,
  .tool-btn kbd { display: none; }
  .mode-btn { padding: 0 12px; }
  .tool-btn:not(.icon-only):not(.fullmap-close) { gap: 4px; padding: 0 9px; }
}

@media (max-width: 820px) {
  :root { --edge: 12px; }
  .hud-top-left { top: calc(max(var(--edge), env(safe-area-inset-top)) + 62px); }
  .brand > .mta-bullet,
  .brand-heading h1,
  .brand-subtitle { display: none; }
  .brand { height: 44px; padding: 0 12px; }
  .repo-link { display: flex; align-items: center; gap: 4px; min-height: 44px; font-size: 12px; }
  .radar { width: 220px; height: 148px; }
  .cluster { width: 220px; }
  #hud-speed { font-size: 34px; }
  .fullmap-title > div { display: none; }
  .fullmap-title { padding: 9px; }
  .fullmap-footer { max-width: calc(100% - 2 * var(--edge)); bottom: calc(var(--edge) + 34px); }
  .map-controls { top: auto; bottom: calc(var(--edge) + 96px); translate: none; }
}

@media (max-width: 620px) {
  .time-btn.active .seg-label { display: none; }
  .time-btn.active { padding: 0 9px; gap: 0; }
  .radar { display: none; }
  .hud-bottom-right { bottom: calc(var(--edge) + 64px); }
  .gauge { display: none; }
  .camera-switch { border-top: 0; }
}

/* Touch controls reserve the bottom corners; mode and camera selection remain within reach. */
#touch-controls {
  position: fixed;
  z-index: 12;
  left: max(var(--edge), env(safe-area-inset-left));
  right: max(var(--edge), env(safe-area-inset-right));
  bottom: calc(max(var(--edge), env(safe-area-inset-bottom)) + 72px);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
  -webkit-touch-callout: none;
}

#touch-controls[hidden],
.touch-action[hidden] { display: none; }

.touch-movement { text-align: center; }

#touch-stick {
  position: relative;
  width: 136px;
  height: 136px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.06) 32%, transparent 33%), var(--glass);
  box-shadow: var(--shadow), inset 0 0 0 12px rgba(255, 255, 255, 0.025);
  pointer-events: auto;
  touch-action: none;
}

.touch-stick-axis::before,
.touch-stick-axis::after {
  content: '';
  position: absolute;
  background: rgba(255, 255, 255, 0.12);
}
.touch-stick-axis::before { top: 16px; bottom: 16px; width: 1px; left: 50%; }
.touch-stick-axis::after { left: 16px; right: 16px; height: 1px; top: 50%; }

#touch-stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(246, 245, 242, 0.8);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  transform: translate(calc(-50% + var(--stick-x, 0px)), calc(-50% + var(--stick-y, 0px)));
  pointer-events: none;
}

#touch-stick.is-pressed #touch-stick-knob { background: var(--taxi); border-color: var(--taxi); }

.touch-caption,
.touch-look-hint {
  color: var(--text-2);
  font-size: 11px;
  font-weight: 550;
  text-shadow: 0 1px 5px #000;
}
.touch-caption { display: block; margin-top: 8px; }
.touch-look-hint {
  position: fixed;
  top: calc(max(var(--edge), env(safe-area-inset-top)) + 120px);
  right: max(var(--edge), env(safe-area-inset-right));
  padding: 4px;
}

.touch-actions {
  display: grid;
  grid-template-columns: repeat(2, 64px);
  gap: 10px;
  padding-bottom: 22px;
}
.touch-action {
  width: 64px;
  height: 64px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: var(--glass-strong);
  box-shadow: var(--shadow);
  font-size: 11px;
  font-weight: 650;
  pointer-events: auto;
  touch-action: none;
}
.touch-action > [aria-hidden] { font-size: 23px; line-height: 1; }
.touch-boost { grid-column: 2; border-color: rgba(255, 194, 26, 0.65); color: var(--taxi); }
.touch-action.is-pressed { color: var(--taxi-ink); background: var(--taxi); border-color: var(--taxi); }

body.touch-enabled .controls-hint,
body.touch-enabled .radar,
body.touch-enabled .gauge,
body.touch-enabled kbd,
body.touch-enabled .toolbar-divider,
body.touch-enabled .seg-label { display: none; }

body.touch-enabled .hud-top-right { top: max(var(--edge), env(safe-area-inset-top)); right: max(var(--edge), env(safe-area-inset-right)); }
body.touch-enabled .toolbar { gap: 2px; padding: 4px; }
body.touch-enabled .time-btn,
body.touch-enabled .time-btn.active { height: 44px; min-width: 44px; padding: 0 8px; gap: 0; }
body.touch-enabled .tool-btn { min-width: 44px; min-height: 44px; }
body.touch-enabled .tool-label { display: none; }
body.touch-enabled .hud-bottom-center { bottom: max(var(--edge), env(safe-area-inset-bottom)); }
body.touch-enabled .mode-label { display: block; font-size: 10px; }
body.touch-enabled .mode-btn { width: 62px; height: 48px; padding: 0; flex-direction: column; justify-content: center; gap: 3px; }
body.touch-enabled .hud-bottom-right { top: calc(max(var(--edge), env(safe-area-inset-top)) + 62px); right: max(var(--edge), env(safe-area-inset-right)); bottom: auto; }
body.touch-enabled .cluster { width: 230px; }
body.touch-enabled .camera-switch { border: 0; }
body.touch-enabled .camera-switch .icon-btn { width: 44px; height: 44px; }
body.touch-enabled .hud-bottom-left { left: max(var(--edge), env(safe-area-inset-left)); bottom: calc(max(var(--edge), env(safe-area-inset-bottom)) + 254px); max-width: calc(100% - 2 * var(--edge)); }
body.touch-enabled .fullmap-header { top: max(var(--edge), env(safe-area-inset-top)); left: max(var(--edge), env(safe-area-inset-left)); right: max(var(--edge), env(safe-area-inset-right)); }
body.touch-enabled .map-controls .icon-btn { width: 44px; height: 44px; }
body.touch-enabled .pop-item { min-height: 44px; }

@media (max-width: 360px) {
  body.touch-enabled .toolbar { width: 194px; height: auto; flex-wrap: wrap; justify-content: center; }
  body.touch-enabled .hud-bottom-right { top: calc(max(var(--edge), env(safe-area-inset-top)) + 114px); }
  .touch-look-hint { top: calc(max(var(--edge), env(safe-area-inset-top)) + 172px); }
}

@media (max-height: 500px) {
  body.touch-enabled .hud-bottom-left { display: none; }
  body.touch-enabled .hud-bottom-right { top: calc(max(var(--edge), env(safe-area-inset-top)) + 58px); }
  #touch-controls { bottom: max(var(--edge), env(safe-area-inset-bottom)); }
}

/* ------------------------------------------------------------------------------------------------------------------
   Compact in-game HUD for desktop and landscape. Portrait phones keep their own layout above and are not touched.
   ------------------------------------------------------------------------------------------------------------------ */
@media (min-width: 641px) and (orientation: landscape) {
  :root { --edge: 12px; --bar-h: 38px; }

  /* Top left: just the badge, name and fps */
  .brand { gap: 8px; padding: 0 12px 0 6px; }
  .mta-bullet { width: 26px; height: 26px; font-size: 11px; }
  .brand .kaiju-class, .brand .brand-tech { display: none; }
  .brand-subtitle { font-size: 11px; line-height: 1.2; }
  .brand-titles { display: flex; align-items: baseline; gap: 8px; }

  /* Top right: icon-only toolbar */
  .toolbar .seg-label, .toolbar .tool-label, .toolbar kbd { display: none; }
  .toolbar .time-btn, .toolbar .tool-btn { min-width: 32px; padding: 0 8px; }

  /* Top centre: one slim score strip, no sub-captions */
  .kaiju-combat-telemetry { top: var(--edge); background: rgba(12, 18, 22, 0.55); }
  .combat-readout { min-width: 70px; gap: 1px; padding: 5px 10px 5px; }
  .combat-readout strong { font-size: 14px; }
  .combat-label { font-size: 8px; }
  .combat-sub { display: none; }
  .combat-divider { margin: 7px 0; }
  .kaiju-threat { top: 58px; width: min(300px, calc(100% - 32px)); gap: 4px; }
  .threat-head { font-size: 11px; }
  .threat-track { height: 4px; }
  .kaiju-banner { top: 28%; }

  /* Bottom centre: slim vitals and weapons, controls hint removed */
  body.kaiju-active #hud-controls-hint { display: none; }
  .kaiju-vitals { bottom: var(--edge); gap: 10px; padding: 6px 8px; background: rgba(12, 18, 22, 0.6); }
  .vital { width: 84px; gap: 3px; }
  .vital-head { font-size: 8px; }
  .vital-track { height: 4px; }
  .weapon-rack { gap: 3px; }
  .weapon-btn { min-width: 0; flex-direction: row; align-items: center; gap: 5px; padding: 4px 7px 6px; font-size: 9px; }
  .weapon-btn kbd { font-size: 8px; }
  .weapon-ammo { position: static; margin-left: 2px; font-size: 9px; }

  /* Bottom left: small radar, small street signs */
  .hud-bottom-left { gap: 6px; }
  .radar { width: 176px; height: 112px; border-radius: 12px; opacity: 0.88; }
  .radar:hover { opacity: 1; }
  .radar-key { display: none; }
  .location-signs { gap: 4px; }
  .street-sign { max-width: 150px; padding: 5px 9px 4px; font-size: 11px; border-radius: 4px; outline-offset: -3px; }
  .location-near { display: none; }

  /* Bottom right: small speed readout, one-button camera switch */
  .cluster { width: 176px; }
  .gauge { padding: 8px 12px 9px; }
  .gauge-label { font-size: 9px; }
  .gauge-speed { margin-top: 2px; }
  #hud-speed { font-size: 26px; }
  .gauge-unit { font-size: 10px; }
  .gauge-meter { margin-top: 6px; height: 3px; }
  .camera-switch { padding: 2px; }
  .camera-switch #cam-prev, .camera-switch #cam-next { display: none; }
  .camera-current { height: 28px; font-size: 11px; gap: 6px; }
}

@media (min-width: 641px) and (orientation: landscape) and (max-height: 560px) {
  .radar { width: 144px; height: 92px; }
  .street-sign { display: none; }
  .kaiju-banner { top: 22%; }
}


@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Combat key reminders under the weapon rack: desktop (mouse + keyboard) only, so touch / portrait layouts are untouched.
   Labels come from keybindings.js via data-kb, so a rebind shows up here immediately. */
.kaiju-keystrip { display: none; }
@media (hover: hover) and (pointer: fine) and (min-width: 641px) {
  body.kaiju-active .kaiju-vitals { flex-wrap: wrap; justify-content: center; row-gap: 7px; }
  .kaiju-keystrip { display: flex; flex-basis: 100%; flex-wrap: wrap; justify-content: center; gap: 3px 11px; margin: 0; padding: 6px 0 0; border-top: 1px solid rgba(246, 245, 242, 0.08); list-style: none; color: var(--text-3); font-family: var(--font-sign); font-size: 9px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap; }
  .kaiju-keystrip li { display: flex; align-items: center; gap: 4px; }
  .kaiju-keystrip kbd { min-width: 15px; padding: 1px 4px; border: 1px solid rgba(246, 245, 242, 0.16); border-radius: 3px; color: var(--text); background: rgba(246, 245, 242, 0.06); font-family: inherit; font-size: 8px; line-height: 1.4; text-align: center; }
  body.kaiju-orbiting .kaiju-reticle { opacity: 0; }
}

/* ------------------------------------------------------------------------------------------------------------------
   Touch play: four zones and nothing else. Top left = score + vitals, top right = pause / camera / map / settings,
   bottom left = stick, bottom right = action pad. Time of day, radar, speed, street signs and captions are hidden so
   the middle of the screen stays clear.
   ------------------------------------------------------------------------------------------------------------------ */
.touch-only { display: none; }
body.touch-enabled .touch-only { display: inline-flex; }

body.touch-enabled {
  --t-top: max(10px, env(safe-area-inset-top));
  --t-left: max(10px, env(safe-area-inset-left));
  --t-right: max(10px, env(safe-area-inset-right));
  --t-bottom: max(14px, env(safe-area-inset-bottom));
  --pad-b: 52px;
  --pad-gap: 8px;
  --stick: 124px;
}

body.touch-enabled.kaiju-active .hud-top-left,
body.touch-enabled.kaiju-active .hud-bottom-left,
body.touch-enabled.kaiju-active .hud-bottom-right,
body.touch-enabled.kaiju-active .hud-bottom-center,
body.touch-enabled.kaiju-active .time-switch,
body.touch-enabled.kaiju-active #btn-toggle-hud,
body.touch-enabled.kaiju-active .toolbar-divider,
body.touch-enabled .kaiju-keystrip,
body.touch-enabled .kaiju-tip { display: none; }

body.touch-enabled.kaiju-active .hud-top-right { top: var(--t-top); right: var(--t-right); }
body.touch-enabled.kaiju-active .toolbar { gap: 2px; padding: 3px; }
body.touch-enabled.kaiju-active .toolbar .tool-btn { width: 40px; min-width: 40px; height: 40px; min-height: 40px; padding: 0; justify-content: center; }

body.touch-enabled.kaiju-active .kaiju-combat-telemetry { top: var(--t-top); left: var(--t-left); width: auto; transform: none; background: rgba(12, 18, 22, 0.6); }
body.touch-enabled.kaiju-active .combat-readout { min-width: 0; flex: none; gap: 1px; padding: 5px 10px; }
body.touch-enabled.kaiju-active .combat-readout strong { font-size: 14px; }
body.touch-enabled.kaiju-active .combat-label { font-size: 8px; }
body.touch-enabled.kaiju-active .combat-sub,
body.touch-enabled.kaiju-active .kaiju-combat-telemetry > :nth-child(3),
body.touch-enabled.kaiju-active .kaiju-combat-telemetry > :nth-child(4) { display: none; }
body.touch-enabled.kaiju-active .combat-divider { margin: 6px 0; }

body.touch-enabled.kaiju-active .kaiju-vitals {
  top: calc(var(--t-top) + 44px);
  left: var(--t-left);
  bottom: auto;
  width: 160px;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 5px;
  padding: 6px 8px;
  transform: none;
  background: rgba(12, 18, 22, 0.6);
}
body.touch-enabled.kaiju-active .vital { width: auto; flex: none; gap: 3px; }
body.touch-enabled.kaiju-active .vital-head { font-size: 8px; }
body.touch-enabled.kaiju-active .vital-track { height: 4px; }
body.touch-enabled.kaiju-active .weapon-rack { width: auto; pointer-events: none; }
body.touch-enabled.kaiju-active .weapon-btn:not(.active) { display: none; }
body.touch-enabled.kaiju-active .weapon-btn.active { min-width: 0; flex: 1; flex-direction: row; align-items: center; gap: 6px; padding: 3px 6px 5px; font-size: 9px; }
body.touch-enabled.kaiju-active .weapon-btn kbd { display: none; }
body.touch-enabled.kaiju-active .weapon-ammo { position: static; margin-left: auto; }

body.touch-enabled.kaiju-active .kaiju-threat,
body.touch-enabled.kaiju-active .kaiju-threat.is-visible { top: calc(var(--t-top) + 54px); left: auto; right: var(--t-right); width: min(170px, 40vw); transform: none; }
body.touch-enabled.kaiju-active .threat-head { justify-content: flex-end; font-size: 10px; }

body.touch-enabled #touch-controls { left: var(--t-left); right: var(--t-right); bottom: var(--t-bottom); align-items: flex-end; gap: 12px; }
body:not(.kaiju-active) #touch-controls,
body.kaiju-over #touch-controls,
body.kaiju-paused #touch-controls { display: none; }

body.touch-enabled #touch-stick { width: var(--stick); height: var(--stick); border: 1.5px solid rgba(246, 245, 242, 0.25); background: rgba(12, 18, 22, 0.35); box-shadow: none; }
body.touch-enabled #touch-stick-knob { width: 46px; height: 46px; border-color: rgba(246, 245, 242, 0.5); background: rgba(246, 245, 242, 0.55); box-shadow: none; }

body.touch-enabled .touch-look-hint { top: auto; right: auto; bottom: calc(var(--t-bottom) + var(--stick) + 12px); left: var(--t-left); pointer-events: none; animation: touch-hint-fade 6s ease forwards; }
@keyframes touch-hint-fade { 0%, 75% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }

.touch-pad {
  display: grid;
  grid-template-columns: repeat(3, var(--pad-b));
  grid-template-rows: repeat(3, var(--pad-b));
  grid-template-areas: "melee weapon shield" "jets fire fire" "boost fire fire";
  gap: var(--pad-gap);
  pointer-events: none;
}
.touch-pad .touch-action {
  width: 100%;
  height: 100%;
  gap: 0;
  border: 1.5px solid rgba(246, 245, 242, 0.28);
  border-radius: 50%;
  color: var(--text);
  background: rgba(12, 18, 22, 0.45);
  box-shadow: none;
  font-family: var(--font-sign);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  backdrop-filter: blur(6px);
}
.touch-pad .pad-melee { grid-area: melee; }
.touch-pad .pad-weapon { grid-area: weapon; }
.touch-pad .pad-shield { grid-area: shield; border-color: rgba(95, 244, 255, 0.55); }
.touch-pad .pad-jets { grid-area: jets; }
.touch-pad .pad-boost { grid-area: boost; border-color: rgba(255, 200, 87, 0.6); }
.touch-pad .pad-fire { grid-area: fire; border: 0; color: var(--taxi-ink); background: var(--warn); font-size: 15px; letter-spacing: 0.14em; }
.touch-pad .touch-action.is-pressed { border-color: var(--text); color: var(--taxi-ink); background: var(--text); }
.touch-pad .pad-fire.is-pressed { background: var(--taxi); transform: scale(0.96); }

@media (max-width: 359px) {
  body.touch-enabled { --pad-b: 46px; --pad-gap: 6px; --stick: 108px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  body.touch-enabled { --pad-b: 46px; --pad-gap: 6px; --stick: 112px; }
}
@media (min-width: 768px) and (min-height: 700px) {
  body.touch-enabled { --pad-b: 60px; --pad-gap: 10px; --stick: 140px; }
}

/* Fullscreen toggle (hidden where the page can't go fullscreen) */
.tool-btn[hidden] { display: none !important; }
#btn-fullscreen .icon-shrink,
#btn-fullscreen.is-fullscreen .icon-expand { display: none; }
#btn-fullscreen.is-fullscreen .icon-shrink { display: block; }

/* During a touch run the whole page is a game surface: no scrolling, zooming, text selection or callouts. */
html:has(body.touch-enabled.kaiju-active),
body.touch-enabled.kaiju-active {
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* Run loadout (left edge, between the brand card and the radar): keyboard layouts only, touch layouts untouched */
.kaiju-loadout { display: none; }
body.kaiju-active:not(.touch-enabled):not(.kaiju-over) .kaiju-loadout { position: fixed; z-index: 8; top: calc(var(--edge) + 92px); left: var(--edge); display: flex; width: 240px; max-height: calc(100dvh - var(--edge) * 2 - 92px - 250px); flex-direction: column; gap: 14px; padding: 12px; overflow-y: auto; border: 1px solid var(--glass-border); border-radius: 8px; color: var(--text); background: var(--hud-glass, rgba(12, 18, 22, 0.42)); backdrop-filter: blur(6px); scrollbar-width: thin; }
body.hud-minimized .kaiju-loadout { visibility: hidden; }
@media (max-height: 620px) { body.kaiju-active:not(.touch-enabled) .kaiju-loadout { display: none; } }
.loadout-group { display: flex; flex-direction: column; gap: 6px; }
.loadout-head { display: flex; align-items: baseline; justify-content: space-between; padding-bottom: 6px; border-bottom: 1px solid var(--glass-border); }
.loadout-head h2 { margin: 0; color: var(--text-3); font-family: var(--font-sign); font-size: 10px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; }
.loadout-meta { color: var(--warn); font-family: var(--font-sign); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; }
.loadout-slots, .loadout-upgrades { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; list-style: none; }
.loadout-slot button { display: flex; width: 100%; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 8px; padding: 6px 8px; border: 1px solid rgba(246, 245, 242, 0.12); border-radius: 4px; color: var(--text-2, var(--text)); background: transparent; font: inherit; text-align: left; cursor: pointer; }
.loadout-slot.is-selected button { border-color: var(--warn); color: var(--text); background: rgba(255, 200, 87, 0.1); }
.loadout-slot-name { font-family: var(--font-sign); font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.loadout-slot.is-selected .loadout-slot-name { color: var(--warn); }
.loadout-slot.is-empty { padding: 6px 8px; border: 1px dashed rgba(246, 245, 242, 0.12); border-radius: 4px; color: var(--text-3); }
.loadout-slot kbd { min-width: 16px; padding: 1px 4px; border: 1px solid rgba(255, 200, 87, 0.5); border-radius: 3px; color: var(--warn); font-family: var(--font-sign); font-size: 9px; text-align: center; }
.loadout-desc { flex-basis: 100%; color: var(--text-3); font-size: 11px; line-height: 1.4; text-wrap: pretty; }
.loadout-hint, .loadout-effect { margin: 0; color: var(--text-3); font-family: var(--font-sign); font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; }
.loadout-effect { color: var(--warn); }
.loadout-upgrade { display: flex; flex-direction: column; gap: 2px; padding: 4px 0 4px 8px; border-left: 2px solid rgba(246, 245, 242, 0.18); }
.loadout-upgrade[data-rarity="rare"] { border-left-color: rgb(95, 244, 255); }
.loadout-upgrade[data-rarity="epic"] { border-left-color: var(--warn); }
.loadout-upgrade-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.loadout-upgrade-name { font-size: 12px; font-weight: 600; }
.loadout-pips { display: inline-flex; flex-shrink: 0; gap: 2px; }
.loadout-pips i { width: 6px; height: 6px; border: 1px solid rgba(246, 245, 242, 0.3); border-radius: 1px; }
.loadout-pips i.on { border-color: var(--warn); background: var(--warn); }
.loadout-none { color: var(--text-3); font-size: 11px; line-height: 1.4; }

/* Lighter in-run HUD glass on keyboard layouts: lower fill + softer blur so the city reads through. Touch/portrait
   layouts and the full map keep their own backgrounds. A faint text shadow keeps the readouts legible on bright sky. */
body.kaiju-active:not(.touch-enabled) {
  --hud-glass: rgba(12, 18, 22, 0.42);
}
body.kaiju-active:not(.touch-enabled) :is(.brand, .toolbar, .radar, .cluster).panel {
  background: var(--hud-glass);
  -webkit-backdrop-filter: blur(6px) saturate(130%);
  backdrop-filter: blur(6px) saturate(130%);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}
body.kaiju-active:not(.touch-enabled) :is(.kaiju-combat-telemetry, .kaiju-vitals, .kaiju-tip, .kaiju-loadout) {
  background: var(--hud-glass);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
body.kaiju-active:not(.touch-enabled) :is(.brand, .toolbar, .cluster, .kaiju-combat-telemetry, .kaiju-vitals, .kaiju-tip, .kaiju-loadout) {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

/* Special ability readout (vitals row) and touch button */
.kaiju-ability { display: none; }
body.kaiju-active .kaiju-ability { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border: 1px solid rgba(246, 245, 242, 0.12); border-radius: 4px; color: var(--text-3); font-family: var(--font-sign); font-size: 10px; font-weight: 700; letter-spacing: 0.1em; white-space: nowrap; }
body.kaiju-active .kaiju-ability.is-ready { border-color: rgba(242, 246, 255, 0.55); color: var(--text); }
.kaiju-ability kbd { min-width: 15px; padding: 1px 4px; border: 1px solid rgba(246, 245, 242, 0.2); border-radius: 3px; font-family: inherit; font-size: 9px; text-align: center; }
.kaiju-ability-count { color: var(--warn); }
body.touch-enabled.kaiju-active .kaiju-ability { display: none; }

.touch-pad { grid-template-columns: repeat(4, var(--pad-b)); grid-template-areas: "ability melee weapon shield" ". jets fire fire" ". boost fire fire"; }
.touch-pad .pad-ability { grid-area: ability; color: var(--text-3); }
.touch-pad .pad-ability.is-ready { border-color: rgba(242, 246, 255, 0.7); color: var(--text); }
.touch-pad .pad-shield.is-on { border-color: rgb(95, 244, 255); color: rgb(95, 244, 255); background: rgba(95, 244, 255, 0.16); }
body.kaiju-drafting #touch-controls { display: none; }

/* Wave debrief & upgrade draft */
.kaiju-draft { position: fixed; inset: 0; z-index: 125; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); overflow-y: auto; background: rgba(2, 6, 8, 0.66); backdrop-filter: blur(8px); }
.kaiju-draft[hidden] { display: none; }
.draft-panel { display: flex; flex-direction: column; gap: 16px; width: min(920px, 100%); padding: 22px; border: 1px solid var(--glass-border); border-radius: 8px; color: var(--text); background: var(--glass-strong); box-shadow: var(--shadow); animation: rise-in 0.4s var(--ease-out) both; }
.draft-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.draft-head h2 { margin: 4px 0 0; font-family: var(--font-sign); font-size: 24px; letter-spacing: 0.04em; text-transform: uppercase; text-wrap: balance; }
.draft-reward { margin: 6px 0 0; color: var(--text-2); font-size: 14px; line-height: 1.5; text-wrap: pretty; }
.draft-grade { display: flex; flex-direction: column; align-items: center; min-width: 76px; padding: 8px 10px; border: 1px solid rgba(246, 245, 242, 0.16); border-radius: 6px; font-family: var(--font-sign); }
.draft-grade span { font-size: 40px; font-weight: 800; line-height: 1; }
.draft-grade span[data-grade="S"], .draft-grade span[data-grade="A"] { color: var(--warn); }
.draft-grade span[data-grade="C"] { color: var(--bad); }
.draft-grade small { margin-top: 4px; color: var(--text-3); font-size: 10px; letter-spacing: 0.1em; }
.draft-lines { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 18px; margin: 0; padding: 0; list-style: none; color: var(--text-2); font-size: 13px; }
.draft-lines li { display: flex; align-items: baseline; gap: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--divider); }
.draft-lines li > :first-child { flex: 1; }
.draft-line-value { color: var(--text); font-variant-numeric: tabular-nums; }
.draft-line-pts { min-width: 40px; color: var(--text-3); font-family: var(--font-sign); font-size: 11px; text-align: right; }
.draft-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.draft-card { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-height: 150px; padding: 14px; border: 1px solid rgba(246, 245, 242, 0.14); border-radius: 6px; color: var(--text); background: rgba(246, 245, 242, 0.03); text-align: left; cursor: pointer; transition: border-color 0.15s ease, background 0.15s ease, transform 0.2s var(--ease-out); }
.draft-card:hover { background: rgba(246, 245, 242, 0.07); transform: translateY(-2px); }
.draft-card:focus-visible { outline: 2px solid var(--warn); outline-offset: 2px; }
.draft-card[data-rarity="rare"] { border-color: rgba(95, 244, 255, 0.4); }
.draft-card[data-rarity="epic"] { border-color: rgba(255, 200, 87, 0.55); }
.draft-card.is-selected { border-color: var(--warn); background: rgba(255, 200, 87, 0.12); box-shadow: inset 0 0 0 1px var(--warn); }
.draft-card-head { display: flex; align-items: center; gap: 8px; color: var(--text-3); font-family: var(--font-sign); font-size: 10px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.draft-card[data-rarity="rare"] .draft-card-head { color: rgb(95, 244, 255); }
.draft-card[data-rarity="epic"] .draft-card-head { color: var(--warn); }
.draft-card-head kbd, .draft-actions kbd { min-width: 18px; padding: 1px 5px; border: 1px solid currentColor; border-radius: 3px; font-family: inherit; font-size: 10px; text-align: center; }
.draft-card strong { font-family: var(--font-sign); font-size: 16px; letter-spacing: 0.02em; }
.draft-card-desc { color: var(--text-2); font-size: 14px; line-height: 1.45; text-wrap: pretty; }
.draft-card-level { margin-top: auto; color: var(--text-3); font-size: 11px; }
.draft-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.draft-hint { margin: 0; color: var(--text-2); font-size: 14px; }
.draft-actions .kaiju-launch { gap: 14px; margin-top: 0; padding: 12px 16px; }
.draft-actions .kaiju-launch:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
body.touch-enabled .draft-actions kbd { display: none; }
@media (max-width: 640px), (max-height: 520px) {
  .draft-panel { gap: 12px; padding: 14px; }
  .draft-head h2 { font-size: 18px; }
  .draft-grade span { font-size: 30px; }
  .draft-lines { grid-template-columns: 1fr; font-size: 12px; }
  .draft-cards { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
  .draft-card { min-height: 0; padding: 10px; gap: 5px; }
  .draft-card strong { font-size: 14px; }
  .draft-actions { flex-direction: column; align-items: stretch; }
  .draft-actions .kaiju-launch { justify-content: center; }
}
