/* HUD layout regions (js/hudlayout.js owns the whole screen). One visual language: cream paper, 2px ink rule, hard shadow,
   radii 12px (cards) / 999px (chips) / 10px (buttons), type 15/13/12 with 10px tracked kickers. */
:root { --hl-gap: 8px; --hl-edge: 16px; --hl-r-card: var(--radius); --hl-r-btn: var(--radius); }

/* ───────────── identity (top-left) + status rail ───────────── */
body.hl-on #hud-left { gap: var(--hl-gap); }
#stats { pointer-events: auto; transition: opacity .25s ease; }
#stats.hl-compact { width: max-content; max-width: 100%; display: flex; align-items: stretch; border-radius: var(--hl-r-card); cursor: default; }
#stats.hl-compact #startup-chip { display: grid; grid-template-columns: 24px; gap: 0; padding: 5px 7px; border-bottom: 0; border-right: 2px solid var(--line-soft); align-items: center; }
#stats.hl-compact #startup-chip canvas { width: 24px; height: 24px; }
#stats.hl-compact #startup-chip span { display: none; }
#stats.hl-compact .stat-row { display: flex; min-width: 0; }
#stats.hl-compact .stat { display: flex; align-items: baseline; gap: 5px; padding: 5px 10px 4px; }
#stats.hl-compact .stat label { display: none; }
#stats.hl-compact .stat b { font-size: 17px; line-height: 24px; }
#stats.hl-compact #stat-box-clout b::after { content: ' followers'; font-size: 11px; font-weight: 700; letter-spacing: 0; color: var(--text-dim); }
#stats.hl-compact .stat.rank { display: none; }
#stats.hl-compact { max-width: calc(100vw - 32px); } #stats.hl-compact .stat b[data-long] { font-size: 15px; } #stats.hl-compact #stat-box-clout b[data-long='xl']::after { content: ''; } /* very long figures: smaller type, and the word gives way before the number does */
#stats.hl-compact #floaters { top: 2px; }

#hl-ticker { width: 100%; height: 0; position: relative; pointer-events: none; }
#hl-ticker:has(#wx-ticker:not(.hl-idle):not([hidden])) { height: 26px; }
#hl-ticker > #wx-ticker { position: absolute; left: 0; top: 0; height: 26px !important; min-height: 0 !important; width: max-content; max-width: min(420px, calc(50vw - 216px)); border-radius: 999px !important; pointer-events: auto; font-size: 12px; box-shadow: 2px 2px 0 rgba(10, 4, 14, .35); animation: hl-in .3s var(--ease-out) both; }
#hl-ticker > #wx-ticker .wx-tk-ic { width: 26px !important; height: 26px !important; }
#hl-ticker > #wx-ticker .wx-tk-tx { max-width: none; flex: 1 1 auto; white-space: nowrap !important; display: block !important; font-size: 12px !important; line-height: 26px; }
#hl-ticker > #wx-ticker .wx-tk-tag { display: none; }
#hl-ticker > #wx-ticker .wx-tk-x { width: 26px !important; height: 26px !important; }

#hl-rail { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--hl-gap); width: 100%; pointer-events: none; }
#hl-rail:empty, #hl-rail:not(:has(> .hl-w:not([hidden]))) { display: none; }
#hl-rail > .hl-w { position: relative !important; inset: auto !important; top: auto !important; left: auto !important; margin: 0 !important; transform: none; flex: 0 0 100%; width: 100% !important; max-width: 100% !important; pointer-events: auto; }
#hl-rail > .hl-w[hidden] { display: none !important; }
#hl-rail > #objective { pointer-events: none; }
#hl-rail > .hl-collapsed { order: 2; flex: none; width: 40px !important; height: 40px !important; min-height: 0 !important; padding: 0 !important; display: grid !important; place-items: center; overflow: visible; background: var(--panel) !important; color: var(--paper-text); border: 2px solid var(--line) !important; border-radius: var(--hl-r-card) !important; box-shadow: var(--shadow) !important; cursor: pointer; pointer-events: auto !important; animation: none !important; -webkit-line-clamp: unset !important; font-size: 0 !important; line-height: 0 !important; }
#hl-rail > .hl-collapsed > * { display: none !important; }
#hl-rail > .hl-collapsed::before { content: attr(data-hl-icon) !important; display: block !important; position: static !important; font: 800 18px/1 var(--font) !important; letter-spacing: 0 !important; color: var(--paper-text) !important; text-transform: none !important; width: auto; height: auto; background: none; border: 0; }
#hl-rail > .hl-collapsed::after { content: attr(data-hl-badge); position: absolute; right: -6px; top: -6px; min-width: 18px; height: 18px; padding: 0 4px; font: 800 11px/15px var(--font); text-align: center; color: var(--on-gold); background: var(--flame); border: 1.5px solid var(--ink); border-radius: 999px; }
#hl-rail > .hl-collapsed:not([data-hl-badge])::after, #hl-rail > .hl-collapsed[data-hl-badge='']::after { display: none; }
#hl-rail > .hl-collapsed:focus-visible, #btn-more:focus-visible, #hl-more-menu button:focus-visible, #stats:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
#hl-rail > #objective.hl-collapsed { border-left-width: 2px !important; }
#hl-rail > #gym-card { z-index: auto; }
.hl-idle { display: none !important; }
.hl-wait { display: none !important; }
body.hl-on #wx-hud { gap: var(--hl-gap); }
body.hl-on #wx-hud:not(:has(> :not(.hl-idle):not([hidden]))) { display: none; }
/* cringe quote-posts sit under whatever the left column currently holds */
body.hl-on #cr-feed { top: max(46%, calc(var(--hl-left-b, 0px) + 12px)); }

/* ───────────── moment (top-centre): one card ───────────── */
#hl-moment { position: absolute; top: calc(var(--hl-edge) + var(--safe-t)); left: 50%; transform: translateX(-50%); width: min(380px, calc(100vw - 600px)); min-width: 260px; display: flex; flex-direction: column; align-items: center; gap: var(--hl-gap); pointer-events: none; z-index: 3; }
#hl-moment > .hl-w { position: static !important; inset: auto !important; transform: none !important; translate: none !important; margin: 0 !important; max-width: 100% !important; min-width: 0 !important; z-index: auto !important; }
#hl-moment > #wx-notes, #hl-moment > #phone-push { width: 100% !important; }
#hl-moment > #wx-notes > :nth-child(n+2), #hl-moment > #phone-push > :nth-child(n+2) { display: none; }
#hl-moment > #phone-push .ph-note { animation-name: hl-in; }
#hl-moment > #phone-push .ph-note.out { transform: translateY(-8px) !important; }
#hl-moment > #wx-todaycard { width: 100% !important; max-height: min(520px, calc(100dvh - 200px)); overflow-y: auto; }
#hl-moment > #hud-top { display: flex; flex-direction: column; align-items: center; gap: var(--hl-gap); width: 100%; }
#hl-moment > #transit-strip { width: max-content; }
#hl-moment > #hud-top > * { max-width: 100% !important; }
#hud.dialog-open #hl-moment, body.cine #hl-moment, body.phone-open #hl-moment { visibility: hidden; }
#wx-todaychip { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px 0 9px; background: var(--panel); color: var(--paper-text); border: 2px solid var(--line); border-radius: 999px; box-shadow: var(--shadow); font: 700 13px/1 var(--font); cursor: pointer; pointer-events: auto; animation: hl-in .35s var(--ease-out) both; }
#wx-todaychip b { font-weight: 800; } #wx-todaychip em { font-style: normal; color: var(--text-dim); font-weight: 600; }
#wx-todaychip kbd { margin-left: 2px; }
#wx-todaychip.out { opacity: 0; transition: opacity .25s; }
@keyframes hl-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ───────────── nav (top-right): minimap + clock in its frame + one waypoint chip ───────────── */
#minimap > #dn-chip { position: absolute !important; left: 0 !important; right: 0 !important; bottom: 0 !important; top: auto !important; z-index: 5; display: flex !important; flex-direction: row !important; align-items: center; justify-content: center; gap: 6px; height: 20px; min-width: 0; margin: 0; padding: 0 6px !important; background: var(--plum) !important; color: var(--paper-text) !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important; }
#minimap > #dn-chip b { font-size: 11.5px !important; gap: 4px; color: inherit; }
#minimap > #dn-chip b::before { width: 7px !important; height: 7px !important; border-color: var(--paper) !important; }
#minimap > #dn-chip small { font-size: 8.5px !important; letter-spacing: .08em; opacity: .8; color: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#waypoint { pointer-events: auto; cursor: pointer; }
#waypoint[data-hl-more]::after, #wx-chip[data-hl-more]::after { content: attr(data-hl-more); flex: none; font: 800 11px/1 var(--font); opacity: .65; }
body.hl-on #wx-chip { margin-top: 0; }
body.hl-on #wx-chip em { display: none; }
/* multiplayer: room badge + leaderboard hang under the nav column instead of sitting on the minimap */
body.hl-on:not(.touch) #net-panel { top: calc(var(--hl-nav-b, 210px) + 10px); }
body.hl-on:not(.touch) #net-board ol { max-height: min(40vh, 300px); }

/* ───────────── action (bottom-centre) ───────────── */
body.hl-on #hud-bottom { bottom: calc(16px + var(--safe-b) + var(--hl-lift, 0px)); }
body.hl-on #dock { bottom: calc(44px + var(--safe-b) + var(--hl-lift, 0px)); }
#toasts > .toast:nth-last-child(n+3) { display: none; }
body.hl-lifted #hotbar { display: none !important; } /* a bottom bar (build mode, workout pad) owns the action row */
body.hl-on:not(.touch) #hud-bottom { width: min(600px, calc(100vw - 2 * (var(--hl-dock-w, 330px) + 28px))); min-width: 280px; }
body.hl-on:not(.touch) .toast { border-radius: var(--radius); }

/* ───────────── dock (bottom-right): Phone · Waymo · More ───────────── */
#btn-more svg { flex: none; }
body.hl-on #dock-buttons > #btn-phone { order: 1; } body.hl-on #dock-buttons > #btn-hail { order: 2; } body.hl-on #dock-buttons > #btn-chat { order: 3; } body.hl-on #dock-buttons > #btn-more { order: 4; }
body.hl-on:not(.touch) #dock-buttons > #btn-phone { order: 5; }
#hl-more-menu { pointer-events: auto; display: flex; flex-direction: column; gap: 6px; min-width: 190px; padding: 8px; background: var(--panel); border: 2px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); animation: toast-in .2s var(--ease-out) both; color: var(--paper-text); }
#hl-more-items, #hl-more-set { display: flex; flex-direction: column; gap: 6px; }
#hl-more-items:empty { display: none; }
#hl-more-set { padding-top: 6px; border-top: 1.5px dashed var(--line-soft); }
#dock #hl-more-menu button { width: 100% !important; height: auto !important; min-height: 38px; padding: 0 10px !important; justify-content: flex-start !important; gap: 8px; box-shadow: none; border-radius: var(--hl-r-btn) !important; font-size: 13px !important; background: var(--panel-2); color: var(--paper-text); text-align: left; }
#dock #hl-more-menu button:active { transform: translate(1px, 1px); }
#dock #hl-more-menu button > span { display: inline !important; flex: 1 1 auto; }
#dock #hl-more-menu button > kbd { margin-left: auto; flex: none; }
#dock #hl-more-menu button > svg { display: block !important; flex: none; }
#dock #hl-more-menu #btn-build { display: none !important; }
#dock #hl-more-menu #btn-hail { color: var(--mint); }
#dock #hl-more-menu [hidden] { display: none !important; }
#hl-more-set button { background: var(--panel-2) !important; color: var(--paper-text); }
body.touch #dock #hl-more-menu button { min-height: 46px; font-size: 14px !important; }
body.touch #dock #hl-more-menu #btn-help { display: none !important; }
body.touch #btn-more span { display: none; }
body:not(.touch) #btn-more svg { display: none; }
/* dock gives way to the hotbar (hudlayout.fitDock): level 2 = icon buttons */
body[data-hl-dock='2']:not(.touch) #dock-buttons > button > span, body[data-hl-dock='2']:not(.touch) #dock-buttons > button > kbd { display: none; }
body[data-hl-dock='2']:not(.touch) #btn-more svg { display: block; }
body[data-hl-dock='2']:not(.touch) #dock-buttons > button { width: 38px; padding: 0; justify-content: center; }
/* anything a late module drops into the dock is filed under More; until that happens it must not sit on the hotbar */
body.hl-on #dock-buttons > button:not(#btn-phone):not(#btn-hail):not(#btn-chat):not(#btn-more) { display: none !important; }
body.co-building #btn-more, body.co-building #btn-hail { display: none !important; }

/* ───────────── HUD modes ───────────── */
body[data-hud='minimal'] #hotbar .slot.empty { display: none; }
body[data-hud='minimal'] #minimap > #dn-chip small { display: none; }
body[data-hud='minimal'] #net-board { display: none; }
body[data-hud='minimal'] #net-ui.board-open #net-board, body[data-hud='minimal'] #net-ui.board-show #net-board { display: block; }

/* ───────────── dev overlay (?hudDebug=1) ───────────── */
#hl-debug { position: fixed; inset: 0; z-index: 200; pointer-events: none; }
#hl-debug i { position: absolute; outline: 1.5px dashed var(--mint); outline-offset: -1px; }
#hl-debug i.bad { outline: 2.5px solid var(--rose); background: rgba(255, 45, 85, .18); }
#hl-debug b { position: absolute; left: 0; top: 0; padding: 0 3px; font: 700 9px/11px ui-monospace, monospace; color: var(--on-gold); background: var(--mint); white-space: nowrap; }
#hl-debug i.bad b { background: #ff2d55; }

/* ───────────── narrow desktop windows ───────────── */
@media (max-width: 1100px) { body.hl-on:not(.touch) #btn-hail kbd, body.hl-on:not(.touch) #btn-phone kbd { display: none; } }
@media (max-width: 900px) { #hl-moment { width: min(320px, calc(100vw - 440px)); min-width: 220px; } }

/* ───────────── phones: portrait ───────────── */
@media (max-width: 760px) and (orientation: portrait) {
  body.hl-on #hud-left { top: calc(8px + var(--safe-t)); left: calc(8px + var(--safe-l)); width: calc(100vw - 132px - var(--safe-l) - var(--safe-r)); max-width: 260px; gap: 6px; }
  #hl-rail { gap: 6px; }
  #hl-rail > .hl-w:not(.hl-collapsed) { max-width: min(214px, calc(100vw - 170px - var(--safe-l) - var(--safe-r))) !important; }
  body.hl-on #dock { top: calc(var(--hl-nav-b, 150px) + 8px); right: calc(8px + var(--safe-r)); bottom: auto; flex-direction: column-reverse; align-items: flex-end; }
  body.hl-on #dock-buttons { flex-direction: column; gap: 8px; }
  #hl-moment { top: calc(var(--hl-top-b, 150px) + 8px); left: calc(8px + var(--safe-l)); right: calc(62px + var(--safe-r)); width: auto; min-width: 0; transform: none; align-items: stretch; }
  #hl-moment > #hud-top { align-items: center; }
  body.touch #hl-moment > #toasts { position: static !important; width: 100%; max-width: none; align-items: center; }
  body.touch #hl-moment > #hud-top { max-width: 100% !important; }
  body.hl-on #cr-feed { left: calc(8px + var(--safe-l)); top: calc(var(--hl-moment-b, 240px) + 8px); width: min(240px, calc(100vw - 150px)); }
  body.hl-on #cr-feed .qp:nth-child(n+2) { display: none; }
  body.hl-on.touch #net-panel { top: auto; bottom: calc(150px + var(--safe-b)); left: auto; right: calc(8px + var(--safe-r)); align-items: flex-end; flex-direction: column-reverse; }
  #hl-more-menu { max-height: calc(100dvh - var(--hl-nav-b, 150px) - 120px); overflow-y: auto; }
  body.hl-on.touch #net-chat { bottom: calc(204px + var(--safe-b)); }
}
/* ───────────── phones: landscape ───────────── */
@media (max-height: 520px) and (orientation: landscape) {
  body.hl-on.touch #hud-left { width: 230px; }
  #hl-rail > .hl-w:not(.hl-collapsed) { max-width: 214px !important; }
  body.touch #hl-moment { top: calc(8px + var(--safe-t)); width: min(290px, calc(100vw - 560px)); min-width: 220px; }
  body.touch #hl-moment > #toasts { position: static !important; translate: none !important; width: 100%; max-width: none; align-items: center; }
  body.touch #hl-moment > #hud-top { flex-direction: row; justify-content: center; max-width: 100% !important; }
  body.hl-on.touch #dock { top: calc(8px + var(--safe-t)); right: calc(116px + var(--safe-r)); bottom: auto; flex-direction: column-reverse; align-items: flex-end; }
  body.hl-on #cr-feed { left: 50%; top: calc(var(--hl-moment-b, 90px) + 8px); }
  body.hl-on.touch #net-panel { top: calc(var(--hl-left-b, 100px) + 8px); }
  #hl-more-menu { max-height: calc(100dvh - 76px); overflow-y: auto; }
  body.hl-lifted.touch #touch-buttons { bottom: calc(var(--hl-lift, 0px) + 8px); }
}
/* touch: the (folded) map attribution sits above the hotbar row, not under slot 1 */
@media (orientation: portrait) { body.hl-on.touch #map .maplibregl-ctrl-bottom-right { bottom: calc(66px + var(--safe-b)); } }
/* ride provider chooser (rides.js, fixed to the body): the action pill never sits on it */
body:has(#ride-choose) #touch-buttons { visibility: hidden; }
body.touch:has(#ride-choose) #ride-hud { display: none !important; } /* the chooser has its own cancel: one decision surface */
/* touch: 44px targets everywhere */
body.touch .cr-dots button { min-height: 44px; min-width: 44px; justify-content: center; } /* creator wizard steps (css/creator.css sizes them 32x30) */
@media (pointer: coarse) { .cr-dots button { min-height: 44px; min-width: 44px; justify-content: center; } }
body.touch .cr-seg button, body.touch .cr-ico, body.touch .cr-skip { min-height: 44px; min-width: 44px; }
body.touch #cine-skip { top: calc(var(--safe-t, 0px) + 6px); gap: 6px; z-index: 5; }
body.touch #cine-skip-btn { height: 44px; min-width: 88px; padding: 0 16px; font-size: 13px; background: rgba(23, 22, 28, .72); touch-action: manipulation; }
body.touch #cine-always { min-height: 44px; display: inline-flex; align-items: center; gap: 6px; padding: 0 8px; }
body.touch #cine-always input { width: 22px; height: 22px; }
body.touch #hl-rail > .hl-collapsed { width: 44px !important; height: 44px !important; }
body.touch #wx-todaychip { height: 44px; padding: 0 14px 0 11px; }
body.touch #wx-todaychip kbd { display: none; }
body.touch #minimap > #dn-chip { height: 22px; gap: 3px; padding: 0 3px !important; }
body.touch #minimap > #dn-chip b { font-size: 12px !important; }
body.touch #minimap > #dn-chip small { font-size: 12px !important; letter-spacing: 0; text-transform: capitalize; font-weight: 700; }
body.touch #waypoint[data-hl-more]::after, body.touch #wx-chip[data-hl-more]::after { font-size: 12px; }
body.touch #waypoint { font-size: 13px; }
body.hl-on.touch #net-invite { min-height: 44px; }
body.hl-on.touch .rh-btns button, body.hl-on.touch #act-chip button { min-height: 44px; }
body.hl-on.touch #wx-col-chip, body.hl-on.touch #wx-ach-chip { height: 44px; font-size: 13px; }
body.hl-on.touch #cringe .cr-sorry { height: 44px; padding: 0 12px; font-size: 13px; }
body.hl-on.touch #stats.hl-compact #floaters { left: 0; right: auto; top: calc(100% + 4px); bottom: auto; align-items: flex-start; z-index: 6; }
body.touch .wx-note small, body.touch #cringe .cr-title, body.touch #cringe .cr-status { font-size: 12px; letter-spacing: .05em; }
body.touch .slot .key, body.touch .slot kbd { font-size: 12px; min-width: 20px; height: 20px; line-height: 17px; }
body.touch #meter span { font-size: 12px; }
body.touch #waypoint { min-height: 30px; position: relative; }
body.touch #waypoint::before { content: ''; position: absolute; inset: -8px -4px; }
body.touch #stats.hl-compact .stat b { font-size: 16px; }
body.touch #stats.hl-compact .stat { padding: 5px 8px 4px; }
body.touch #stats.hl-compact #stat-box-clout b::after { font-size: 12px; }

@media (prefers-reduced-motion: reduce) { #wx-todaychip, #hl-more-menu, #hl-ticker > #wx-ticker { animation: none !important; } #stats { transition: none; } }
