/* CARider run HUD: off-white on translucent charcoal, one muted denim accent. No backdrop-filter. */
.hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; font-family: var(--font, system-ui, sans-serif); color: var(--off-white, #eeeeea); }
.hud [hidden] { display: none !important; }
.hud button { pointer-events: auto; }

/* desaturate overlay (coffee break) */
.hud-tint { position: absolute; inset: 0; background: #8a8e96; mix-blend-mode: saturation; opacity: 0; }

.hud-top {
  position: absolute; left: calc(14px + var(--safe-l, 0px)); right: calc(14px + var(--safe-r, 0px)); top: calc(12px + var(--safe-t, 0px));
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
}
.hud-mission {
  width: min(340px, calc(100vw - 110px - var(--safe-l, 0px) - var(--safe-r, 0px)));
  padding: 9px 12px 10px; border-radius: 12px;
  background: var(--panel, rgba(38, 42, 49, 0.86)); border: 1px solid var(--panel-line, rgba(238, 238, 234, 0.1));
}
.hud-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-variant-numeric: tabular-nums; }
.hud-goal { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 1.2em; }
.hud-goal:not(:empty)::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 8px; background: var(--denim-soft, #8d9cb4); transform: rotate(45deg); position: relative; top: -1px; }
.hud-time { flex: none; font-size: 13px; font-weight: 700; letter-spacing: 0.04em; min-height: 1.2em; }
.hud-row2 { margin-top: 7px; }
.hud-remain, .hud-score { font-size: 12px; font-weight: 600; color: var(--text-dim, rgba(238, 238, 234, 0.68)); white-space: nowrap; min-height: 1.2em; }
.hud-score { color: var(--off-white, #eeeeea); }
.hud-bonus { margin-top: 4px; font-size: 11px; letter-spacing: 0.03em; color: var(--text-dim, rgba(238, 238, 234, 0.68)); min-height: 1.2em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-bonus.ok { color: var(--denim-soft, #8d9cb4); }
.hud-brief-sub { margin: -6px 0 0; font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 600; color: var(--off-white, #eeeeea); text-shadow: 0 1px 10px rgba(38, 42, 49, 0.6); opacity: 0; }
.hud-briefing.run .hud-brief-sub { animation: hud-fade 2.5s ease forwards; }
.hud-bar { margin-top: 8px; height: 3px; border-radius: 2px; background: rgba(238, 238, 234, 0.14); overflow: hidden; }
.hud-bar i { display: block; height: 100%; background: var(--denim-soft, #8d9cb4); transform: scaleX(0); transform-origin: 0 50%; transition: transform 0.2s linear; }
.hud-top.done-ok .hud-bar i { background: var(--off-white, #eeeeea); }
.hud-top.done-ko .hud-bar i { background: rgba(238, 238, 234, 0.35); }

.hud-side { flex: none; position: relative; width: 52px; }
.hud-power {
  width: 52px; height: 52px; border-radius: 12px; position: relative; --f: 1;
  background: var(--panel, rgba(38, 42, 49, 0.86)); border: 1px solid var(--panel-line, rgba(238, 238, 234, 0.1));
  display: grid; place-items: center; opacity: 0.0; transition: opacity 0.25s;
}
.hud-power.on { opacity: 1; }
.hud-power.active { border-color: var(--denim-soft, #8d9cb4); }
/* R9: a timed boost fades out with powerups.info.fade (--f, 1 -> 0): icon, timer and border ease down, no blink */
.hud-power.timed { border-color: rgba(141, 156, 180, calc(0.12 + 0.88 * var(--f))); }
.hud-power.timed .hud-icon { opacity: calc(0.22 + 0.78 * var(--f)); }
.hud-power.timed .hud-ptimer { opacity: calc(0.15 + 0.85 * var(--f)); }
.hud-icon { width: 26px; height: 26px; margin-top: -3px; }
.hud-power:not(.timed) .hud-icon { margin-top: 0; }
.hud-icon svg, .hud-chip svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: block; }
/* timer bar only for a timed boost (Greg has none, R10) */
.hud-ptimer { position: absolute; left: 8px; right: 8px; bottom: 7px; height: 3px; border-radius: 2px; background: rgba(238, 238, 234, 0.14); overflow: hidden; visibility: hidden; }
.hud-power.timed .hud-ptimer { visibility: visible; }
.hud-ptimer i { display: block; height: 100%; background: var(--denim-soft, #8d9cb4); transform: scaleX(0); transform-origin: 0 50%; transition: transform 0.12s linear; }
/* chips under the box: Greg still on under a boost, a held Rollback. Absolutely placed, fixed slots. */
.hud-chips { position: absolute; top: 58px; right: 0; width: 52px; height: 24px; }
.hud-chip {
  position: absolute; top: 0; width: 24px; height: 24px; padding: 4px; box-sizing: border-box; border-radius: 8px;
  background: var(--panel, rgba(38, 42, 49, 0.86)); border: 1px solid var(--panel-line, rgba(238, 238, 234, 0.1));
  opacity: 0; transition: opacity 0.25s;
}
.hud-chip.on { opacity: 1; }
.hud-chip-greg { left: 0; border-color: var(--denim-soft, #8d9cb4); }
.hud-chip-held { right: 0; color: var(--text-dim, rgba(238, 238, 234, 0.68)); }

/* R9: soft edge glow while a boost runs, its opacity is the boost's fade (set by hud.js) */
.hud-glow { position: absolute; inset: 0; opacity: 0; background: radial-gradient(ellipse 75% 70% at 50% 55%, rgba(93, 110, 136, 0) 55%, rgba(93, 110, 136, 0.42) 100%); }
.hud-glow[data-kind="prod"] { background: radial-gradient(ellipse 75% 70% at 50% 55%, rgba(214, 186, 120, 0) 55%, rgba(214, 186, 120, 0.4) 100%); }

/* R5-R7: remaining damage budget, filled pip = one hit left. Fixed width for the run (set at start). */
.hud-left { display: flex; align-items: center; min-width: 0; }
.hud-lives { flex: none; display: flex; gap: 4px; margin-right: 10px; }
.hud-lives i { display: block; width: 7px; height: 7px; border-radius: 50%; background: var(--off-white, #eeeeea); box-shadow: inset 0 0 0 1px var(--off-white, #eeeeea); transition: background-color 0.3s, box-shadow 0.3s; }
.hud-lives i.out { background: transparent; box-shadow: inset 0 0 0 1px rgba(238, 238, 234, 0.32); }
.hud-lives i.lost { animation: hud-pip 0.7s ease; }
.hud-lives.hit { animation: hud-lives 0.7s ease; }
@keyframes hud-pip { 0% { transform: scale(1); background: var(--off-white, #eeeeea); } 30% { transform: scale(1.7); background: var(--off-white, #eeeeea); } 100% { transform: scale(1); } }
@keyframes hud-lives { 0%, 100% { opacity: 1; } 25% { opacity: 0.45; } }

/* power-up name flash */
.hud-flash {
  position: absolute; left: 50%; top: 27%; transform: translate(-50%, 0); opacity: 0; white-space: nowrap;
  padding: 9px 20px; border-radius: 999px; font-size: clamp(16px, 2.4vw, 22px); font-weight: 700; letter-spacing: 0.04em;
  background: var(--panel, rgba(38, 42, 49, 0.86)); border: 1px solid var(--panel-line, rgba(238, 238, 234, 0.1));
}
.hud-flash.show { animation: hud-flash 1.1s ease forwards; }
.hud-flash.shield { border-color: var(--denim-soft, #8d9cb4); }
@keyframes hud-flash { 0% { opacity: 0; transform: translate(-50%, 8px); } 15% { opacity: 1; transform: translate(-50%, 0); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -6px); } }

/* speech line (Greg): a quiet bubble above the rider, absolutely placed (no layout shift) */
.hud-say {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, 6px); opacity: 0; max-width: min(420px, 86vw);
  padding: 8px 16px; border-radius: 14px; font-size: clamp(14px, 2vw, 17px); font-weight: 600; font-style: italic; text-align: center;
  background: var(--panel, rgba(38, 42, 49, 0.86)); border: 1px solid var(--panel-line, rgba(238, 238, 234, 0.1));
  transition: opacity 0.25s, transform 0.25s;
}
.hud-say::after { content: ""; position: absolute; left: 50%; top: 100%; margin-left: -7px; border: 7px solid transparent; border-bottom: 0; border-top-color: var(--panel, rgba(38, 42, 49, 0.86)); }
.hud-say.show { opacity: 1; transform: translate(-50%, 0); }

/* briefing */
.hud-briefing { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 0 24px; text-align: center; }
.hud-brief-title {
  margin: 0; max-width: min(560px, 90vw); padding: 14px 22px; border-radius: 14px; font-size: clamp(17px, 2.6vw, 24px); font-weight: 600; line-height: 1.3;
  background: var(--panel, rgba(38, 42, 49, 0.86)); border: 1px solid var(--panel-line, rgba(238, 238, 234, 0.1));
}
.hud-go {
  margin: 0; font-size: clamp(64px, 14vmin, 120px); font-weight: 800; letter-spacing: -0.02em; line-height: 1; opacity: 0;
  color: var(--off-white, #eeeeea); text-shadow: 0 2px 18px rgba(38, 42, 49, 0.55);
}
.hud-briefing.run .hud-brief-title { animation: hud-fade 2.5s ease forwards; }
.hud-briefing.run .hud-go { animation: hud-go 2.5s ease forwards; }
@keyframes hud-fade { 0% { opacity: 0; transform: translateY(8px); } 12% { opacity: 1; transform: none; } 70% { opacity: 1; } 100% { opacity: 0; } }
@keyframes hud-go { 0%, 55% { opacity: 0; transform: scale(0.85); } 68% { opacity: 1; transform: scale(1); } 85% { opacity: 1; } 100% { opacity: 0; transform: scale(1.12); } }

/* results / pause */
.hud-screen { position: absolute; inset: 0; display: grid; place-items: center; padding: calc(16px + var(--safe-t, 0px)) calc(16px + var(--safe-r, 0px)) calc(16px + var(--safe-b, 0px)) calc(16px + var(--safe-l, 0px)); background: rgba(38, 42, 49, 0.28); pointer-events: auto; overflow: auto; }
.hud-card {
  width: min(420px, 100%); padding: 24px 24px 22px; text-align: center; border-radius: 16px;
  background: var(--panel, rgba(38, 42, 49, 0.86)); border: 1px solid var(--panel-line, rgba(238, 238, 234, 0.1)); box-shadow: 0 12px 32px rgba(38, 42, 49, 0.18);
  animation: hud-card 0.35s cubic-bezier(.2, .8, .2, 1);
}
@keyframes hud-card { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.hud-verdict { margin: 0; font-size: 11px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--denim-soft, #8d9cb4); }
.hud-results.ko .hud-verdict { color: var(--text-dim, rgba(238, 238, 234, 0.68)); }
.hud-line-out { margin: 12px 0 0; font-size: clamp(16px, 4.2vw, 19px); line-height: 1.4; font-weight: 500; min-height: 2.8em; }
.hud-big { margin: 14px 0 0; line-height: 1; font-variant-numeric: tabular-nums; display: grid; gap: 8px; }
.hud-big-l { font-size: 11px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-dim, rgba(238, 238, 234, 0.68)); }
.hud-best { margin: 10px 0 0; font-size: 14px; font-weight: 600; color: var(--text-dim, rgba(238, 238, 234, 0.68)); min-height: 1.3em; }
.hud-best.record { color: var(--off-white, #eeeeea); letter-spacing: 0.04em; }
.hud-brk { margin: 8px 0 20px; font-size: 11px; line-height: 1.4; color: var(--text-dim, rgba(238, 238, 234, 0.68)); min-height: 1.4em; }
.best-line { margin: -6px 0 14px; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; color: var(--denim-soft, #8d9cb4); min-height: 1.2em; }
.hud-big-n { font-size: clamp(56px, 16vw, 84px); font-weight: 800; letter-spacing: -0.03em; }
.hud-btns { display: grid; gap: 10px; }
.hud-pause .hud-btns { margin-top: 18px; }
.hud-btn {
  min-height: 52px; padding: 0 18px; border-radius: 12px; cursor: pointer; font-size: 15px; font-weight: 700; letter-spacing: 0.04em;
  color: var(--off-white, #eeeeea); background: transparent; border: 1px solid rgba(238, 238, 234, 0.22);
  transition: background-color 0.15s, transform 0.1s;
}
.hud-btn:hover { background: rgba(238, 238, 234, 0.08); }
.hud-btn:active { transform: scale(0.985); }
.hud-btn.primary { background: var(--denim, #4a5a74); border-color: transparent; }
.hud-btn.primary:hover { background: var(--denim-2, #5d6e88); }

@media (orientation: landscape) and (max-height: 520px) {
  .hud-top { top: calc(8px + var(--safe-t, 0px)); }
  .hud-card { padding: 14px 18px; width: min(560px, 100%); }
  .hud-big { margin: 6px 0 0; } .hud-big-n { font-size: 44px; } .hud-brk { margin-bottom: 10px; }
  .hud-line-out { min-height: 0; margin-top: 8px; }
  .hud-btns { grid-template-columns: 1fr 1fr; }
  .hud-btn { min-height: 46px; }
  .hud-go { font-size: 64px; }
}
@media (prefers-reduced-motion: reduce) { .hud * { animation-duration: 0.01s !important; transition: none !important; } }
