/* ==========================================================================
   NOUMA · the world — a full-bleed HUD over a living field

   The page IS the artwork. Everything else floats above it as a fixed instrument
   panel; the document never scrolls, because a swarm that scrolls is a report
   about a swarm rather than a view of one.

   Three layers, bottom to top:

     0  #world-field   the canvas: the swarm, the flow field, the market aura
     2  .hud-vignette  a soft radial darkening, so the eye lands on the middle
     3  .hud-grain     a static paper tooth, normally composited and cached
     10 .hud-panel     the four corner instruments

   Performance note that drives several choices below: the field repaints every
   frame, so nothing above it may use `backdrop-filter` or a heavy blend mode —
   either forces the whole scene to re-composite per frame, and the cost lands on
   the canvas rather than on the panel. Panels therefore use a plain translucent
   fill, and the grain is a static overlay the compositor can cache.

   Typography: no webfont is added. The three already shipped do the work through
   weight, size and tracking — Space Grotesk at 300 weight and display sizes reads
   as a scientific plate, and JetBrains Mono carries every figure. Adding a fourth
   face would put a network request on the critical path of the landing screen to
   buy a shape nobody can name.
   ========================================================================== */

:root {
  /* --- the live palette. `world.ts` retints these from the market temperature,
         so the whole scene warms toward hot and cools toward cold. --- */
  --hud-paper: #f2eee6;
  /* Nearly opaque on purpose. At 0.87 the swarm showed through the panels, which read as dirty
     glass rather than as an instrument. The field is still visible around them, which is the point. */
  --hud-panel: rgba(244, 240, 232, 0.94);
  --hud-ink: #1a1a18;
  --hud-ink-rgb: 26, 26, 24;
  --hud-accent: #9a8c6e;
  --hud-accent-rgb: 154, 140, 110;
  --hud-hair: rgba(26, 26, 24, 0.14);
  --hud-muted: rgba(26, 26, 24, 0.5);

  /* --- the four behaviour colours, fixed rather than temperature-derived: they
         identify a state, and a state that changes colour with the weather is a
         state nobody can learn. --- */
  --hud-agitate: #c05e3c;
  --hud-explore: #c99a3f;
  --hud-aggregate: #5b7c8d;
  --hud-rest: #8b9a86;

  --hud-display: "Space Grotesk", system-ui, sans-serif;
  --hud-mono: "JetBrains Mono", ui-monospace, monospace;

  --hud-pad: clamp(14px, 2.4vw, 28px);
}

/* --------------------------------------------------------------------------
   the page
   -------------------------------------------------------------------------- */

.world-page {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--hud-paper);
  color: var(--hud-ink);
  transition: background 1.6s linear;
}

/* The shell normally wraps every screen in a padded, scrollable column. The
   world is the one screen that must escape it, so the wrapper is flattened for
   the duration — a `position: fixed` child inside a transformed or constrained
   ancestor would be clipped to it, which is how a "full-bleed" canvas ends up
   400px tall. */
.shell-content:has(.world-page) {
  display: block;
  overflow: hidden;
  padding: 0;
}

.world-field {
  position: fixed;
  inset: 0;
  display: block;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  cursor: crosshair;
}

/* A static paper tooth. `background-image` rather than a second canvas so the
   compositor caches it once instead of repainting noise every frame. */
.hud-grain {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.hud-vignette {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(
    120% 90% at 50% 45%,
    transparent 40%,
    rgba(var(--hud-ink-rgb), 0.07) 100%
  );
}

/* --------------------------------------------------------------------------
   the top bar
   -------------------------------------------------------------------------- */

.hud-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: var(--hud-pad);
  pointer-events: none;
}

.hud-topbar > * {
  pointer-events: auto;
}

.hud-wordmark {
  display: flex;
  align-items: baseline;
  gap: 9px;
}

.hud-wordmark .mark {
  fill: var(--hud-accent);
  opacity: 0.9;
  transform: translateY(3px);
  transition: fill 1.6s linear;
}

.hud-wordmark .name {
  font-family: var(--hud-display);
  font-weight: 400;
  font-size: clamp(20px, 2.6vw, 28px);
  letter-spacing: 0.02em;
  color: var(--hud-ink);
}

.hud-topmeta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--hud-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: lowercase;
  color: var(--hud-muted);
}

.hud-topmeta .sep {
  opacity: 0.4;
}

/* The one motion in the chrome: a status dot that breathes when the link is up.
   Motion on a *state* is allowed; motion on a *value* would say the value is
   unstable, which is a different and false claim. */
.hud-link-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(var(--hud-ink-rgb), 0.3);
  transition: background 0.6s ease;
}

.hud-link-dot[data-tone="ok"] {
  background: var(--hud-accent);
}

@media (prefers-reduced-motion: no-preference) {
  .hud-link-dot[data-tone="ok"] {
    animation: hud-breathe 3.4s ease-in-out infinite;
  }
}

@keyframes hud-breathe {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(var(--hud-accent-rgb), 0.45);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(var(--hud-accent-rgb), 0);
  }
}

.hud-topmeta .hud-chip {
  font-family: var(--hud-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--hud-muted);
  background: transparent;
  border: 1px solid var(--hud-hair);
  border-radius: 2px;
  padding: 4px 7px;
  cursor: pointer;
  transition: color 0.25s, border-color 0.25s;
}

.hud-topmeta .hud-chip:hover {
  color: var(--hud-ink);
  border-color: rgba(var(--hud-accent-rgb), 0.55);
}

/* --------------------------------------------------------------------------
   the corner instruments
   -------------------------------------------------------------------------- */

.hud-panel {
  position: fixed;
  z-index: 10;
  background: var(--hud-panel);
  border: 1px solid var(--hud-hair);
  border-radius: 2px;
  padding: 14px 16px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 8px 30px rgba(var(--hud-ink-rgb), 0.05);
  transition:
    background 1.6s linear,
    border-color 1.6s linear,
    opacity 0.45s ease;
}

.hud-panel-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  font-family: var(--hud-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--hud-muted);
}

/* --- economy, top-left --- */

.hud-panel-econ {
  left: var(--hud-pad);
  top: calc(var(--hud-pad) + 46px);
  width: clamp(290px, 27vw, 360px);
}

.hud-econ-mode {
  font-family: var(--hud-mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--hud-accent);
  border: 1px solid rgba(var(--hud-accent-rgb), 0.4);
  border-radius: 2px;
  padding: 1px 5px;
}

.hud-hero {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.hud-hero-value {
  font-family: var(--hud-display);
  font-weight: 300;
  font-size: clamp(30px, 4.6vw, 46px);
  line-height: 1;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--hud-ink);
}

.hud-hero-unit {
  font-family: var(--hud-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--hud-muted);
}

/* --- the micro grids: two columns of name-over-value, ruling line above --- */

.hud-micro {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px 14px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--hud-hair);
}

.hud-micro > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.hud-micro dt {
  font-family: var(--hud-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--hud-muted);
}

.hud-micro dd {
  margin: 0;
  font-family: var(--hud-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--hud-ink);
  opacity: 0.88;
}

/* --- the decision feed, inside the economy panel --- */

.hud-feed {
  margin-top: 12px;
  max-height: 118px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-family: var(--hud-mono);
  font-size: 10px;
  color: var(--hud-muted);
}

.hud-feed-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-feed-row .who {
  color: var(--hud-ink);
  opacity: 0.75;
}

.hud-feed-row .kind {
  margin-left: auto;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  color: var(--hud-accent);
}

/* A quiet tick, said once rather than forty-eight times. */
.hud-feed-quiet {
  font-family: var(--hud-mono);
  font-size: 10px;
  line-height: 1.6;
  color: var(--hud-muted);
  font-style: italic;
}

/* --- temperature, bottom-left --- */

.hud-panel-temp {
  left: var(--hud-pad);
  bottom: var(--hud-pad);
  width: clamp(250px, 27vw, 340px);
}

.hud-regime-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.hud-regime {
  font-family: var(--hud-display);
  font-weight: 600;
  font-size: clamp(19px, 2.4vw, 25px);
  letter-spacing: 0.04em;
  text-transform: lowercase;
  color: var(--hud-accent);
  transition: color 1.2s linear;
}

.hud-temp-value {
  font-family: var(--hud-mono);
  font-weight: 300;
  font-size: clamp(15px, 1.9vw, 19px);
  font-variant-numeric: tabular-nums;
  color: var(--hud-ink);
  opacity: 0.82;
}

/* The meter is three pixels tall and carries one value. A gradient would suggest
   a range the swarm is not currently in. */
.hud-meter {
  position: relative;
  height: 3px;
  margin: 12px 0 6px;
  background: rgba(var(--hud-ink-rgb), 0.1);
  border-radius: 2px;
}

.hud-meter-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 50%;
  border-radius: 2px;
  background: var(--hud-accent);
  transition:
    width 1.1s cubic-bezier(0.22, 1, 0.36, 1),
    background 1.2s linear;
}

.hud-meter-tick {
  position: absolute;
  top: -3px;
  width: 1px;
  height: 9px;
  background: rgba(var(--hud-ink-rgb), 0.28);
}

.hud-meter-scale {
  display: flex;
  justify-content: space-between;
  font-family: var(--hud-mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--hud-muted);
  opacity: 0.7;
}

.hud-spark {
  display: block;
  width: 100%;
  height: 40px;
  margin-top: 12px;
}

/* --- population, top-right --- */

.hud-panel-pop {
  right: var(--hud-pad);
  top: calc(var(--hud-pad) + 46px);
  width: clamp(226px, 24vw, 296px);
}

.hud-pop-size {
  font-family: var(--hud-mono);
  font-size: 12px;
  color: var(--hud-accent);
  opacity: 0.9;
}

.hud-dist {
  display: flex;
  gap: 2px;
  height: 8px;
  margin-bottom: 10px;
}

.hud-dist-seg {
  height: 100%;
  min-width: 0;
  border-radius: 1px;
  transition: flex-grow 1s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s;
}

.hud-dist-seg[data-behaviour="agitate"] {
  background: var(--hud-agitate);
}
.hud-dist-seg[data-behaviour="explore"] {
  background: var(--hud-explore);
}
.hud-dist-seg[data-behaviour="aggregate"] {
  background: var(--hud-aggregate);
}
.hud-dist-seg[data-behaviour="rest"] {
  background: var(--hud-rest);
}
.hud-dist-seg[data-empty="true"] {
  opacity: 0.14;
}

.hud-dist-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px 12px;
}

.hud-dist-legend li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--hud-mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--hud-muted);
}

.hud-dist-legend .sw {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.hud-dist-legend b {
  margin-left: auto;
  font-weight: 500;
  color: var(--hud-ink);
  font-variant-numeric: tabular-nums;
}

/* --- about, bottom-right --- */

.hud-panel-about {
  right: var(--hud-pad);
  bottom: var(--hud-pad);
  width: clamp(250px, 27vw, 344px);
}

.hud-about-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.hud-about-head .hud-panel-title {
  margin-bottom: 0;
}

.hud-about-body {
  font-family: var(--hud-mono);
  font-size: 10.5px;
  line-height: 1.72;
  color: var(--hud-ink);
  opacity: 0.82;
}

.hud-about-points {
  list-style: none;
  margin: 10px 0 0;
  padding: 10px 0 0;
  border-top: 1px solid var(--hud-hair);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.hud-about-points li {
  position: relative;
  padding-left: 12px;
  font-family: var(--hud-mono);
  font-size: 9.5px;
  line-height: 1.55;
  color: var(--hud-muted);
}

.hud-about-points li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 6px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--hud-accent);
  opacity: 0.8;
}

/* --------------------------------------------------------------------------
   actions
   -------------------------------------------------------------------------- */

.hud-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 12px;
}

.hud-btn {
  font-family: var(--hud-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: lowercase;
  color: var(--hud-muted);
  background: transparent;
  border: 1px solid var(--hud-hair);
  border-radius: 2px;
  padding: 5px 9px;
  cursor: pointer;
  transition: color 0.25s, border-color 0.25s, background 0.25s;
}

.hud-btn:hover,
.hud-btn:focus-visible {
  color: var(--hud-ink);
  border-color: rgba(var(--hud-accent-rgb), 0.55);
  background: rgba(var(--hud-accent-rgb), 0.08);
}

/* --------------------------------------------------------------------------
   the drawer

   One drawer, reused. It takes over the right edge and dims the panels behind
   it rather than covering them with a scrim: the field stays visible, because a
   drawer that hides the swarm is a drawer that has replaced the piece.
   -------------------------------------------------------------------------- */

.hud-drawer {
  position: fixed;
  z-index: 20;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(560px, 92vw);
  display: flex;
  flex-direction: column;
  background: var(--hud-panel);
  border-left: 1px solid var(--hud-hair);
  box-shadow: -18px 0 60px rgba(var(--hud-ink-rgb), 0.12);
  transform: translateX(101%);
  visibility: hidden;
  transition:
    transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s linear 0.5s,
    background 1.6s linear;
}

.hud-drawer[data-open="true"] {
  transform: translateX(0);
  visibility: visible;
  transition:
    transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s,
    background 1.6s linear;
}

@media (prefers-reduced-motion: reduce) {
  .hud-drawer,
  .hud-drawer[data-open="true"] {
    transition: none;
  }
}

.hud-drawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--hud-hair);
}

.hud-drawer-title {
  font-family: var(--hud-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--hud-muted);
}

.hud-drawer-sub {
  flex: 1;
  font-family: var(--hud-mono);
  font-size: 9.5px;
  color: var(--hud-accent);
  opacity: 0.9;
}

.hud-drawer-close {
  font-family: var(--hud-mono);
  font-size: 15px;
  line-height: 1;
  color: var(--hud-muted);
  background: transparent;
  border: 0;
  padding: 4px 6px;
  cursor: pointer;
  transition: color 0.25s, transform 0.25s;
}

.hud-drawer-close:hover {
  color: var(--hud-ink);
  transform: rotate(90deg);
}

.hud-drawer-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 18px 28px;
  font-family: var(--hud-mono);
  font-size: 11px;
  line-height: 1.65;
  color: var(--hud-ink);
}

/* panels recede while the drawer is out, but stay readable enough to orient by */
.hud-page[data-drawer="true"] .hud-panel {
  opacity: 0.12;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   the drawer's own tables — defined here rather than in styles.css so the world
   screen owns everything it renders
   -------------------------------------------------------------------------- */

.hud-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--hud-mono);
  font-size: 10.5px;
}

.hud-table th {
  position: sticky;
  top: 0;
  padding: 6px 8px;
  text-align: left;
  font-weight: 500;
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--hud-muted);
  background: var(--hud-paper);
  border-bottom: 1px solid var(--hud-hair);
}

.hud-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(var(--hud-ink-rgb), 0.06);
  font-variant-numeric: tabular-nums;
  vertical-align: baseline;
}

.hud-table tr:hover td {
  background: rgba(var(--hud-accent-rgb), 0.06);
}

.hud-stage {
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 2px;
  border: 1px solid var(--hud-hair);
  color: var(--hud-muted);
}

.hud-stage[data-stage="ADULT"] {
  color: var(--hud-accent);
  border-color: rgba(var(--hud-accent-rgb), 0.5);
}
.hud-stage[data-stage="ELDER"] {
  color: var(--hud-explore);
}
.hud-stage[data-stage="DEATH"] {
  opacity: 0.45;
}

/* the empty and error states, because a panel with nothing to show must say so
   rather than render a convincing zero */
.hud-empty {
  padding: 18px 0;
  font-family: var(--hud-mono);
  font-size: 10.5px;
  line-height: 1.7;
  color: var(--hud-muted);
}

.hud-alert {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 9px;
  margin-bottom: 6px;
  border-left: 2px solid var(--hud-hair);
  background: rgba(var(--hud-ink-rgb), 0.03);
  font-size: 10.5px;
  line-height: 1.55;
}

.hud-alert[data-level="L3"] {
  border-left-color: #ff5470;
}
.hud-alert[data-level="L2"] {
  border-left-color: var(--hud-explore);
}
.hud-alert[data-level="L1"] {
  border-left-color: var(--hud-aggregate);
}

.hud-alert .lvl {
  flex: none;
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--hud-muted);
}

/* --------------------------------------------------------------------------
   deep data drawer: trust network, lineage & individual fly profile
   -------------------------------------------------------------------------- */

.hud-section-title {
  margin: 18px 0 8px;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--hud-muted);
  border-bottom: 1px solid var(--hud-hair);
  padding-bottom: 4px;
}

.hud-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.hud-stat-card {
  padding: 8px 10px;
  background: rgba(var(--hud-ink-rgb), 0.025);
  border: 1px solid var(--hud-hair);
  border-radius: 2px;
}

.hud-stat-card .label {
  font-size: 8.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--hud-muted);
  margin-bottom: 3px;
}

.hud-stat-card .value {
  font-family: var(--hud-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--hud-ink);
  font-variant-numeric: tabular-nums;
}

.hud-badge {
  display: inline-block;
  padding: 1px 6px;
  font-size: 8.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 2px;
  border: 1px solid var(--hud-hair);
}

.hud-badge[data-tier="FULL_COOP"] {
  color: var(--hud-accent);
  border-color: rgba(var(--hud-accent-rgb), 0.6);
  background: rgba(var(--hud-accent-rgb), 0.08);
}

.hud-badge[data-tier="CAUTIOUS"] {
  color: var(--hud-explore);
  border-color: rgba(184, 150, 78, 0.4);
}

.hud-badge[data-tier="MINIMAL"] {
  color: var(--hud-muted);
}

.hud-badge[data-tier="HOSTILE"] {
  color: #c94444;
  border-color: rgba(201, 68, 68, 0.4);
}

.hud-progress-track {
  width: 100%;
  height: 4px;
  background: rgba(var(--hud-ink-rgb), 0.08);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 4px;
}

.hud-progress-fill {
  height: 100%;
  background: var(--hud-accent);
}

.hud-clickable-row {
  cursor: pointer;
}

.hud-clickable-row:hover td {
  background: rgba(var(--hud-accent-rgb), 0.1) !important;
}

/* --------------------------------------------------------------------------
   Fly Quick Picker Grid (48 Flies Direct Access)
   -------------------------------------------------------------------------- */

.hud-picker-wrap {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--hud-hair);
}

.hud-picker-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 8.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--hud-muted);
  margin-bottom: 6px;
}

.hud-fly-picker {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 3px;
}

.hud-picker-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--hud-mono);
  font-size: 8px;
  border: 1px solid var(--hud-hair);
  border-radius: 2px;
  background: rgba(var(--hud-ink-rgb), 0.03);
  color: var(--hud-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.hud-picker-cell:hover {
  border-color: var(--hud-accent);
  color: var(--hud-ink);
  background: rgba(var(--hud-accent-rgb), 0.18);
  transform: scale(1.15);
  z-index: 2;
}

.hud-picker-cell[data-stage="ADULT"] {
  border-color: rgba(var(--hud-accent-rgb), 0.45);
}

.hud-picker-cell[data-stage="ELDER"] {
  border-color: rgba(184, 150, 78, 0.45);
  color: var(--hud-explore);
}

.hud-picker-cell[data-stage="YOUTH"] {
  border-color: rgba(16, 185, 129, 0.45);
  color: #10b981;
}

/* --------------------------------------------------------------------------
   Lifecycle & Family Lineage UI
   -------------------------------------------------------------------------- */

.hud-life-container {
  margin: 6px 0 16px;
}

.hud-life-labels {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  font-family: var(--hud-mono);
  color: var(--hud-muted);
  margin-bottom: 4px;
}

.hud-life-track {
  width: 100%;
  height: 6px;
  background: rgba(var(--hud-ink-rgb), 0.06);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--hud-hair);
}

.hud-life-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981 0%, #f59e0b 60%, #ef4444 100%);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.hud-kinship-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.hud-kinship-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--hud-mono);
  font-size: 9.5px;
  padding: 3px 8px;
  border: 1px solid var(--hud-hair);
  border-radius: 3px;
  background: rgba(var(--hud-ink-rgb), 0.03);
  color: var(--hud-ink);
  cursor: pointer;
  transition: all 0.2s ease;
}

.hud-kinship-chip:hover {
  border-color: var(--hud-accent);
  background: rgba(var(--hud-accent-rgb), 0.12);
  color: var(--hud-accent);
}

/* --------------------------------------------------------------------------
   Dual-Mode Switcher: Human HUD <-> Agent 402 Terminal
   -------------------------------------------------------------------------- */

.hud-mode-pill {
  display: inline-flex;
  align-items: center;
  background: rgba(var(--hud-ink-rgb), 0.05);
  border: 1px solid var(--hud-hair);
  border-radius: 20px;
  padding: 2px;
  margin-right: 8px;
  gap: 2px;
}

.hud-mode-btn {
  font-family: var(--hud-mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  padding: 3px 9px;
  border-radius: 16px;
  border: none;
  background: transparent;
  color: var(--hud-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.hud-mode-btn.is-active {
  background: var(--hud-ink);
  color: var(--hud-paper);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.hud-chip-highlight {
  border-color: rgba(245, 158, 11, 0.5) !important;
  color: #b45309 !important;
  background: rgba(245, 158, 11, 0.08) !important;
  font-weight: 500;
}

/* --------------------------------------------------------------------------
   Agent 402 Fullscreen Protocol Terminal Overlay
   -------------------------------------------------------------------------- */

.agent-terminal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #07080c;
  color: #d1d5db;
  font-family: var(--hud-mono);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
}

.agent-terminal-overlay[data-active="false"] {
  display: none;
}

.terminal-header {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: #0d0f17;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.terminal-header .title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: #f59e0b;
}

.terminal-header .dot-live {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.terminal-body {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 1.2fr;
  overflow: hidden;
}

@media (max-width: 1000px) {
  .terminal-body {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
}

.terminal-pane {
  padding: 24px;
  overflow-y: auto;
  box-sizing: border-box;
}

.terminal-pane-left {
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: #090b10;
}

.terminal-subhead {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #9ca3af;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.code-block {
  background: #030407;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 4px;
  padding: 14px 16px;
  font-size: 11px;
  line-height: 1.65;
  color: #e5e7eb;
  margin-bottom: 20px;
  white-space: pre-wrap;
  word-break: break-all;
  position: relative;
}

.code-amber { color: #f59e0b; }
.code-green { color: #10b981; }
.code-purple { color: #a78bfa; }
.code-cyan { color: #38bdf8; }
.code-dim { color: #6b7280; }

.sandbox-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f59e0b;
  color: #07080c;
  font-family: var(--hud-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 8px 16px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 16px;
}

.sandbox-btn:hover {
  background: #fbbf24;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.4);
}

.terminal-stream-log {
  background: #020305;
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: 4px;
  padding: 16px;
  font-size: 10.5px;
  line-height: 1.7;
  min-height: 190px;
  max-height: 320px;
  overflow-y: auto;
  color: #94a3b8;
}

/* --------------------------------------------------------------------------
   narrow screens

   The four corners cannot coexist below about 900px. The two instrument panels
   stay; the population and about panels fold into the drawer, which is the only
   honest thing to do — shrinking them to keep all four would produce four panels
   with nothing legible in them.
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
  .hud-panel-pop,
  .hud-panel-about {
    display: none;
  }

  .hud-panel-econ,
  .hud-panel-temp {
    width: min(360px, calc(100vw - 2 * var(--hud-pad)));
  }

  .hud-panel-temp {
    bottom: var(--hud-pad);
  }

  .hud-feed {
    display: none;
  }
}
