/* One committed dark theme: slate night sky, parchment text, gold for spent
   points, and an accent that takes the colour of the selected class.
   Layout: phone = one section and one tree at a time; wide = everything visible. */
:root {
  color-scheme: dark;
  --bg: #13151b;
  --panel: #1b1f28;
  --raised: #242a36;
  --line: #333a49;
  --text: #e9e4d6;
  --muted: #a3a3ad;
  --gold: #ebb53d;
  --warn: #ee8a6b;
  --class: #c69b6d;
  --font-display: "Cinzel", "Iowan Old Style", Georgia, serif;
  --font-body: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --cell-w: 68px;
  --cell-h: 64px;
  --gap-x: 10px;
  --gap-y: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font-body);
  padding-bottom: 24px;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0; text-wrap: balance; }
h1 { font-size: 1.25rem; letter-spacing: 0.02em; }
h2 { font-size: 1.05rem; margin-bottom: 12px; }
h3 { font-size: 0.8rem; font-family: var(--font-body); font-weight: 700; letter-spacing: 0.08em;
     text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; }
p { margin: 0 0 10px; }
a { color: var(--class); }
button, input { font: inherit; color: inherit; }
button {
  background: var(--raised); border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 12px; cursor: pointer;
}
button:hover { border-color: var(--class); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--class); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.warn { color: var(--warn); }

/* ---------- header ---------- */
.top { padding: 16px 16px 10px; display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: end; }
.build-line { color: var(--muted); font-size: 0.85rem; margin: 2px 0 0; }
.classes { display: flex; flex-wrap: wrap; gap: 6px; }
.classes button { padding: 5px 10px; font-weight: 600; border-left: 4px solid var(--c); }
.classes button[aria-pressed="true"] { background: var(--c); color: #14161c; border-color: var(--c); }

/* ---------- level bar ---------- */
.levelbar {
  position: sticky; top: 0; z-index: 5;
  background: var(--panel); border-block: 1px solid var(--line);
  padding: 10px 16px; display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center;
}
.level-control { display: flex; align-items: center; gap: 10px; flex: 1 1 260px; }
.level-control label { font-weight: 700; }
.level-control input { flex: 1; accent-color: var(--class); min-width: 120px; }
.level-control output { font: 700 1.3rem var(--font-display); min-width: 2ch; text-align: right;
                        font-variant-numeric: tabular-nums; }
.points { flex: 2 1 260px; font-size: 0.95rem; }
.points strong { color: var(--gold); font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: 8px; }

/* ---------- section tabs (phone) ---------- */
.views { display: flex; gap: 0; padding: 10px 16px 0; }
.views button { flex: 1; border-radius: 0; border-right-width: 0; padding: 8px 2px; font-weight: 600; font-size: 0.92rem; }
.views button:first-child { border-radius: 6px 0 0 6px; }
.views button:last-child { border-radius: 0 6px 6px 0; border-right-width: 1px; }
.views button[aria-pressed="true"] { background: var(--class); color: #14161c; border-color: var(--class); }

main { padding: 14px 16px 0; }
.view { display: none; }
main[data-view="talents"] .view-talents,
main[data-view="bonuses"] .view-bonuses,
main[data-view="skills"] .view-skills,
main[data-view="stats"] .view-stats,
main[data-view="updates"] .view-updates,
main[data-view="data"] .view-data { display: block; }

/* ---------- trees ---------- */
.tree-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tree-tabs button { flex: 1; padding: 6px 4px; font-size: 0.9rem; }
.tree-tabs button[aria-pressed="true"] { border-color: var(--class); box-shadow: inset 0 -3px 0 var(--class); }
.tree-tabs .num { color: var(--gold); font-weight: 700; }

.trees { display: flex; flex-wrap: wrap; gap: 20px; justify-content: center; }
.tree { display: none; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.tree.current { display: block; }
.tree-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.tree-head h2 { margin: 0; flex: 1; }
.tree-head .num { color: var(--gold); font-weight: 700; }
.tree-head button { padding: 2px 8px; font-size: 0.8rem; }

.grid {
  position: relative; display: grid;
  grid-template-columns: repeat(4, var(--cell-w)); grid-auto-rows: var(--cell-h);
  gap: var(--gap-y) var(--gap-x);
}
.grid svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.grid svg path { fill: none; stroke: var(--line); stroke-width: 3; }
.grid svg path.met { stroke: var(--gold); }

.node {
  position: relative; z-index: 1; width: var(--cell-w); height: var(--cell-h);
  padding: 4px 4px 14px; border-radius: 8px; border: 2px solid var(--line);
  background: var(--raised); color: var(--muted);
  font-size: 0.64rem; line-height: 1.15; font-weight: 600; text-align: center;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.node .name { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
              overflow-wrap: break-word; hyphens: auto; }
.node .rank { position: absolute; right: 3px; bottom: 1px; font-size: 0.7rem; font-variant-numeric: tabular-nums; }
.node.active-ability { border-radius: 16px; }
.node.open { color: var(--text); border-color: color-mix(in srgb, var(--class) 70%, var(--line)); }
.node.learned { color: var(--text); border-color: var(--gold); }
.node.learned .rank { color: var(--gold); }
.node.maxed { background: color-mix(in srgb, var(--gold) 22%, var(--raised)); }
.node.selected { box-shadow: 0 0 0 3px var(--class); }
.hint { text-align: center; color: var(--muted); font-size: 0.85rem; margin: 12px 0 0; }

/* ---------- selected talent ---------- */
.detail {
  position: sticky; bottom: 0; z-index: 4; margin-top: 14px;
  background: var(--raised); border: 1px solid var(--class); border-radius: 10px;
  padding: 10px 12px; box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.45);
}
.detail-head { display: flex; gap: 10px; align-items: center; }
.detail-head h2 { margin: 0; flex: 1; font-size: 1rem; }
.detail-head .rank { color: var(--gold); font-weight: 700; font-variant-numeric: tabular-nums; }
.detail-head button { min-width: 40px; font-weight: 700; font-size: 1.1rem; padding: 4px 10px; }
.detail p { margin: 6px 0 0; font-size: 0.92rem; }
.detail .cost { color: var(--muted); font-size: 0.85rem; }
.detail b { color: var(--gold); }

/* ---------- panels ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { text-align: left; padding: 5px 8px 5px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.82rem; }
td.num, th.num { text-align: right; padding-right: 0; padding-left: 8px; white-space: nowrap; }
tr.now td { color: var(--class); font-weight: 700; }
.scroll { overflow-x: auto; }
.total-value { color: var(--gold); font-weight: 700; }
.taken { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.taken li { font-size: 0.92rem; }
.taken .t-name { font-weight: 700; }
.taken .t-rank { color: var(--gold); font-variant-numeric: tabular-nums; margin-left: 4px; }
.taken .t-text { display: block; color: var(--muted); }
.attrs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.attrs label { display: grid; gap: 3px; font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.attrs input { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
               padding: 6px; font-variant-numeric: tabular-nums; }
.note { font-size: 0.85rem; color: var(--muted); max-width: 65ch; }
.save-row { display: flex; gap: 8px; }
.save-row input { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line);
                  border-radius: 6px; padding: 6px 8px; }
.builds { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.builds li { display: flex; gap: 8px; align-items: center; font-size: 0.92rem; }
.builds .b-name { flex: 1; overflow-wrap: anywhere; }
.builds button { padding: 3px 9px; font-size: 0.85rem; }
/* ---------- game updates ---------- */
.badge { display: inline-block; min-width: 1.4em; margin-left: 5px; padding: 0 5px; border-radius: 9px;
         background: var(--gold); color: #14161c; font-size: 0.75rem; line-height: 1.4em; }
.badge[hidden], .update-note[hidden] { display: none; }
.update-note { margin: 10px 16px 0; padding: 8px 12px; border: 1px solid var(--gold); border-radius: 8px;
               background: color-mix(in srgb, var(--gold) 12%, var(--panel)); font-size: 0.92rem; }
.update-note button { margin-left: 8px; padding: 2px 10px; }
.upd-filter { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.upd-filter button[aria-pressed="true"] { background: var(--class); color: #14161c; border-color: var(--class); }
.upd-entry { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 10px; }
.upd-entry > h3 { margin: 0 0 4px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.upd-entry .upd-new { color: var(--gold); font-size: 0.8rem; font-weight: 700; }
.upd-class { margin: 8px 0 0; font-size: 0.95rem; }
.upd-list { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 7px; }
.upd-list li { display: grid; grid-template-columns: 24px 1fr; gap: 2px 8px; font-size: 0.9rem; }
.upd-list .u-icon { grid-row: span 2; width: 24px; height: 24px; }
.upd-list .u-icon img { display: block; border-radius: 4px; }
.upd-list .u-head { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.upd-list .u-name { font-weight: 700; }
.upd-list button.u-name { background: none; border: 0; padding: 0; color: inherit; font: inherit; font-weight: 700;
                          text-decoration: underline dotted; cursor: pointer; }
.upd-list .u-kind { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.u-kind.added { color: #7ccf7c; } .u-kind.removed { color: #e57373; } .u-kind.changed { color: var(--gold); }
.upd-list .u-body { color: var(--muted); }
.upd-list .u-was { text-decoration: line-through; opacity: 0.75; }
.upd-more { font-size: 0.85rem; }
.node.recent::after { content: ""; position: absolute; top: 3px; right: 3px; width: 8px; height: 8px;
                      border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 2px var(--panel); }
.tip-recent { color: var(--gold); font-size: 0.85rem; }

.credits {
  margin: 28px 16px 0; padding-top: 14px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 0.8rem; line-height: 1.5; max-width: 110ch;
}

.toast {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 10;
  background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 8px;
  font-weight: 600; max-width: calc(100% - 32px); margin: 0;
}

/* ---------- icons ---------- */
img.icon { border-radius: 4px; vertical-align: middle; flex: none; background: var(--raised); }
.node img.icon { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 6px; display: none; }
.node.has-icon img.icon { display: block; }
.node.has-icon .name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.node.has-icon .rank { right: 2px; bottom: 2px; padding: 0 4px; border-radius: 4px; background: rgba(12, 14, 19, 0.85); color: var(--text); }
.node.has-icon.learned .rank { color: var(--gold); }
.node.has-icon:not(.open):not(.learned) img.icon { filter: grayscale(1) brightness(0.5); }
.taken img.icon { margin-right: 6px; }
.detail-head img.icon { width: 36px; height: 36px; }

/* ---------- hover tooltip ---------- */
.tooltip {
  position: fixed; z-index: 20; width: max-content; max-width: min(330px, calc(100vw - 16px));
  background: #0d0f14; border: 1px solid color-mix(in srgb, var(--gold) 55%, var(--line)); border-radius: 8px;
  padding: 10px 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55); pointer-events: none; font-size: 0.88rem;
}
.tooltip[hidden] { display: none; }
.tooltip p { margin: 6px 0 0; }
.tip-head { display: flex; gap: 10px; align-items: center; }
.tip-head img.icon { width: 32px; height: 32px; }
.tip-name { font-weight: 700; font-size: 0.98rem; }
.tip-rank { color: var(--gold); font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.tip-cost { color: var(--muted); font-size: 0.8rem; }
.tip-next { color: var(--muted); }
.tip-next b { color: color-mix(in srgb, var(--gold) 70%, var(--muted)); }
.tip-hint { color: var(--muted); font-size: 0.78rem; font-style: italic; }
.scaled { color: #8fd18a; font-variant-numeric: tabular-nums; }

/* ---------- skills ---------- */
.seg { display: flex; margin-bottom: 10px; }
.seg button { flex: 1; border-radius: 0; padding: 6px; font-weight: 600; }
.seg button:first-child { border-radius: 6px 0 0 6px; border-right-width: 0; }
.seg button:last-child { border-radius: 0 6px 6px 0; }
.seg button[aria-pressed="true"] { background: var(--class); color: #14161c; border-color: var(--class); }
.lv-row { display: grid; grid-template-columns: 2.4rem 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.lv-row .lv { font: 700 1.1rem var(--font-display); color: var(--gold); text-align: right; }
.lv-row.future { opacity: 0.5; }
.lv-row.now { background: color-mix(in srgb, var(--class) 14%, transparent); box-shadow: inset 3px 0 0 var(--class); }
.lv-list, .tree-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.lv-list li { display: flex; align-items: center; gap: 6px; font-size: 0.92rem; min-width: 0; }
.s-name { font-weight: 600; overflow-wrap: anywhere; }
.s-tag { font-size: 0.72rem; font-weight: 700; padding: 0 6px; border-radius: 999px; border: 1px solid var(--line);
         color: var(--muted); white-space: nowrap; }
.s-tag.new { color: var(--gold); border-color: var(--gold); }
.s-tab { font-size: 0.78rem; margin-left: auto; white-space: nowrap; }
.tree-list li { display: grid; gap: 2px; padding-bottom: 6px; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
.tree-list li > div:first-child { display: flex; align-items: center; gap: 6px; }
.s-levels { font-size: 0.85rem; padding-left: 28px; }
.s-levels .have { color: var(--gold); font-weight: 700; }

/* ---------- wide: show everything at once ---------- */
@media (min-width: 900px) {
  h1 { font-size: 1.5rem; }
  .views, .tree-tabs { display: none; }
  .view, .tree { display: block; }
  .panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; margin-top: 20px;
            align-items: start; }
  .skills-scroll { max-height: 640px; overflow-y: auto; padding-right: 6px; }
}
@media (max-width: 350px) {
  :root { --cell-w: 60px; --gap-x: 6px; }
}
@media (prefers-reduced-motion: no-preference) {
  .node { transition: border-color 0.12s, background-color 0.12s; }
}
