.breeding-tree-load-more {
  width: 100%;
  margin-top: 0.55rem;
}

.breeding-tree-save-row input,
.breeding-tree-tool select {
  width: 100%;
  min-width: 0;
  min-height: 2.35rem;
  padding: 0.45rem 0.58rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(3, 17, 25, 0.84);
  color: var(--text);
  font: inherit;
  font-size: 0.75rem;
}

.breeding-tree-save-row input {
  flex: 1 1 auto;
}

.breeding-tree-save-buttons {
  margin-top: 0.45rem;
}

.breeding-tree-save-buttons .breeding-tree-action {
  flex: 1 1 50%;
}

.breeding-tree-stage {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 700px;
  overflow: hidden;
}

.breeding-tree-viewport {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  background:
    radial-gradient(circle at 50% 10%, rgba(98, 231, 237, 0.08), transparent 32rem),
    linear-gradient(rgba(98, 231, 237, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(98, 231, 237, 0.035) 1px, transparent 1px),
    #061720;
  background-size: auto, 28px 28px, 28px 28px, auto;
  scrollbar-color: rgba(98, 231, 237, 0.38) transparent;
}

.breeding-tree-canvas {
  --breeding-tree-zoom: 1;
  display: grid;
  min-width: max-content;
  min-height: 100%;
  padding: 2rem;
  place-items: start center;
  transform: scale(var(--breeding-tree-zoom));
  transform-origin: top center;
  transition: transform 180ms ease;
}

.breeding-tree-empty {
  display: grid;
  align-self: center;
  justify-self: center;
  gap: 0.35rem;
  min-width: min(26rem, 70vw);
  padding: 2rem;
  border: 1px dashed rgba(98, 231, 237, 0.28);
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
}

.breeding-tree-empty strong {
  color: var(--text);
}

.breeding-tree-root,
.breeding-tree-root ul {
  position: relative;
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.breeding-tree-root ul {
  padding-top: 2.2rem;
}

.breeding-tree-root li {
  position: relative;
  display: grid;
  justify-items: center;
}

.breeding-tree-root li > ul::before,
.breeding-tree-root li > ul > li::before,
.breeding-tree-root li > ul > li::after {
  position: absolute;
  content: "";
  pointer-events: none;
}

.breeding-tree-root li > ul::before {
  top: 0;
  left: 50%;
  width: 1px;
  height: 1.1rem;
  background: rgba(98, 231, 237, 0.55);
}

.breeding-tree-root li > ul > li::before {
  top: -1.1rem;
  left: 50%;
  width: calc(100% + 1rem);
  height: 1px;
  background: rgba(98, 231, 237, 0.4);
}

.breeding-tree-root li > ul > li:first-child::before {
  left: 50%;
  width: calc(50% + 0.5rem);
}

.breeding-tree-root li > ul > li:last-child::before {
  right: 50%;
  left: auto;
  width: calc(50% + 0.5rem);
}

.breeding-tree-root li > ul > li::after {
  top: -1.1rem;
  left: 50%;
  width: 1px;
  height: 1.1rem;
  background: rgba(98, 231, 237, 0.55);
}

.breeding-tree-node {
  position: relative;
  display: grid;
  grid-template-columns: 54px minmax(5.5rem, 1fr);
  align-items: center;
  gap: 0.55rem;
  width: 11.5rem;
  min-height: 4.25rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid rgba(139, 188, 201, 0.28);
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(13, 45, 57, 0.98), rgba(4, 20, 29, 0.98));
  color: var(--text);
  font: inherit;
  text-align: left;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.breeding-tree-node:hover {
  border-color: rgba(98, 231, 237, 0.62);
  transform: translateY(-1px);
}

.breeding-tree-node.is-selected {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(98, 231, 237, 0.2), 0 10px 28px rgba(0, 0, 0, 0.36);
}

.breeding-tree-node img,
.breeding-tree-node .breeding-tree-thumb-fallback {
  width: 54px;
  height: 54px;
  border-radius: 10px;
}

.breeding-tree-node > span {
  display: grid;
  min-width: 0;
}

.breeding-tree-node strong {
  overflow: hidden;
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.breeding-tree-node small {
  color: var(--muted);
  font-size: 0.64rem;
}

.breeding-tree-node i {
  position: absolute;
  right: -0.45rem;
  bottom: -0.45rem;
  display: grid;
  width: 1.3rem;
  height: 1.3rem;
  place-items: center;
  border: 1px solid var(--cyan);
  border-radius: 50%;
  background: #08232e;
  color: var(--cyan);
  font-style: normal;
  font-weight: 900;
}

.breeding-tree-global-status {
  min-height: 2rem;
  margin: 0;
  padding: 0.45rem 0.75rem;
  border-top: 1px solid var(--line);
  background: rgba(3, 17, 25, 0.94);
}

.breeding-tree-global-status[data-state="limit"] {
  color: #ffd59b;
}

@media (max-width: 1080px) {
  .breeding-tree-workspace {
    grid-template-columns: 1fr;
  }

  .breeding-tree-sidebar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .breeding-tree-stage {
    min-height: 620px;
  }
}

@media (max-width: 760px) {
  .breeding-tree-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .breeding-tree-actions {
    width: 100%;
    overflow-x: auto;
  }

  .breeding-tree-sidebar {
    grid-template-columns: 1fr;
  }

  .breeding-tree-stage {
    min-height: 540px;
  }

  .breeding-tree-canvas {
    padding: 1.25rem;
  }

  .breeding-tree-node {
    width: 10rem;
  }

  .breeding-tree-pair-pal {
    grid-template-columns: 30px minmax(0, 1fr) auto;
  }

  .breeding-tree-pair-pal img,
  .breeding-tree-pair-pal .breeding-tree-thumb-fallback {
    width: 30px;
    height: 30px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .breeding-tree-action,
  .breeding-tree-load-more,
  .breeding-tree-node,
  .breeding-tree-canvas {
    transition: none;
  }
}
