/* Technology trees: nodes on a grid with lines and tier marks, and the dialog a node opens. */
:root{--tree-bg:#1f3050;--tree-grid:rgb(255 255 255 / 5%);--tree-line:#45b9a8;--tree-text:#eef3fb;--tree-edge:#dbe8f2;--tree-row:110px;--tree-solo:#4d94ff;--tree-rally:#b66cff;--tree-defense:#ff9a3d}
:root[data-theme=dark]{--tree-bg:#131c2f;--tree-line:#3aa597}

.tree{background-color:var(--tree-bg);background-image:linear-gradient(var(--tree-grid) 1px,transparent 1px),linear-gradient(90deg,var(--tree-grid) 1px,transparent 1px);background-size:40px 40px;border:1px solid var(--border);border-radius:var(--radius);padding:0 6px;color:var(--tree-text);overflow:hidden;margin:12px auto 20px;max-width:600px;direction:ltr}
.tree-field{position:relative;height:calc(var(--rows) * var(--tree-row));margin:20px 0 16px}
.tree-lines{position:absolute;inset:0;width:100%;height:100%;overflow:visible}
.tree-lines line{stroke:var(--tree-line);stroke-width:3;stroke-linecap:round;vector-effect:non-scaling-stroke}
.tree-node{--tree-shape:66px;position:absolute;width:calc(100% / var(--cols));height:var(--tree-shape);margin-top:calc(var(--tree-shape) / -2);transform:translate(-50%);padding:0;border:0;background:none;color:inherit;cursor:pointer;-webkit-tap-highlight-color:transparent}
.tree-diamond{--tree-shape:82px}
.tree:has(.tree-diamond){--tree-row:136px;max-width:680px}
.tree-shape{position:absolute;left:50%;top:0;width:var(--tree-shape);height:var(--tree-shape);transform:translate(-50%)}
.tree-shape img{position:absolute;z-index:1;left:50%;top:50%;width:46px;height:46px;margin:-23px 0 0 -23px;object-fit:contain}
.tree-diamond .tree-shape img{width:58px;height:58px;margin:-29px 0 0 -29px}
.tree-diamond .tree-shape:before,.tree-diamond .tree-shape:after{content:"";position:absolute;clip-path:polygon(50% 0,100% 50%,50% 100%,0 50%)}
.tree-diamond .tree-shape:before{inset:0;background:var(--tree-edge)}
.tree-diamond .tree-shape:after{inset:4px;background:linear-gradient(165deg,#74f2ff,#17a5ee 52%,#0c6fc6)}
.tree-diamond .tree-shape{filter:drop-shadow(0 2px 3px rgb(0 0 0 / 45%))}
.tree-badge{position:absolute;z-index:2;left:50%;transform:translate(-50%);top:-6px;min-width:24px;padding:0 7px;border-radius:99px;background:#080e1ad9;color:#fff;font-size:.72rem;font-weight:700;line-height:1.4;text-align:center;white-space:nowrap;font-variant-numeric:tabular-nums}
.tree-name{position:absolute;top:100%;inset-inline:2px;margin-top:3px;padding:1px 0;font-size:.72rem;font-weight:600;line-height:1.2;text-align:center;overflow-wrap:anywhere;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;color:var(--tree-text);text-shadow:0 0 3px var(--tree-bg),0 0 6px var(--tree-bg),0 1px 2px var(--tree-bg)}
.tree-diamond .tree-name{font-size:.84rem}
.tree-diamond .tree-badge{font-size:.78rem}
.tree-node:hover .tree-shape,.tree-node:focus-visible .tree-shape{filter:brightness(1.15) drop-shadow(0 0 4px #ffd45c)}
.tree-node:focus-visible{outline:none}
.tree-mark{position:absolute;inset-inline-start:2px;transform:translateY(-50%);padding:1px 9px;border:1px solid rgb(255 255 255 / 25%);border-radius:99px;background:#ffffff1f;color:var(--tree-text);font-size:.72rem;font-weight:700;white-space:nowrap}

.tree-dialog{width:min(94vw,820px);max-height:min(88vh,900px);padding:0;border:1px solid var(--border);border-radius:var(--radius);background:var(--surface);color:var(--text);box-shadow:0 12px 40px #00000073}
.tree-dialog::backdrop{background:#080c149e}
.tree-sheet{padding:16px 16px 18px}
.tree-x{position:sticky;top:0;z-index:1;float:right;width:36px;height:36px;margin:-4px -4px 4px 8px;border:1px solid var(--border);border-radius:99px;background:var(--surface-2);font-size:1.4rem;line-height:1;cursor:pointer}
html[dir=rtl] .tree-x{float:left;margin:-4px 8px 4px -4px}
.tree-title{display:flex;gap:12px;align-items:center;margin:0 0 10px;font-size:1.25rem}
.tree-title img{flex:none;width:52px;height:52px;object-fit:contain}
.tree-body>p{margin:0 0 10px}
body:has(.tree-dialog[open]){overflow:hidden}
@media (max-width:520px){.tree-sheet{padding:12px}.tree-title{font-size:1.1rem}.tree-title img{width:44px;height:44px}}
.tree-total{margin:12px 0;padding:12px 14px;border:1px solid var(--border);border-radius:12px;background:var(--surface-2)}
.tree-total h3{margin:0 0 8px;font-size:.95rem}
.tree-total .eq-stat strong{text-align:end}

/* Power Armor Core: square and hexagon (core) nodes, module tabs, dimmed layers. */
.tree-square{--tree-shape: 58px}
.tree-hex{--tree-shape: 68px}
.tree-square .tree-shape{border-radius:13px;background:#1a1f2b;box-shadow:0 0 0 3px var(--tone, var(--tree-edge)),0 2px 6px #0000007f}
.tree-square .tree-shape img{inset-inline-start:0;top:0;width:100%;height:100%;margin:0;border-radius:13px}
.tree-hex .tree-shape{filter:drop-shadow(0 0 5px var(--tone, transparent))}
.tree-hex .tree-shape img{width:74px;height:68px;margin:-34px 0 0 -37px}
.tree-square .tree-badge,.tree-hex .tree-badge{top:auto;bottom:1px}
.tree-off{opacity:.38;filter:grayscale(.75)}
.tree-lines line.tree-off{opacity:.25;filter:none}
.tree-note{margin:0 0 10px;padding:6px 10px;border-inline-start:3px solid var(--accent);border-radius:4px;background:color-mix(in srgb,var(--accent) 10%,transparent);font-size:.9rem}
.tree-tabs{display:flex;flex-wrap:wrap;gap:8px;margin:12px 0}
.tree-tab{display:inline-flex;gap:8px;align-items:center;padding:5px 14px 5px 6px;border:2px solid var(--border);border-radius:99px;background:var(--surface);cursor:pointer;font-weight:600}
.tree-tab[aria-pressed=true]{border-color:var(--tone);background:color-mix(in srgb,var(--tone) 16%,var(--surface))}
.tree-tab img{width:32px;height:32px;object-fit:contain}
.tree-sum{display:flex;flex-wrap:wrap;gap:6px 20px;margin:8px 0 0;font-variant-numeric:tabular-nums}
.tree-sum img{width:24px;height:24px;object-fit:contain;vertical-align:middle}
.tree-panel[hidden],.tree-tabs[hidden]{display:none}
.tree-tabbed .tree-panel>h2{display:none}
