* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #070b0d;
  color: #eefaf5;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app {
  position: fixed;
  inset: 0;
  background: #070b0d;
}

#sim-canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  touch-action: none;
  cursor: crosshair;
}

.toolbar {
  position: fixed;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 9px;
  background: rgb(8 14 16 / 76%);
  border: 1px solid rgb(179 244 227 / 18%);
  border-radius: 8px;
  box-shadow: 0 18px 60px rgb(0 0 0 / 34%);
  backdrop-filter: blur(14px);
  z-index: 3;
}

.toolbar strong {
  margin: 0 8px 0 2px;
  font-size: 15px;
  letter-spacing: 0.02em;
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid rgb(191 251 235 / 24%);
  border-radius: 6px;
  background: #142023;
  color: #eaf8f3;
  padding: 7px 10px;
  cursor: pointer;
}

button:hover,
button.active {
  background: #244145;
  border-color: rgb(120 235 204 / 52%);
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid #79efcd;
  outline-offset: 2px;
}

label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #b9d8d1;
  white-space: nowrap;
}

.preset-strip {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.preset-strip button {
  padding: 6px 8px;
  font-size: 12px;
}

.status {
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 3;
  padding: 8px 10px;
  border: 1px solid rgb(179 244 227 / 16%);
  border-radius: 6px;
  background: rgb(8 14 16 / 72%);
  color: #b9d8d1;
  font-size: 12px;
  backdrop-filter: blur(12px);
}

.creature-card {
  position: fixed;
  z-index: 4;
  width: min(340px, calc(100vw - 24px));
  max-height: min(320px, calc(100vh - 96px));
  overflow: auto;
  transform: translate(-50%, calc(-100% - 20px));
  padding: 14px;
  border: 1px solid rgb(151 255 221 / 34%);
  border-radius: 8px;
  background: rgb(10 18 21 / 92%);
  box-shadow: 0 22px 80px rgb(0 0 0 / 46%);
  backdrop-filter: blur(16px);
}

.creature-card::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -9px;
  width: 16px;
  height: 16px;
  transform: translateX(-50%) rotate(45deg);
  background: rgb(10 18 21 / 92%);
  border-right: 1px solid rgb(151 255 221 / 34%);
  border-bottom: 1px solid rgb(151 255 221 / 34%);
}

.creature-card.hidden {
  display: none;
}

.creature-card h2 {
  margin: 0 26px 12px 0;
  font-size: 17px;
}

#close-card {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  padding: 0;
  line-height: 1;
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px 12px;
  font-size: 12px;
}

.card-grid span {
  color: #9abdb5;
}

.card-grid strong {
  color: #eefaf5;
  font-weight: 650;
  text-align: right;
}

.lab-panel {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgb(151 255 221 / 18%);
}

.lab-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.lab-heading span {
  color: #d5fff3;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lab-heading button {
  padding: 6px 8px;
  border-color: rgb(125 239 205 / 42%);
  background: #193431;
  color: #d8fff4;
  font-size: 12px;
}

.lab-sliders {
  display: grid;
  gap: 8px;
}

.lab-slider {
  display: grid;
  grid-template-columns: 72px minmax(86px, 1fr) 34px;
  gap: 8px;
  align-items: center;
  color: #b9d8d1;
  font-size: 12px;
}

.lab-slider input {
  width: 100%;
  min-width: 0;
  accent-color: #75f1cc;
}

.lab-slider output {
  color: #eefaf5;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.evolution-panel {
  position: fixed;
  top: 74px;
  right: 14px;
  z-index: 3;
  width: min(300px, calc(100vw - 28px));
  max-height: calc(100vh - 130px);
  overflow: auto;
  padding: 12px;
  border: 1px solid rgb(179 244 227 / 18%);
  border-radius: 8px;
  background: rgb(8 14 16 / 76%);
  box-shadow: 0 18px 60px rgb(0 0 0 / 34%);
  backdrop-filter: blur(14px);
}

.evolution-panel.collapsed .evolution-summary,
.evolution-panel.collapsed .lineage-list {
  display: none;
}

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

.evolution-heading span {
  color: #d5fff3;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.evolution-heading button {
  width: 26px;
  height: 26px;
  padding: 0;
}

.evolution-summary {
  margin-bottom: 8px;
  color: #9abdb5;
  font-size: 12px;
}

.lineage-list {
  display: grid;
  gap: 7px;
}

.lineage-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px 10px;
  width: 100%;
  padding: 9px;
  text-align: left;
  background: rgb(20 32 35 / 86%);
  border: 1px solid rgb(191 251 235 / 24%);
  border-radius: 6px;
}

.lineage-row.selected {
  border-color: rgb(117 241 204 / 72%);
  background: rgb(30 64 59 / 90%);
}

.lineage-title {
  color: #eefaf5;
  font-size: 13px;
  font-weight: 700;
}

.lineage-metric {
  color: #9abdb5;
  font-size: 11px;
}

.lineage-bar {
  grid-column: 1 / -1;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgb(151 255 221 / 12%);
}

.follow-lineage {
  grid-column: 2;
  padding: 4px 7px;
  font-size: 11px;
}

.lineage-bar i {
  display: block;
  height: 100%;
  background: #75f1cc;
}

.lineage-empty {
  margin: 0;
  color: #9abdb5;
  font-size: 12px;
}

@media (max-width: 760px) {
  .toolbar {
    right: 10px;
    left: 10px;
    top: 10px;
  }

  .toolbar strong {
    width: 100%;
  }

  .status {
    right: 10px;
    left: 10px;
  }

  .creature-card {
    transform: translate(-50%, calc(-100% - 14px));
  }

  .evolution-panel {
    top: auto;
    right: 10px;
    bottom: 52px;
    left: 10px;
    width: auto;
    max-height: 34vh;
  }
}
