/* ───────────────────────────────────────────────────────────────────────────
   Cook & Run — HUD (ui/hud.js), Round 3 "dark glass".
   Reference: docs/r3/ui/{Driver-HUD,Driver-Defend,Cook-Lab,Cook-Shop,End,HUD-Kit}.png and their
   src/*.html (values copied from there). Tokens: css/tokens.css (imported below so every harness
   that only links hud.css still gets them; index.html should link fonts.css + tokens.css first).
   Rules: 16 px margins, 8 px grid, panels in a row share one height, 1 px hairlines, no bounce,
   no tilt; fades/slides ≤ 8 px over 120–200 ms. Per-frame writes are transforms / text only.
   ─────────────────────────────────────────────────────────────────────────── */
@import url("fonts.css");
@import url("tokens.css");

.crh {
  --m: var(--g-margin, 16px);
  --vig: 0;
  position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 5;
  font-family: var(--g-font); color: var(--g-text-1); line-height: 1;
  user-select: none; -webkit-user-select: none; -webkit-font-smoothing: antialiased;
}
.crh *, .crh *::before, .crh *::after { box-sizing: border-box; }
.crh svg { display: block; }
:where(.crh) i { font-style: normal; }
:where(.crh) b { font-weight: inherit; }   /* zero specificity: .g-num / component weights win */
.crh .g-label, .crh .g-num { white-space: nowrap; }
.crh .g-panel { color: var(--g-text-1); }

/* danger vignette (bust filling / cop at the RV) — static, opacity only */
.crh-vig { position: absolute; inset: 0; opacity: var(--vig); transition: opacity .3s linear;
  background: radial-gradient(ellipse 75% 70% at 50% 45%, rgba(120, 18, 14, 0) 55%, rgba(120, 18, 14, .42) 100%); }

/* shared slim meter (Wanted slider, health bars, banner progress) */
.crh-meter { position: relative; display: block; flex: 1 1 auto; min-width: 0; height: 5px; border-radius: 3px; background: var(--g-track); overflow: hidden; }
.crh-meter > i, .crh-meter > em { position: absolute; inset: 0; border-radius: 3px; transform-origin: 0 50%; transform: scaleX(0); }
.crh-meter > i { background: var(--g-amber); transition: transform var(--g-fast) linear; }

/* ── top-left: Wanted ────────────────────────────────────────────────────── */
.crh-heat { position: absolute; left: var(--m); top: var(--m); width: var(--g-side); height: var(--g-row-top); padding: 10px 12px 0; }
.crh-heat-h { display: flex; align-items: center; justify-content: space-between; height: 12px; }
.crh-heat-s { display: inline-flex; align-items: center; gap: 5px; font-stretch: 75%; font-weight: 750; font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--g-text-2); white-space: nowrap; }
.crh-heat-s i, .crh-heat-s svg { width: 12px; height: 12px; flex: none; }
.crh-heat-s svg { stroke-width: 2.2; }
.crh-heat-r { display: flex; align-items: center; gap: 10px; height: 14px; margin-top: 10px; }
.crh-stars { display: flex; gap: 2px; flex: none; }
.crh-star { display: block; width: 14px; height: 14px; flex: none; }
.crh-star svg { width: 100%; height: 100%; }
.crh-star path { fill: none; stroke: var(--g-star-off); stroke-width: 1.8; stroke-linejoin: round; }
.crh-star.on path { fill: var(--g-amber); stroke: var(--g-amber); }
.crh-heat-v { min-width: 28px; text-align: right; font-size: 12px; font-weight: 700; color: var(--g-text-1); }
.crh-heat.st-seen .crh-heat-s { color: var(--g-amber); }
.crh-heat.st-cool .crh-heat-s { color: var(--g-blue-text); }
.crh-heat.st-cool .crh-heat-s svg { stroke: var(--g-blue); }
.crh-heat.st-cool .crh-meter i { background: var(--g-blue); }
.crh-heat.st-max .crh-heat-s, .crh-heat.st-max .crh-heat-v { color: var(--g-red-text); }
.crh-heat.st-max .crh-heat-s svg { stroke: var(--g-red); }
.crh-heat.st-max .crh-meter i { background: var(--g-red); }
.crh-heat.st-shots .crh-heat-s { color: var(--g-rust-text); }
.crh-heat.st-shots .crh-heat-s svg { stroke: var(--g-rust); }
.crh-heat.st-shots .crh-meter i { background: var(--g-rust); }
.crh-heat.st-gave .crh-heat-s { color: var(--g-green-text); }
.crh-heat.st-gave .crh-meter i { background: var(--g-text-3); }

/* ── top-centre: route strip (600 px; pins stand on the road at their real km) ── */
.crh-prog { position: absolute; left: 50%; top: var(--m); translate: -50% 0; height: var(--g-row-top);
  width: min(var(--g-strip), calc(100% - 4 * var(--m) - 2 * var(--g-side))); }
.crh-prog > * { position: absolute; left: 0; top: 0; display: block; }
.crh-rd { left: 16px; right: 28px; top: 28.5px; height: 3px; border-radius: 2px; background: rgba(241, 236, 228, .22); }
.crh-prog > .crh-rd-fill { left: 16px; top: 28.5px; height: 3px; border-radius: 2px; background: var(--g-amber); transform-origin: 0 50%; transform: scaleX(0); transition: transform var(--g-fast) linear; }
.crh-tick { top: 33px; width: 1px; height: 4px; background: rgba(241, 236, 228, .32); }
.crh-brg { top: 21px; width: 14px; height: 8px; }
.crh-flag { top: 11px; width: 14px; height: 20px; }
.crh-brg svg, .crh-flag svg { width: 100%; height: 100%; }
.crh-pin { top: 5px; width: 18px; height: 24px; }
.crh-pin svg { width: 18px; height: 24px; overflow: visible; }
.crh-pin .pb { fill: rgba(14, 15, 17, .92); stroke: rgba(241, 236, 228, .72); stroke-width: 1.1; }
.crh-pin text { font-family: var(--g-font); font-stretch: 85%; font-weight: 700; font-size: 9px; fill: var(--g-text-1); }
.crh-pin .pt, .crh-pin .px { display: none; fill: none; stroke: #0E0F11; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.crh-pin.next .pb { fill: var(--g-amber); stroke: #0E0F11; stroke-width: .8; }
.crh-pin.next text { font-weight: 800; font-size: 9.5px; fill: var(--g-ink); }
.crh-pin.done .pb, .crh-pin.miss .pb { fill: rgba(241, 236, 228, .34); stroke: none; }
.crh-pin.done text, .crh-pin.miss text { display: none; }
.crh-pin.done .pt, .crh-pin.miss .px { display: inline; }
.crh-pin.miss .pb { fill: rgba(241, 236, 228, .22); }
.crh-rvm { top: 24px; width: 22px; height: 12px; transition: transform var(--g-fast) linear; z-index: 1; }
.crh-rvm svg { width: 22px; height: 12px; }
.crh-nd { top: 9px; font-size: 11px; font-weight: 750; color: var(--g-amber); }
.crh-al { top: 39px; white-space: nowrap; line-height: 1; transition: transform var(--g-fast) linear; }
.crh-al .g-label { color: var(--g-text-1); }
.crh-al-km { font-size: 10px; font-weight: 600; color: var(--g-text-2); }
.crh-prog > .crh-diff { left: auto; right: 12px; top: 37px; display: flex; align-items: center; gap: 4px; }
.crh-diff-f { display: flex; }
.crh-diff-f i, .crh-diff-f svg { width: 10px; height: 10px; }
.crh-diff .g-label { font-size: 8.5px; }

/* ── top-right: bags · score · Q ─────────────────────────────────────────── */
.crh-run { position: absolute; right: var(--m); top: var(--m); width: var(--g-side); height: var(--g-row-top); padding: 10px 12px 0; display: flex; align-items: stretch; gap: 12px; }
.crh-bags { width: 78px; flex: none; }
.crh-bags-v { display: flex; align-items: baseline; gap: 2px; margin-top: 6px; }
.crh-bags-v i { width: 14px; height: 14px; flex: none; align-self: center; margin-right: 4px; }
.crh-bags-v i svg { width: 14px; height: 14px; }
.crh-bags-v b { font-size: 19px; }
.crh-bags-v span { font-size: 13px; font-weight: 600; color: var(--g-text-2); }
.crh-run.ok .crh-bags-v i { color: var(--g-green); }
.crh-vr { flex: none; width: 1px; height: 34px; margin-top: 1px; background: var(--g-line-2); }
.crh-score { flex: 1 1 auto; min-width: 0; }
.crh-score-h { display: flex; align-items: center; justify-content: space-between; }
.crh-q { font-stretch: 75%; font-weight: 750; font-size: 9px; letter-spacing: .08em; text-transform: uppercase; color: var(--g-green-text); white-space: nowrap; }
.crh-score > b { display: block; margin-top: 6px; font-size: 19px; overflow: hidden; text-overflow: ellipsis; }

/* ── centre line under the strip: next stop / pull in / missed / bridge / loading / alerts ── */
.crh-line { position: absolute; left: 50%; top: calc(var(--m) + var(--g-row-top) + 8px); translate: -50% -4px; opacity: 0;
  width: min(var(--g-strip), calc(100% - 4 * var(--m) - 2 * var(--g-side))); display: flex; justify-content: center;
  transition: opacity var(--g-slow) var(--g-ease), translate var(--g-slow) var(--g-ease); }
.crh-line.on { opacity: 1; translate: -50% 0; }
.crh-ban { position: relative; display: inline-flex; align-items: center; gap: 8px; height: 28px; padding: 0 10px; border-radius: var(--g-radius-sm); white-space: nowrap; max-width: 100%; }
.crh-ban-i { width: 14px; height: 14px; flex: none; color: var(--g-amber); }
.crh-ban-i svg { width: 100%; height: 100%; }
.crh-ban.flip .crh-ban-i svg { transform: scaleX(-1); }
.crh-ban-n { font-weight: 650; font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.crh-ban-s { font-weight: 500; font-size: 12px; color: var(--g-text-2); flex: none; }
.crh-ban-bar.crh-meter { display: none; width: 64px; flex: none; }
.crh-ban-v { display: none; font-size: 12px; font-weight: 700; }
.crh-ban.has-bar .crh-ban-bar, .crh-ban.has-bar .crh-ban-v { display: block; }
.crh-ban.tone-good .crh-ban-i { color: var(--g-green); }
.crh-ban.tone-good .crh-ban-l { color: var(--g-green-text); }
.crh-ban.tone-warn { border-color: rgba(242, 185, 15, .55); }
.crh-ban.tone-warn .crh-ban-l { color: var(--g-amber); }
.crh-ban.tone-alert { border-color: rgba(229, 72, 58, .75); }
.crh-ban.tone-alert .crh-ban-i { width: 15px; height: 15px; color: var(--g-red); }
.crh-ban.tone-alert .crh-ban-n { font-weight: 700; }
.crh-ban.tone-alert .crh-ban-bar i { background: var(--g-red); }
.crh-ban.tone-miss { border-color: rgba(229, 72, 58, .5); }
.crh-ban.tone-miss .crh-ban-i { color: var(--g-red); }
.crh-ban.tone-miss .crh-ban-l { color: var(--g-red-text); }

/* ── right column: the other player's chip, cops inbound, toasts ─────────── */
.crh-side { position: absolute; right: var(--m); top: calc(var(--m) + var(--g-row-top) + 8px); display: flex; flex-direction: column; align-items: flex-end; gap: 6px; max-width: calc(50% - var(--g-strip) / 2 + var(--g-side)); }
.crh-tags { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; max-width: 100%; }
.crh-tag { position: relative; display: inline-flex; align-items: center; gap: 8px; height: 28px; padding: 0 10px; border-radius: var(--g-radius-sm); white-space: nowrap; overflow: hidden; max-width: 100%; }
.crh-tag-i { width: 14px; height: 14px; flex: none; color: var(--g-teal); }
.crh-tag-i svg { width: 100%; height: 100%; }
.crh-tag-l { font-stretch: 75%; font-weight: 750; font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--g-teal-text); }
.crh-tag-n { font-weight: 600; font-size: 12px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.crh-tag-s { font-weight: 500; font-size: 12px; color: var(--g-text-2); flex: none; }
.crh-tag-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; display: none; }
.crh-tag-bar i { position: absolute; inset: 0; background: var(--g-teal); transform-origin: 0 50%; transform: scaleX(0); transition: transform var(--g-fast) linear; }
.crh-tag.has-bar .crh-tag-bar { display: block; }
.crh-tag.who-rook .crh-tag-i { color: var(--g-rust); }
.crh-tag.who-rook .crh-tag-l { color: var(--g-rust-text); }
.crh-tag.who-rook .crh-tag-bar i { background: var(--g-rust); }
.crh-tag.tone-bad { border-color: rgba(229, 72, 58, .75); }
.crh-tag.tone-bad .crh-tag-i { color: var(--g-red); }
.crh-tag.tone-bad .crh-tag-bar i { background: var(--g-red); }
.crh-tag--cops .crh-tag-i { color: var(--g-blue); }
.crh-tag--cops .crh-tag-l { color: var(--g-blue-text); }

.crh-toasts { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; max-width: 100%; }
.crh-toasts--b { position: absolute; left: 50%; bottom: var(--m); translate: -50% 0; align-items: center; width: min(560px, 100% - 2 * var(--m)); }
.crh-toast { position: relative; display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 11px; border-radius: var(--g-radius-sm); white-space: nowrap;
  max-width: min(460px, 100%); animation: crhToastIn var(--g-slow) var(--g-ease) both; transition: opacity var(--g-slow) var(--g-ease), translate var(--g-slow) var(--g-ease); }
.crh-toast i { width: 14px; height: 14px; flex: none; color: var(--g-amber); }
.crh-toast i svg { width: 100%; height: 100%; }
.crh-toast b { font-weight: 650; font-size: 12.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.crh-toast .s { font-weight: 500; font-size: 11.5px; color: var(--g-text-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.crh-toast .v { font-size: 13px; font-weight: 750; color: var(--g-amber); flex: none; }
.crh-toast.tone-good i { color: var(--g-green); }
.crh-toast.tone-good .v { color: var(--g-green-text); }
.crh-toast.tone-bad i { color: var(--g-red); }
.crh-toast.tone-bad .v { color: var(--g-red-text); }
.crh-toast.tone-heat i { color: var(--g-rust); }
.crh-toast.tone-heat .v { color: var(--g-rust-text); }
.crh-toast.tone-cops i { color: var(--g-blue); }
.crh-toast.tone-cops .v { color: var(--g-blue-text); }
.crh-toast.out { opacity: 0; translate: 0 -6px; }
@keyframes crhToastIn { from { opacity: 0; translate: 6px 0; } }
.crh-toasts--b .crh-toast { animation-name: crhToastUp; }
@keyframes crhToastUp { from { opacity: 0; translate: 0 6px; } }

/* ── bottom-left: RV hull · Rook · Doc ───────────────────────────────────── */
.crh-hp { position: absolute; left: var(--m); bottom: var(--m); width: var(--g-side); height: var(--g-row-bottom); padding: 7px 12px; display: flex; flex-direction: column; gap: 5px; }
.crh-bar { display: flex; align-items: center; gap: 8px; height: 14px; }
.crh-bar .g-label { width: 50px; flex: none; }
.crh-bar .crh-meter > em { background: rgba(255, 255, 255, .34); transition: transform .5s ease-out .35s; }
.crh-bar--rv .crh-meter > i { background: var(--g-hull); }
.crh-bar--rook .crh-meter > i { background: var(--g-rust); }
.crh-bar--doc .crh-meter > i { background: var(--g-teal); }
.crh-bar > b { width: 24px; flex: none; text-align: right; font-size: 12px; font-weight: 700; }
.crh-bar.low .crh-meter > i { background: var(--g-red); }
.crh-bar.low > b { color: var(--g-red-text); }
.crh-heal { display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; flex: none; border-radius: 50%; background: rgba(91, 191, 106, .22); color: var(--g-green); visibility: hidden; }
.crh-heal svg { width: 10px; height: 10px; }
.crh-bar.regen .crh-heal { visibility: visible; animation: crhPulse 1.2s ease-in-out infinite; }
@keyframes crhPulse { 50% { opacity: .4; } }

/* ── bottom-right: gadget keycaps (keycap top-left · count top-right) ────── */
.crh-gad { position: absolute; right: var(--m); bottom: var(--m); height: var(--g-row-bottom); padding: 5px 6px; display: flex; gap: 4px; background: var(--g-glass-hi); }
.crh-key { position: relative; flex: none; width: 54px; height: 52px; border-radius: 7px; background: rgba(255, 255, 255, .06); border: 1px solid var(--g-line); color: var(--g-text-1); overflow: hidden; --p: 0; }
.crh-key kbd { position: absolute; left: 4px; top: 4px; display: inline-flex; align-items: center; justify-content: center; min-width: 14px; height: 14px; padding: 0; border: 1px solid rgba(241, 236, 228, .34); border-radius: 3px; font-family: var(--g-font); font-stretch: 85%; font-weight: 700; font-size: 8.5px; line-height: 1; color: var(--g-text-1); }
.crh-key--nitro kbd { padding: 0 3px; }
.crh-key-c { position: absolute; right: 5px; top: 5px; font-size: 10px; font-weight: 700; }
.crh-key-i { position: absolute; left: 50%; top: 15px; width: 18px; height: 18px; translate: -50% 0; }
.crh-key-i svg { width: 18px; height: 18px; }
.crh-key-l { position: absolute; left: 0; right: 0; bottom: 6px; text-align: center; font-stretch: 75%; font-weight: 750; font-size: 8.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--g-text-2); white-space: nowrap; }
.crh-key-ov { position: absolute; inset: 0; border-radius: 6px; display: none; background: conic-gradient(from 0deg, rgba(0, 0, 0, 0) 0 calc(var(--p) * 100%), rgba(0, 0, 0, .45) 0 100%); }
.crh-key.empty { background: rgba(255, 255, 255, .03); color: var(--g-text-3); }
.crh-key.cd { color: var(--g-text-3); }
.crh-key.cd .crh-key-ov { display: block; }
.crh-key.cd .crh-key-c { color: var(--g-text-1); }
.crh-key.cd .crh-key-l, .crh-key.act .crh-key-l { color: var(--g-amber); }
.crh-key.act { background: rgba(242, 185, 15, .12); border-color: var(--g-amber); color: var(--g-amber); }
.crh-key.act .crh-key-c { color: var(--g-text-1); }
.crh-key.off { opacity: .4; }

/* ── bottom-centre: DEFEND over the dash (driver) ────────────────────────── */
.crh-def { position: absolute; left: 50%; bottom: 100px; translate: -50% 0; display: none; flex-direction: column; align-items: center; gap: 8px; }
.crh-def.on { display: flex; animation: crhUp var(--g-slow) var(--g-ease) both; }
@keyframes crhUp { from { opacity: 0; translate: -50% 6px; } }
.crh-def-row { display: flex; align-items: center; gap: 8px; }
.crh-ring { position: relative; width: 64px; height: 64px; padding: 7px; flex: none; background: var(--g-glass-hi); }
.crh-ring svg { width: 48px; height: 48px; }
.crh-ring circle { fill: none; stroke-width: 4; }
.crh-ring .bg { stroke: var(--g-track); }
.crh-ring .fg { stroke: var(--g-red); stroke-linecap: round; transition: stroke-dasharray var(--g-fast) linear; }
.crh-ring.tone-amber .fg { stroke: var(--g-amber); }
.crh-ring.tone-dim .fg { stroke: transparent; }
.crh-ring.tone-dim .crh-ring-c { color: var(--g-text-3); }
.crh-ring-c { position: absolute; inset: 7px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.crh-ring-c i, .crh-ring-c svg { width: 14px; height: 14px; }
.crh-ring-c b { font-size: 10.5px; font-weight: 750; }
.crh-defend { pointer-events: auto; position: relative; display: flex; align-items: center; gap: 12px; width: 312px; height: 64px; padding: 0 12px 0 10px; margin: 0; border-radius: var(--g-radius);
  background: var(--g-glass-hi); border: 1px solid rgba(229, 72, 58, .9); box-shadow: 0 0 0 4px rgba(229, 72, 58, .16), 0 6px 18px rgba(0, 0, 0, .3);
  -webkit-backdrop-filter: blur(var(--g-blur)); backdrop-filter: blur(var(--g-blur)); cursor: pointer; overflow: hidden; color: var(--g-text-1); font-family: var(--g-font); text-align: left;
  transition: background var(--g-fast) var(--g-ease), border-color var(--g-fast) var(--g-ease); }
.crh-defend:hover { background: rgba(28, 16, 15, .9); }
.crh-defend:focus-visible { outline: 2px solid var(--g-amber); outline-offset: 2px; }
.crh-def-ic { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex: none; border-radius: var(--g-radius-sm); background: rgba(229, 72, 58, .22); color: var(--g-red); }
.crh-def-ic svg { width: 22px; height: 22px; }
.crh-def-t { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; flex: 1 1 auto; min-width: 0; white-space: nowrap; }
.crh-def-t b { font-stretch: 70%; font-weight: 800; font-size: 26px; line-height: 1; letter-spacing: .04em; text-transform: uppercase; }
.crh-def-t small { font-weight: 500; font-size: 11.5px; line-height: 1; color: var(--g-text-2); }
.crh-def-g { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; opacity: .9; padding: 0 4px 0 10px; border-left: 1px solid var(--g-line-2); color: var(--g-text-2); }
.crh-def-g .g-rev { width: 24px; height: 10.1px; }
.crh-def-g .g-long { width: 40px; height: 7.3px; }
.crh-defend .g-keycap { min-width: 30px; height: 30px; font-size: 14px; }
.crh-def-p { position: absolute; left: 0; bottom: 0; width: 100%; height: 3px; background: var(--g-red); border-radius: 0 2px 0 9px; transform-origin: 0 50%; transform: scaleX(0); transition: transform var(--g-fast) linear; }
.crh-def.st-held .crh-defend, .crh-def.st-up .crh-defend { border-color: var(--g-red); cursor: default; }
.crh-def.st-locked .crh-defend { border-color: var(--g-line); box-shadow: var(--g-shadow); cursor: default; }
.crh-def.st-locked .crh-defend:hover { background: var(--g-glass-hi); }
.crh-def.st-locked .crh-def-ic { background: rgba(255, 255, 255, .06); color: var(--g-text-3); }
.crh-def.st-locked .crh-def-t b { color: var(--g-text-3); }
.crh-def.st-locked .crh-def-g { opacity: .45; }
.crh-def-info { position: relative; display: inline-flex; align-items: center; gap: 8px; height: 24px; padding: 0 10px; border-radius: var(--g-radius-sm); background: var(--g-glass-hi); white-space: nowrap; }
.crh-def-info b { font-size: 12px; font-weight: 700; }

/* small speed readout when not in the cab (chase / wreck camera) */
.crh-spd { position: absolute; left: 50%; bottom: var(--m); translate: -50% 0; height: var(--g-pill); padding: 0 10px; display: none; align-items: center; gap: 5px; border-radius: var(--g-radius-sm); }
.crh-spd b { font-size: 14px; }
.crh--driver.crh--m-drive:not(.crh--fp):not(.crh--garage) .crh-spd { display: inline-flex; }

/* ── big moments: set-piece captions, area titles, countdown (Fraunces) ─── */
.crh-caption, .crh-area { position: absolute; left: 50%; translate: -50% 0; display: none; flex-direction: column; align-items: center; text-align: center; width: min(92%, 900px); }
.crh-caption.on, .crh-area.on { display: flex; animation: crhRise var(--g-slow) var(--g-ease) both; }
.crh-caption.out, .crh-area.out { opacity: 0; translate: -50% -6px; transition: opacity var(--g-slow) var(--g-ease), translate var(--g-slow) var(--g-ease); }
@keyframes crhRise { from { opacity: 0; translate: -50% 6px; } }
.crh-caption { top: 25%; gap: 12px; }
.crh-caption b, .crh-area b { font-family: var(--g-font-display); font-weight: 800; line-height: 1; letter-spacing: -.01em; font-variation-settings: 'SOFT' 100, 'opsz' 144; color: var(--g-text-1); text-shadow: 0 4px 24px rgba(0, 0, 0, .5), 0 1px 2px rgba(0, 0, 0, .4); }
.crh-caption b { font-size: clamp(32px, 4.4vw, 60px); }
.crh-caption small { display: inline-flex; align-items: center; height: var(--g-pill); padding: 0 12px; border-radius: var(--g-radius-sm); background: var(--g-glass); border: 1px solid var(--g-line);
  -webkit-backdrop-filter: blur(var(--g-blur)); backdrop-filter: blur(var(--g-blur)); font-weight: 600; font-size: 13px; color: var(--g-text-1); white-space: nowrap; }
.crh-area { top: 38%; gap: 10px; }
.crh-area .g-label { letter-spacing: .24em; padding-left: .24em; color: var(--g-text-1); text-shadow: 0 1px 6px rgba(0, 0, 0, .6); }
.crh-area b { font-size: clamp(36px, 4.8vw, 64px); }
.crh-area small { font-stretch: 88%; font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; letter-spacing: .04em; color: var(--g-text-1); text-shadow: 0 1px 6px rgba(0, 0, 0, .6); }
.crh-count { position: absolute; left: 50%; top: 40%; translate: -50% -50%; }
.crh-count b { display: block; font-family: var(--g-font-display); font-weight: 800; font-size: clamp(88px, 11vw, 136px); line-height: 1; font-variation-settings: 'SOFT' 100, 'opsz' 144;
  color: var(--g-text-1); text-shadow: 0 6px 30px rgba(0, 0, 0, .45); animation: crhCount 260ms var(--g-ease) both; }
.crh-count b.go { color: var(--g-amber); }
@keyframes crhCount { from { opacity: 0; translate: 0 8px; } }

/* ── end screen (End.png) ────────────────────────────────────────────────── */
.crh-end { position: absolute; inset: 0; display: none; z-index: 10;
  background: linear-gradient(90deg, rgba(10, 11, 13, .86) 0%, rgba(10, 11, 13, .64) 46%, rgba(10, 11, 13, .2) 100%); }
.crh-end.on { display: block; animation: crhFade var(--g-slow) var(--g-ease) both; }
@keyframes crhFade { from { opacity: 0; } }
.crh-end-in { position: absolute; inset: 0; }
.crh-end-in > * { position: absolute; }
.crh-end-mark { left: 48px; top: 30px; font-weight: 900; font-stretch: 62%; font-size: 32px; line-height: .9; letter-spacing: .01em; text-transform: uppercase; white-space: nowrap; }
.crh-end-mark span { -webkit-text-stroke: .03em #22262A; paint-order: stroke fill; text-shadow: .05em .06em 0 #22262A; }
.crh-end-mark .c { color: #4F8F8A; }
.crh-end-mark .a { display: inline-block; margin: 0 .12em; font-family: var(--g-font-display); font-weight: 900; font-size: .72em; line-height: 1; font-variation-settings: 'SOFT' 100, 'opsz' 144; color: #F1EAD8; }
.crh-end-mark .r { color: #D9A83A; }
.crh-end-run { right: 48px; top: 28px; padding: 6px 10px; border-radius: var(--g-radius-sm); background: var(--g-glass-hi); text-align: right; }
.crh-end-run b { display: block; font-size: 10px; color: var(--g-text-1); }
.crh-end-run span { display: block; margin-top: 5px; font-weight: 500; font-size: 12px; color: var(--g-text-2); white-space: nowrap; }
.crh-end-head { left: 48px; top: 98px; }
.crh-end-where { display: inline-block; padding: 5px 9px; border-radius: 6px; background: var(--g-glass-hi); font-size: 10px; color: var(--g-text-1); }
.crh-end-title { margin: 10px 0 0; font-family: var(--g-font-display); font-weight: 800; font-size: 108px; line-height: .95; letter-spacing: -.01em; font-variation-settings: 'SOFT' 100, 'opsz' 144;
  color: var(--g-text-1); text-shadow: 0 4px 24px rgba(40, 10, 10, .45); white-space: nowrap; }
.crh-end-card { left: 48px; top: 268px; width: 560px; padding: 18px; border-radius: var(--g-radius-lg); background: var(--g-glass-hi); border: 1px solid var(--g-line); box-shadow: var(--g-shadow);
  -webkit-backdrop-filter: blur(var(--g-blur)); backdrop-filter: blur(var(--g-blur)); }
.crh-end-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.crh-end-top .g-label { font-size: 10px; }
.crh-end-pay { display: block; margin-top: 8px; font-weight: 800; font-size: 52px; line-height: 1; }
.crh-end-rate { text-align: right; }
.crh-end-stars { display: flex; justify-content: flex-end; gap: 3px; }
.crh-end-stars .crh-star { width: 22px; height: 22px; }
.crh-end-rate p { margin: 8px 0 0 auto; max-width: 150px; font-weight: 500; font-size: 12px; line-height: 1.35; color: var(--g-text-2); }
.crh-end-grid { display: grid; grid-template-columns: repeat(4, 1fr); margin: 18px -18px -18px; border-top: 1px solid var(--g-line); }
.crh-end-st { padding: 14px 18px; min-width: 0; }
.crh-end-st + .crh-end-st { border-left: 1px solid var(--g-line); }
.crh-end-st .g-label { display: flex; align-items: center; gap: 6px; }
.crh-end-st .g-label svg { width: 13px; height: 13px; flex: none; color: var(--g-text-2); }
.crh-end-st b { display: block; margin-top: 8px; font-size: 24px; }
.crh-end-istar { color: var(--g-amber); }
.crh svg.crh-istar { display: inline-block; width: .8em; height: .8em; vertical-align: -.05em; margin: 0 .04em; }
.crh-end-btns { left: 48px; top: 520px; display: flex; align-items: center; gap: 12px; }
.crh-end-btns .g-btn { width: 200px; pointer-events: auto; }
.crh-end-wait { display: inline-flex; align-items: center; height: 50px; padding: 0 16px; border-radius: var(--g-radius-sm); background: var(--g-glass-hi); font-weight: 600; font-size: 14px; color: var(--g-text-2); }
.crh-end-diff { display: inline-flex; align-items: center; gap: 6px; height: 50px; padding: 0 14px; border-radius: var(--g-radius-sm); background: var(--g-glass-hi);
  border: 1px solid color-mix(in srgb, var(--dc, #E07A3C) 55%, transparent); }
.crh-end-diff .f { display: flex; }
.crh-end-diff .f i, .crh-end-diff .f svg { width: 12px; height: 12px; }
.crh-end-diff .g-label { color: var(--dc, #E07A3C); }
.crh-end-crew { right: 48px; bottom: 64px; width: 462px; padding: 12px 16px; display: flex; align-items: center; gap: 16px; border-radius: var(--g-radius-lg); background: var(--g-glass-hi);
  border: 1px solid var(--g-line); box-shadow: var(--g-shadow); -webkit-backdrop-filter: blur(var(--g-blur)); backdrop-filter: blur(var(--g-blur)); }
.crh-end-crew > div { display: flex; align-items: center; gap: 12px; flex: 1 1 0; min-width: 0; }
.crh-end-crew .vr { width: 1px; height: 44px; flex: none; background: var(--g-line-2); }
.crh-end-crew b { font-weight: 700; font-size: 15px; }
.crh-end-crew p { margin: 4px 0 0; font-weight: 500; font-size: 12px; line-height: 1.4; color: var(--g-text-2); }
.crh-end-crew .av { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 10px; font-family: var(--g-font-display); font-weight: 800; font-size: 22px; font-variation-settings: 'SOFT' 100, 'opsz' 144; }
.crh-end-crew .av.rook { background: rgba(224, 122, 60, .2); color: var(--g-rust-text); box-shadow: inset 0 0 0 1px rgba(224, 122, 60, .45); }
.crh-end-crew .av.doc { background: rgba(95, 179, 168, .2); color: var(--g-teal-text); box-shadow: inset 0 0 0 1px rgba(95, 179, 168, .45); }
.crh-end-in.lost .crh-end-title { color: #F6DCD6; }
.crh--ended > :not(.crh-end) { opacity: 0; transition: opacity var(--g-slow) var(--g-ease); }

/* ═════════════════════════════════════════════════════════════════════════
   Modes (hud.setMode) — which panels show
   drive  : everything (driver)                       lab   : cook in the van (VanHud draws the lab panels)
   roof   : DefendClient draws the centre + bust      shop  : Doc's shop run (ShopRun draws timer / list)
   garage : on-foot tutorial (also automatic from snap.phase === 'garage')
   ═════════════════════════════════════════════════════════════════════════ */
.crh--m-roof .crh-prog, .crh--m-roof .crh-run, .crh--m-roof .crh-line, .crh--m-roof .crh-tags,
.crh--m-roof .crh-gad, .crh--m-roof .crh-def, .crh--m-roof .crh-spd { display: none !important; }
.crh--m-roof .crh-hp { left: auto; right: var(--m); }
.crh--m-roof .crh-side { top: calc(var(--m) + var(--g-row-top) + 16px); }
.crh--m-shop .crh-prog, .crh--m-shop .crh-line, .crh--m-shop .crh-gad, .crh--m-shop .crh-def, .crh--m-shop .crh-spd { display: none !important; }
.crh--m-shop .crh-hp { left: auto; right: var(--m); }
.crh--m-lab .crh-gad, .crh--m-lab .crh-def, .crh--m-lab .crh-spd { display: none !important; }
.crh--garage .crh-line, .crh--garage .crh-def, .crh--garage .crh-spd, .crh--garage .crh-vig,
.crh--m-garage .crh-line, .crh--m-garage .crh-def, .crh--m-garage .crh-spd { display: none !important; }
/* body classes main.js already sets (fallback when setMode isn't wired yet) */
body.in-shop .crh .crh-prog, body.in-shop .crh .crh-line, body.in-shop .crh .crh-gad, body.in-shop .crh .crh-def, body.in-shop .crh .crh-spd { display: none !important; }
body.in-shop .crh .crh-hp { left: auto; right: var(--m); }
body.in-lab .crh .crh-gad, body.in-lab .crh .crh-def, body.in-lab .crh .crh-spd { display: none !important; }

/* the 2D lab docked on the right (style.css body.lab-local): toasts sit to its left instead of on top of it */
@media (min-width: 761px) {
  body.lab-local:not(.lab-hidden) .crh-side .crh-toasts { position: absolute; top: 34px; right: calc(max(420px, min(500px, 38vw)) + 8px); width: max-content; }
}

/* ── touch (phones / tablets; the driver's touch buttons own the bottom corners) ── */
body.touch.role-driver .crh-gad, body.touch.lab-local .crh-gad { display: none; }
body.touch.role-driver .crh--m-drive .crh-hp, body.touch.lab-local .crh--m-drive .crh-hp { top: calc(var(--m) + var(--g-row-top) + 8px); bottom: auto; }
body.touch.role-driver .crh-def, body.touch.lab-local .crh-def { bottom: 16px; }
body.touch.role-driver .crh-def-info, body.touch.lab-local .crh-def-info { display: none; }
body.touch .crh-defend { touch-action: manipulation; }
body.touch.role-driver .crh-def-g, body.touch.lab-local .crh-def-g { display: none; }   /* clears the DRIFT button on phones */
body.touch.role-driver .crh-defend, body.touch.lab-local .crh-defend { width: 236px; }

/* ── responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .crh { --g-side: 208px; }
  .crh-bags { width: 66px; }
}
@media (max-width: 900px), (max-height: 520px) {
  .crh { --m: 8px; --g-side: 188px; }
  .crh-run { gap: 8px; padding: 10px 10px 0; }
  .crh-heat { padding: 10px 10px 0; }
  .crh-heat-r { gap: 7px; }
  .crh-bags { width: 60px; }
  .crh-bags-v b, .crh-score > b { font-size: 17px; }
  .crh-hp { padding: 7px 10px; }
  .crh-bar .g-label { width: 44px; }
  .crh-key { width: 48px; height: 48px; }
  .crh-gad { height: 60px; }
  .crh-key-i { top: 13px; }
  .crh-key-l { bottom: 5px; font-size: 8px; }
  .crh-def { bottom: 84px; }
  .crh-end-title { font-size: 84px; }
}
@media (max-width: 640px) {
  .crh { --g-side: calc(50% - 12px); }
  .crh-heat, .crh-run { width: calc(50% - 12px); }
  .crh-prog, .crh-line { width: calc(100% - 16px); }
  .crh-prog { top: calc(var(--m) + var(--g-row-top) + 8px); }
  .crh-line { top: calc(var(--m) + 2 * var(--g-row-top) + 16px); }
  .crh-side { top: calc(var(--m) + 2 * var(--g-row-top) + 52px); max-width: calc(100% - 16px); }
  .crh--m-roof .crh-side, .crh--m-shop .crh-side { top: calc(var(--m) + var(--g-row-top) + 16px); }
  .crh-stars { gap: 1px; }
  .crh-star { width: 12px; height: 12px; }
  .crh-hp { width: min(232px, calc(50% - 12px)); }
  .crh-bar .g-label { width: 38px; }
  .crh-gad { padding: 4px; gap: 3px; }
  .crh-key { width: 42px; height: 46px; }
  .crh-key-l { display: none; }
  .crh-key-i { top: 18px; }
  .crh-defend { width: 248px; gap: 10px; }
  .crh-def-g { display: none; }
  .crh-toast { max-width: 100%; }
  .crh-toasts--b { bottom: calc(var(--m) + var(--g-row-bottom) + 44px); }   /* above the health panel + pills */
  .crh-caption { top: 30%; }
  .crh-area { top: 42%; }
}
/* the end screen flows as one column on small screens */
@media (max-width: 1000px), (max-height: 600px) {
  .crh-end { background: rgba(10, 11, 13, .8); }
  .crh-end-in { overflow: auto; padding: 16px; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; pointer-events: auto; }
  .crh-end-in > * { position: static; }
  .crh-end-mark { font-size: 24px; }
  .crh-end-run { align-self: stretch; text-align: left; }
  .crh-end-title { margin-top: 6px; font-size: clamp(44px, 12vw, 72px); white-space: normal; }
  .crh-end-card, .crh-end-crew { width: 100%; max-width: 560px; }
  .crh-end-pay { font-size: 40px; }
  .crh-end-btns { flex-wrap: wrap; }
  .crh-end-btns .g-btn { width: auto; min-width: 150px; }
}
@media (max-width: 520px) {
  .crh-end-grid { grid-template-columns: repeat(2, 1fr); }
  .crh-end-st:nth-child(3) { border-left: 0; }
  .crh-end-st:nth-child(n + 3) { border-top: 1px solid var(--g-line); }
  .crh-end-top { flex-direction: column; }
  .crh-end-rate { text-align: left; }
  .crh-end-stars { justify-content: flex-start; }
  .crh-end-rate p { margin-left: 0; }
  .crh-end-crew { flex-direction: column; align-items: stretch; }
  .crh-end-crew .vr { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .crh *, .crh *::before, .crh *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
