<!-- SOLID CITY · part 527 -->
t('2d'), mapImg = null, MAP = { cx: 8600, cz: 0, span: 76000, n: MOBILE ? 150 : 200 };
function buildMap() {
  var c = document.createElement('canvas'); c.width = c.height = MAP.n; var g = c.getContext('2d'), id = g.createImageData(MAP.n, MAP.n);
  for (var j = 0; j < MAP.n; j++) for (var i = 0; i < MAP.n; i++) {
    var x = MAP.cx - MAP.span / 2 + (i + 0.5) / MAP.n * MAP.span, z = MAP.cz - MAP.span / 2 + (j + 0.5) / MAP.n * MAP.span, h = heightAt(x, z), o = (j * MAP.n + i) * 4;
    if (h < 0) { id.data[o] = 10; id.data[o + 1] = 14 + Math.max(0, 30 + h / 20); id.data[o + 2] = 28 + Math.max(0, 30 + h / 20); }
    else { var t = Math.min(1, h / 3500); id.data[o] = 40 + t * 180; id.data[o + 1] = 26 + t * 130; id.data[o + 2] = 22 + t * 60; if (h > 2900) { id.data[o] = id.data[o + 1] = id.data[o + 2] = 225; } }
    id.data[o + 3] = 255;
  }
  g.putImageData(id, 0, 0); mapImg = c;
}
function drawRadar(ax, az, heading) {
  var W = radar.width, H = radar.height, flying = S.mode !== 'walk';
  var rad = !flying ? 900 : S.ship.y > 20000 ? 40000 : S.ship.y > 4000 ? 18000 : 7000;   // metres from centre to edge
  rg.save(); rg.clearRect(0, 0, W, H); rg.beginPath(); rg.arc(W / 2, H / 2, W / 2 - 2, 0, Math.PI * 2); rg.clip();
  rg.fillStyle = '#04070c'; rg.fillRect(0, 0, W, H);
  if (mapImg) {
    var px = mapImg.width / MAP.span, sxp = (ax - (MAP.cx - MAP.span / 2)) * px, szp = (az - (MAP.cz - MAP.span / 2)) * px, sr = rad * px;
    rg.imageSmoothingEnabled = true; rg.drawImage(mapImg, sxp - sr, szp - sr, sr * 2, sr * 2, 0, 0, W, H);
  }
  var sc = (W / 2) / rad;
  function blip(x, z, col, r, txt) { var bx = W / 2 + (x - ax) * sc, by = H / 2 + (z - az) * sc; var d = Math.hypot(bx - W / 2, by - H / 2); if (d > W / 2 - 8) { bx = W / 2 + (bx - W / 2) / d * (W / 2 - 8); by = H / 2 + (by - H / 2) / d * (W / 2 - 8); } rg.fillStyle = col; rg.beginPath(); rg.arc(bx, by, r, 0, Math.PI * 2); rg.fill(); if (txt) { rg.font = 'bold 15px system-ui'; rg.fillText(txt, bx + r + 2, by + 5); } }
  rg.fillStyle = 'rgba(30,20,24,.6)'; var cr = 800 * sc; rg.beginPath(); rg.arc(W / 2 + (0 - ax) * sc, H / 2 + (0 - az) * sc, Math.max(cr, 3), 0, Math.PI * 2); rg.fill();
  blip(D.plaza.x, D.plaza.z, '#e8c36a', 6, flying ? '' : 'F');
  blip(D.studio.x, D.studio.z, '#e8c36a', 6, flying ? '' : 'M');
  blip(D.port.x, D.port.z, '#ff3048', 7, flying ? 'PORT' : 'S');
  blip(D.soul.x, D.soul.z, '#49a6ff', 5, flying ? '' : 'SP');
  if (!flying) blip(SABLE_POS.x, SABLE_POS.z, '#ff8fa0', 4, '');
  if (window.CityHyper) try { CityHyper.radar(rg, blip, flying, sc, ax, az); } catch (e) {}
  if (window.CityWatch) try { CityWatch.radar(rg, blip, flying, sc, ax, az); } catch (e) {}
  if (window.CityCitizens) try { CityCitizens.radar(rg, blip, flying, sc, ax, az); } catch (e) {}
  if (window.CityMonuments) try { CityMonuments.radar(rg, blip, flying, sc, ax, az); } catch (e) {}
  if (window.CitySanctuary) try { CitySanctuary.radar(rg, blip, flying, sc, ax, az); } catch (e) {}
  if (window.CityCampus) try { CityCampus.radar(rg, blip, flying, sc, ax, az); } catch (e) {}
  if (window.CityBook) try { CityBook.radar(rg, blip, flying, sc, ax, az); } catch (e) {}
  if (window.CityPodium) try { CityPodium.radar(rg, blip, flying, sc, ax, az); } catch (e) {}
  // you
  rg.translate(W / 2, H / 2); rg.rotate(-heading); rg.fillStyle = '#fff'; rg.beginPath(); rg.moveTo(0, -11); rg.lineTo(7, 8); rg.lineTo(0, 4); rg.lineTo(-7, 8); rg.closePath(); rg.fill();
  rg.restore();
  rg.strokeStyle = 'rgba(232,195,106,.5)'; rg.lineWidth = 2; rg.beginPath(); rg.arc(W / 2, H / 2, W / 4, 0, Math.PI * 2); rg.stroke();
  rg.fillStyle = '#e8c36a'; rg.font = 'bold 16px system-ui'; rg.fillText('N', W / 2 - 6, 20);
  rg.font = '13px system-ui'; rg.fillText((rad / 1000).toFixed(rad < 2000 ? 1 : 0) + ' km', W / 2 - 18, H - 10);
}
var hudT = 0;
function whereName(x, z) {
  var best = null, bd = 1e9; [D.plaza, D.studio, D.port, D.soul, D.strike].forEach(function (d) { var dd = Math.hypot(x - d.x, z - d.z); if (dd < bd) { bd = dd; best = d; } });
  if (bd < 160) return best.name; if (window.CampusMap) { var cn = CampusMap.nameAt(x, z); if (cn) return cn; } if (Math.hypot(x, z) < 820) return 'SOLID CITY';
  for (var k = 0; k < VOLCANOES.length; k++) { var V = VOLCANOES[k]; if (V.name && Math.hypot(x - V.x, z - V.z) < V.r * 0.45) return V.name; }
  return landMask(x, z) > 0 ? 'THE ISLANDS' : 'OPEN OCEAN';
}
function updateHUD(dt) {
  hudT -= dt; if (hudT > 0) return; hudT = 0.12;
  var flying = S.mode !== 'walk', x = flying ? S.ship.x : S.p.x, z = flying ? S.ship.z : S.p.z, y = flying ? S.ship.y : S.p.y;
  var spd = flying ? S.ship.speed : (Math.abs(input.sx) + Math.abs(input.sy) > 0.08 || input.keys.KeyW || input.keys.KeyS || input.keys.KeyA || input.keys.KeyD ? 8 : 0);
  var alt = flying ? y - Math.max(0, groundAt(x, z)) : y;
  $('h-mode').textContent = { walk: 'ON FOOT', boarded: 'SHIP · ON PAD', countdown: 'COUNTDOWN', launch: 'LAUNCH', fly: y > 25000 ? 'ORBIT' : y > 12