@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;450;500;550;600;650;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --bg: #141d1c;
  --panel: #18211f;
  --border: #ffffff12;
  --text: #e4e8dc;
  --muted: #8d9c90;
  --green: #c4d99b;
  --mono: 'IBM Plex Mono', monospace;
  --sans: 'DM Sans', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  user-select: none;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  background: none;
  border: 0;
  transition:
    background 0.16s,
    color 0.16s,
    transform 0.16s;
}
button:hover {
  color: #edffd0;
  background: #ffffff0c;
}
button:focus-visible,
a:focus-visible,
canvas:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}
button.active {
  color: var(--green);
}
a {
  color: inherit;
  text-decoration: none;
}

/* Immersive Full-Screen Container */
main {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  display: block;
}

.map-area {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #15292f;
  overflow: hidden;
  z-index: 1;
}

#world {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
  outline: none;
}
#world:active {
  cursor: grabbing;
}

/* Floating Glassmorphic HUD Sidebars */
.sidebar {
  position: absolute;
  top: 14px;
  bottom: 14px;
  z-index: 10;
  padding: 20px 20px 18px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #455444 transparent;
  background: #131e1ceb;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid #ffffff18;
  border-radius: 12px;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  transition:
    transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.22s ease;
}

.left-sidebar {
  left: 14px;
  width: 285px;
  max-height: calc(100dvh - 28px);
}
.left-sidebar.collapsed {
  transform: translateX(calc(-100% - 24px));
  opacity: 0;
  pointer-events: none;
}

.right-sidebar {
  right: 14px;
  width: 320px;
  max-height: calc(100dvh - 28px);
}
.right-sidebar.collapsed {
  transform: translateX(calc(100% + 24px));
  opacity: 0;
  pointer-events: none;
}

/* Sidebar Top Bar & Brand */
.sidebar-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px 8px;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand-group {
  display: contents;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.6px;
  white-space: nowrap;
  grid-column: 1;
  grid-row: 1;
}
.brand svg {
  color: var(--green);
  flex-shrink: 0;
}
.brand-dot {
  color: var(--green);
}
.world-tag {
  grid-column: 1 / -1;
  grid-row: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  font: 9.5px var(--mono);
  letter-spacing: 0.5px;
  color: #b4bfb1;
}
.status-dot {
  width: 6px;
  height: 6px;
  background: #b6d88c;
  display: inline-block;
  border-radius: 50%;
  box-shadow: 0 0 8px #c2e99833;
}
.status-dot.offline {
  background: #d8a06c;
}
.divider {
  color: #647566;
  margin: 0 4px;
}

.sidebar-header-actions {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  gap: 6px;
  align-items: center;
}
.icon-button {
  width: 25px;
  height: 25px;
  border: 1px solid #8d9c9044;
  border-radius: 50%;
  font: 12px var(--mono);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.16s ease;
}
.icon-button:hover {
  color: var(--green);
  border-color: var(--green);
  background: #ffffff0a;
}
.toggle-button {
  border-radius: 6px;
}

.floating-toggle {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 9;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: #141f1cee;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid #ffffff22;
  border-radius: 20px;
  color: var(--text);
  font: 11px var(--mono);
  letter-spacing: 0.5px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: all 0.18s ease;
}
.floating-toggle:hover {
  color: var(--green);
  border-color: var(--green);
  transform: scale(1.02);
}

.floating-footer {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: #141f1ce0;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid #ffffff15;
  border-radius: 20px;
  font: 8px var(--mono);
  letter-spacing: 0.8px;
  color: #7e947c;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  white-space: nowrap;
}
.floating-footer span:first-child {
  color: #a4c490;
}
.floating-footer .status-dot {
  width: 4px;
  height: 4px;
  margin-right: 4px;
}

/* Field Station Content */
.eyebrow,
.section-heading {
  font: 9px var(--mono);
  font-weight: 500;
  letter-spacing: 1.5px;
  color: #a2b294;
}
.eyebrow {
  display: flex;
  justify-content: space-between;
}
.eyebrow span {
  color: #6b7c69;
}

h1 {
  font-size: 21px;
  line-height: 1.3;
  font-weight: 500;
  letter-spacing: -0.7px;
  margin: 12px 0 8px;
}
.intro {
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--muted);
  margin: 0 0 18px;
}

section.world-section,
.left-sidebar > section {
  padding: 18px 0;
  border-top: 1px solid var(--border);
}
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.small-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--green);
}

.day-row {
  margin-top: 12px;
  font-size: 24px;
  font-weight: 450;
  letter-spacing: -0.8px;
}
.day-row > span:first-child {
  font-variant-numeric: tabular-nums;
}
.day-row > span:last-child {
  float: right;
  font: 12px var(--mono);
  color: #9ca88e;
  margin-top: 8px;
  letter-spacing: 0;
}
.day-track {
  height: 3px;
  background: #ffffff12;
  margin-top: 16px;
  position: relative;
}
.day-track div {
  width: 25%;
  height: 3px;
  background: var(--green);
}
.day-track > span {
  position: absolute;
  top: -7px;
  left: 25%;
  color: #d9dfaf;
  font-size: 13px;
}
.clock-labels,
.chart-labels {
  display: flex;
  justify-content: space-between;
  font: 8px var(--mono);
  letter-spacing: 0.6px;
  color: #71806f;
  margin-top: 8px;
}

.playback {
  margin-top: 16px;
  display: flex;
  gap: 8px;
}
.playback > button {
  width: 35px;
  border: 1px solid #a9bd8544;
  color: var(--green);
  border-radius: 4px;
  font-size: 17px;
}
.speed-group {
  border: 1px solid #ffffff12;
  border-radius: 4px;
  display: flex;
  flex: 1;
  padding: 3px;
}
.speed-group button {
  flex: 1;
  font: 10px var(--mono);
  padding: 6px 0;
  color: #8e9c88;
  border-radius: 2px;
}
.speed-group button.active {
  background: #c4d99b;
  color: #243024;
}

.live-tag {
  font: 8px var(--mono);
  color: #c4d99b;
  letter-spacing: 1px;
}
.main-stat {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-top: 12px;
}
.main-stat > span:first-child {
  font-size: 36px;
  letter-spacing: -1.6px;
  font-weight: 450;
  line-height: 1.2;
}
.stat-species {
  font-size: 11px;
  color: #9faa94;
}
.stat-species i {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
  margin-right: 6px;
}

#population-chart {
  width: 100%;
  height: 52px;
  margin-top: 7px;
  display: block;
}
.chart-labels {
  font-size: 7px;
  margin-top: 4px;
}
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 18px;
}
.stat-grid > div {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.metric-label {
  font-size: 10px;
  color: var(--muted);
}
.stat-grid strong {
  font: 17px var(--mono);
  font-weight: 400;
  letter-spacing: -0.5px;
}

.weather-title {
  font-size: 15px;
  margin-top: 14px;
}
.weather-metrics {
  display: flex;
  justify-content: space-between;
  color: #83927d;
  font: 10px var(--mono);
  margin-top: 12px;
}
.weather-metrics b {
  color: #c4cdbc;
  font-weight: 400;
}
.weather-bar {
  height: 3px;
  background: #ffffff0c;
  margin-top: 10px;
}
.weather-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: #85a8a0;
}
.small-copy {
  font-size: 10px;
  line-height: 1.7;
  color: #7e8e7d;
  margin: 12px 0 0;
}
.sidebar-foot {
  margin-top: auto;
  display: flex;
  gap: 10px;
  padding-top: 18px;
  color: #afb9a4;
  font-size: 10px;
  line-height: 1.7;
}
.sidebar-foot span:not(.tiny-orbit) {
  color: #6f806d;
}
.tiny-orbit {
  font-size: 22px;
  color: #839873;
}

/* Map Top Overlay Controls */
.map-top {
  position: absolute;
  left: 20px;
  right: 20px;
  top: 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  z-index: 5;
}
.map-title {
  margin-left: 300px;
  transition: margin-left 0.28s ease;
}
.left-sidebar.collapsed ~ .map-area .map-title,
.left-sidebar.collapsed + .map-area .map-title {
  margin-left: 80px;
}
.map-title > .eyebrow {
  font-size: 10px;
  color: #dae3cf;
  letter-spacing: 2px;
  text-shadow: 0 1px 4px #152720;
}
.map-title > span:last-child {
  display: block;
  font: 9px var(--mono);
  color: #abc0b0;
  margin-top: 6px;
  text-shadow: 0 1px 4px #152720;
}

.layer-controls {
  display: flex;
  background: #14211ee8;
  border: 1px solid #ffffff18;
  padding: 4px;
  border-radius: 6px;
  align-self: start;
  pointer-events: auto;
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  margin-right: 330px;
  transition: margin-right 0.28s ease;
}
.right-sidebar.collapsed ~ .map-area .layer-controls,
.right-sidebar.collapsed + .map-area .layer-controls {
  margin-right: 0;
}

.layer-controls button {
  font-size: 10px;
  padding: 6px 11px;
  color: #97a68e;
  border-radius: 4px;
}
.layer-controls button.active {
  background: #c4d99b24;
  color: #d2e1bb;
}

.map-legend {
  position: absolute;
  top: 76px;
  left: 320px;
  display: flex;
  gap: 13px;
  pointer-events: none;
  z-index: 5;
  transition: left 0.28s ease;
}
.map-legend span {
  font: 8px var(--mono);
  color: #a6bbad;
  text-shadow: 0 1px 3px #142c2b;
}
.map-legend i {
  width: 5px;
  height: 5px;
  border-radius: 1px;
  display: inline-block;
  margin-right: 5px;
}

.compass {
  position: absolute;
  right: 340px;
  top: 80px;
  width: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #d1ddbc99;
  pointer-events: none;
  z-index: 5;
  transition: right 0.28s ease;
}
.compass span {
  font: 9px var(--mono);
}
.compass svg {
  height: 44px;
  width: 30px;
}

.map-bottom {
  position: absolute;
  bottom: 20px;
  left: 320px;
  right: 340px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 5;
  transition:
    left 0.28s ease,
    right 0.28s ease;
}
.coordinate-info {
  display: flex;
  flex-direction: column;
  gap: 5px;
  text-shadow: 0 1px 4px #142320;
}
.coordinate-info > span:first-child {
  font: 9px var(--mono);
  color: #c8d6bc;
  letter-spacing: 1px;
}
.coordinate-info > span:last-child {
  font-size: 9px;
  color: #92aa9b;
}

.zoom-tools {
  pointer-events: auto;
  display: flex;
  align-items: center;
  background: #14211eed;
  border: 1px solid #ffffff1a;
  border-radius: 5px;
  height: 32px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}
.zoom-tools button {
  font-size: 18px;
  width: 30px;
  height: 30px;
}
.zoom-tools span {
  font: 9px var(--mono);
  min-width: 36px;
  text-align: center;
  color: #a4b798;
}
#fit {
  border-left: 1px solid #ffffff15;
  margin-left: 2px;
}

.map-tools {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  border: 1px solid #ffffff22;
  border-radius: 7px;
  padding: 5px;
  background: #17251ff0;
  box-shadow: 0 8px 24px #08161244;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 6;
}
.tool {
  display: flex;
  gap: 7px;
  align-items: center;
  padding: 8px 13px;
  white-space: nowrap;
  font-size: 10px;
  color: #9fb28f;
  border-radius: 4px;
}
.tool span {
  font-size: 16px;
  line-height: 12px;
}
.tool.active {
  background: #c7d9a4;
  color: #273724;
}

.spawn-options {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  width: 260px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 14px;
  border: 1px solid #ffffff22;
  border-radius: 10px;
  background: #17251ff5;
  box-shadow: 0 8px 24px #08161244;
}
.spawn-options .eyebrow,
.spawn-options small {
  grid-column: 1 / -1;
}
.spawn-options button {
  padding: 9px 8px;
  border: 1px solid #ffffff22;
  border-radius: 5px;
}
.spawn-options button.active {
  background: var(--green);
  color: #273724;
  border-color: var(--green);
}
.spawn-options small {
  color: var(--muted);
  font-size: 11px;
}

#loading {
  position: absolute;
  inset: 0;
  background: #152521;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  z-index: 20;
}
#loading.hidden {
  display: none;
}
#loading h2 {
  font-size: 25px;
  font-weight: 450;
  letter-spacing: -1px;
  margin: 25px 0 9px;
}
#loading p {
  font-size: 12px;
  color: #95a88b;
}
.loading-orbit {
  width: 52px;
  height: 52px;
  border: 1px solid #c4d99b20;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: rotate 2s linear infinite;
}
@keyframes rotate {
  to {
    transform: rotate(360deg);
  }
}

/* Creature Inspector */
.specimen-illustration {
  height: 200px;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 6px;
}
.specimen-illustration svg {
  width: 90px;
  height: 90px;
  transform: rotate(-10deg);
  position: relative;
  opacity: 0.85;
}
.orbit {
  position: absolute;
  border: 1px solid #bdd29914;
  border-radius: 50%;
}
.o1 {
  width: 136px;
  height: 136px;
}
.o2 {
  width: 178px;
  height: 178px;
}
.o2:after {
  content: '';
  position: absolute;
  width: 5px;
  height: 5px;
  background: #a7bf7f;
  border-radius: 50%;
  top: 22px;
  right: 24px;
}
.specimen-illustration > span {
  position: absolute;
  bottom: 0;
  font: 7px var(--mono);
  color: #65775d;
  letter-spacing: 1.25px;
}
#empty-inspector h2 {
  font-size: 20px;
  font-weight: 450;
  letter-spacing: -0.6px;
  margin: 26px 0 10px;
}
#empty-inspector > p {
  font-size: 12px;
  line-height: 1.8;
  color: #8e9e87;
  margin: 0 0 18px;
}
.outline-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid #bed4962e;
  border-radius: 4px;
  padding: 10px 12px;
  color: #bdcfa6;
  font-size: 10.5px;
}
.outline-button span {
  font-size: 14px;
}
.field-note {
  border-top: 1px solid var(--border);
  margin-top: 28px;
  padding-top: 20px;
}
.field-note .eyebrow {
  font-size: 8px;
  color: #748c69;
}
.field-note p {
  color: #8e9f84;
  font-size: 11px;
  line-height: 1.8;
}
.observation-tip {
  margin-top: auto;
  padding-top: 24px;
  display: flex;
  gap: 10px;
  align-items: center;
  color: #6e8163;
}
.observation-tip > span {
  font-size: 22px;
}
.observation-tip p {
  font-size: 9px;
  line-height: 1.6;
  margin: 0;
}

.specimen-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 22px;
}
.specimen-heading .eyebrow {
  font-size: 8px;
}
.specimen-heading h2 {
  font-size: 21px;
  letter-spacing: -0.7px;
  font-weight: 450;
  margin: 6px 0 0;
}
#sex-badge {
  font-size: 21px;
  color: var(--green);
  background: #c4d99b0a;
  padding: 8px;
  border: 1px solid #c4d99b19;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.creature-meta {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #8e9f85;
  margin: 14px 0 22px;
}
#creature-state {
  color: #c1d7a4;
  text-transform: capitalize;
}
.vital {
  margin-top: 15px;
}
.vital label {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #8e9f85;
}
.vital label span {
  font: 9px var(--mono);
  color: #c5d2ba;
}
.meter {
  height: 4px;
  background: #ffffff0b;
  margin-top: 7px;
  border-radius: 2px;
  overflow: hidden;
}
.meter i {
  display: block;
  height: 100%;
  width: 0;
  transition: width 0.3s;
  background: #c5da9c;
}
#health-meter {
  background: #78b89b;
}
.emotion-row {
  display: flex;
  justify-content: space-between;
  margin: 18px 0;
  font-size: 10px;
  color: #8e9f85;
}
.emotion-row b {
  font: 10px var(--mono);
  color: #b4c2a5;
  margin-left: 7px;
}

.inspector-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  gap: 18px;
  margin-bottom: 16px;
}
.inspector-tabs button {
  padding: 8px 0;
  font-size: 11px;
  color: #7f9278;
  border-bottom: 1px solid transparent;
}
.inspector-tabs button.active {
  color: #c4d99b;
  border-color: #c4d99b;
}
.tab-panel {
  min-height: 230px;
}
dl {
  margin: 0;
}
dl > div {
  display: flex;
  justify-content: space-between;
  margin: 0 0 12px;
  font-size: 10px;
}
dt {
  color: #8e9f85;
}
dd {
  margin: 0;
  color: #cbd6bf;
  font-family: var(--mono);
  font-size: 9px;
}

.interaction-buttons {
  display: flex;
  gap: 8px;
  margin: 20px 0 10px;
}
.interaction-buttons button {
  border: 1px solid #ffffff19;
  border-radius: 4px;
  padding: 9px 7px;
  font-size: 10px;
  flex: 1;
  color: #c4d3b2;
}

#brain-canvas {
  width: 100%;
  height: 210px;
  border: 1px solid #ffffff0b;
  border-radius: 4px;
  background: #111a1733;
}
.brain-legend {
  display: flex;
  justify-content: space-between;
  color: #829673;
  font: 8px var(--mono);
  margin: 5px 0 15px;
}
#dna {
  font: 10px/1.9 var(--mono);
  word-break: break-all;
  color: #abc394;
  background: #101a174d;
  border: 1px solid #ffffff0b;
  border-radius: 4px;
  padding: 10px;
  margin: 12px 0 15px;
  max-height: 150px;
  overflow-y: auto;
  letter-spacing: 1.4px;
}
#dna span:nth-child(3n) {
  color: #83b3a3;
}
#dna span:nth-child(3n + 1) {
  color: #cabb8d;
}
#dna span.highlight-gene {
  background: #d4e8b0;
  color: #101a17 !important;
  border-radius: 2px;
  font-weight: bold;
}

.genome-decoded {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 10px 0 16px;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 4px;
}
.gene-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 8px;
  background: #111e1a55;
  border: 1px solid #ffffff0a;
  border-radius: 4px;
  font-size: 11px;
  transition: all 0.15s ease;
  cursor: default;
}
.gene-row:hover {
  background: #1a2f28aa;
  border-color: #83b3a344;
}
.gene-row-name {
  color: #c9dbb8;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.gene-row-name small {
  color: #798d73;
  font: 9px var(--mono);
}
.gene-row-val {
  font: 11px var(--mono);
  color: #e0f0cc;
  text-align: right;
}

.toast {
  position: absolute;
  bottom: 120px;
  left: 50%;
  transform: translate(-50%, 10px);
  opacity: 0;
  pointer-events: none;
  background: #d3dfbd;
  color: #273924;
  padding: 9px 15px;
  border-radius: 4px;
  font-size: 11px;
  transition: all 0.2s;
  white-space: nowrap;
  z-index: 15;
}
.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
.map-tools:has(.spawn-options:not([hidden])) ~ .toast {
  bottom: calc(250px + env(safe-area-inset-bottom));
}

dialog {
  background: #1e2c25;
  color: var(--text);
  border: 1px solid #b3c89444;
  border-radius: 8px;
  width: 470px;
  padding: 30px;
  box-shadow: 0 30px 100px #0008;
}
dialog::backdrop {
  background: #06140cb0;
  backdrop-filter: blur(5px);
}
dialog h2 {
  font-size: 25px;
  font-weight: 450;
  letter-spacing: -0.8px;
}
dialog p {
  color: #a6b69c;
  line-height: 1.8;
  font-size: 12px;
}
dialog dl {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 14px;
  margin: 22px 0;
}
dialog dt,
dialog dd {
  font-size: 11px;
}
dialog > button {
  float: right;
  font-size: 22px;
  margin-top: -12px;
  margin-right: -8px;
}
[hidden] {
  display: none !important;
}

/* Dynamic Contacts, Senses, Brain Inputs */
.mobile-playback {
  display: none;
}
#close-inspector {
  font-size: 18px;
  padding: 0 3px;
  line-height: 16px;
  color: var(--muted);
}
.contact-heading {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.sense-contacts {
  display: grid;
  gap: 5px;
  margin-top: 10px;
}
.sense-contacts > p {
  font-size: 10px;
  color: var(--muted);
  margin: 4px 0;
}
.sense-contact {
  display: grid;
  grid-template-columns: 7px 1fr;
  align-items: center;
  gap: 2px 7px;
  width: 100%;
  padding: 6px 8px;
  text-align: left;
  background: #ffffff08;
  border: 1px solid #ffffff10;
  border-radius: 4px;
}
.sense-contact > i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  grid-row: span 2;
}
.sense-contact > span {
  font-size: 10px;
  color: #e0e9d6;
  text-transform: capitalize;
}
.sense-contact > small {
  font: 8px var(--mono);
  color: #8c9d8f;
  grid-column: 2;
}

.role-key {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px 9px;
  margin: 12px 0 16px;
  color: #a9b8a6;
  font: 9px var(--mono);
}
.role-key span {
  display: flex;
  align-items: center;
  gap: 7px;
}
.role-key i {
  width: 7px;
  height: 7px;
  display: inline-block;
  border-radius: 50%;
}

.sense-intro {
  margin: 0 0 16px !important;
  color: #b9cbaa;
}
.sense-legend {
  border-top: 1px solid var(--border);
  padding: 12px 0 2px;
  display: flex;
  gap: 13px;
  flex-wrap: wrap;
  font: 8px var(--mono);
  color: #9caa95;
}
.sense-legend i {
  display: inline-block;
  width: 7px;
  height: 7px;
  border: 1px solid currentColor;
  border-radius: 50%;
  margin-right: 4px;
}
.seen-mark {
  color: #e5f4b6;
}
.smelled-mark {
  color: #f1b371;
}
.food-mark {
  color: #f8df8d;
}

.plant-trend {
  font: 8px var(--mono);
  color: #a9c681;
  margin-top: 3px;
  white-space: nowrap;
}
.plant-trend.falling {
  color: #d5ae86;
}
.biomass-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 14px;
  margin-top: 15px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--muted);
}
.biomass-row strong {
  font: 12px var(--mono);
  color: #c6d5ad;
}
.diet-counts {
  display: grid;
  gap: 5px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 13px;
}
.diet-counts span {
  display: flex;
  justify-content: space-between;
  color: #9dad94;
  font-size: 10px;
}
.diet-counts b {
  font: 10px var(--mono);
  color: #d4dfc4;
}

.brain-input-heading {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin: 15px 0 9px;
}
.brain-input-heading span {
  font-size: 7px;
  color: #829673;
}
.brain-inputs {
  display: grid;
  gap: 3px;
}
.brain-inputs > div {
  display: flex;
  justify-content: space-between;
  gap: 5px;
  align-items: center;
  padding: 5px 7px;
  background: linear-gradient(90deg, #dfa26c25 var(--activity), transparent var(--activity));
  border: 1px solid #ffffff0a;
  border-radius: 3px;
  color: #a9b9a2;
  font-size: 9px;
}
.brain-inputs > div span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brain-inputs b {
  white-space: nowrap;
  font-size: 8px;
  font-family: var(--mono);
  color: #d7e9c5;
}

.brain-edge-key,
.brain-trend-key {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  color: #9eae9d;
  font: 8px var(--mono);
  margin: 10px 0;
}
.brain-edge-key i,
.brain-trend-key i {
  display: inline-block;
  width: 12px;
  height: 2px;
  vertical-align: middle;
  margin-right: 3px;
}
.positive-edge {
  background: #acdc93;
}
.negative-edge {
  background: #efa181;
}
.new-edge {
  background: #8cdef0;
}
.forecast-mark {
  background: #95d9c9;
}
.connection-mark {
  background: #e8bd80;
}
.brain-hover {
  font: 9px/1.5 var(--mono);
  color: #c9d9bd;
  min-height: 28px;
  padding: 7px 0;
  border-top: 1px solid var(--border);
}
#brain-history {
  width: 100%;
  height: 56px;
  display: block;
  background: #111a1733;
  border: 1px solid #ffffff0b;
  border-radius: 3px;
}
.brain-trend-key {
  margin: 7px 0 15px;
}
.ray-key {
  margin: 0 0 10px !important;
}

/* Responsive mobile and tablet styling */
.sidebar-backdrop {
  display: none;
}

@media (max-width: 1100px) {
  .map-title {
    margin-left: 20px;
  }
  .layer-controls {
    margin-right: 20px;
  }
  .map-legend {
    left: 20px;
    top: 120px;
  }
  .compass {
    right: 20px;
    top: 120px;
  }
  .map-bottom {
    left: 20px;
    right: 20px;
  }
}

@media (max-width: 800px) {
  html,
  body,
  main {
    width: 100vw;
    height: 100dvh;
    overflow: hidden;
  }

  .floating-footer {
    display: none;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 25;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  .sidebar-backdrop.active {
    opacity: 1;
    pointer-events: auto;
  }

  /* Left Sidebar Drawer */
  .left-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(340px, 86vw);
    max-height: 100dvh;
    border-radius: 0 20px 20px 0;
    border-left: none;
    border-top: none;
    border-bottom: none;
    padding: calc(14px + env(safe-area-inset-top)) 18px calc(18px + env(safe-area-inset-bottom));
    box-shadow: 10px 0 40px rgba(0, 0, 0, 0.7);
    transform: translateX(0);
    transition:
      transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
      opacity 0.22s ease;
    z-index: 30;
  }
  .left-sidebar.collapsed {
    transform: translateX(-105%);
    opacity: 0;
    pointer-events: none;
  }

  /* Right Sidebar Bottom Sheet */
  .right-sidebar {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    max-height: 82dvh;
    border-radius: 22px 22px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    padding: 12px 18px calc(18px + env(safe-area-inset-bottom));
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.7);
    transform: translateY(0);
    transition:
      transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
      opacity 0.22s ease;
    z-index: 30;
  }
  .right-sidebar::before {
    content: '';
    display: block;
    width: 38px;
    height: 4px;
    background: #ffffff30;
    border-radius: 2px;
    margin: 0 auto 10px;
  }
  .right-sidebar.collapsed {
    transform: translateY(105%);
    opacity: 0;
    pointer-events: none;
  }
  .specimen-illustration {
    height: 110px;
  }
  .specimen-illustration svg {
    width: 65px;
    height: 65px;
  }
  .o1 {
    width: 85px;
    height: 85px;
  }
  .o2 {
    width: 115px;
    height: 115px;
  }
  .tab-panel {
    min-height: 180px;
  }

  #close-inspector {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #ffffff14;
    border: 1px solid #ffffff22;
    color: var(--text);
    font-size: 19px;
    line-height: 1;
    cursor: pointer;
  }
  #close-inspector:active {
    background: #ffffff28;
  }

  /* Floating Station Button */
  .floating-toggle {
    top: calc(10px + env(safe-area-inset-top));
    left: 10px;
    padding: 7px 13px;
    font-size: 11px;
    border-radius: 20px;
    z-index: 12;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  }
  .floating-toggle svg {
    width: 14px;
    height: 14px;
  }

  /* Top HUD */
  .map-top {
    position: absolute;
    top: calc(10px + env(safe-area-inset-top));
    left: 10px;
    right: 10px;
    pointer-events: none;
    display: flex;
    justify-content: flex-end;
    align-items: center;
  }
  .map-title {
    display: none;
  }
  .layer-controls {
    margin-right: 0;
    position: absolute;
    top: calc(48px + env(safe-area-inset-top));
    left: 10px;
    padding: 2px;
    border-radius: 16px;
    background: #14211eed;
    border: 1px solid #ffffff1c;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
    z-index: 10;
  }
  .layer-controls button {
    padding: 5px 9px;
    font-size: 10px;
    border-radius: 12px;
  }

  /* Mobile Playback pill in top right */
  .mobile-playback {
    display: flex;
    position: absolute;
    top: calc(10px + env(safe-area-inset-top));
    right: 10px;
    background: #14211ef0;
    border: 1px solid #ffffff24;
    border-radius: 20px;
    padding: 2px 4px;
    gap: 2px;
    z-index: 12;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  }
  .mobile-playback button {
    padding: 6px 12px;
    font: 11px var(--mono);
    color: var(--green);
    border-radius: 14px;
    min-width: 32px;
  }
  .mobile-playback button:active {
    background: #ffffff14;
  }

  /* Compass */
  .compass {
    right: 10px;
    top: calc(52px + env(safe-area-inset-top));
    transform: scale(0.7);
    transform-origin: top right;
    z-index: 8;
  }

  /* Map Legend */
  .map-legend {
    position: absolute;
    top: auto;
    bottom: calc(68px + env(safe-area-inset-bottom));
    left: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    background: #14211ec4;
    border: 1px solid #ffffff15;
    border-radius: 10px;
    padding: 4px 8px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    max-width: calc(100vw - 75px);
    pointer-events: none;
    z-index: 8;
  }
  .map-legend span {
    font-size: 8px;
  }

  /* Map Bottom & Tools */
  .map-bottom {
    position: static;
  }
  .coordinate-info {
    display: none;
  }
  .zoom-tools {
    position: absolute;
    right: 10px;
    bottom: calc(68px + env(safe-area-inset-bottom));
    flex-direction: column;
    height: auto;
    width: 36px;
    border-radius: 18px;
    overflow: hidden;
    background: #14211eed;
    border: 1px solid #ffffff1c;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    z-index: 11;
  }
  .zoom-tools button {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
  }
  .zoom-tools span {
    display: none;
  }
  #fit {
    border-left: none;
    border-top: 1px solid #ffffff14;
    margin: 0;
    font-size: 13px;
  }

  .map-tools {
    bottom: calc(14px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
    padding: 4px 6px;
    border-radius: 24px;
    background: #15241ff4;
    border: 1px solid #ffffff24;
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.5);
    z-index: 12;
  }
  .tool {
    padding: 7px 12px;
    font-size: 11px;
    border-radius: 18px;
    gap: 5px;
  }
  .tool span {
    font-size: 14px;
  }

  /* Tabs and action buttons inside inspector */
  .inspector-tabs {
    gap: 12px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .inspector-tabs::-webkit-scrollbar {
    display: none;
  }
  .inspector-tabs button {
    padding: 8px 4px;
    font-size: 12px;
    white-space: nowrap;
  }
  .interaction-buttons button {
    padding: 11px 8px;
    font-size: 11px;
  }
  #follow {
    padding: 11px 8px;
  }

  /* Dialog Help Modal */
  dialog {
    width: calc(100vw - 28px);
    max-width: calc(100vw - 28px);
    padding: 20px 16px;
    max-height: 85dvh;
    overflow-y: auto;
    border-radius: 14px;
  }
  dialog dl {
    grid-template-columns: 1fr 1fr;
    gap: 8px 10px;
  }
}
