/* ui/DriveHud: two framed panels in daylight square blocks, a 3 px ink border and a hard ink ledge
   (the design canvas's Arena HUD; the two-panel structure is Sproks's, 2026-10-18). Desktop and
   phone are the same structure, scaled: --hud-edge is the gap to the screen's edge. */
.tk-dhud {
  --hud-edge: 14px;
  --hud-map: 128px;
  position: absolute;
  inset: 0;
  pointer-events: none;
  color: var(--tk-ink);
  font-family: var(--tk-font-ui);
  user-select: none;
}
.tk-dhud__block {
  background: var(--tk-paper);
  border: var(--tk-border);
  box-shadow: var(--tk-ledge);
  box-sizing: border-box;
}

/* The status panel: the map, then the run and your bot. */
.tk-dhud__status {
  position: absolute;
  left: var(--hud-edge);
  top: var(--hud-edge);
  display: flex;
  gap: 12px;
  padding: 8px;
  max-width: calc(100vw - 2 * var(--hud-edge));
}
.tk-dhud__status[data-low="true"] {
  border-color: var(--tk-coral);
  box-shadow: 0 5px 0 var(--tk-coral);
  animation: tk-dhud-low 0.9s steps(2, jump-none) infinite;
}
@keyframes tk-dhud-low {
  from { background: var(--tk-paper); }
  to { background: color-mix(in srgb, var(--tk-coral) 18%, var(--tk-paper)); }
}
@media (prefers-reduced-motion: reduce) {
  .tk-dhud__status[data-low="true"] { animation: none; }
}
.tk-dhud__map {
  width: var(--hud-map);
  height: var(--hud-map);
  flex: none;
  border: 2px solid var(--tk-ink);
  box-sizing: border-box;
  image-rendering: pixelated;
}
.tk-dhud__status-body {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  width: 250px;
}
.tk-dhud__status-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font: 400 22px/1 var(--tk-font-display);
}
.tk-dhud__dot { color: var(--tk-ink-dim); }
.tk-dhud__wrecks { color: var(--tk-coral); }
.tk-dhud__bot { display: flex; flex-direction: column; gap: 7px; }
.tk-dhud__bot-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tk-dhud__tier {
  flex: none;
  padding: 3px 6px;
  background: var(--tk-sky);
  border: 2px solid var(--tk-ink);
  color: var(--tk-paper);
  font: 400 14px/1 var(--tk-font-display);
}
.tk-dhud__bot-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 400 16px/1 var(--tk-font-display);
  text-transform: uppercase;
}
.tk-dhud__pips { display: inline-flex; gap: 3px; flex: none; }
.tk-dhud__pip {
  width: 10px;
  height: 10px;
  background: var(--tk-paper-2);
  border: 2px solid var(--tk-ink);
  box-sizing: border-box;
}
.tk-dhud__pip[data-lit="true"] { background: var(--tk-sun); }
.tk-dhud__weld { display: flex; align-items: center; gap: 7px; }
.tk-dhud__weld-icon {
  flex: none;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--tk-paper-2);
  border: 2px solid var(--tk-ink);
  box-sizing: border-box;
  font: 400 12px/1 var(--tk-font-display);
}
.tk-dhud__weld-icon img { width: 100%; height: 100%; display: block; }
.tk-dhud__weld-bar {
  flex: 1;
  height: 12px;
  background: var(--tk-paper-2);
  border: 2px solid var(--tk-ink);
  box-sizing: border-box;
}
.tk-dhud__weld-fill { display: block; height: 100%; background: var(--tk-teal); }
.tk-dhud__weld-text { flex: none; font: 700 12px/1 var(--tk-font-ui); white-space: nowrap; }
.tk-dhud__hull-line { display: flex; align-items: center; gap: 7px; }
.tk-dhud__hull {
  flex: 1;
  display: flex;
  height: 12px;
  border: 2px solid var(--tk-ink);
  box-sizing: border-box;
}
.tk-dhud__seg { flex: 1; background: var(--tk-paper-2); border-right: 1px solid var(--tk-ink); }
.tk-dhud__seg:last-of-type { border-right: 0; }
.tk-dhud__seg[data-lit="true"] { background: var(--tk-lime); }
.tk-dhud__status[data-low="true"] .tk-dhud__seg[data-lit="true"] { background: var(--tk-coral); }
.tk-dhud__hull-text { flex: none; font: 700 12px/1 var(--tk-font-ui); font-variant-numeric: tabular-nums; }

/* The standing panel: the top drivers, and the pause button in its end cap; the feed under it. */
.tk-dhud__right {
  position: absolute;
  right: var(--hud-edge);
  top: var(--hud-edge);
  width: 280px;
  max-width: calc(100vw - 2 * var(--hud-edge));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}
.tk-dhud__standing {
  width: 100%;
  display: flex;
  align-items: stretch;
}
.tk-dhud__board { flex: 1; min-width: 0; padding: 8px 6px; }
.tk-dhud__title {
  font: 400 13px/1 var(--tk-font-display);
  padding: 0 6px 6px;
  text-transform: uppercase;
}
.tk-dhud__rows { margin: 0; padding: 0; list-style: none; }
.tk-dhud__row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 6px;
  font: 600 14px/1.2 var(--tk-font-ui);
}
.tk-dhud__row[data-local="true"] { background: var(--tk-sun); border: 2px solid var(--tk-ink); }
.tk-dhud__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-dhud__score { font-variant-numeric: tabular-nums; }
.tk-dhud__badge {
  min-width: 18px;
  padding: 2px 4px;
  text-align: center;
  border: 2px solid var(--tk-ink);
  font: 400 11px/1 var(--tk-font-display);
}
.tk-dhud__badge[data-tone="sun"] { background: var(--tk-sun); }
.tk-dhud__badge[data-tone="paper"] { background: var(--tk-paper); }
.tk-dhud__badge[data-tone="sky"] { background: var(--tk-sky); color: var(--tk-paper); }
.tk-dhud__badge-gap { width: 26px; }
.tk-dhud__pause {
  pointer-events: auto;
  flex: none;
  width: 44px;
  border: 0;
  border-left: var(--tk-border);
  background: var(--tk-paper-2);
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12px;
}
.tk-dhud__pause:hover { background: var(--tk-sun); }
.tk-dhud__pause:focus-visible { outline: 3px solid var(--tk-sky); outline-offset: -3px; }
.tk-dhud__pause-bars { display: flex; gap: 5px; }
.tk-dhud__pause-bars span { width: 6px; height: 18px; background: var(--tk-ink); }
.tk-dhud__feed {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.tk-dhud__feed-row {
  padding: 4px 8px;
  background: var(--tk-paper);
  border: 2px solid var(--tk-ink);
  font: 600 13px/1.2 var(--tk-font-ui);
}
.tk-dhud__feed-row[data-local="true"] { background: var(--tk-coral); color: var(--tk-paper); }

.tk-dhud__controls {
  position: absolute;
  left: 50%;
  bottom: var(--hud-edge);
  transform: translateX(-50%);
  padding: 5px 10px;
  background: var(--tk-paper);
  border: 2px solid var(--tk-ink);
  font: 600 12px/1.2 var(--tk-font-ui);
  white-space: nowrap;
  /* A reminder for the run's start, then out of the way (2026-10-19: fewer words on screen). */
  animation: tk-dhud-fade 1.2s ease 14s forwards;
}
@keyframes tk-dhud-fade { to { opacity: 0; visibility: hidden; } }

/* The reticle: the cursor (the parent's --tk-aim-x, --tk-aim-y), else the screen centre; the count of guns that can fire there, while some cannot. */
.tk-dhud__reticle {
  position: absolute;
  left: var(--tk-aim-x, 50%);
  top: var(--tk-aim-y, 50%);
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px;
}
.tk-dhud__tick {
  position: absolute;
  width: 12px;
  height: 12px;
  box-sizing: border-box;
  border: 0 solid var(--tk-ink);
}
.tk-dhud__tick[data-corner="tl"] { left: 0; top: 0; border-left-width: 3px; border-top-width: 3px; }
.tk-dhud__tick[data-corner="tr"] { right: 0; top: 0; border-right-width: 3px; border-top-width: 3px; }
.tk-dhud__tick[data-corner="bl"] { left: 0; bottom: 0; border-left-width: 3px; border-bottom-width: 3px; }
.tk-dhud__tick[data-corner="br"] { right: 0; bottom: 0; border-right-width: 3px; border-bottom-width: 3px; }
.tk-dhud__reticle-count {
  position: absolute;
  left: 50%;
  top: calc(100% + 10px);
  transform: translateX(-50%);
  padding: 2px 6px;
  background: var(--tk-paper);
  border: 2px solid var(--tk-ink);
  font: 700 13px/1 var(--tk-font-ui);
  white-space: nowrap;
}
.tk-dhud__reticle[data-none="true"] .tk-dhud__tick { border-color: var(--tk-coral); }
.tk-dhud__reticle[data-none="true"] .tk-dhud__reticle-count { background: var(--tk-coral); color: var(--tk-paper); }

/* Phones and narrow windows: the same two panels, smaller; the board keeps three rows and the
   controls line goes (a phone drives with its own controls). */
@media (max-width: 760px), (max-height: 480px) {
  .tk-dhud { --hud-edge: 8px; --hud-map: 76px; }
  .tk-dhud__status { gap: 8px; padding: 6px; }
  .tk-dhud__status-body { width: 168px; gap: 5px; }
  .tk-dhud__status-line { font-size: 16px; }
  .tk-dhud__bot-name { font-size: 13px; }
  .tk-dhud__weld-text, .tk-dhud__hull-text { display: none; }
  .tk-dhud__right { width: 190px; gap: 8px; }
  .tk-dhud__row { font-size: 12px; padding: 2px 4px; }
  .tk-dhud__row:nth-child(n + 4):not([data-local="true"]) { display: none; }
  .tk-dhud__pause { width: 44px; }
  .tk-dhud__feed-row { font-size: 11px; }
  .tk-dhud__feed-row:nth-child(n + 3) { display: none; }
  .tk-dhud__controls { display: none; }
}
/* The way out (client/DriveHudModel canCross): teal, under the hull. */
.tk-dhud__exit {
  margin-top: 6px;
  padding: 4px 8px;
  background: var(--tk-teal);
  border: 2px solid var(--tk-ink);
  font: 700 12px/1.25 var(--tk-font-ui);
  color: var(--tk-ink);
}
/* The run's moments (client/RunToasts): centred under the top panels. */
.tk-dhud__toasts {
  position: absolute;
  left: 50%;
  top: 196px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.tk-dhud__coach, .tk-dhud__toast {
  padding: 8px 14px;
  background: var(--tk-paper);
  border: var(--tk-border);
  box-shadow: var(--tk-ledge);
  font: 700 15px/1.25 var(--tk-font-ui);
  color: var(--tk-ink);
  text-align: center;
  max-width: min(520px, 80vw);
}
.tk-dhud__coach { background: var(--tk-sky); color: var(--tk-paper); }
.tk-dhud__toast { font: 400 18px/1.1 var(--tk-font-display); }
.tk-dhud__toast[data-kind="streak"] { background: var(--tk-coral); color: var(--tk-paper); }
.tk-dhud__toast[data-kind="stage"], .tk-dhud__toast[data-kind="tier"] { background: var(--tk-sun); }
/* The edge arrows (2026-10-19): a chevron in the bot's paint, edged in ink, pointing at it. */
.tk-dhud__edges { position: absolute; inset: 0; pointer-events: none; }
.tk-dhud__edge {
  position: absolute;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  background: var(--tk-ink);
  transform: rotate(var(--edge-angle));
  clip-path: polygon(0 0, 100% 50%, 0 100%, 28% 50%);
}
.tk-dhud__edge::after {
  content: "";
  position: absolute;
  inset: 4px 4px 4px 2px;
  background: var(--edge-color);
  clip-path: polygon(0 0, 100% 50%, 0 100%, 28% 50%);
}
.tk-dhud__layer { position: absolute; inset: 0; pointer-events: none; }
/* The thumb sticks (TouchSticks, a phone's run): a square base where the thumb landed, a block at its tip. */
.tk-dhud__sticks { position: absolute; inset: 0; pointer-events: none; }
.tk-dhud__stick {
  position: absolute;
  width: calc(var(--stick-r) * 2);
  height: calc(var(--stick-r) * 2);
  margin: calc(var(--stick-r) * -1) 0 0 calc(var(--stick-r) * -1);
  box-sizing: border-box;
  border: 3px solid rgba(29, 36, 51, 0.55);
  background: rgba(255, 250, 240, 0.18);
}
.tk-dhud__stick-tip {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--stick-r) * 0.8);
  height: calc(var(--stick-r) * 0.8);
  transform: translate(calc(-50% + var(--tip-x)), calc(-50% + var(--tip-y)));
  box-sizing: border-box;
  border: var(--tk-border);
  background: var(--tk-paper);
  box-shadow: var(--tk-ledge);
}
.tk-dhud__stick[data-stick="move"][data-live="true"] .tk-dhud__stick-tip { background: var(--tk-teal); }
.tk-dhud__stick[data-stick="aim"][data-live="true"] .tk-dhud__stick-tip { background: var(--tk-coral); }
/* A size offer put away (a phone's Later): bottom centre, over the controls line. */
.tk-dhud__offer {
  position: absolute;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  pointer-events: auto;
  padding: 10px 18px;
  background: var(--tk-sun);
  color: var(--tk-ink);
  border: var(--tk-border);
  box-shadow: var(--tk-ledge);
  font: 400 18px/1 var(--tk-font-display);
  text-transform: uppercase;
  cursor: pointer;
}
/* Phones and narrow windows, after the rules above: the way-out note slim, the run's moments higher. */
@media (max-width: 760px), (max-height: 480px) {
  .tk-dhud__exit { margin-top: 4px; padding: 2px 6px; font-size: 10px; }
  .tk-dhud__toasts { top: 110px; }
  .tk-dhud__coach, .tk-dhud__toast { padding: 5px 10px; font-size: 13px; }
}
