/* Optix theme.
   The token block below is lifted from apps-launcher/src/client/styles/theme.css
   and kept in the same order, so the two are diffable. Only the dark scheme is
   carried: this is a booth game on a dark road and there is no light variant to
   be had. src/theme.js holds the same palette for the canvas. */
:root {
  --color-background: #121212;
  --color-background-alt: #1e1e1e;
  --color-surface: #1e1e1e;
  --color-surface-alt: #2a2a2a;

  --color-text: #ffffff;
  --color-text-secondary: #b0b0b0;
  --color-text-disabled: #6b6b6b;

  --color-border: #3d3d3d;
  --color-border-light: #525252;
  --color-border-focus: #f26722;

  --color-primary: #f26722;
  --color-primary-rgb: 242, 103, 34;      /* the same, for rgba(): src/brand-page.js sets both for a brand's theme */
  --color-primary-light: #f58b52;
  --color-primary-dark: #d85417;
  --color-primary-contrast: #ffffff;

  --color-success: #22c55e;
  --color-warning: #f59e0b;
  --color-error: #ef4444;

  /* Glass ladder: fill 0.06 -> 0.12 on hover, border 0.1 -> 0.2 on hover. */
  --color-glass-nav: rgba(18, 18, 18, 0.6);
  --color-glass-panel: rgba(18, 18, 18, 0.55);
  --color-glass-floating: rgba(18, 18, 18, 0.94);
  --color-glass-border: rgba(255, 255, 255, 0.08);
  --color-glass-divider: rgba(255, 255, 255, 0.06);
  --color-glass-fill: rgba(255, 255, 255, 0.06);
  --color-glass-fill-hover: rgba(255, 255, 255, 0.12);
  --color-glass-fill-subtle: rgba(255, 255, 255, 0.03);
  --color-glass-control-border: rgba(255, 255, 255, 0.1);
  --color-glass-control-border-hover: rgba(255, 255, 255, 0.2);

  --blur-glass-nav: blur(20px) saturate(1.4);
  --blur-glass-panel: blur(20px) saturate(1.3);
  --shadow-glass: 0 4px 24px rgba(0, 0, 0, 0.3), inset 0 0 0 1px rgba(255, 255, 255, 0.04);

  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;

  --border-radius-md: 4px;
  --border-radius-lg: 8px;
  --border-radius-xl: 12px;

  --typography-caption-font-size: 0.75rem;
  --typography-body2-font-size: 0.875rem;
  --typography-letter-spacing-caps: 0.08em;

  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-family-mono:
    ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --focus-ring-width: 2px;
  --focus-ring-offset: 2px;
  --control-height: 36px;

  --transition-duration-short: 250ms;
  --transition-easing-easeInOut: cubic-bezier(0.4, 0, 0.2, 1);

  /* Game-local. The rails live in the verge beside the road; below the width
     where a verge exists at all, the compact stripe takes over. --road-left and
     --road-right are written by game.resize() on every layout change. */
  --topbar-height: 56px;
  --chrome-top: calc(var(--topbar-height) + env(safe-area-inset-top, 0px));
  --rail-width: 248px;
  --rail-gap: 20px;
  --road-left: 50vw;
  --road-right: 50vw;
  --road-width: 0px;

  color-scheme: dark;
  accent-color: var(--color-primary);
}

@media (prefers-reduced-motion: reduce) {
  :root { --transition-duration-short: 1ms; }
}

* { box-sizing: border-box; }

/* The UA's `[hidden] { display: none }` is a user-agent rule, so any author
   `display:` — .name-form's grid, .screen's contents, .rail's flex — silently
   beats it and the element stays on screen with its hidden attribute set. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--color-background);
  color: var(--color-text);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: var(--typography-body2-font-size);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: var(--font-family-mono); }
.dim { color: var(--color-text-secondary); font-weight: 400; }
.err { color: var(--color-error); }

:where(button, select, input, a):focus-visible {
  outline: var(--focus-ring-width) solid var(--color-border-focus);
  outline-offset: var(--focus-ring-offset);
}

/* ------------------------------- the road -------------------------------- */

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: var(--color-background);
}

#video {
  position: fixed;
  top: -10px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* -------------------------------- chrome --------------------------------- */

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md);
  height: var(--chrome-top);
  padding: env(safe-area-inset-top, 0px) var(--spacing-md) 0;
  background: var(--color-glass-nav);
  backdrop-filter: var(--blur-glass-nav);
  -webkit-backdrop-filter: var(--blur-glass-nav);
  border-bottom: 1px solid var(--color-glass-border);
}

.brand { display: flex; align-items: center; gap: var(--spacing-md); min-width: 0; overflow: hidden; }
.brand-logo { height: 20px; width: auto; display: block; }
.brand-logo:not([src]) { visibility: hidden; }   /* until brand-page.js names the brand's: never another brand's */
/* In the games the logo goes back to the hub (index.html). Pointer only: tabindex="-1"
   keeps it out of the tab order, so it never takes the focus a title screen's Enter
   relies on. */
.brand-home { display: block; flex: none; transition: opacity var(--transition-duration-short) var(--transition-easing-easeInOut); }
.brand-home:hover { opacity: 0.7; }
.brand-rule { width: 1px; height: 20px; background: var(--color-glass-border); }
.brand-name {
  font-size: var(--typography-caption-font-size);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--typography-letter-spacing-caps);
  text-transform: uppercase;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.topbar-right { display: flex; align-items: center; gap: var(--spacing-sm); min-width: 0; }

/* The chrome sheds its least useful parts as the window narrows, in the order
   a booth operator would give them up. */
@media (max-width: 1240px) {
  .brand-name, .brand-rule { display: none; }
}
@media (max-width: 1000px) {
  .topbar-right kbd { display: none; }
  .control { max-width: 132px; }
  /* Collapse to the indicator dot rather than dropping it: the attract screen
     still carries the full sentence, so this only has to stay present. */
  .privacy-chip { font-size: 0; gap: 0; padding: 0 10px; }
}
@media (max-width: 800px) {
  #btnFullscreen { display: none; }
  .topbar { padding: 0 var(--spacing-sm); }
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
  height: var(--control-height);
  padding: 0 12px;
  border-radius: 999px;
  background: var(--color-glass-fill-subtle);
  border: 1px solid var(--color-glass-border);
  color: var(--color-text-secondary);
  font-size: var(--typography-caption-font-size);
  text-transform: uppercase;
  letter-spacing: var(--typography-letter-spacing-caps);
  white-space: nowrap;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-text-disabled);
  transition: background var(--transition-duration-short) var(--transition-easing-easeInOut);
}
.dot.live { background: var(--color-success); box-shadow: 0 0 8px var(--color-success); }
.dot.busy { background: var(--color-warning); box-shadow: 0 0 8px var(--color-warning); }
.dot.err  { background: var(--color-error); box-shadow: 0 0 8px var(--color-error); }

/* ------------------------------- controls -------------------------------- */

.btn, .control {
  font: inherit;
  font-size: var(--typography-caption-font-size);
  height: var(--control-height);
  padding: 0 12px;
  color: var(--color-text);
  background: var(--color-glass-fill);
  border: 1px solid var(--color-glass-control-border);
  border-radius: var(--border-radius-lg);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
  white-space: nowrap;
  transition:
    background var(--transition-duration-short) var(--transition-easing-easeInOut),
    border-color var(--transition-duration-short) var(--transition-easing-easeInOut);
}
.btn:hover, .control:hover {
  background: var(--color-glass-fill-hover);
  border-color: var(--color-glass-control-border-hover);
}
.btn.ghost { background: transparent; }
a.btn { text-decoration: none; }
.btn.ghost:hover { background: var(--color-glass-fill); }
.btn.primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-primary-contrast);
  font-weight: var(--font-weight-semibold);
}
.btn.primary:hover { background: var(--color-primary-light); border-color: var(--color-primary-light); }
.btn.big {
  height: 44px;
  padding: 0 var(--spacing-lg);
  font-size: var(--typography-body2-font-size);
}
.btn[disabled] { opacity: 0.45; pointer-events: none; }
/* Muted is a state, not a disabled control — it stays fully clickable and says
   so by going quiet rather than by going grey. */
.btn.is-off { color: var(--color-text-disabled); border-style: dashed; }

.control { cursor: pointer; max-width: 190px; }
select.control { padding-right: var(--spacing-sm); }
input.control { cursor: text; }

kbd {
  font: 10px/1.6 var(--font-family-mono);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--color-glass-border);
  border-radius: var(--border-radius-md);
  padding: 1px 5px;
  color: var(--color-text-secondary);
}
.btn.primary kbd { background: rgba(0, 0, 0, 0.22); border-color: rgba(255, 255, 255, 0.2); color: #fff; }

/* --------------------------------- rails --------------------------------- */

.rail {
  position: fixed;
  top: calc(var(--chrome-top) + var(--spacing-md));
  bottom: var(--spacing-md);
  width: var(--rail-width);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  pointer-events: none;
}
/* Docked to the verge rather than to the window edge, and capped, so on a wide
   monitor the instruments sit beside the road instead of in the far corners.
   Both edges are pinned and the auto margin picks which one the cap hugs. */
.rail { width: auto; max-width: var(--rail-width); }
.rail-left {
  left: var(--spacing-md);
  right: calc(100% - var(--road-left) + var(--rail-gap));
  margin-left: auto;
  margin-right: 0;
}
.rail-right {
  left: calc(100% - var(--road-right) + var(--rail-gap));
  right: var(--spacing-md);
  margin-left: 0;
  margin-right: auto;
  align-items: stretch;
}

.card {
  background: var(--color-glass-panel);
  backdrop-filter: var(--blur-glass-panel);
  -webkit-backdrop-filter: var(--blur-glass-panel);
  border: 1px solid var(--color-glass-border);
  border-radius: var(--border-radius-xl);
  box-shadow: var(--shadow-glass);
  padding: var(--spacing-md);
}
.card-title {
  margin: 0 0 var(--spacing-sm);
  font-size: var(--typography-caption-font-size);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--typography-letter-spacing-caps);
  color: var(--color-text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--spacing-sm);
}
.card-note { margin: 0; font-size: var(--typography-caption-font-size); color: var(--color-text-disabled); }

/* Gauges. Tabular numerals throughout, because a score that reflows as it
   counts up reads as broken rather than as fast. */
.gauge { display: flex; flex-direction: column; gap: 2px; padding: 10px var(--spacing-md); }
.gauge-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: var(--typography-letter-spacing-caps);
  color: var(--color-text-secondary);
}
.gauge-value {
  font-family: var(--font-family-mono);
  font-size: 1.5rem;
  font-weight: var(--font-weight-semibold);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.gauge-value small { font-size: 0.75rem; color: var(--color-text-secondary); margin-left: 3px; }
.gauge-primary { border-color: rgba(var(--color-primary-rgb), 0.35); }
.gauge-primary .gauge-value { font-size: 2.25rem; color: var(--color-primary); }

/* Leaderboard. */
.board { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.board li {
  display: grid;
  grid-template-columns: 1.4rem 1fr auto;
  align-items: baseline;
  gap: var(--spacing-sm);
  padding: 5px 6px;
  border-radius: var(--border-radius-md);
  font-size: var(--typography-caption-font-size);
}
.board li:nth-child(odd) { background: var(--color-glass-fill-subtle); }
.board li.is-new {
  background: rgba(var(--color-primary-rgb), 0.18);
  box-shadow: inset 0 0 0 1px rgba(var(--color-primary-rgb), 0.45);
}
.board .rank { color: var(--color-text-disabled); font-family: var(--font-family-mono); }
.board li:nth-child(1) .rank { color: var(--color-primary); }
.board .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .pts { font-family: var(--font-family-mono); font-variant-numeric: tabular-nums; font-weight: var(--font-weight-semibold); }

/* Compact cluster for windows with no verge to spare. */
.stripe {
  position: fixed;
  top: calc(var(--chrome-top) + var(--spacing-sm));
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: none;
  gap: var(--spacing-md);
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--color-glass-panel);
  backdrop-filter: var(--blur-glass-panel);
  -webkit-backdrop-filter: var(--blur-glass-panel);
  border: 1px solid var(--color-glass-border);
  font-size: var(--typography-caption-font-size);
  color: var(--color-text-secondary);
  white-space: nowrap;
}
.stripe b {
  font-family: var(--font-family-mono);
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
}

@media (max-width: 1180px) {
  .rail { display: none; }
  .stripe { display: flex; }
}

/* ----------------------------- centre screens ---------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--chrome-top) + var(--spacing-md)) var(--spacing-md) var(--spacing-md);
  pointer-events: none;
}
.screen { display: contents; }

.scrim {
  pointer-events: auto;
  max-width: 480px;
  padding: var(--spacing-xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-md);
  text-align: center;
  background: var(--color-glass-floating);
  backdrop-filter: var(--blur-glass-panel);
  -webkit-backdrop-filter: var(--blur-glass-panel);
  border: 1px solid var(--color-glass-border);
  border-radius: var(--border-radius-xl);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55), var(--shadow-glass);
  animation: rise var(--transition-duration-short) var(--transition-easing-easeInOut);
}
.scrim-wide { max-width: 560px; }

/* While the rails are docked to the verge, the only space a modal can have is
   the road plus its two gaps — anything wider slices through the instruments
   and reads as a bug rather than as a layer. Below the rails' breakpoint there
   is nothing to avoid and the card takes its natural width. */
@media (min-width: 1181px) {
  .scrim, .scrim-wide {
    max-width: min(560px, calc(var(--road-width) + 2 * var(--rail-gap) - 8px));
  }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .scrim { animation: none; }
}

.eyebrow {
  margin: 0;
  font-size: var(--typography-caption-font-size);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--typography-letter-spacing-caps);
  color: var(--color-primary);
}
.scrim h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.15;
  letter-spacing: -0.01em;
  font-weight: var(--font-weight-semibold);
}
.scrim h2 { margin: 0; font-size: 1.25rem; font-weight: var(--font-weight-semibold); line-height: 1.3; }
.scrim p { margin: 0; color: var(--color-text-secondary); }
.scrim .lede { color: var(--color-text); }

.warn-line {
  margin: 0;
  padding: 8px 12px;
  border-radius: var(--border-radius-lg);
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: var(--color-text);
  font-size: var(--typography-caption-font-size);
}

/* Privacy surfaces. A booth grants camera permission once at setup, so no player
   after that ever sees the browser's own prompt — these are the only notice they
   get, which is why one of them is always on screen rather than tucked into a
   screen they might skip. Deliberately quiet: it is a reassurance, not a warning,
   and styling it as an alert would imply there is something to be alarmed about. */
.privacy-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  height: var(--control-height);
  padding: 0 12px;
  border-radius: 999px;
  background: var(--color-glass-fill-subtle);
  border: 1px solid var(--color-glass-border);
  color: var(--color-text-secondary);
  font-size: var(--typography-caption-font-size);
  text-transform: uppercase;
  letter-spacing: var(--typography-letter-spacing-caps);
  white-space: nowrap;
  cursor: default;
}
.privacy-chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-success);
  flex: none;
}

.privacy-note {
  margin: 0;
  padding: 8px 12px;
  border-radius: var(--border-radius-lg);
  background: var(--color-glass-fill-subtle);
  border: 1px solid var(--color-glass-border);
  color: var(--color-text-secondary);
  font-size: var(--typography-caption-font-size);
  line-height: 1.45;
  max-width: 46ch;
}
.privacy-note strong { color: var(--color-text); font-weight: var(--font-weight-semibold); }

.howto {
  display: grid;
  gap: var(--spacing-sm);
  width: 100%;
  text-align: left;
  margin-top: var(--spacing-xs);
}
.howto-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--border-radius-lg);
  background: var(--color-glass-fill-subtle);
  border: 1px solid var(--color-glass-divider);
  font-size: var(--typography-caption-font-size);
  color: var(--color-text-secondary);
}
.howto-n {
  flex: none;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-primary-contrast);
  font-size: 0.6875rem;
  font-weight: var(--font-weight-semibold);
}

.cta-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-md);
  flex-wrap: wrap;
  margin-top: var(--spacing-xs);
}

.bar-track {
  width: 100%;
  max-width: 320px;
  height: 6px;
  border-radius: 999px;
  background: var(--color-glass-fill);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 0;
  background: var(--color-primary);
  transition: width 80ms linear;
}

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--color-glass-fill);
  border-top-color: var(--color-primary);
  animation: spin 900ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* Countdown: no card, just the number on the open road ahead of the truck —
   centred vertically it lands squarely on the cab, which reads as a mistake. */
.countdown {
  align-self: flex-start;
  margin-top: 12vh;
  pointer-events: none;
  font-family: var(--font-family-mono);
  font-size: clamp(6rem, 22vh, 14rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--color-primary);
  text-shadow: 0 0 40px rgba(var(--color-primary-rgb), 0.55), 0 8px 40px rgba(0, 0, 0, 0.8);
  line-height: 1;
  animation: pop 400ms var(--transition-easing-easeInOut);
}
@keyframes pop {
  from { opacity: 0; transform: scale(1.35); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) { .countdown { animation: none; } }

/* Result. */
.score-hero { display: flex; flex-direction: column; align-items: center; gap: 0; }
.score-hero-value {
  font-family: var(--font-family-mono);
  font-size: 4.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--color-primary);
}
.score-hero-label {
  font-size: var(--typography-caption-font-size);
  text-transform: uppercase;
  letter-spacing: var(--typography-letter-spacing-caps);
  color: var(--color-text-secondary);
}

/* Four tiles across a card whose width is set by the road. The longest label
   ("Near misses") wraps to two lines on a narrow road and the row stays even,
   which is why the tiles are not auto-fit — three-plus-an-orphan is worse than
   a wrapped word. */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--spacing-sm);
  width: 100%;
  margin: 0;
}
.stats > div {
  padding: var(--spacing-sm);
  border-radius: var(--border-radius-lg);
  background: var(--color-glass-fill-subtle);
  border: 1px solid var(--color-glass-divider);
}
.stats dt {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: var(--typography-letter-spacing-caps);
  color: var(--color-text-secondary);
}
.stats dd {
  margin: 2px 0 0;
  font-family: var(--font-family-mono);
  font-variant-numeric: tabular-nums;
  font-weight: var(--font-weight-semibold);
}

.name-form {
  width: 100%;
  display: grid;
  gap: var(--spacing-sm);
  padding: var(--spacing-md);
  border-radius: var(--border-radius-lg);
  background: rgba(var(--color-primary-rgb), 0.10);
  border: 1px solid rgba(var(--color-primary-rgb), 0.35);
}
.name-form label { font-size: var(--typography-caption-font-size); color: var(--color-text); }
.name-row { display: flex; gap: var(--spacing-sm); }
.name-row .control { flex: 1; max-width: none; }

@media (max-width: 560px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .scrim { padding: var(--spacing-lg); }
  .scrim h1 { font-size: 1.5rem; }
  .score-hero-value { font-size: 3rem; }
}

/* ------------------------------ debug drawer ----------------------------- */

.panel {
  position: fixed;
  top: var(--chrome-top);
  right: 0;
  bottom: 0;
  z-index: 40;
  width: 396px;
  max-width: 100vw;
  overflow-y: auto;
  padding: 0 var(--spacing-lg) var(--spacing-xl);
  background: var(--color-glass-floating);
  backdrop-filter: var(--blur-glass-panel);
  -webkit-backdrop-filter: var(--blur-glass-panel);
  border-left: 1px solid var(--color-glass-border);
  box-shadow: -16px 0 48px rgba(0, 0, 0, 0.45);
}
.panel.hidden { display: none; }
.panel-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md);
  padding: var(--spacing-md) 0;
  margin-bottom: var(--spacing-xs);
  background: var(--color-glass-floating);
  border-bottom: 1px solid var(--color-glass-divider);
  font-weight: var(--font-weight-semibold);
}

.block { padding: var(--spacing-md) 0; border-bottom: 1px solid var(--color-glass-divider); }
.block:last-child { border-bottom: 0; }
.block-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.6875rem;
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--typography-letter-spacing-caps);
  color: var(--color-text-secondary);
  margin-bottom: 10px;
}
.preview-wrap { line-height: 0; }
#preview, #trace {
  width: 100%;
  border-radius: var(--border-radius-lg);
  background: #0a0a0a;
  border: 1px solid var(--color-glass-border);
}
.note { font-size: var(--typography-caption-font-size); color: var(--color-text-secondary); margin-top: var(--spacing-sm); min-height: 1em; }
.note.warn { color: var(--color-warning); }
.hint { font-size: var(--typography-caption-font-size); color: var(--color-text-secondary); line-height: 1.6; }
.hint b { color: var(--color-text); font-variant-numeric: tabular-nums; }

.readout {
  margin-top: 9px;
  font-size: 11.5px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px 14px;
}
.readout span { color: var(--color-text-secondary); }
.readout b { float: right; font-weight: var(--font-weight-semibold); font-variant-numeric: tabular-nums; color: var(--color-text); }

.ctl { margin-bottom: 13px; }
.ctl-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: var(--typography-caption-font-size);
  margin-bottom: 5px;
}
.ctl-head b {
  font-family: var(--font-family-mono);
  font-weight: var(--font-weight-semibold);
  font-size: 11.5px;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
}
.ctl-help { font-size: 11px; color: var(--color-text-secondary); margin-top: var(--spacing-xs); line-height: 1.45; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: var(--color-glass-fill);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
  border: 2px solid var(--color-background);
}
input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
  border: 2px solid var(--color-background);
}
.ctl .control, .ctl select { width: 100%; max-width: none; }
.switch { display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: var(--typography-caption-font-size); }
.switch input { accent-color: var(--color-primary); width: 15px; height: 15px; cursor: pointer; }
.row { display: flex; gap: var(--spacing-sm); margin-top: var(--spacing-md); flex-wrap: wrap; }
.keys { font-size: var(--typography-caption-font-size); color: var(--color-text-secondary); display: grid; gap: 5px; }

/* The drawer would sit on top of the right rail; move the rail out of its way
   rather than letting two panels fight over the same pixels. */
body.debug-open .rail-right { right: calc(396px + var(--spacing-md)); }
@media (max-width: 1700px) {
  body.debug-open .rail-right { display: none; }
}
