/* 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 color-mix(in srgb, var(--tk-ink) 55%, transparent);
  background: color-mix(in srgb, var(--tk-paper) 18%, transparent);
}
.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; }
}
/* Invite friends (an online room): under the board, pointer events on like the pause. */
.tk-dhud__invite {
  pointer-events: auto;
  flex: none;
  width: 44px;
  border: 0;
  border-right: var(--tk-border);
  background: var(--tk-paper-2);
  color: var(--tk-ink);
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10px;
}
.tk-dhud__invite:hover { background: var(--tk-sun); }
.tk-dhud__invite:focus-visible { outline: 3px solid var(--tk-sky); outline-offset: -3px; }
.tk-dhud__invite[data-copied="true"] { background: var(--tk-lime); }
/* Sproks's person and plus; a tick while the link is copied. */
.tk-dhud__invite-glyph {
  width: 24px;
  height: 24px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='8' r='4'/%3E%3Cpath d='M2 21v-1a6 6 0 0 1 6-6h2a6 6 0 0 1 6 6v1'/%3E%3Cpath d='M19 8v6M16 11h6'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='8' r='4'/%3E%3Cpath d='M2 21v-1a6 6 0 0 1 6-6h2a6 6 0 0 1 6 6v1'/%3E%3Cpath d='M19 8v6M16 11h6'/%3E%3C/svg%3E") center / contain no-repeat;
}
.tk-dhud__invite[data-copied="true"] .tk-dhud__invite-glyph {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12.5l5 5L20 6.5'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12.5l5 5L20 6.5'/%3E%3C/svg%3E");
}

/* The controls card (client/FirstRun, 2026-10-19): a new driver's first runs, bottom left (the
   middle is where the rocks to shoot are), until the controls are practised. Keycaps, a mouse that
   aims, a mouse whose left button fires. */
.tk-dhud__learn {
  position: absolute;
  left: var(--hud-edge);
  bottom: calc(var(--hud-edge) + 8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px 18px 14px;
  background: var(--tk-paper);
  border: var(--tk-border);
  box-shadow: var(--tk-ledge);
  color: var(--tk-ink);
  pointer-events: auto;
  transition: opacity 0.45s ease;
}
.tk-dhud__learn[data-fading="true"] { opacity: 0; pointer-events: none; }
.tk-dhud__learn-title { font: 400 14px/1 var(--tk-font-display); text-transform: uppercase; letter-spacing: 0.04em; }
.tk-dhud__learn-row { display: flex; align-items: flex-end; gap: 26px; }
.tk-dhud__learn-group { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 92px; }
.tk-dhud__learn-picture { display: flex; align-items: flex-end; justify-content: center; height: 66px; }
.tk-dhud__learn-label { font: 400 16px/1 var(--tk-font-display); text-transform: uppercase; }
.tk-dhud__learn-note { font: 600 12px/1.2 var(--tk-font-ui); color: color-mix(in srgb, var(--tk-ink) 70%, transparent); white-space: nowrap; }
.tk-dhud__pad { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.tk-dhud__pad-row { display: flex; gap: 4px; }
.tk-dhud__cap {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  box-sizing: border-box;
  background: var(--tk-paper);
  border: 2px solid var(--tk-ink);
  box-shadow: 0 3px 0 var(--tk-ink);
  font: 700 15px/1 var(--tk-font-ui);
  animation: tk-dhud-cap 1.4s steps(2, jump-none) infinite;
}
.tk-dhud__cap[data-key="up"], .tk-dhud__cap[data-key="down"] { background: var(--tk-sun); }
@keyframes tk-dhud-cap { to { transform: translateY(2px); box-shadow: 0 1px 0 var(--tk-ink); } }
.tk-dhud__mouse {
  position: relative;
  display: flex;
  width: 38px;
  height: 58px;
  box-sizing: border-box;
  background: var(--tk-paper);
  border: 3px solid var(--tk-ink);
  box-shadow: 0 3px 0 var(--tk-ink);
}
.tk-dhud__mouse-button { flex: 1; height: 22px; border-bottom: 3px solid var(--tk-ink); }
.tk-dhud__mouse-button:first-child { border-right: 3px solid var(--tk-ink); }
.tk-dhud__mouse[data-lit="true"] .tk-dhud__mouse-button:first-child { background: var(--tk-coral); animation: tk-dhud-click 0.8s steps(2, jump-none) infinite; }
@keyframes tk-dhud-click { to { background: var(--tk-paper); } }
.tk-dhud__mouse:not([data-lit])::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 34px;
  width: 26px;
  height: 3px;
  margin-left: -13px;
  background: var(--tk-sky);
  box-shadow: 0 0 0 1px var(--tk-ink);
  animation: tk-dhud-nudge 1.2s ease-in-out infinite alternate;
}
@keyframes tk-dhud-nudge { from { transform: translateX(-7px); } to { transform: translateX(7px); } }
.tk-dhud__thumb {
  position: relative;
  width: 56px;
  height: 56px;
  box-sizing: border-box;
  border: 3px solid var(--tk-ink);
  background: color-mix(in srgb, var(--tk-sky) 22%, var(--tk-paper));
}
.tk-dhud__thumb-tip {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  background: var(--tk-ink);
  animation: tk-dhud-nudge 1.2s ease-in-out infinite alternate;
}
.tk-dhud__thumb[data-side="right"] .tk-dhud__thumb-tip { background: var(--tk-coral); }
.tk-dhud__learn-skip {
  padding: 6px 14px;
  background: var(--tk-paper);
  border: 2px solid var(--tk-ink);
  box-shadow: 0 3px 0 var(--tk-ink);
  font: 700 13px/1 var(--tk-font-ui);
  color: var(--tk-ink);
  cursor: pointer;
}
.tk-dhud__learn-skip:hover { background: var(--tk-sun); }
/* The first weld (client/FirstRun weldFlash): the weld row beats in sun yellow. */
.tk-dhud__weld[data-flash="true"] {
  outline: 3px solid var(--tk-sun);
  outline-offset: 3px;
  animation: tk-dhud-weld 0.35s steps(2, jump-none) 8;
}
@keyframes tk-dhud-weld { to { outline-color: var(--tk-coral); outline-offset: 6px; } }
/* The rock to shoot, off the screen: a bigger sun-yellow chevron that beats. */
.tk-dhud__edge[data-mark="true"] { width: 38px; height: 38px; margin: -19px 0 0 -19px; animation: tk-dhud-mark 0.8s ease-in-out infinite alternate; }
@keyframes tk-dhud-mark { to { scale: 1.2; } }
@media (prefers-reduced-motion: reduce) {
  .tk-dhud__cap, .tk-dhud__mouse-button, .tk-dhud__mouse::after, .tk-dhud__thumb-tip, .tk-dhud__weld[data-flash="true"], .tk-dhud__edge[data-mark="true"] { animation: none; }
}
@media (max-width: 760px), (max-height: 500px) {
  .tk-dhud__learn { gap: 6px; padding: 8px 12px 10px; }
  .tk-dhud__learn-row { gap: 16px; }
  .tk-dhud__learn-picture { height: 54px; }
  .tk-dhud__learn-note { display: none; }
}
/* The coach's hint on a first run (2026-10-19): bottom left, where the controls card was, small and
   out of the way of the yard ahead of the bot. */
.tk-dhud__help {
  position: absolute;
  left: var(--hud-edge);
  bottom: calc(var(--hud-edge) + 8px);
  max-width: min(340px, 44vw);
  pointer-events: none;
}
.tk-dhud__help .tk-dhud__coach {
  padding: 8px 12px;
  background: var(--tk-paper);
  color: var(--tk-ink);
  border: var(--tk-border);
  border-left: 8px solid var(--tk-sky);
  box-shadow: var(--tk-ledge-sm);
  font: 700 13px/1.3 var(--tk-font-ui);
  text-align: left;
}
