.trees { display: grid; gap: var(--s4); margin-top: var(--s4); grid-template-columns: 1fr; }
@media (min-width: 640px) and (max-width: 979px) { .trees { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 980px) { .trees { grid-template-columns: repeat(3, 1fr); } }

.tree { overflow: hidden; display: flex; flex-direction: column; }
.tree-head {
  display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.tree-head img { width: 32px; height: 32px; }
.tree-head h2 { font-size: 18px; flex: 1; }
.tree-head .pts { font: 700 18px var(--font-display); color: var(--gold-hi); }
.tree-head .btn { min-height: 30px; padding: 0 var(--s2); font-size: 13px; }

.tree-body { position: relative; padding: var(--s3); isolation: isolate; }
.tree-body::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: var(--bg-img) center / cover no-repeat; opacity: .28; filter: saturate(.7);
}
.tree-body::after {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(180deg, rgba(11,13,18,.2), rgba(11,13,18,.75));
}

.grid { position: relative; aspect-ratio: 400 / 620; max-width: 360px; margin: 0 auto; }
.links { position: absolute; inset: 0; width: 100%; height: 100%; color: rgba(160, 150, 130, .5); pointer-events: none; }
.links path { fill: none; stroke: currentColor; stroke-width: 5; }
.links .on { color: var(--green); }
.links .done { color: var(--gold); }
.links path { marker-end: url(#ah); }
.links path.on { marker-end: url(#ah-on); }
.links path.done { marker-end: url(#ah-done); }
.ah { fill: rgba(160, 150, 130, .5); }
.ah-on { fill: var(--green); }
.ah-done { fill: var(--gold); }

.node {
  position: absolute; width: 17%; aspect-ratio: 1; transform: translate(-50%, -50%);
  padding: 0; border: 0; background: none; cursor: pointer; border-radius: 9px;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.node img {
  width: 100%; height: 100%; border-radius: 9px;
  box-shadow: 0 0 0 2px #3a3a3a, 0 3px 8px rgba(0,0,0,.6);
  filter: grayscale(1) brightness(.55);
  transition: filter .2s var(--ease), transform .3s var(--spring);
}
.node .rank {
  position: absolute; right: -8px; bottom: -8px; min-width: 30px; padding: 0 5px;
  font: 700 12px/19px var(--font-body); text-align: center; border-radius: 6px;
  background: #0b0d12; color: #8a857b; box-shadow: 0 0 0 1px #3a3a3a;
}
.node .mark { position: absolute; left: -4px; top: -4px; width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 0 2px #0b0d12; }
.node:hover img { transform: scale(1.07); }
.node:active img { transform: scale(.94); }
.node:focus-visible { outline-offset: 4px; }

.node.can img { filter: none; box-shadow: 0 0 0 2px var(--green), 0 3px 8px rgba(0,0,0,.6); }
.node.can .rank { color: var(--green); box-shadow: 0 0 0 1px var(--green); }
.node.some img { filter: none; box-shadow: 0 0 0 2px var(--green), 0 0 14px rgba(95, 208, 104, .35); }
.node.some .rank { color: var(--green); box-shadow: 0 0 0 1px var(--green); }
.node.max img { filter: none; box-shadow: 0 0 0 2px var(--gold-hi), 0 0 16px rgba(242, 201, 110, .4); }
.node.max .rank { color: var(--gold-hi); box-shadow: 0 0 0 1px var(--gold-hi); }
.node.active-ability img { border-radius: 50%; }
.node.active-ability { border-radius: 50%; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.dot-new, .mark-new { background: #56c1ff; }
.legend { display: flex; flex-wrap: wrap; gap: var(--s4); margin-top: var(--s4); font-size: 14px; }

/* Narrow widths (phones, or an iframe in a narrow article column): one tree at a time as tabs,
   classes on one scrollable line, so the tool stays about one screen tall. */
.tree-tabs { display: none; }
@media (max-width: 639px) {
  #classes { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  #classes::-webkit-scrollbar { display: none; }
  #classes .chip { flex: none; }
  .toolbar .stat b { font-size: 18px; }
  /* the tabs already show points per tree */
  .toolbar .stat:has(#split) { display: none; }
  .toolbar { gap: var(--s2); }
  .toolbar .spacer { flex-basis: 100%; height: 0; }
  .toolbar .btn { flex: 1; min-height: 36px; padding: 0 var(--s2); font-size: 14px; }
  .tree-tabs {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s1); margin-top: var(--s4);
    padding: var(--s1); border-radius: var(--r2); background: var(--surface-1); border: 1px solid var(--line);
  }
  .tree-tab {
    display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 var(--s2);
    border: 0; border-radius: var(--r1); background: none; color: var(--muted); font: 600 14px var(--font-body); cursor: pointer;
    transition: background-color .2s var(--ease), color .2s var(--ease), transform .25s var(--spring);
  }
  .tree-tab img { width: 20px; height: 20px; border-radius: 4px; }
  .tree-tab b { color: var(--gold-hi); }
  .tree-tab:hover { color: var(--text); background: var(--surface-2); }
  .tree-tab:active { transform: scale(.96); }
  .tree-tab[aria-selected="true"] { color: var(--text); background: var(--surface-3); box-shadow: var(--shadow-1); }
  .trees { margin-top: var(--s2); }
  .tree:not(.is-active) { display: none; }
}
@media (max-width: 379px) { .tree-tab img { display: none; } }
