* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: rgba(255, 255, 255, 0.85);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#universe {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  background: radial-gradient(ellipse at center, #0a0820 0%, #050315 45%, #000 100%);
  cursor: crosshair;
  touch-action: none;
}

#ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.panel {
  background: rgba(8, 8, 20, 0.45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 16px 20px;
}

#hud-left {
  position: absolute;
  top: 24px;
  left: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 280px;
}

#hud-top-left {
  min-width: 240px;
}

#hud-unlocks,
#hud-instruments {
  min-width: 240px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 1.2s ease, transform 1.2s ease, visibility 0s linear 1.2s;
}
#hud-unlocks.revealed,
#hud-instruments.revealed {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: opacity 1.2s ease, transform 1.2s ease, visibility 0s linear 0s;
}
.unlocks-title {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 10px;
}
#unlocks-list,
#instruments-list {
  list-style: none;
}

/* Unlocks: warm gold "trophy" feel, reserved for non-instrument earnings */
#unlocks-list li {
  font-size: 13px;
  padding: 6px 0 6px 12px;
  color: rgba(255, 226, 184, 0.88);
  border-left: 2px solid rgba(255, 200, 138, 0.55);
  margin: 6px 0;
  line-height: 1.4;
  letter-spacing: 0.5px;
  font-variant: small-caps;
  animation: unlockIn 1.4s cubic-bezier(0.16, 1, 0.3, 1);
  transition: color 0.25s ease, border-left-color 0.25s ease, opacity 0.25s ease;
}

/* Instruments: cool steel-blue "equipment" feel, distinct from Unlocks */
#instruments-list li {
  font-size: 13px;
  padding: 6px 0 6px 12px;
  color: rgba(190, 210, 240, 0.88);
  border-left: 2px solid rgba(159, 184, 255, 0.55);
  margin: 6px 0;
  line-height: 1.4;
  letter-spacing: 0.5px;
  font-variant: small-caps;
  animation: unlockIn 1.4s cubic-bezier(0.16, 1, 0.3, 1);
  transition: color 0.25s ease, border-left-color 0.25s ease, opacity 0.25s ease;
}
#instruments-list li .item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
#instruments-list li .item-label {
  flex: 1;
}
#instruments-list li.toggleable .item-label {
  cursor: pointer;
  pointer-events: auto;
  user-select: none;
}
#instruments-list li.toggleable .item-label:hover {
  color: rgba(220, 235, 255, 1);
}
#instruments-list li.disabled {
  color: rgba(170, 175, 185, 0.45);
  border-left-color: rgba(170, 175, 185, 0.25);
}
#instruments-list li.disabled .item-label {
  text-decoration: line-through;
  text-decoration-color: rgba(170, 175, 185, 0.4);
}
#instruments-list li.toggleable.disabled .item-label:hover {
  color: rgba(210, 215, 225, 0.75);
}

.instruments-tools {
  border-top: 1px solid rgba(184, 164, 255, 0.15);
  padding-top: 8px;
  margin-top: 8px;
  pointer-events: auto;
}
.instruments-tools-header {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 6px;
}
.instruments-tool {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: transparent;
  border: 1px solid rgba(159, 184, 255, 0.24);
  border-radius: 6px;
  padding: 6px 10px;
  color: rgba(190, 210, 240, 0.88);
  cursor: pointer;
  font: inherit;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.instruments-tool:hover:not([disabled]):not([aria-pressed="true"]),
.instruments-tool:focus-visible:not([disabled]):not([aria-pressed="true"]) {
  background: rgba(184, 164, 255, 0.08);
  border-color: rgba(184, 164, 255, 0.4);
  color: rgba(220, 235, 255, 1);
  outline: none;
}
.instruments-tool[aria-pressed="true"] {
  background: rgba(184, 164, 255, 0.15);
  border-color: rgba(184, 164, 255, 0.5);
  color: rgba(230, 240, 255, 1);
}
.instruments-tool[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}
.tool-glyph {
  font-size: 1.1em;
  flex-shrink: 0;
}
.tool-label {
  flex: 1;
  text-align: left;
}
.tool-cost {
  margin-left: auto;
  opacity: 0.6;
  font-size: 0.85em;
  font-variant-numeric: tabular-nums;
}
.instruments-tools-readout {
  font-size: 0.8em;
  opacity: 0.65;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

/* Instrument themed icon (speaker/eye). Click to quick-toggle. */
.instrument-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(190, 210, 240, 0.8);
  cursor: pointer;
  pointer-events: auto;
  user-select: none;
  transition: color 0.2s ease, transform 0.2s ease;
  flex-shrink: 0;
}
.instrument-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}
.instrument-icon:hover {
  color: rgba(230, 245, 255, 1);
  transform: scale(1.1);
}
.instrument-icon .icon-strike {
  opacity: 0;
  transition: opacity 0.25s ease;
  /* Animate the strike drawing in by clipping its length */
  stroke-dasharray: 20;
  stroke-dashoffset: 20;
}
#instruments-list li.disabled .instrument-icon {
  color: rgba(180, 188, 200, 0.55);
}
#instruments-list li.disabled .instrument-icon .icon-strike {
  opacity: 1;
  stroke-dashoffset: 0;
  transition: opacity 0.25s ease, stroke-dashoffset 0.4s ease;
}

/* Settings gear icon */
.settings-toggle {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: rgba(190, 210, 240, 0.55);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 11px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease, transform 0.3s ease;
  font-family: inherit;
}
.settings-toggle:hover, .settings-toggle:focus {
  color: rgba(220, 235, 255, 1);
  border-color: rgba(190, 210, 255, 0.7);
  background: rgba(190, 210, 255, 0.12);
  outline: none;
}
#instruments-list li.expanded .settings-toggle {
  transform: rotate(45deg);
  color: rgba(220, 235, 255, 1);
  border-color: rgba(190, 210, 255, 0.7);
}

/* Settings panel (inline drawer below each instrument) */
.settings-panel {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  margin-top: 0;
  transition: max-height 0.35s ease, opacity 0.25s ease, margin-top 0.3s ease;
}
#instruments-list li.expanded .settings-panel {
  max-height: 600px;
  opacity: 1;
  margin-top: 8px;
}
.setting-row {
  display: block;
  margin: 10px 0;
}
.setting-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}
.setting-label {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-variant: normal;
}
.setting-value {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  color: rgba(220, 235, 255, 0.85);
  font-variant-numeric: tabular-nums;
  font-variant: normal;
}

/* Custom-styled range input */
.setting-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  pointer-events: auto;
  margin: 0;
}
.setting-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(190, 210, 255, 0.95);
  border: 1px solid rgba(159, 184, 255, 0.6);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(159, 184, 255, 0.4);
  transition: transform 0.15s ease;
}
.setting-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}
.setting-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(190, 210, 255, 0.95);
  border: 1px solid rgba(159, 184, 255, 0.6);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(159, 184, 255, 0.4);
}

/* Custom-styled select dropdown */
.setting-select {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: rgba(220, 235, 255, 0.9);
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  font-variant: normal;
  letter-spacing: 0.2px;
  cursor: pointer;
  pointer-events: auto;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path d='M3 4.5l3 3 3-3' stroke='%23b6cdf5' stroke-width='1.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 11px;
  padding-right: 26px;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}
.setting-select:focus, .setting-select:hover {
  outline: none;
  border-color: rgba(190, 210, 255, 0.55);
  background-color: rgba(255, 255, 255, 0.1);
}
.setting-select option {
  background: rgba(10, 8, 24, 0.98);
  color: rgba(220, 235, 255, 0.9);
}

/* iOS-style toggle switch for boolean settings */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 16px;
  pointer-events: auto;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.25s ease, border-color 0.25s ease;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  background: rgba(190, 210, 240, 0.85);
  border-radius: 50%;
  top: 1px;
  left: 1px;
  transition: transform 0.25s ease, background 0.25s ease;
}
.toggle-switch input:checked + .toggle-slider {
  background: rgba(159, 184, 255, 0.42);
  border-color: rgba(190, 210, 255, 0.6);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(16px);
  background: rgba(230, 240, 255, 1);
}

/* Restore-defaults button: subtle low-priority chip */
.settings-reset {
  display: block;
  margin: 12px auto 2px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(190, 210, 240, 0.55);
  font-size: 9px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  padding: 4px 14px;
  border-radius: 12px;
  cursor: pointer;
  pointer-events: auto;
  font-family: inherit;
  font-variant: normal;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.settings-reset:hover, .settings-reset:focus {
  color: rgba(220, 235, 255, 0.95);
  border-color: rgba(190, 210, 255, 0.5);
  background: rgba(190, 210, 255, 0.08);
  outline: none;
}
@keyframes unlockIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
    text-shadow: 0 0 24px rgba(255, 226, 184, 0.9);
  }
  to {
    opacity: 1;
    transform: translateX(0);
    text-shadow: 0 0 0 rgba(255, 226, 184, 0);
  }
}

.era-line {
  font-size: 16px;
  margin-bottom: 14px;
  font-weight: 500;
}
.era-line.lens-line {
  margin-top: -4px;
  margin-bottom: 14px;
  /* Hidden by default, the opening-thermal whisper reveals it dramatically. */
  opacity: 0;
  max-height: 0;
  margin-bottom: 0;
  overflow: hidden;
  transition: opacity 2.4s ease, max-height 1.6s ease, margin-bottom 1.6s ease;
  pointer-events: none;
}
.era-line.lens-line.revealed {
  opacity: 1;
  max-height: 64px;
  margin-bottom: 14px;
  pointer-events: auto;
}
.era-line.lens-line.revealed.inactive {
  opacity: 0.35;
}
.era-line.year-line {
  margin-bottom: 10px;
}
.era-line.year-line #year-count {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.4px;
  color: rgba(255, 255, 255, 0.92);
}
.era-line .label {
  display: block;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 4px;
}
#era-name {
  color: #c7b6ff;
  font-size: 17px;
  letter-spacing: 0.3px;
}
#era-info {
  vertical-align: 2px;
  margin-left: 6px;
}
#lens-name {
  color: #9fb8ff;
  font-size: 14px;
  letter-spacing: 0.5px;
  font-variant: small-caps;
  transition: color 1.5s ease, text-shadow 1s ease, transform 1s ease;
  display: inline-block;
}
#lens-name.visible {
  color: #ffd28a;
}

/* Drawn-attention pulse, used when a whisper specifically points to an element */
.whisper-attention {
  animation: whisperAttention 2.6s ease-in-out infinite;
  transform-origin: left center;
}
@keyframes whisperAttention {
  0%, 100% {
    text-shadow: 0 0 0 rgba(159, 184, 255, 0);
    transform: scale(1);
  }
  50% {
    text-shadow:
      0 0 16px rgba(159, 184, 255, 0.95),
      0 0 36px rgba(159, 184, 255, 0.55),
      0 0 64px rgba(120, 100, 220, 0.3);
    transform: scale(1.08);
  }
}

.stat-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: 6px 0;
}
.stat-line.stat-conditional {
  /* Hidden until the corresponding metric becomes meaningful (> 0). */
  opacity: 0;
  max-height: 0;
  margin: 0;
  overflow: hidden;
  pointer-events: none;
  transition: opacity 1.2s ease, max-height 0.9s ease, margin 0.9s ease;
}
.stat-line.stat-conditional.revealed {
  opacity: 1;
  max-height: 40px;
  margin: 6px 0;
  pointer-events: auto;
}
.stat-line .label {
  color: rgba(255, 255, 255, 0.45);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 1.2px;
}
.stat-line span:last-child {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 14px;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  padding: 0;
  margin-left: 5px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
  font-family: inherit;
  font-size: 9px;
  font-weight: 600;
  line-height: 1;
  text-align: center;
  cursor: pointer;
  pointer-events: auto;
  user-select: none;
  vertical-align: middle;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.info-icon:hover, .info-icon:focus {
  color: #fff;
  border-color: rgba(184, 164, 255, 0.7);
  background: rgba(184, 164, 255, 0.12);
  outline: none;
}

#info-tooltip {
  position: fixed;
  z-index: 200;
  max-width: 300px;
  padding: 16px 20px;
  background: rgba(10, 8, 24, 0.94);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(184, 164, 255, 0.32);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5),
              0 0 60px rgba(184, 164, 255, 0.08);
  color: rgba(255, 255, 255, 0.82);
  font-size: 13px;
  line-height: 1.55;
  letter-spacing: 0.15px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#info-tooltip.visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}
#info-tooltip .tip-title {
  display: block;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #c7b6ff;
  margin-bottom: 8px;
  font-weight: 500;
}
#info-tooltip p {
  margin: 0;
}
#info-tooltip p + p {
  margin-top: 10px;
}

#macro-inspector,
#emitter-inspector {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 180;
  min-width: 156px;
  padding: 12px 14px 11px;
  background: rgba(10, 8, 24, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(184, 164, 255, 0.32);
  border-radius: 10px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.5),
              0 0 48px rgba(184, 164, 255, 0.08);
  color: rgba(255, 255, 255, 0.86);
  font-size: 12px;
  line-height: 1.45;
  letter-spacing: 0.2px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease;
  will-change: transform, opacity;
  transform: translate3d(-9999px, -9999px, 0);
}
#macro-inspector[data-visible="1"],
#emitter-inspector[data-visible="1"] {
  opacity: 1;
}
/* Emitter inspector: warm amber accent to match emitter glyph + catalog row. */
#emitter-inspector {
  border-color: rgba(212, 168, 92, 0.45);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.5),
              0 0 48px rgba(212, 168, 92, 0.12);
}
#emitter-inspector .mi-kind { color: rgba(232, 188, 112, 0.95); }
#inspector-leader,
#emitter-inspector-leader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 179;
  pointer-events: none;
  overflow: visible;
  opacity: 0;
  transition: opacity 0.18s ease;
}
#inspector-leader[data-visible="1"],
#emitter-inspector-leader[data-visible="1"] {
  opacity: 1;
}
#inspector-leader polyline {
  fill: none;
  stroke: rgba(184, 164, 255, 0.78);
  stroke-width: 1;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 3px rgba(184, 164, 255, 0.45))
          drop-shadow(0 0 8px rgba(184, 164, 255, 0.25));
}
#emitter-inspector-leader polyline {
  fill: none;
  stroke: rgba(232, 188, 112, 0.85);
  stroke-width: 1;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 3px rgba(232, 188, 112, 0.45))
          drop-shadow(0 0 8px rgba(232, 188, 112, 0.25));
}
#macro-inspector .mi-kind,
#emitter-inspector .mi-kind {
  display: block;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #c7b6ff;
  font-weight: 500;
}
#macro-inspector[data-kind="cradle"] .mi-kind {
  color: #ffd49b;
}
#macro-inspector[data-kind="star"] .mi-kind {
  color: #ffe8a8;
}
#macro-inspector[data-kind="star"] {
  border-color: rgba(255, 232, 168, 0.45);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.5),
              0 0 56px rgba(255, 232, 168, 0.16);
}
#macro-inspector .mi-name,
#emitter-inspector .mi-name {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  letter-spacing: 0.2px;
  margin-bottom: 2px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#macro-inspector .mi-header,
#emitter-inspector .mi-header {
  margin-bottom: 8px;
}
#macro-inspector .mi-titles,
#emitter-inspector .mi-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
#macro-inspector .mi-hint,
#emitter-inspector .mi-hint {
  margin-top: 8px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.38);
  letter-spacing: 0.4px;
  font-style: italic;
}
#macro-inspector .mi-row,
#emitter-inspector .mi-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 2px 0;
}
#macro-inspector .mi-label,
#emitter-inspector .mi-label {
  color: rgba(255, 255, 255, 0.48);
}
#macro-inspector .mi-value,
#emitter-inspector .mi-value {
  color: rgba(255, 255, 255, 0.92);
  font-variant-numeric: tabular-nums;
}
#macro-inspector[data-pinned="1"] {
  border-color: rgba(199, 182, 255, 0.55);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.55),
              0 0 56px rgba(184, 164, 255, 0.18);
}

#macro-context-menu {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 220;
  min-width: 180px;
  padding: 8px;
  background: rgba(10, 8, 24, 0.96);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(184, 164, 255, 0.45);
  border-radius: 10px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.6),
              0 0 56px rgba(184, 164, 255, 0.14);
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  letter-spacing: 0.2px;
  pointer-events: auto;
  opacity: 0;
  transform: translate3d(-9999px, -9999px, 0) scale(0.96);
  transform-origin: top left;
  transition: opacity 0.12s ease, transform 0.12s ease;
  will-change: transform, opacity;
  user-select: none;
}
#macro-context-menu[data-visible="1"] {
  opacity: 1;
}
#macro-context-menu .mcm-header {
  padding: 4px 8px 8px;
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(184, 164, 255, 0.18);
}
#macro-context-menu .mcm-title {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #c7b6ff;
  font-weight: 500;
}
#macro-context-menu[data-kind="cradle"] .mcm-title {
  color: #ffd49b;
}
#macro-context-menu .mcm-actions {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#macro-context-menu .mcm-actions[hidden] { display: none; }
#macro-context-menu .mcm-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.88);
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
#macro-context-menu .mcm-item:hover,
#macro-context-menu .mcm-item:focus-visible {
  background: rgba(184, 164, 255, 0.15);
  color: #fff;
  outline: none;
}
#macro-context-menu .mcm-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  color: rgba(199, 182, 255, 0.85);
  font-size: 13px;
}
#macro-context-menu[data-tracked="1"] .mcm-item[data-action="track"] .mcm-glyph {
  color: #c7b6ff;
}
#macro-context-menu[data-kind="cradle"][data-tracked="1"] .mcm-item[data-action="track"] .mcm-glyph {
  color: #ffd49b;
}
#macro-context-menu .mcm-item[data-action="emitter-remove"] {
  opacity: 0.75;
}
#macro-context-menu .mcm-item[data-action="emitter-remove"]:hover,
#macro-context-menu .mcm-item[data-action="emitter-remove"]:focus-visible {
  opacity: 1;
}
#macro-context-menu .mcm-rename {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 4px 0;
}
#macro-context-menu .mcm-rename[hidden] { display: none; }
#macro-context-menu .mcm-input {
  width: 100%;
  padding: 7px 9px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(184, 164, 255, 0.55);
  border-radius: 6px;
  color: #fff;
  font-size: 13px;
  font-family: inherit;
  letter-spacing: 0.2px;
  outline: none;
  box-sizing: border-box;
}
#macro-context-menu .mcm-input:focus {
  border-color: rgba(199, 182, 255, 0.95);
  box-shadow: 0 0 0 2px rgba(184, 164, 255, 0.18);
}
#macro-context-menu .mcm-rename-hint {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.42);
  letter-spacing: 0.4px;
  font-style: italic;
  padding: 0 2px;
}

#hud-top-right {
  position: absolute;
  top: 24px;
  right: 24px;
  max-width: 320px;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(100vh - 48px);
}
#hud-laws {
  flex: 0 0 auto;
}
#hud-catalog {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
}
.catalog-title {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 8px;
  flex: 0 0 auto;
}
/* Catalog subsections: each has a header (chevron + label + count) and a
   collapsible list. Header click toggles `.collapsed` on the parent
   `.catalog-section`. */
.catalog-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-bottom: 6px;
}
.catalog-section[hidden] { display: none; }
.catalog-section + .catalog-section {
  border-top: 1px solid rgba(184, 164, 255, 0.12);
  padding-top: 6px;
  margin-top: 6px;
}
.catalog-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 4px 4px 4px 2px;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  text-align: left;
  transition: color 0.15s ease;
  flex: 0 0 auto;
}
.catalog-section-header:hover {
  color: rgba(255, 255, 255, 0.85);
}
.catalog-chevron {
  display: inline-block;
  width: 12px;
  font-size: 11px;
  transition: transform 0.18s ease;
}
.catalog-section.collapsed .catalog-chevron {
  transform: rotate(-90deg);
}
.catalog-section-label {
  flex: 1 1 auto;
  color: rgba(184, 164, 255, 0.78);
  font-weight: 500;
}
.catalog-section-count {
  color: rgba(255, 255, 255, 0.45);
  font-variant-numeric: tabular-nums;
  font-size: 10px;
}
.catalog-section.collapsed .catalog-section-list {
  display: none;
}
.catalog-section-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}
.catalog-section-list::-webkit-scrollbar { width: 6px; }
.catalog-section-list::-webkit-scrollbar-thumb {
  background: rgba(184, 164, 255, 0.18);
  border-radius: 3px;
}
.catalog-section-list li {
  list-style: none;
  padding: 7px 10px 7px 10px;
  margin: 4px 0;
  border-left: 2px solid rgba(184, 164, 255, 0.4);
  border-radius: 0 6px 6px 0;
  background: rgba(184, 164, 255, 0.04);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.catalog-section-list li:hover {
  background: rgba(184, 164, 255, 0.12);
  border-left-color: rgba(199, 182, 255, 0.85);
}
.catalog-section-list li.is-pinned {
  background: rgba(184, 164, 255, 0.16);
  border-left-color: #c7b6ff;
}
.catalog-section-list li[data-kind="cradle"] {
  border-left-color: rgba(255, 212, 155, 0.55);
}
.catalog-section-list li[data-kind="cradle"]:hover,
.catalog-section-list li[data-kind="cradle"].is-pinned {
  border-left-color: #ffd49b;
}
.catalog-section-list li.is-star,
.catalog-section-list li[data-kind="star"] {
  border-left-color: rgba(255, 232, 168, 0.62);
}
.catalog-section-list li.is-star:hover,
.catalog-section-list li.is-star.is-pinned,
.catalog-section-list li[data-kind="star"]:hover,
.catalog-section-list li[data-kind="star"].is-pinned {
  background: rgba(255, 232, 168, 0.12);
  border-left-color: #ffe8a8;
}
.catalog-section-list .cat-row-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.catalog-section-list .cat-titles {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}
.catalog-section-list .cat-title {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.92);
  letter-spacing: 0.2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.catalog-section-list .cat-sub {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.4px;
  font-variant-numeric: tabular-nums;
}
.catalog-section-list .cat-chevron {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  margin: -4px -4px -4px 0;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: rgba(199, 182, 255, 0.85);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease, transform 0.2s ease;
}
/* Quick untrack button on tracked entries. Sits between titles and chevron.
   Filled gold star; clicking removes the macro from tracking. */
.catalog-section-list .cat-star {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  margin: -2px 2px -2px 0;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: rgba(255, 215, 130, 0.85);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.catalog-section-list .cat-star svg {
  width: 16px;
  height: 16px;
  display: block;
  filter: drop-shadow(0 0 2px rgba(255, 215, 130, 0.35));
}
.catalog-section-list .cat-star:hover {
  color: #ffe9a5;
  background: rgba(255, 215, 130, 0.18);
  border-color: rgba(255, 215, 130, 0.4);
  transform: scale(1.1);
}
.catalog-section-list .cat-star:active {
  transform: scale(0.9);
}
.catalog-section-list .cat-chevron:hover {
  color: #fff;
  background: rgba(184, 164, 255, 0.18);
  border-color: rgba(184, 164, 255, 0.35);
}
.catalog-section-list li.is-expanded .cat-chevron {
  transform: rotate(90deg);
  color: #fff;
  background: rgba(184, 164, 255, 0.14);
}
.catalog-section-list li[data-kind="cradle"] .cat-chevron:hover,
.catalog-section-list li[data-kind="cradle"].is-expanded .cat-chevron {
  background: rgba(255, 212, 155, 0.16);
  border-color: rgba(255, 212, 155, 0.35);
}
.catalog-section-list li.is-star .cat-chevron:hover,
.catalog-section-list li.is-star.is-expanded .cat-chevron,
.catalog-section-list li[data-kind="star"] .cat-chevron:hover,
.catalog-section-list li[data-kind="star"].is-expanded .cat-chevron {
  background: rgba(255, 232, 168, 0.18);
  border-color: rgba(255, 232, 168, 0.38);
}
.catalog-section-list .cat-timeline {
  margin-top: 8px;
  padding: 6px 0 2px 8px;
  border-left: 1px solid rgba(184, 164, 255, 0.22);
  display: none;
  flex-direction: column;
  gap: 6px;
}
.catalog-section-list li.is-expanded .cat-timeline {
  display: flex;
}
.catalog-section-list li[data-kind="cradle"] .cat-timeline {
  border-left-color: rgba(255, 212, 155, 0.28);
}
.catalog-section-list li.is-star .cat-timeline,
.catalog-section-list li[data-kind="star"] .cat-timeline {
  border-left-color: rgba(255, 232, 168, 0.34);
}
.catalog-section-list .cat-event {
  font-size: 11px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.78);
}
.catalog-section-list .cat-event-year {
  display: block;
  font-size: 9px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(199, 182, 255, 0.7);
  font-variant-numeric: tabular-nums;
  margin-bottom: 1px;
}
.catalog-section-list .cat-event[data-kind="born"] .cat-event-year,
.catalog-section-list .cat-event[data-kind="born-cradle"] .cat-event-year {
  color: rgba(199, 182, 255, 0.95);
}
.catalog-section-list .cat-event[data-kind="cradle"] .cat-event-year,
.catalog-section-list .cat-event[data-kind="born-cradle"] .cat-event-year {
  color: rgba(255, 212, 155, 0.95);
}
.catalog-section-list .cat-event[data-kind="ignited"] {
  position: relative;
}
.catalog-section-list .cat-event[data-kind="ignited"]::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 4px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #ffe8a8;
  box-shadow: 0 0 10px rgba(255, 232, 168, 0.75);
}
.catalog-section-list .cat-event[data-kind="ignited"] .cat-event-year {
  color: rgba(255, 232, 168, 0.98);
  text-shadow: 0 0 10px rgba(255, 232, 168, 0.4);
}
.catalog-section-list .cat-event-label {
  display: block;
  word-break: break-word;
}
.catalog-section-list .cat-event-name {
  color: rgba(255, 255, 255, 0.92);
}
.catalog-section-list .cat-event-tombstone {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: -2px;
  width: 10px;
  height: 12px;
  margin: 0 5px 0 4px;
  color: rgba(255, 255, 255, 0.5);
}
.catalog-section-list .cat-event-tombstone svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Emitter rows in the Deployed subsection. Differentiate from tracked
   body rows with the amber accent that emitters use everywhere else. */
.catalog-section-list li.cat-emitter {
  border-left-color: rgba(212, 168, 92, 0.55);
  cursor: default;
}
.catalog-section-list li.cat-emitter:hover {
  border-left-color: rgba(232, 188, 112, 0.85);
  background: rgba(212, 168, 92, 0.08);
}
.catalog-section-list li.cat-emitter.is-paused {
  opacity: 0.6;
  border-left-color: rgba(180, 160, 140, 0.4);
}
.catalog-section-list li.cat-emitter.is-hidden {
  opacity: 0.45;
}
.catalog-section-list li.cat-emitter.is-pinned {
  border-left-color: rgba(232, 188, 112, 0.95);
  background: rgba(212, 168, 92, 0.10);
  box-shadow: inset 0 0 0 1px rgba(232, 188, 112, 0.25);
}
.catalog-section-list li.cat-emitter .cat-sub {
  color: rgba(220, 200, 170, 0.6);
}
.cat-emitter-actions {
  display: flex;
  gap: 4px;
  flex: 0 0 auto;
}
.cat-emitter-actions .cat-eye {
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: rgba(220, 200, 170, 0.75);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.cat-emitter-actions .cat-eye:hover {
  background: rgba(212, 168, 92, 0.15);
  color: #fff;
  border-color: rgba(212, 168, 92, 0.4);
}
.cat-emitter-actions .cat-eye svg {
  width: 16px;
  height: 16px;
  display: block;
}
.cat-emitter-actions .cat-eye .icon-strike {
  opacity: 0;
  stroke-dasharray: 20;
  stroke-dashoffset: 20;
  transition: opacity 0.2s ease, stroke-dashoffset 0.3s ease;
}
.cat-emitter.is-hidden .cat-eye .icon-strike {
  opacity: 1;
  stroke-dashoffset: 0;
}

/* Power (pause/resume) button. Two stacked SVGs; .is-paused on parent li
   swaps which icon is visible. */
.cat-emitter-actions .cat-power {
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: rgba(220, 200, 170, 0.75);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  position: relative;
}
.cat-emitter-actions .cat-power:hover {
  background: rgba(212, 168, 92, 0.15);
  color: #fff;
  border-color: rgba(212, 168, 92, 0.4);
}
.cat-emitter-actions .cat-power svg {
  width: 16px;
  height: 16px;
  display: block;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.cat-emitter-actions .cat-power .icon-off { display: none; }
.cat-emitter.is-paused .cat-power .icon-on { display: none; }
.cat-emitter.is-paused .cat-power .icon-off { display: block; }
.cat-emitter.is-paused .cat-power { color: rgba(180, 160, 140, 0.6); }

/* Delete button with confirm step. Trash icon by default; first click adds
   .is-confirming which swaps in the "Confirm?" label and a red accent. */
.cat-emitter-actions .cat-trash {
  height: 28px;
  min-width: 28px;
  padding: 0 6px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: rgba(220, 200, 170, 0.75);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: 11px;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.cat-emitter-actions .cat-trash:hover {
  background: rgba(220, 110, 110, 0.18);
  color: #ffd0d0;
  border-color: rgba(220, 110, 110, 0.45);
}
.cat-emitter-actions .cat-trash svg {
  width: 16px;
  height: 16px;
  display: block;
}
.cat-emitter-actions .cat-trash .confirm-label { display: none; }
.cat-emitter-actions .cat-trash.is-confirming {
  background: rgba(220, 110, 110, 0.25);
  color: #fff;
  border-color: rgba(220, 110, 110, 0.6);
  padding: 0 10px;
}
.cat-emitter-actions .cat-trash.is-confirming .icon-trash { display: none; }
.cat-emitter-actions .cat-trash.is-confirming .confirm-label { display: inline; }

.catalog-empty {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.3);
  font-style: italic;
  flex: 0 0 auto;
}
.laws-title {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 10px;
}
#laws-list {
  list-style: none;
}
#laws-list li {
  font-size: 13px;
  padding: 6px 0 6px 12px;
  color: rgba(255, 255, 255, 0.78);
  font-style: italic;
  border-left: 2px solid rgba(184, 164, 255, 0.4);
  margin: 6px 0;
  line-height: 1.4;
  animation: lawIn 1.2s ease-out;
}
#laws-list li .info-icon {
  font-style: normal;
  vertical-align: 1px;
}
.laws-empty {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.3);
  font-style: italic;
}
#laws-list:not(:empty) + .laws-empty { display: none; }

@keyframes lawIn {
  from { opacity: 0; transform: translateX(8px); }
  to   { opacity: 1; transform: translateX(0); }
}

#hud-bottom {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  transition: opacity 0.6s ease;
}

#hint {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 2px;
  text-transform: uppercase;
  text-align: center;
  white-space: nowrap;
}

#whisper {
  position: absolute;
  top: 25%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 17px;
  font-style: italic;
  letter-spacing: 0.5px;
  text-align: center;
  line-height: 1.55;
  color: rgba(199, 182, 255, 0.88);
  text-shadow: 0 0 28px rgba(184, 164, 255, 0.4),
               0 0 60px rgba(120, 100, 220, 0.2);
  opacity: 0;
  pointer-events: none;
  max-width: min(640px, 72vw);
  transition: opacity 2.2s ease;
  will-change: opacity;
}
#whisper.show { opacity: 1; }

#reset-btn {
  position: absolute;
  bottom: 24px;
  right: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(8, 8, 20, 0.5);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.55);
  font-size: 18px;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.2s ease;
  font-family: inherit;
}
#reset-btn:hover {
  color: #fff;
  border-color: rgba(184, 164, 255, 0.5);
  transform: rotate(-90deg);
}
#reset-btn.armed {
  color: #fff;
  background: rgba(120, 30, 60, 0.7);
  border-color: rgba(255, 120, 140, 0.7);
  transform: scale(1.1);
  animation: armedPulse 1s ease-in-out infinite;
}

/* Recenter button: sits above the mute button in the right-side stack.
   Hidden via the [hidden] attribute by default; main.js toggles it
   when the camera override is active. */
#recenter-btn {
  position: absolute;
  bottom: 168px;
  right: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(8, 8, 20, 0.5);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.55);
  font-size: 20px;
  cursor: pointer;
  pointer-events: auto;
  transition: color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
  font-family: inherit;
}
#recenter-btn:hover {
  color: #fff;
  border-color: rgba(184, 164, 255, 0.5);
  transform: scale(1.08);
}
#recenter-btn[hidden] { display: none; }

/* Camera zoom readout: small numeric pill that sits to the left of the
   recenter button. Always visible, updates every frame. Tabular numerals
   so the value doesn't dance as digits change. */
#zoom-indicator {
  position: absolute;
  bottom: 168px;
  right: 72px;
  height: 40px;
  line-height: 40px;
  padding: 0 4px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.6px;
  text-align: right;
  pointer-events: none;
}

/* Camera controls tutorial: one-time hint that appears alongside the
   cosmos-yours whisper at the end of the First Light cinematic, when
   manual camera unlocks for the first time. Auto-dismisses on the
   first manual camera interaction OR after a short timeout. */
#camera-tutorial {
  position: absolute;
  bottom: 96px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  max-width: 520px;
  padding: 10px 18px;
  background: rgba(10, 8, 24, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(199, 182, 255, 0.32);
  border-radius: 22px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 13px;
  letter-spacing: 0.3px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease, transform 0.6s ease;
  z-index: 60;
}
#camera-tutorial[hidden] { display: none; }
#camera-tutorial.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
#camera-tutorial .ct-key {
  display: inline-block;
  margin: 0 2px;
  padding: 1px 6px;
  border: 1px solid rgba(199, 182, 255, 0.4);
  border-radius: 4px;
  font-size: 11px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  color: rgba(255, 255, 255, 0.92);
  vertical-align: 1px;
}
#camera-tutorial .ct-sep {
  margin: 0 8px;
  color: rgba(199, 182, 255, 0.5);
}

/* Settings button: sits above the reset button, same circular chrome. */
#settings-btn {
  position: absolute;
  bottom: 72px;
  right: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(8, 8, 20, 0.5);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.55);
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  pointer-events: auto;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease, transform 0.25s ease;
  font-family: inherit;
}
#settings-btn:hover {
  color: #fff;
  border-color: rgba(184, 164, 255, 0.5);
}
#settings-btn.expanded {
  color: #fff;
  border-color: rgba(184, 164, 255, 0.7);
  background: rgba(40, 30, 70, 0.6);
  transform: rotate(45deg);
}

#mute-btn {
  position: absolute;
  bottom: 120px;
  right: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(8, 8, 20, 0.5);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.55);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  pointer-events: auto;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
  font-family: inherit;
}
#mute-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}
#mute-btn .icon-strike {
  opacity: 0;
  stroke-dasharray: 20;
  stroke-dashoffset: 20;
  transition: opacity 0.25s ease, stroke-dashoffset 0.4s ease;
}
#mute-btn:hover {
  color: #fff;
  border-color: rgba(184, 164, 255, 0.5);
}
#mute-btn.muted {
  color: rgba(255, 140, 160, 0.9);
  border-color: rgba(255, 120, 140, 0.55);
  background: rgba(40, 8, 16, 0.6);
}
#mute-btn.muted .icon-strike {
  opacity: 1;
  stroke-dashoffset: 0;
}
#mute-btn.muted:hover {
  color: #fff;
  border-color: rgba(255, 160, 180, 0.85);
}

/* Floating global settings popup, anchored bottom-right above the buttons. */
#settings-panel {
  position: absolute;
  bottom: 172px;
  right: 24px;
  min-width: 260px;
  max-width: 320px;
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0s linear 0.25s;
  pointer-events: none;
}
#settings-panel.revealed {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0s linear 0s;
  pointer-events: auto;
}
#settings-content .setting-row { margin: 10px 0; }
#settings-content .setting-row:last-child { margin-bottom: 4px; }
@keyframes armedPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 120, 140, 0.4); }
  50%      { box-shadow: 0 0 0 8px rgba(255, 120, 140, 0); }
}

#discovery-banner {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  padding: 28px 48px;
  background: rgba(18, 10, 38, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(184, 164, 255, 0.35);
  border-radius: 18px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 80vw;
  box-shadow: 0 0 80px rgba(184, 164, 255, 0.15);
}
#discovery-banner.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
#discovery-banner .title {
  display: block;
  font-size: 11px;
  letter-spacing: 4px;
  color: #b8a4ff;
  text-transform: uppercase;
  margin-bottom: 10px;
}
#discovery-banner .era-title {
  font-size: 22px;
  color: #fff;
  letter-spacing: 0.5px;
  margin-bottom: 14px;
}
#discovery-banner .law {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.65);
  font-style: italic;
  letter-spacing: 0.3px;
}

/* ---------------------------------------------------------------------------
 * MOBILE LAYOUT (touch devices, narrow viewports).
 * Scoped strictly: only active when the viewport is ≤932px AND pointer is
 * coarse (touch). Desktop browsers, including desktop Safari, never match
 * this query no matter the window size.
 * --------------------------------------------------------------------------- */
@media (max-width: 932px) and (pointer: coarse) {
  /* Use dynamic viewport units to dodge the iOS Safari URL-bar height jump. */
  html, body { height: 100dvh; }
  #universe {
    width: 100dvw;
    height: 100dvh;
  }
  #ui {
    inset: 0;
    /* Allow safe-area padding without affecting absolute children. */
  }

  /* ---- Top-left panel ---- */
  #hud-left {
    top: max(8px, env(safe-area-inset-top, 0px));
    left: max(8px, env(safe-area-inset-left, 0px));
    gap: 8px;
    max-width: 58vw;
  }
  #hud-top-left {
    min-width: 0;
    padding: 10px 12px;
    pointer-events: auto;
  }
  #hud-top-left .era-line { font-size: 13px; margin-bottom: 8px; }
  #hud-top-left .era-line.year-line { margin-bottom: 6px; }
  #hud-top-left .era-line.lens-line.revealed { margin-bottom: 6px; max-height: 48px; }
  #hud-top-left #year-count { font-size: 18px; }
  #hud-top-left #era-name { font-size: 14px; }
  #hud-top-left #lens-name { font-size: 12px; }
  #hud-top-left .era-line .label { font-size: 9px; margin-bottom: 2px; letter-spacing: 1.2px; }
  #hud-top-left .stat-line { font-size: 12px; padding: 3px 0; }
  #hud-top-left .stat-line .label { font-size: 9px; letter-spacing: 1.2px; }

  /* Stats inside top-left: collapsed by default, tap "Stats" to expand. */
  #hud-top-left .stat-body { display: none; margin-top: 4px; }
  #hud-top-left.stats-expanded .stat-body { display: block; }
  #hud-top-left .stat-toggle {
    display: block;
    margin-top: 8px;
    background: transparent;
    border: 1px solid rgba(184, 164, 255, 0.18);
    color: rgba(255, 255, 255, 0.55);
    font-family: inherit;
    font-size: 9px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: 8px;
    cursor: pointer;
  }
  #hud-top-left .stat-toggle::after { content: " ▾"; opacity: 0.6; }
  #hud-top-left.stats-expanded .stat-toggle::after { content: " ▴"; }

  #hud-instruments,
  #hud-unlocks {
    min-width: 0;
    padding: 10px 12px;
    pointer-events: auto;
  }
  #hud-instruments .unlocks-title,
  #hud-unlocks .unlocks-title { margin-bottom: 6px; }
  #instruments-list li { font-size: 12px; padding: 5px 0 5px 10px; gap: 6px; }
  #instruments-list .instrument-name { letter-spacing: 0.5px; }

  /* ---- Top-right panel ---- */
  #hud-top-right {
    top: max(8px, env(safe-area-inset-top, 0px));
    right: max(8px, env(safe-area-inset-right, 0px));
    max-width: 42vw;
    min-width: 0;
    max-height: calc(100dvh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 180px);
    gap: 8px;
  }
  #hud-laws,
  #hud-catalog {
    padding: 10px 12px;
    pointer-events: auto;
  }
  .laws-title,
  .catalog-title { margin-bottom: 6px; font-size: 9px; letter-spacing: 1.2px; }
  #laws-list li { font-size: 11px; padding: 4px 8px; margin: 4px 0; }
  .catalog-section-list li { font-size: 11px; }
  .laws-empty, .catalog-empty { font-size: 11px; }

  /* ---- Collapsible panels: body hidden until expanded ---- */
  .panel.is-collapsible .panel-body { display: none; }
  .panel.is-collapsible.is-expanded .panel-body { display: block; }
  .panel.is-collapsible .panel-header {
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    position: relative;
    padding-right: 18px;
    /* tap target height */
    min-height: 22px;
    display: flex;
    align-items: center;
    margin-bottom: 0;
  }
  .panel.is-collapsible .panel-header::after {
    content: "▾";
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: rgba(184, 164, 255, 0.55);
    transition: transform 0.18s ease;
  }
  .panel.is-collapsible.is-expanded .panel-header::after {
    transform: translateY(-50%) rotate(180deg);
  }
  .panel.is-collapsible.is-expanded .panel-header { margin-bottom: 8px; }

  /* Catalog: when expanded, give it its own scroll area capped to viewport. */
  #hud-catalog.is-collapsible.is-expanded .panel-body {
    display: flex;
    flex-direction: column;
    max-height: 40dvh;
  }
  #hud-catalog .catalog-section-list {
    max-height: 40dvh;
  }
  #hud-catalog .cat-title {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    font-size: 12px;
  }
  #hud-catalog .cat-sub { font-size: 10px; }

  /* ---- Whisper: positioned in lower-middle band, well below era banner ---- */
  #whisper {
    top: auto;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 26dvh);
    left: 50%;
    transform: translate(-50%, 0);
    font-size: 14px;
    line-height: 1.4;
    max-width: 84vw;
    padding: 0 12px;
  }

  /* ---- Era discovery banner: smaller, positioned above the whisper band ---- */
  #discovery-banner {
    padding: 16px 20px;
    max-width: 84vw;
    top: 35%;
  }
  #discovery-banner .title { font-size: 9px; letter-spacing: 2.5px; margin-bottom: 6px; }
  #discovery-banner .era-title { font-size: 17px; margin-bottom: 8px; }
  #discovery-banner .law { font-size: 12px; }

  /* ---- Bottom action buttons: respect safe area, tighter stack ---- */
  #reset-btn {
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    right: max(10px, env(safe-area-inset-right, 0px));
    width: 38px; height: 38px;
  }
  #recenter-btn {
    bottom: calc(150px + env(safe-area-inset-bottom, 0px));
    right: max(10px, env(safe-area-inset-right, 0px));
    width: 38px; height: 38px;
  }
  #settings-btn {
    bottom: calc(58px + env(safe-area-inset-bottom, 0px));
    right: max(10px, env(safe-area-inset-right, 0px));
    width: 38px; height: 38px;
  }
  #mute-btn {
    bottom: calc(104px + env(safe-area-inset-bottom, 0px));
    right: max(10px, env(safe-area-inset-right, 0px));
    width: 38px; height: 38px;
  }
  #mute-btn svg { width: 16px; height: 16px; }

  /* Hide the bottom hint on mobile: it eats space and overlaps action buttons. */
  #hud-bottom { display: none; }

  /* ---- Settings popup: bottom-anchored drawer with internal scroll ---- */
  #settings-panel {
    bottom: calc(152px + env(safe-area-inset-bottom, 0px));
    right: max(10px, env(safe-area-inset-right, 0px));
    left: max(10px, env(safe-area-inset-left, 0px));
    min-width: 0;
    max-width: none;
    max-height: 55dvh;
    overflow-y: auto;
  }

  /* ---- Macro inspector + context menu: tighter on small screens ---- */
  #macro-inspector {
    max-width: 60vw;
    font-size: 12px;
  }
  #macro-context-menu {
    max-width: 70vw;
  }

  /* ---- Reduce side margins so panels fit without clipping ---- */
  .panel { padding: 10px 12px; border-radius: 12px; }
}

/* ---------------------------------------------------------------------------
 * MOBILE — landscape phones (short height). Stack laws + catalog horizontally
 * and put top-left in compact mode.
 * --------------------------------------------------------------------------- */
@media (max-height: 500px) and (pointer: coarse) {
  #hud-left { max-width: 40vw; }
  #hud-top-right { max-width: 40vw; }
  #whisper { bottom: calc(env(safe-area-inset-bottom, 0px) + 20dvh); font-size: 13px; }
  #discovery-banner { top: 50%; padding: 12px 18px; }
  #discovery-banner .era-title { font-size: 15px; }
}

/* v0.5: Instruments panel subsections. Reuses the catalog-section layout
   for the chevron / label / count header, but the section list inside is
   the instruments list (lenses, modes, tools) rather than catalog rows.
   Override the catalog-specific scrolling + padding so the instruments
   sections feel native to their panel. */
#hud-instruments .catalog-section {
  margin-top: 6px;
  pointer-events: auto;
}
#hud-instruments .catalog-section-header {
  padding: 4px 0;
  pointer-events: auto;
}
#hud-instruments .catalog-section-list {
  list-style: none;
  margin: 4px 0 0 0;
  padding: 0;
  max-height: none;
  overflow: visible;
}
#hud-instruments .catalog-section[data-section="tools"] .instruments-tools {
  border-top: none;
  padding-top: 4px;
  margin-top: 4px;
}

/* Inducer mode buttons live in the Upgrades section. Each row is one mode.
   Three states are styled: locked (pre-era), available (era reached but
   not purchased), unlocked (selectable). The currently-active mode gets
   the "is-active" treatment matching .instruments-tool[aria-pressed]. */
#inducer-modes-list li.inducer-mode {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  margin: 3px 0;
  border: 1px solid rgba(159, 184, 255, 0.18);
  border-radius: 6px;
  color: rgba(190, 210, 240, 0.85);
  font-size: 12px;
  cursor: pointer;
  pointer-events: auto;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
#inducer-modes-list li.inducer-mode:hover:not(.is-locked) {
  background: rgba(184, 164, 255, 0.06);
  border-color: rgba(184, 164, 255, 0.35);
  color: rgba(220, 235, 255, 1);
}
#inducer-modes-list li.inducer-mode.is-active {
  background: rgba(184, 164, 255, 0.18);
  border-color: rgba(184, 164, 255, 0.55);
  color: rgba(230, 240, 255, 1);
}
#inducer-modes-list li.inducer-mode.is-locked {
  opacity: 0.45;
  cursor: not-allowed;
}
#inducer-modes-list li.inducer-mode.is-available {
  border-color: rgba(255, 215, 110, 0.45);
  color: rgba(255, 230, 170, 0.95);
}
#inducer-modes-list li.inducer-mode.is-available:hover {
  background: rgba(255, 215, 110, 0.08);
  border-color: rgba(255, 215, 110, 0.7);
}
#inducer-modes-list .im-glyph {
  flex-shrink: 0;
  width: 14px;
  text-align: center;
  font-size: 13px;
}
#inducer-modes-list .im-label {
  flex: 1;
  text-align: left;
}
#inducer-modes-list .im-meta {
  margin-left: auto;
  opacity: 0.7;
  font-size: 0.85em;
  font-variant-numeric: tabular-nums;
}

/* Calibration countdown badge on emitter rows in the Catalog "Deployed"
   section. Pulses subtly until calibration ends; turns red as the timer
   nears zero so the player feels the suspense. */
.cat-emitter .cat-calibration {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  background: rgba(255, 215, 110, 0.12);
  color: rgba(255, 230, 170, 0.95);
  border: 1px solid rgba(255, 215, 110, 0.4);
  animation: cal-pulse 1.4s ease-in-out infinite;
}
.cat-emitter .cat-calibration[data-urgent="true"] {
  background: rgba(255, 110, 110, 0.16);
  color: rgba(255, 190, 190, 1);
  border-color: rgba(255, 110, 110, 0.55);
}
@keyframes cal-pulse {
  0%, 100% { opacity: 0.85; }
  50%      { opacity: 0.4; }
}
