:root {
  --bg: #030c09;
  --bg-deep: #020806;
  --surface: #071710;
  --surface-raised: #0a1e16;
  --surface-soft: #0c241a;
  --line: #183a2b;
  --line-bright: #2b5a43;
  --line-hot: #477c5e;
  --text: #e5f2dd;
  --text-soft: #b2cbb9;
  --muted: #789b86;
  --faint: #4e705e;
  --lime: #c5f76c;
  --lime-deep: #7eaf3d;
  --mint: #6cebb7;
  --cyan: #7bdcdf;
  --amber: #ffc95e;
  --coral: #ff737b;
  --violet: #be9cff;
  --red: #ff5e6c;
  --font-pixel: "Silkscreen", "DotGothic16", monospace;
  --font-jp: "DotGothic16", "IBM Plex Mono", monospace;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --panel-shadow: 0 16px 32px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(194, 255, 219, 0.035);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg-deep);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 12% -10%, rgba(92, 156, 94, 0.13), transparent 32rem),
    radial-gradient(circle at 92% 32%, rgba(44, 123, 102, 0.095), transparent 34rem),
    linear-gradient(165deg, #06130f 0%, #030c09 45%, #020806 100%);
  font-family: var(--font-jp);
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: none;
  text-rendering: geometricPrecision;
}

body::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  content: "";
  opacity: 0.22;
  background-image: radial-gradient(rgba(195, 255, 208, 0.25) 0.45px, transparent 0.7px);
  background-size: 3px 3px;
  mask-image: linear-gradient(to bottom, black, transparent 90%);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
  font: inherit;
}

button:focus-visible,
a:focus-visible,
canvas:focus-visible {
  outline: 1px solid var(--lime);
  outline-offset: 3px;
}

button:disabled {
  cursor: wait;
  opacity: 0.45;
}

a {
  color: inherit;
  text-decoration: none;
}

::selection {
  color: #0b1c12;
  background: var(--lime);
}

[hidden] {
  display: none !important;
}

* {
  scrollbar-width: thin;
  scrollbar-color: #315b44 #07140e;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #07140e;
}

::-webkit-scrollbar-thumb {
  border: 2px solid #07140e;
  border-radius: 0;
  background: #315b44;
}

.page-grid {
  position: fixed;
  z-index: -2;
  inset: 0;
  pointer-events: none;
  opacity: 0.62;
  background-image:
    linear-gradient(rgba(96, 156, 119, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(96, 156, 119, 0.045) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at 50% 32%, black 5%, transparent 78%);
}

.ambient-glow {
  position: fixed;
  z-index: -3;
  inset: -12%;
  pointer-events: none;
  background:
    radial-gradient(circle at 24% 7%, rgba(154, 241, 137, 0.055), transparent 26rem),
    radial-gradient(circle at 79% 56%, rgba(69, 202, 164, 0.045), transparent 34rem);
  filter: blur(28px);
}

.app-shell {
  width: min(1560px, calc(100% - 44px));
  margin: 0 auto;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 78px;
  border-bottom: 1px solid var(--line);
}

.topbar::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  width: 74px;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, var(--lime-deep));
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
  transition: opacity 0.16s ease;
}

.brand:hover {
  opacity: 0.83;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line-bright);
  background:
    linear-gradient(135deg, rgba(126, 206, 139, 0.1), transparent 45%),
    #06150f;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.32), inset 0 0 0 3px #04100c;
}

.brand-mark svg {
  width: 30px;
  height: 30px;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.brand-kicker {
  margin-bottom: 4px;
  color: var(--faint);
  font-family: var(--font-pixel);
  font-size: 7px;
  letter-spacing: 0.11em;
}

.brand-title {
  color: var(--text);
  font-family: var(--font-pixel);
  font-size: 23px;
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1.1;
  white-space: nowrap;
}

.brand-title b {
  color: var(--lime);
  font-weight: 400;
}

.brand-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.12em;
  line-height: 1;
}

.environment-cluster {
  display: flex;
  align-items: stretch;
  min-height: 44px;
  margin-left: auto;
  border: 1px solid var(--line);
  background: rgba(6, 20, 14, 0.62);
  box-shadow: inset 0 1px 0 rgba(173, 242, 193, 0.025);
}

.day-cycle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 176px;
  padding: 7px 13px;
  border-right: 1px solid var(--line);
}

.day-orb {
  position: relative;
  display: grid;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #31513f;
  background: #07150f;
}

.day-orb i {
  display: block;
  width: 8px;
  height: 8px;
  background: var(--amber);
  box-shadow:
    0 -6px 0 -3px var(--amber),
    0 6px 0 -3px var(--amber),
    -6px 0 0 -3px var(--amber),
    6px 0 0 -3px var(--amber);
  transition: 0.4s ease;
}

.day-orb.is-night i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #9bded0;
  box-shadow: 4px -2px 0 0 #06140f;
}

.day-orb.is-dusk i {
  background: #ff9a66;
  box-shadow:
    0 -6px 0 -3px #ff9a66,
    0 6px 0 -3px #ff9a66,
    -6px 0 0 -3px #ff9a66,
    6px 0 0 -3px #ff9a66;
}

.day-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.micro-label {
  color: var(--faint);
  font-family: var(--font-pixel);
  font-size: 7px;
  font-weight: 400;
  letter-spacing: 0.1em;
  line-height: 1.2;
}

.day-copy strong {
  margin-top: 2px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.055em;
}

.phase-name {
  align-self: flex-end;
  margin-left: 2px;
  padding: 2px 5px;
  color: var(--amber);
  border: 1px solid rgba(255, 201, 94, 0.22);
  background: rgba(255, 201, 94, 0.055);
  font-size: 9px;
  line-height: 1.3;
  white-space: nowrap;
}

.weather-readout {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 139px;
  padding: 7px 12px;
  transition: background 0.2s ease;
}

.weather-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.1;
}

.weather-copy strong {
  max-width: 100px;
  margin-top: 2px;
  overflow: hidden;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.035em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.weather-glyph {
  position: relative;
  display: flex;
  width: 16px;
  height: 16px;
  align-items: flex-end;
  gap: 2px;
}

.weather-glyph i {
  display: block;
  width: 3px;
  background: var(--mint);
  opacity: 0.58;
}

.weather-glyph i:nth-child(1) {
  height: 6px;
}

.weather-glyph i:nth-child(2) {
  height: 11px;
}

.weather-glyph i:nth-child(3) {
  height: 15px;
}

.weather-readout[data-tone="good"] .weather-glyph i {
  background: var(--lime);
  opacity: 0.8;
}

.weather-readout[data-tone="warn"] .weather-glyph i {
  background: var(--amber);
}

.weather-readout[data-tone="danger"] .weather-glyph i {
  background: var(--coral);
}

.weather-readout[data-tone="strange"] .weather-glyph i {
  background: var(--violet);
}

.weather-readout[data-tone="good"] {
  background: rgba(167, 235, 99, 0.04);
}

.weather-readout[data-tone="warn"] {
  background: rgba(255, 201, 94, 0.045);
}

.weather-readout[data-tone="danger"] {
  background: rgba(255, 94, 108, 0.06);
}

.weather-readout[data-tone="strange"] {
  background: rgba(190, 156, 255, 0.055);
}

.weather-timer {
  margin-left: auto;
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.02em;
}

.weather-readout[data-tone="danger"] .weather-timer {
  color: var(--coral);
}

.action-cluster {
  display: flex;
  align-items: stretch;
  gap: 7px;
  flex: 0 0 auto;
}

.audio-button {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 9px;
  padding: 6px 11px;
  cursor: pointer;
  border: 1px solid var(--line-bright);
  background: rgba(7, 21, 15, 0.76);
  transition: border-color 0.16s ease, background 0.16s ease;
}

.audio-button:hover {
  border-color: var(--line-hot);
  background: #0a2218;
}

.audio-button.is-on {
  border-color: #4f7c42;
  background: rgba(112, 158, 66, 0.11);
}

.equalizer {
  display: flex;
  width: 15px;
  height: 17px;
  align-items: flex-end;
  gap: 2px;
}

.equalizer i {
  display: block;
  width: 2px;
  height: 4px;
  background: var(--faint);
  transition: height 0.2s ease, background 0.2s ease;
}

.equalizer i:nth-child(2) {
  height: 8px;
}

.equalizer i:nth-child(3) {
  height: 6px;
}

.equalizer i:nth-child(4) {
  height: 11px;
}

.audio-button.is-on .equalizer i {
  background: var(--lime);
  animation: equalizer 0.8s steps(4, end) infinite alternate;
}

.audio-button.is-on .equalizer i:nth-child(2) {
  animation-delay: -0.35s;
}

.audio-button.is-on .equalizer i:nth-child(3) {
  animation-delay: -0.58s;
}

.audio-button.is-on .equalizer i:nth-child(4) {
  animation-delay: -0.17s;
}

.audio-copy {
  display: flex;
  min-width: 28px;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
}

.audio-copy > span:last-child {
  margin-top: 1px;
  color: var(--muted);
  font-family: var(--font-pixel);
  font-size: 8px;
  letter-spacing: 0.05em;
}

.audio-button.is-on .audio-copy > span:last-child {
  color: var(--lime);
}

.square-button {
  display: grid;
  width: 42px;
  min-height: 42px;
  cursor: pointer;
  place-items: center;
  color: var(--muted);
  border: 1px solid var(--line);
  background: rgba(7, 21, 15, 0.76);
  font-family: var(--font-pixel);
  font-size: 13px;
  transition: color 0.16s ease, border-color 0.16s ease;
}

.square-button:hover {
  color: var(--lime);
  border-color: var(--line-hot);
}

.new-button {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 7px;
  padding: 0 13px;
  cursor: pointer;
  color: #12210d;
  border: 1px solid #d5ff94;
  background: var(--lime);
  box-shadow: 3px 3px 0 #385224;
  font-family: var(--font-pixel);
  font-size: 8px;
  letter-spacing: 0.015em;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.16s ease;
}

.new-button:hover {
  background: #d4ff86;
}

.new-button:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 #385224;
}

.new-button-icon {
  display: grid;
  width: 13px;
  height: 13px;
  place-items: center;
}

.new-button-icon svg {
  width: 11px;
  height: 11px;
}

/* --------------------------------------------------------------------------
   Main layout
   -------------------------------------------------------------------------- */

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 342px;
  gap: 16px;
  align-items: start;
  padding: 14px 0 0;
}

.observation-column {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 14px;
}

.sidebar {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 14px;
}

.panel {
  position: relative;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(121, 196, 139, 0.035), transparent 34%),
    linear-gradient(180deg, #081a13 0%, #06140f 100%);
  box-shadow: var(--panel-shadow);
}

.panel::before {
  position: absolute;
  z-index: 1;
  top: -1px;
  left: -1px;
  width: 8px;
  height: 8px;
  content: "";
  border-top: 1px solid var(--line-bright);
  border-left: 1px solid var(--line-bright);
  pointer-events: none;
}

.panel::after {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 8px;
  height: 8px;
  content: "";
  border-right: 1px solid var(--line-bright);
  border-bottom: 1px solid var(--line-bright);
  pointer-events: none;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--lime-deep);
  font-family: var(--font-pixel);
  font-size: 8px;
  letter-spacing: 0.065em;
  line-height: 1.4;
}

.eyebrow > span {
  color: var(--faint);
}

.live-pip,
.recording-label i {
  display: inline-block;
  width: 5px;
  height: 5px;
  background: var(--coral);
  box-shadow: 0 0 7px rgba(255, 94, 108, 0.8);
  animation: blink 1.8s steps(2, end) infinite;
}

/* Telemetry strip */

.telemetry {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  min-height: 66px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(29, 62, 44, 0.27), transparent 75%),
    #06140f;
  box-shadow: var(--panel-shadow);
}

.metric {
  position: relative;
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 9px 12px 10px;
  border-right: 1px solid var(--line);
}

.metric:last-child {
  border-right: 0;
}

.metric::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 22px;
  height: 1px;
  content: "";
  background: var(--line-bright);
}

.metric-alert::before {
  background: var(--coral);
}

.metric-heading {
  display: flex;
  align-items: baseline;
  gap: 5px;
  overflow: hidden;
  color: var(--muted);
  font-size: 9.5px;
  letter-spacing: 0.03em;
  line-height: 1.3;
  white-space: nowrap;
}

.metric-heading b {
  color: var(--faint);
  font-family: var(--font-pixel);
  font-size: 6px;
  font-weight: 400;
  letter-spacing: 0;
}

.metric-heading em {
  overflow: hidden;
  color: #42614f;
  font-family: var(--font-pixel);
  font-size: 6px;
  font-style: normal;
  letter-spacing: 0.02em;
  text-overflow: ellipsis;
}

.metric-number {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 5px;
  line-height: 1;
}

.metric-number strong {
  color: var(--text);
  font-family: var(--font-pixel);
  font-size: 19px;
  font-weight: 400;
  letter-spacing: 0.01em;
}

.metric-number small {
  overflow: hidden;
  color: var(--faint);
  font-family: var(--font-pixel);
  font-size: 6px;
  letter-spacing: 0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-number small.is-up {
  color: var(--lime);
}

.metric-number small.is-down {
  color: var(--coral);
}

.metric-alert .metric-number strong {
  color: #ffc0a1;
}

/* Stage */

.stage-section {
  min-width: 0;
}

.stage-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 0 2px 9px;
}

.stage-heading h1 {
  display: flex;
  align-items: baseline;
  gap: 11px;
  margin: 3px 0 0;
  color: var(--text);
  font-family: var(--font-jp);
  font-size: 24px;
  font-weight: 400;
  letter-spacing: 0.055em;
  line-height: 1.2;
}

.stage-heading h1 span {
  color: var(--faint);
  font-family: var(--font-pixel);
  font-size: 8px;
  font-weight: 400;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.stage-meta {
  display: flex;
  align-items: center;
  gap: 13px;
  padding-bottom: 2px;
  white-space: nowrap;
}

.auto-state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 9px;
}

.auto-state i {
  width: 4px;
  height: 4px;
  background: var(--mint);
  box-shadow: 0 0 5px rgba(108, 235, 183, 0.7);
}

.auto-state.is-paused {
  color: var(--amber);
}

.auto-state.is-paused i {
  background: var(--amber);
  box-shadow: none;
}

.pixel-resolution {
  color: var(--faint);
  font-family: var(--font-pixel);
  font-size: 7px;
  letter-spacing: 0.03em;
}

.stage-deck {
  position: relative;
  padding: 7px;
  border: 1px solid var(--line-bright);
  background:
    linear-gradient(135deg, rgba(100, 158, 120, 0.1), transparent 20%),
    linear-gradient(315deg, rgba(47, 104, 78, 0.17), transparent 26%),
    #0a1a13;
  box-shadow:
    0 0 0 1px #020907,
    0 22px 50px rgba(0, 0, 0, 0.38),
    inset 0 0 0 1px rgba(184, 246, 195, 0.035);
}

.stage-deck::before,
.stage-deck::after {
  position: absolute;
  z-index: 3;
  width: 16px;
  height: 16px;
  content: "";
  pointer-events: none;
}

.stage-deck::before {
  top: 2px;
  left: 2px;
  border-top: 1px solid var(--lime-deep);
  border-left: 1px solid var(--lime-deep);
}

.stage-deck::after {
  right: 2px;
  bottom: 2px;
  border-right: 1px solid var(--lime-deep);
  border-bottom: 1px solid var(--lime-deep);
}

.stage-viewport {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid #2e5a43;
  background: #020a07;
  box-shadow: inset 0 0 48px rgba(0, 0, 0, 0.68);
  isolation: isolate;
}

#worldCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: manipulation;
}

.glass-sheen {
  position: absolute;
  z-index: 2;
  inset: 0;
  pointer-events: none;
  opacity: 0.46;
  background:
    linear-gradient(116deg, transparent 0 27%, rgba(181, 255, 209, 0.034) 27.1% 33%, transparent 33.1%),
    linear-gradient(294deg, transparent 0 72%, rgba(164, 238, 198, 0.03) 72.1% 75%, transparent 75.1%),
    radial-gradient(ellipse at 72% 8%, rgba(213, 255, 228, 0.06), transparent 32%);
  mix-blend-mode: screen;
}

.screen-scanlines {
  position: absolute;
  z-index: 2;
  inset: 0;
  pointer-events: none;
  opacity: 0.28;
  background: repeating-linear-gradient(
    to bottom,
    rgba(1, 9, 6, 0.2) 0,
    rgba(1, 9, 6, 0.2) 1px,
    transparent 1px,
    transparent 3px
  );
}

.stage-corner {
  position: absolute;
  z-index: 8;
  width: 13px;
  height: 13px;
  pointer-events: none;
  opacity: 0.72;
}

.stage-corner-tl {
  top: 10px;
  left: 10px;
  border-top: 1px solid rgba(202, 255, 218, 0.55);
  border-left: 1px solid rgba(202, 255, 218, 0.55);
}

.stage-corner-tr {
  top: 10px;
  right: 10px;
  border-top: 1px solid rgba(202, 255, 218, 0.55);
  border-right: 1px solid rgba(202, 255, 218, 0.55);
}

.stage-corner-bl {
  bottom: 10px;
  left: 10px;
  border-bottom: 1px solid rgba(202, 255, 218, 0.35);
  border-left: 1px solid rgba(202, 255, 218, 0.35);
}

.stage-corner-br {
  right: 10px;
  bottom: 10px;
  border-right: 1px solid rgba(202, 255, 218, 0.35);
  border-bottom: 1px solid rgba(202, 255, 218, 0.35);
}

.stage-hud-top {
  position: absolute;
  z-index: 4;
  top: 13px;
  right: 16px;
  left: 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
  color: rgba(198, 230, 206, 0.42);
  font-family: var(--font-pixel);
  font-size: 7px;
  letter-spacing: 0.045em;
  text-shadow: 1px 1px 0 #020806;
}

.recording-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: rgba(230, 246, 228, 0.65);
}

.recording-label i {
  width: 4px;
  height: 4px;
}

.recording-label b {
  margin-left: 2px;
  color: rgba(198, 230, 206, 0.42);
  font-weight: 400;
}

.hud-coordinates {
  padding-top: 1px;
  color: rgba(175, 209, 184, 0.35);
}

.focus-tag {
  position: absolute;
  z-index: 9;
  top: 31px;
  left: 15px;
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: 230px;
  padding: 5px 6px 5px 7px;
  border: 1px solid rgba(148, 197, 167, 0.28);
  background: rgba(3, 15, 10, 0.84);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(3px);
}

.focus-tag > span:nth-child(2) {
  display: flex;
  min-width: 0;
  flex-direction: column;
  line-height: 1.05;
}

.focus-tag strong {
  overflow: hidden;
  color: var(--text);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.focus-swatch {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  background: hsl(var(--focus-hue, 110) 78% 62%);
  box-shadow: 2px 2px 0 hsl(var(--focus-hue, 110) 60% 27%);
}

.focus-tag button {
  display: grid;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  cursor: pointer;
  place-items: center;
  color: var(--muted);
  border: 1px solid transparent;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1;
}

.focus-tag button:hover {
  color: var(--text);
  border-color: var(--line);
}

.stage-banner {
  position: absolute;
  z-index: 12;
  top: 15px;
  left: 50%;
  display: flex;
  min-width: 220px;
  max-width: min(430px, calc(100% - 150px));
  align-items: center;
  gap: 8px;
  padding: 6px 11px;
  border: 1px solid var(--line-bright);
  background: rgba(4, 19, 13, 0.92);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.3);
  transform: translateX(-50%);
  animation: banner-in 0.24s steps(3, end);
  backdrop-filter: blur(4px);
}

.stage-banner::before {
  width: 4px;
  height: 22px;
  content: "";
  background: var(--mint);
}

.stage-banner[data-tone="good"]::before {
  background: var(--lime);
}

.stage-banner[data-tone="warn"]::before {
  background: var(--amber);
}

.stage-banner[data-tone="danger"]::before {
  background: var(--coral);
}

.stage-banner[data-tone="strange"]::before {
  background: var(--violet);
}

.stage-banner[data-tone="lineage"]::before {
  background: var(--cyan);
}

.banner-kicker {
  flex: 0 0 auto;
  color: var(--faint);
  font-family: var(--font-pixel);
  font-size: 6px;
  letter-spacing: 0.06em;
}

.stage-banner strong {
  overflow: hidden;
  color: var(--text);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.banner-sub {
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-bottom {
  position: absolute;
  z-index: 10;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 38px 13px 12px;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent 0%, rgba(2, 11, 7, 0.38) 42%, rgba(2, 10, 7, 0.87) 100%);
}

.stage-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  pointer-events: none;
  flex-wrap: wrap;
}

.legend-entry {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: rgba(198, 227, 205, 0.66);
  font-size: 9px;
  letter-spacing: 0.03em;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.45);
}

.pixel-icon {
  display: inline-block;
  width: 7px;
  height: 7px;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.35);
}

.icon-plant {
  background: var(--lime);
  clip-path: polygon(0 100%, 0 30%, 30% 30%, 30% 0, 100% 0, 100% 70%, 70% 70%, 70% 100%);
}

.icon-herbivore {
  background: var(--mint);
}

.icon-omnivore {
  background: var(--amber);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.icon-predator {
  background: var(--coral);
  clip-path: polygon(0 0, 100% 50%, 0 100%, 24% 50%);
}

.scene-controls {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px;
  pointer-events: auto;
  border: 1px solid rgba(91, 137, 105, 0.54);
  background: rgba(3, 16, 10, 0.91);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.31);
  backdrop-filter: blur(5px);
}

.control-button {
  display: grid;
  width: 28px;
  height: 26px;
  cursor: pointer;
  place-items: center;
  color: var(--mint);
  border: 1px solid transparent;
  background: transparent;
}

.control-button:hover {
  border-color: var(--line-bright);
  background: #0d281c;
}

.control-button svg {
  width: 11px;
  height: 11px;
}

.speed-switch {
  display: flex;
  align-items: center;
  gap: 1px;
}

.speed-switch button {
  width: 26px;
  height: 24px;
  cursor: pointer;
  color: var(--faint);
  border: 1px solid transparent;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 9px;
  line-height: 1;
  transition: color 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.speed-switch button:hover {
  color: var(--text);
  border-color: var(--line);
}

.speed-switch button.is-active {
  color: #0e1b0b;
  border-color: var(--lime);
  background: var(--lime);
}

.control-separator {
  width: 1px;
  height: 15px;
  margin: 0 2px;
  background: var(--line);
}

.action-button {
  display: flex;
  height: 26px;
  align-items: center;
  gap: 3px;
  padding: 0 7px;
  cursor: pointer;
  color: var(--muted);
  border: 1px solid transparent;
  background: transparent;
  font-size: 9px;
  line-height: 1;
  white-space: nowrap;
}

.action-button > span:first-child {
  color: var(--lime);
  font-family: var(--font-pixel);
  font-size: 10px;
}

.action-button:hover {
  color: var(--text);
  border-color: var(--line-bright);
  background: #0d281c;
}

.action-mutate > span:first-child {
  color: var(--violet);
}

.action-button:disabled {
  color: var(--faint);
  border-color: transparent;
  background: transparent;
}

.first-run-hint {
  position: absolute;
  z-index: 9;
  bottom: 61px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border: 1px solid rgba(164, 219, 178, 0.25);
  background: rgba(3, 16, 10, 0.84);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.25);
  transform: translateX(-50%);
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
  backdrop-filter: blur(3px);
}

.first-run-hint.is-gone {
  opacity: 0;
  transform: translate(-50%, 4px);
}

.first-run-hint > span:not(.hint-cursor) {
  color: var(--text-soft);
  font-size: 10px;
  white-space: nowrap;
}

.first-run-hint small {
  padding-left: 8px;
  color: var(--faint);
  border-left: 1px solid var(--line);
  font-size: 8px;
  white-space: nowrap;
}

.hint-cursor {
  position: relative;
  display: block;
  width: 8px;
  height: 8px;
  border: 1px solid var(--lime);
  background: rgba(197, 247, 108, 0.2);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.35);
  animation: hint-pulse 1.8s steps(2, end) infinite;
}

/* Chart */

.chart-panel {
  min-width: 0;
  overflow: hidden;
}

.chart-heading {
  padding: 10px 14px 2px;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 2px;
  color: var(--muted);
  font-size: 8px;
  white-space: nowrap;
}

.chart-key {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.chart-key i {
  display: inline-block;
  width: 10px;
  height: 2px;
}

.chart-key b {
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
}

.key-pop i {
  background: var(--lime);
}

.key-flora i {
  background: var(--mint);
  opacity: 0.8;
}

.key-lineage i {
  background: var(--amber);
  opacity: 0.8;
}

.chart-range {
  padding-left: 9px;
  color: var(--faint);
  border-left: 1px solid var(--line);
  font-size: 8px;
}

.chart-wrap {
  width: 100%;
  height: 80px;
  padding: 0 7px 7px;
}

#historyChart {
  display: block;
  width: 100%;
  height: 100%;
}

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 13px 9px;
}

.panel-heading h2 {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 2px 0 0;
  color: var(--text);
  font-family: var(--font-jp);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0.045em;
  line-height: 1.25;
}

.panel-heading h2 span {
  color: var(--faint);
  font-family: var(--font-pixel);
  font-size: 7px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.panel-counter {
  display: flex;
  align-items: baseline;
  gap: 4px;
  padding-top: 2px;
}

.panel-counter strong {
  color: var(--lime);
  font-family: var(--font-pixel);
  font-size: 17px;
  font-weight: 400;
  line-height: 1;
}

.panel-counter small {
  color: var(--faint);
  font-family: var(--font-pixel);
  font-size: 6px;
}

.panel-close {
  display: grid;
  width: 21px;
  height: 21px;
  cursor: pointer;
  place-items: center;
  color: var(--muted);
  border: 1px solid var(--line);
  background: transparent;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1;
}

.panel-close:hover {
  color: var(--text);
  border-color: var(--line-bright);
}

.species-panel {
  display: flex;
  min-height: 0;
  flex-direction: column;
}

.species-list {
  position: relative;
  max-height: 232px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  border-top: 1px solid var(--line);
}

.species-row {
  position: relative;
  border-bottom: 1px solid rgba(24, 58, 43, 0.72);
}

.species-row:last-child {
  border-bottom: 0;
}

.species-button {
  display: grid;
  width: 100%;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px 11px 9px;
  cursor: pointer;
  text-align: left;
  border: 0;
  background: transparent;
  transition: background 0.14s ease;
}

.species-button:hover {
  background: rgba(111, 172, 125, 0.065);
}

.species-row.is-focused .species-button {
  background: rgba(111, 172, 125, 0.1);
  box-shadow: inset 2px 0 0 var(--lime);
}

.species-swatch {
  position: relative;
  display: block;
  width: 10px;
  height: 10px;
  background: hsl(var(--hue) 82% 61%);
  box-shadow:
    2px 2px 0 hsl(var(--hue) 58% 27%),
    0 0 8px hsla(var(--hue), 82%, 61%, 0.16);
}

.species-swatch::after {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 3px;
  height: 2px;
  content: "";
  background: hsl(var(--hue) 95% 82%);
}

.species-identity {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
  line-height: 1.2;
}

.species-name {
  overflow: hidden;
  color: var(--text);
  font-size: 11px;
  letter-spacing: 0.045em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.species-role {
  color: var(--faint);
  font-size: 8px;
  letter-spacing: 0.03em;
}

.species-count {
  display: flex;
  align-items: baseline;
  gap: 2px;
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: 12px;
}

.species-count small {
  color: var(--faint);
  font-family: var(--font-jp);
  font-size: 7px;
}

.species-bar {
  position: absolute;
  right: 11px;
  bottom: 5px;
  left: 42px;
  display: block;
  height: 1px;
  overflow: hidden;
  background: rgba(42, 82, 61, 0.4);
}

.species-bar i {
  display: block;
  width: 0;
  height: 100%;
  background: hsl(var(--hue) 78% 57%);
  opacity: 0.72;
  transition: width 0.5s ease;
}

.panel-empty {
  margin: 0;
  padding: 16px 13px;
  color: var(--faint);
  font-size: 10px;
}

.panel-note {
  margin: 0;
  padding: 7px 11px 8px;
  color: #4a6b58;
  border-top: 1px solid rgba(24, 58, 43, 0.64);
  font-size: 8px;
  letter-spacing: 0.02em;
}

/* Inspector */

.inspector-panel {
  flex: 0 0 auto;
}

.inspector-empty {
  display: flex;
  min-height: 164px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 8px 20px 22px;
  text-align: center;
}

.scan-reticle {
  position: relative;
  width: 44px;
  height: 44px;
  margin-bottom: 2px;
  border: 1px solid rgba(98, 152, 115, 0.33);
  background:
    linear-gradient(90deg, transparent 49%, rgba(91, 145, 106, 0.16) 50%, transparent 51%),
    linear-gradient(0deg, transparent 49%, rgba(91, 145, 106, 0.16) 50%, transparent 51%);
}

.scan-reticle i {
  position: absolute;
  width: 9px;
  height: 9px;
  border-color: var(--line-hot);
  border-style: solid;
}

.scan-reticle i:nth-child(1) {
  top: -1px;
  left: -1px;
  border-width: 1px 0 0 1px;
}

.scan-reticle i:nth-child(2) {
  top: -1px;
  right: -1px;
  border-width: 1px 1px 0 0;
}

.scan-reticle i:nth-child(3) {
  bottom: -1px;
  left: -1px;
  border-width: 0 0 1px 1px;
}

.scan-reticle i:nth-child(4) {
  right: -1px;
  bottom: -1px;
  border-width: 0 1px 1px 0;
}

.scan-reticle b {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  background: var(--lime);
  box-shadow: 0 0 9px rgba(197, 247, 108, 0.5);
  transform: translate(-50%, -50%);
  animation: reticle-pulse 2s steps(2, end) infinite;
}

.inspector-empty p {
  margin: 0;
  color: var(--text-soft);
  font-size: 11px;
  letter-spacing: 0.03em;
}

.inspector-empty > span {
  color: var(--faint);
  font-size: 9px;
}

.inspector-body {
  padding: 0 12px 11px;
  border-top: 1px solid var(--line);
}

.specimen-heading {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 0 9px;
}

.specimen-swatch {
  position: relative;
  display: block;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  background: hsl(var(--specimen-hue, 110) 80% 59%);
  box-shadow:
    inset -4px -4px 0 hsl(var(--specimen-hue, 110) 60% 31%),
    2px 2px 0 rgba(0, 0, 0, 0.4);
}

.specimen-swatch::before {
  position: absolute;
  top: 3px;
  left: 5px;
  width: 6px;
  height: 4px;
  content: "";
  background: hsl(var(--specimen-hue, 110) 96% 82%);
}

.specimen-swatch i {
  position: absolute;
  width: 3px;
  height: 3px;
  background: #eaffda;
}

.specimen-swatch i:first-child {
  top: 10px;
  left: 10px;
}

.specimen-swatch i:last-child {
  top: 10px;
  right: 7px;
}

.specimen-name-block {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  line-height: 1.15;
}

.specimen-name-block strong {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.05em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.specimen-name-block span {
  margin-top: 3px;
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: 0.025em;
}

.role-badge {
  flex: 0 0 auto;
  padding: 2px 5px;
  color: var(--mint);
  border: 1px solid rgba(108, 235, 183, 0.26);
  background: rgba(108, 235, 183, 0.05);
  font-size: 8px;
  line-height: 1.4;
}

.inspector-body.is-predator .role-badge {
  color: var(--coral);
  border-color: rgba(255, 115, 123, 0.29);
  background: rgba(255, 115, 123, 0.055);
}

.vital-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 2px 0 9px;
}

.vital-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 35px;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: 0.02em;
}

.vital-row > span:first-child {
  color: var(--faint);
}

.vital-row b {
  color: var(--text-soft);
  font-size: 8px;
  font-weight: 400;
  text-align: right;
}

.mini-track {
  display: block;
  height: 4px;
  overflow: hidden;
  background: #102a1d;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
}

.mini-track i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--lime);
  transition: width 0.22s ease;
}

.vital-row:nth-child(2) .mini-track i {
  background: var(--cyan);
}

.gene-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 0 9px;
  border-top: 1px solid rgba(24, 58, 43, 0.62);
  border-bottom: 1px solid rgba(24, 58, 43, 0.62);
}

.gene-row {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 7px;
}

.gene-row > span:first-child {
  color: var(--text-soft);
  font-size: 8.5px;
  letter-spacing: 0.025em;
  white-space: nowrap;
}

.gene-row > span:first-child em {
  margin-left: 2px;
  color: var(--faint);
  font-family: var(--font-pixel);
  font-size: 5px;
  font-style: normal;
  letter-spacing: 0.01em;
}

.gene-track {
  display: block;
  height: 3px;
  overflow: hidden;
  background: #102a1d;
}

.gene-track i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--lime);
  background: color-mix(in srgb, var(--lime) 72%, var(--mint));
  opacity: 0.9;
  transition: width 0.24s ease;
}

.gene-row:nth-child(4) .gene-track i {
  background: var(--mint);
}

.inspector-body.is-predator .gene-row:nth-child(4) .gene-track i {
  background: var(--coral);
}

.gene-row b {
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 400;
  text-align: right;
}

.specimen-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 13px;
  padding-top: 8px;
  color: var(--faint);
  font-size: 7.5px;
}

.specimen-footer b {
  margin-left: 2px;
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 400;
}

.specimen-footer span:last-child {
  margin-left: auto;
}

/* Log */

.log-panel {
  display: flex;
  min-height: 168px;
  flex: 1 1 200px;
  flex-direction: column;
}

.live-stamp {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding-top: 3px;
  color: var(--faint);
  font-family: var(--font-pixel);
  font-size: 6px;
  white-space: nowrap;
}

.live-stamp i {
  display: inline-block;
  width: 4px;
  height: 4px;
  background: var(--mint);
  animation: blink 2.2s steps(2, end) infinite;
}

.event-log {
  max-height: 245px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  border-top: 1px solid var(--line);
}

.log-entry {
  display: grid;
  grid-template-columns: 47px 46px minmax(0, 1fr);
  align-items: baseline;
  gap: 6px;
  padding: 6px 11px;
  color: var(--text-soft);
  border-bottom: 1px solid rgba(24, 58, 43, 0.5);
  font-size: 9px;
  line-height: 1.55;
  animation: log-in 0.24s steps(3, end);
}

.log-entry:last-child {
  border-bottom: 0;
}

.log-time {
  color: #466553;
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.log-tag {
  color: var(--muted);
  font-family: var(--font-pixel);
  font-size: 6px;
  letter-spacing: 0.025em;
  white-space: nowrap;
}

.log-message {
  min-width: 0;
}

.log-entry.tone-good .log-tag {
  color: var(--lime);
}

.log-entry.tone-warn .log-tag {
  color: var(--amber);
}

.log-entry.tone-danger .log-tag {
  color: var(--coral);
}

.log-entry.tone-strange .log-tag {
  color: var(--violet);
}

.log-entry.tone-lineage .log-tag {
  color: var(--cyan);
}

.log-entry.tone-lineage .log-message {
  color: #d8f3e3;
}

.log-empty {
  padding: 12px;
  color: var(--faint);
  font-size: 9px;
  list-style: none;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.footer {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 46px;
  margin-top: 15px;
  padding: 10px 2px 17px;
  color: var(--faint);
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.02em;
}

.footer-signature {
  color: var(--muted);
  font-family: var(--font-pixel);
  font-size: 7px;
  letter-spacing: 0.035em;
}

.footer-signature span {
  margin-left: 3px;
  color: #3e5e4b;
}

.seed-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 5px;
  cursor: pointer;
  color: var(--faint);
  border: 1px solid transparent;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.02em;
  transition: color 0.14s ease, border-color 0.14s ease;
}

.seed-button:hover {
  color: var(--text-soft);
  border-color: var(--line);
}

.seed-button b {
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.05em;
}

.copy-mark {
  color: var(--faint);
  font-size: 10px;
}

.footer-note {
  color: #486552;
  font-family: var(--font-jp);
  font-size: 8px;
}

.footer-runtime {
  margin-left: auto;
  color: #466252;
}

.footer-runtime b {
  color: var(--muted);
  font-weight: 400;
}

.footer-runtime span {
  margin: 0 3px;
  color: #2d4a3a;
}

/* --------------------------------------------------------------------------
   Dialog and toast
   -------------------------------------------------------------------------- */

.help-dialog {
  width: min(760px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
  margin: auto;
  padding: 0;
  overflow: visible;
  color: var(--text);
  border: 1px solid var(--line-hot);
  background:
    linear-gradient(135deg, rgba(91, 160, 113, 0.09), transparent 24%),
    #071610;
  box-shadow: 0 0 0 1px #020a06, 10px 10px 0 rgba(0, 0, 0, 0.35);
  font-family: var(--font-jp);
}

.help-dialog::backdrop {
  background: rgba(1, 7, 5, 0.78);
  backdrop-filter: blur(3px);
}

.help-inner {
  max-height: calc(100vh - 32px);
  padding: 23px 25px 20px;
  overflow-y: auto;
}

.help-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 15px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.help-heading h2 {
  margin: 4px 0 0;
  font-family: var(--font-jp);
  font-size: 25px;
  font-weight: 400;
  letter-spacing: 0.06em;
}

.help-close {
  width: 26px;
  height: 26px;
  font-size: 15px;
}

.help-intro {
  max-width: 650px;
  margin: 16px 0;
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.9;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}

.help-grid article {
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(8, 25, 17, 0.72);
}

.help-index {
  color: var(--lime-deep);
  font-family: var(--font-pixel);
  font-size: 6px;
  letter-spacing: 0.03em;
}

.help-grid h3 {
  margin: 8px 0 5px;
  color: var(--text);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.05em;
}

.help-grid p {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.75;
}

.help-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 17px;
  margin: 16px 0;
  padding: 10px 12px;
  color: var(--muted);
  border: 1px solid rgba(24, 58, 43, 0.9);
  background: rgba(4, 14, 10, 0.55);
  font-size: 9px;
}

.help-controls span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

kbd {
  display: inline-grid;
  min-width: 17px;
  height: 17px;
  padding: 0 3px;
  place-items: center;
  color: var(--text-soft);
  border: 1px solid var(--line-bright);
  background: #0a2117;
  box-shadow: 1px 1px 0 #020a06;
  font-family: var(--font-mono);
  font-size: 7px;
  line-height: 1;
}

.help-audio {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 0 0 16px;
  color: var(--faint);
  font-size: 9px;
  line-height: 1.7;
}

.help-audio b {
  color: var(--mint);
  font-family: var(--font-pixel);
  font-size: 7px;
  font-weight: 400;
}

.audio-dot {
  width: 5px;
  height: 5px;
  flex: 0 0 auto;
  margin-top: 5px;
  background: var(--mint);
  animation: blink 2s steps(2, end) infinite;
}

.help-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.help-footer > span {
  max-width: 470px;
  color: var(--faint);
  font-size: 8px;
  line-height: 1.7;
}

.primary-button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 13px;
  cursor: pointer;
  color: #10200c;
  border: 1px solid #e2ffab;
  background: var(--lime);
  box-shadow: 3px 3px 0 #344d22;
  font-size: 10px;
}

.primary-button:hover {
  background: #d6ff8d;
}

.toast {
  position: fixed;
  z-index: 100;
  bottom: 25px;
  left: 50%;
  padding: 7px 13px;
  color: #11210b;
  background: var(--lime);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.38);
  opacity: 0;
  transform: translate(-50%, 8px);
  pointer-events: none;
  font-size: 10px;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.noscript-notice {
  position: fixed;
  z-index: 200;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  padding: 32px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 40%, rgba(36, 74, 50, 0.36), transparent 28rem),
    rgba(2, 8, 6, 0.94);
}

.noscript-notice .eyebrow {
  color: var(--mint);
}

.noscript-notice strong {
  color: var(--text);
  font-family: var(--font-pixel);
  font-size: clamp(18px, 4vw, 28px);
  letter-spacing: 0.04em;
}

.noscript-notice p {
  max-width: 34rem;
  margin: 0;
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.9;
}

/* --------------------------------------------------------------------------
   Motion
   -------------------------------------------------------------------------- */

@keyframes blink {
  0%,
  48% {
    opacity: 1;
  }
  49%,
  100% {
    opacity: 0.28;
  }
}

@keyframes equalizer {
  0% {
    height: 3px;
  }
  35% {
    height: 13px;
  }
  65% {
    height: 6px;
  }
  100% {
    height: 11px;
  }
}

@keyframes banner-in {
  from {
    opacity: 0;
    transform: translate(-50%, -4px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@keyframes log-in {
  from {
    opacity: 0;
    transform: translateY(-3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes reticle-pulse {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 1;
  }
}

@keyframes hint-pulse {
  0%,
  100% {
    border-color: rgba(197, 247, 108, 0.6);
  }
  50% {
    border-color: rgba(197, 247, 108, 1);
    background: rgba(197, 247, 108, 0.32);
  }
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1270px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr) 320px;
  }

  .environment-cluster {
    margin-left: 0;
  }

  .day-cycle {
    min-width: 158px;
  }

  .brand-title {
    font-size: 21px;
  }

  .topbar {
    gap: 15px;
  }

  .metric-heading em {
    display: none;
  }

  .chart-legend {
    gap: 9px;
  }

  .chart-range {
    display: none;
  }
}

@media (max-width: 1080px) {
  .app-shell {
    width: min(100% - 30px, 1000px);
  }

  .topbar {
    flex-wrap: wrap;
    gap: 12px 18px;
    padding: 10px 0;
  }

  .environment-cluster {
    order: 3;
    width: 100%;
    flex: 1 0 100%;
  }

  .day-cycle {
    flex: 1;
  }

  .weather-readout {
    min-width: 165px;
    flex: 0 1 auto;
  }

  .action-cluster {
    margin-left: auto;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
  }

  .species-panel,
  .inspector-panel {
    min-height: 100%;
  }

  .log-panel {
    grid-column: 1 / -1;
  }

  .event-log {
    max-height: 190px;
  }

  .footer {
    margin-top: 13px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: calc(100% - 22px);
  }

  .brand {
    gap: 8px;
  }

  .brand-mark {
    width: 37px;
    height: 37px;
  }

  .brand-mark svg {
    width: 26px;
    height: 26px;
  }

  .brand-title {
    font-size: 19px;
  }

  .brand-kicker {
    font-size: 6px;
  }

  .brand-sub {
    font-size: 8px;
  }

  .environment-cluster {
    min-height: 39px;
  }

  .day-cycle {
    min-width: 0;
    padding: 5px 9px;
    gap: 7px;
  }

  .day-orb {
    width: 19px;
    height: 19px;
  }

  .day-orb i {
    transform: scale(0.78);
  }

  .phase-name {
    display: none;
  }

  .weather-readout {
    min-width: 0;
    flex: 1;
    justify-content: flex-end;
    padding: 5px 9px;
  }

  .weather-timer {
    display: none;
  }

  .audio-button {
    min-height: 37px;
    padding: 5px 8px;
  }

  .square-button {
    min-height: 37px;
    width: 37px;
  }

  .new-button {
    min-height: 37px;
    padding: 0 10px;
  }

  .new-button span:last-child {
    display: none;
  }

  .workspace {
    padding-top: 10px;
    gap: 12px;
  }

  .observation-column,
  .sidebar {
    gap: 12px;
  }

  .telemetry {
    grid-template-columns: repeat(3, 1fr);
  }

  .metric {
    min-height: 52px;
    padding: 7px 9px;
    border-bottom: 1px solid var(--line);
  }

  .metric:nth-child(3) {
    border-right: 0;
  }

  .metric:nth-child(n + 4) {
    border-bottom: 0;
  }

  .metric-number strong {
    font-size: 16px;
  }

  .metric-heading {
    font-size: 8.5px;
  }

  .metric-heading b {
    display: none;
  }

  .stage-heading {
    align-items: flex-start;
    padding-bottom: 7px;
  }

  .stage-heading h1 {
    display: block;
    font-size: 20px;
  }

  .stage-heading h1 span {
    display: block;
    margin-top: 3px;
    font-size: 7px;
  }

  .stage-meta {
    padding-top: 3px;
  }

  .pixel-resolution {
    display: none;
  }

  .stage-deck {
    padding: 4px;
  }

  .stage-banner {
    top: 10px;
    right: 8px;
    left: 8px;
    max-width: none;
    padding: 5px 7px;
    transform: none;
    animation: none;
  }

  .stage-banner strong {
    font-size: 10px;
  }

  .banner-sub {
    display: none;
  }

  .banner-kicker {
    font-size: 5px;
  }

  .stage-hud-top {
    top: 10px;
    right: 12px;
    left: 12px;
    font-size: 6px;
  }

  .hud-coordinates {
    display: none;
  }

  .focus-tag {
    top: 25px;
    left: 10px;
    max-width: 185px;
  }

  .stage-bottom {
    padding: 32px 6px 7px;
    justify-content: center;
  }

  .stage-legend {
    display: none;
  }

  .scene-controls {
    width: auto;
    justify-content: center;
  }

  .first-run-hint {
    top: 25px;
    right: 10px;
    bottom: auto;
    left: auto;
    display: none;
  }

  .chart-heading {
    padding: 9px 10px 1px;
  }

  .chart-heading h2 {
    font-size: 13px;
  }

  .chart-legend {
    gap: 7px;
    font-size: 7px;
  }

  .chart-range,
  .chart-key.key-lineage {
    display: none;
  }

  .chart-wrap {
    height: 65px;
  }

  .chart-key b {
    font-size: 8px;
  }

  .sidebar {
    display: flex;
    align-items: stretch;
    flex-direction: column;
  }

  .species-list {
    max-height: 206px;
  }

  .inspector-empty {
    min-height: 130px;
    padding-bottom: 16px;
  }

  .scan-reticle {
    width: 34px;
    height: 34px;
  }

  .event-log {
    max-height: 205px;
  }

  .footer {
    flex-wrap: wrap;
    gap: 7px 14px;
    padding: 9px 1px 15px;
  }

  .footer-note {
    display: none;
  }

  .footer-runtime {
    margin-left: auto;
  }

  .seed-button {
    order: 3;
    width: 100%;
    padding: 0;
    border-color: transparent;
  }

  .help-inner {
    padding: 17px 15px 15px;
  }

  .help-heading h2 {
    font-size: 21px;
  }

  .help-intro {
    margin: 13px 0;
    font-size: 11px;
  }

  .help-grid {
    grid-template-columns: 1fr;
  }

  .help-grid article {
    padding: 9px 10px;
  }

  .help-grid h3 {
    margin: 5px 0 3px;
    font-size: 12px;
  }

  .help-controls {
    margin: 12px 0;
  }

  .help-footer {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .primary-button {
    min-height: 38px;
  }
}

@media (max-width: 460px) {
  .brand-title {
    font-size: 17px;
  }

  .brand-sub,
  .brand-kicker {
    display: none;
  }

  .action-cluster {
    gap: 5px;
  }

  .audio-copy {
    display: none;
  }

  .audio-button {
    width: 37px;
    justify-content: center;
  }

  .new-button {
    width: 37px;
    justify-content: center;
    padding: 0;
  }

  .weather-copy strong {
    max-width: 82px;
  }

  .stage-heading h1 {
    font-size: 18px;
  }

  .stage-meta .auto-state {
    font-size: 8px;
  }

  .scene-controls {
    gap: 1px;
    padding: 3px;
  }

  .control-button {
    width: 26px;
  }

  .speed-switch button {
    width: 24px;
  }

  .action-button {
    padding: 0 5px;
  }

  .action-button > span:last-child {
    display: none;
  }

  .action-button > span:first-child {
    font-size: 12px;
  }

  .chart-key.key-flora {
    display: none;
  }

  .log-entry {
    grid-template-columns: 42px 40px minmax(0, 1fr);
    gap: 4px;
    padding: 5px 9px;
    font-size: 8.5px;
  }

  .log-time {
    font-size: 6px;
  }

  .log-tag {
    font-size: 5px;
  }
}

/* --------------------------------------------------------------------------
   Touch ergonomics
   -------------------------------------------------------------------------- */

@media (pointer: coarse) {
  .control-button {
    width: 36px;
    height: 36px;
  }

  .speed-switch button {
    width: 32px;
    height: 34px;
    font-size: 10px;
  }

  .action-button {
    height: 36px;
    padding: 0 9px;
  }

  .species-button {
    min-height: 42px;
  }

  .panel-close {
    width: 30px;
    height: 30px;
  }

  .seed-button {
    min-height: 28px;
  }
}

/* --------------------------------------------------------------------------
   Handheld landscape cockpit
   Left: the dish. Right: telemetry, drift chart and observation panels.
   -------------------------------------------------------------------------- */

@media (orientation: landscape) and (max-width: 1180px) and (max-height: 600px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }

  body {
    min-height: 100dvh;
  }

  .app-shell {
    display: grid;
    width: 100%;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    grid-template-rows: 40px minmax(0, 1fr) 24px;
    padding:
      max(6px, env(safe-area-inset-top))
      max(8px, env(safe-area-inset-right))
      max(4px, env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));
    margin: 0;
  }

  /* Compact header */
  .topbar {
    height: 40px;
    min-height: 40px;
    flex: 0 0 auto;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 0;
  }

  .brand {
    min-width: 0;
    gap: 7px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .brand-mark svg {
    width: 25px;
    height: 25px;
  }

  .brand-kicker,
  .brand-sub {
    display: none;
  }

  .brand-title {
    font-size: 17px;
    letter-spacing: 0.015em;
  }

  .environment-cluster {
    order: 0;
    width: auto;
    min-width: 0;
    min-height: 0;
    height: 32px;
    flex: 0 1 auto;
    margin-left: auto;
    gap: 0;
  }

  .environment-cluster .micro-label,
  .phase-name,
  .weather-timer {
    display: none;
  }

  .day-cycle {
    min-width: 0;
    flex: 0 0 auto;
    gap: 6px;
    padding: 2px 8px;
  }

  .day-orb {
    width: 18px;
    height: 18px;
  }

  .day-orb i {
    transform: scale(0.78);
  }

  .day-copy strong {
    margin-top: 0;
    font-size: 12px;
    letter-spacing: 0.035em;
  }

  .weather-readout {
    min-width: 0;
    flex: 0 0 auto;
    justify-content: flex-start;
    gap: 6px;
    padding: 2px 8px;
  }

  .weather-glyph {
    width: 14px;
    height: 14px;
    transform: scale(0.86);
  }

  .weather-copy strong {
    max-width: 82px;
    margin-top: 0;
    font-size: 10px;
  }

  .action-cluster {
    order: 0;
    gap: 5px;
    margin-left: 0;
  }

  .audio-button,
  .square-button,
  .new-button {
    width: 34px;
    min-width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    justify-content: center;
  }

  .audio-copy,
  .new-button > span:last-child {
    display: none;
  }

  .equalizer {
    transform: scale(0.86);
  }

  /* Dish on the left, everything else on the right */
  .workspace {
    display: grid;
    min-height: 0;
    flex: 1 1 auto;
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-columns: minmax(0, 1fr) clamp(236px, 34vw, 330px);
    align-items: start;
    gap: 6px;
    padding: 7px 0 0;
    overflow: hidden;
  }

  .observation-column {
    display: contents;
  }

  .stage-section {
    display: flex;
    width: min(
      100%,
      calc(
        (
            100dvh - 40px - 24px - 7px - 8px - max(6px, env(safe-area-inset-top)) -
              max(4px, env(safe-area-inset-bottom))
          ) * 16 / 9 + 8px
      )
    );
    grid-row: 1 / -1;
    grid-column: 1;
    align-self: center;
    justify-self: center;
    flex-direction: column;
    min-height: 0;
  }

  .stage-heading,
  .stage-legend,
  .first-run-hint {
    display: none;
  }

  .stage-deck {
    width: 100%;
    padding: 3px;
  }

  .stage-viewport {
    width: 100%;
    aspect-ratio: 16 / 9;
  }

  .stage-hud-top {
    top: 8px;
    right: 10px;
    left: 10px;
    font-size: 6px;
  }

  .hud-coordinates {
    font-size: 5.5px;
  }

  .focus-tag {
    top: 24px;
    left: 10px;
    max-width: 210px;
  }

  .stage-banner {
    top: 9px;
    right: 9px;
    left: 9px;
    max-width: none;
    padding: 5px 8px;
    transform: none;
    animation: none;
  }

  .stage-banner strong {
    font-size: 10px;
  }

  .banner-sub {
    display: none;
  }

  .stage-bottom {
    justify-content: center;
    padding: 24px 7px 7px;
  }

  .scene-controls {
    width: auto;
    max-width: 100%;
    gap: 2px;
    padding: 3px;
  }

  .control-button {
    width: 38px;
    height: 40px;
  }

  .speed-switch button {
    width: 34px;
    height: 36px;
    font-size: 10px;
  }

  .action-button {
    height: 40px;
    padding: 0 9px;
  }

  .control-separator {
    margin: 0 1px;
  }

  /* Right rail */
  .telemetry {
    min-height: 0;
    grid-row: 1;
    grid-column: 2;
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .metric,
  .metric:nth-child(3) {
    min-height: 38px;
    gap: 2px;
    padding: 4px 5px;
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }

  .metric:last-child {
    border-right: 0;
  }

  .metric-heading {
    gap: 2px;
    font-size: 7.5px;
    line-height: 1.2;
  }

  .metric-heading b,
  .metric-heading em,
  .metric-number small {
    display: none;
  }

  .metric-number strong {
    font-size: 15px;
  }

  .chart-panel {
    grid-row: 2;
    grid-column: 2;
  }

  .chart-heading {
    align-items: center;
    gap: 6px;
    padding: 5px 8px 0;
  }

  .chart-heading .eyebrow,
  .chart-heading h2 span,
  .chart-range,
  .chart-key.key-lineage,
  .chart-key.key-flora {
    display: none;
  }

  .chart-heading h2 {
    margin: 0;
    font-size: 11px;
    line-height: 1.3;
  }

  .chart-legend {
    gap: 5px;
    padding-bottom: 0;
    font-size: 7px;
  }

  .chart-key {
    gap: 3px;
  }

  .chart-key i {
    width: 8px;
  }

  .chart-key b {
    font-size: 8px;
  }

  .chart-wrap {
    height: 40px;
    padding: 3px 5px 5px;
  }

  .sidebar {
    display: flex;
    min-height: 0;
    grid-row: 3;
    grid-column: 2;
    gap: 6px;
    padding-right: 2px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar .inspector-panel {
    order: 2;
  }

  .sidebar:has(.inspector-body:not([hidden])) .inspector-panel {
    order: -1;
  }

  .panel-heading {
    gap: 8px;
    padding: 7px 8px 5px;
  }

  .panel-heading .eyebrow {
    font-size: 6px;
  }

  .panel-heading h2 {
    gap: 4px;
    margin-top: 1px;
    font-size: 12px;
  }

  .panel-heading h2 span {
    display: none;
  }

  .species-panel,
  .inspector-panel {
    min-height: 0;
  }

  .panel-counter strong {
    font-size: 14px;
  }

  .panel-close {
    width: 28px;
    height: 28px;
    margin: -3px -2px 0 0;
  }

  .species-list,
  .event-log {
    max-height: none;
    overflow: visible;
  }

  .species-button {
    min-height: 40px;
    gap: 7px;
    padding: 6px 8px;
  }

  .species-name {
    font-size: 10px;
  }

  .species-sub {
    font-size: 7px;
  }

  .species-count {
    font-size: 8px;
  }

  .panel-note {
    display: none;
  }

  .inspector-empty {
    min-height: 92px;
    padding: 10px 8px 12px;
  }

  .inspector-empty > p {
    font-size: 10px;
  }

  .inspector-empty > span {
    font-size: 8px;
  }

  .scan-reticle {
    width: 30px;
    height: 30px;
  }

  .inspector-body {
    padding: 0 9px 9px;
  }

  .specimen-heading {
    padding: 6px 0;
  }

  .vital-list {
    gap: 4px;
    padding: 2px 0 6px;
  }

  .gene-list {
    gap: 3px;
    padding: 6px 0;
  }

  .specimen-footer {
    gap: 6px 10px;
    padding-top: 6px;
  }

  .log-panel {
    min-height: 0;
    flex: 0 0 auto;
  }

  .log-entry {
    grid-template-columns: 38px 36px minmax(0, 1fr);
    gap: 4px;
    padding: 4px 8px;
    font-size: 8px;
  }

  .log-time {
    font-size: 5.5px;
  }

  .log-tag {
    font-size: 5px;
  }

  /* Compact footer, still inside the safe area */
  .footer {
    height: 24px;
    min-height: 24px;
    flex: 0 0 auto;
    flex-wrap: nowrap;
    gap: 12px;
    margin: 0;
    padding: 2px 0 0;
    font-size: 7px;
  }

  .footer-signature,
  .footer-note {
    display: none;
  }

  .seed-button {
    order: 0;
    width: auto;
    min-height: 20px;
    padding: 0 2px;
    border-color: transparent;
    font-size: 7px;
  }

  .footer-runtime {
    margin-left: auto;
    font-size: 7px;
  }

  .toast {
    bottom: calc(28px + env(safe-area-inset-bottom));
  }

  .help-dialog {
    width: min(700px, calc(100% - 24px));
    max-height: calc(100dvh - 16px);
  }

  .help-inner {
    max-height: calc(100dvh - 16px);
    padding: 14px 18px 13px;
  }

  .help-heading {
    padding-bottom: 8px;
  }

  .help-heading h2 {
    font-size: 18px;
  }

  .help-intro {
    margin: 9px 0;
    font-size: 10px;
    line-height: 1.7;
  }

  .help-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .help-grid article {
    padding: 8px 9px;
  }

  .help-grid h3 {
    margin: 4px 0 2px;
    font-size: 11px;
  }

  .help-grid p {
    font-size: 9px;
    line-height: 1.65;
  }

  .help-controls {
    gap: 6px 10px;
    margin: 9px 0;
    font-size: 8px;
  }

  .help-audio {
    margin: 7px 0;
    font-size: 8px;
  }

  .help-footer {
    align-items: center;
    flex-direction: row;
    gap: 9px;
    padding-top: 8px;
    font-size: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
