:root {
  --bg: #121212;
  --panel: #1c1c1c;
  --panel-2: #242424;
  --line: #333;
  --text: #e6e6e6;
  --muted: #9a9a9a;
  --gold: #ffd100;
  --green: #40bf40;
  --accent: #3fc7eb;
  --cell: 64px;   /* pas de la grille */
  --icon: 44px;   /* taille d'une icône */
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, input { font: inherit; color: inherit; }

.page { max-width: 1180px; margin: 0 auto; padding: 16px; }
.page-head h1 { margin: 0; font-size: 26px; }
.page-head .sub { margin: 2px 0 16px; color: var(--muted); }

/* ---------- Barre d'outils ---------- */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 8px;
}
.class-bar { display: flex; flex-wrap: wrap; gap: 6px; }
.class-btn {
  width: 36px; height: 36px; padding: 0; border-radius: 4px; cursor: pointer;
  border: 2px solid transparent; background: #000 center/cover no-repeat;
  filter: grayscale(.4) brightness(.85); transition: filter .15s, border-color .15s;
}
.class-btn:hover { filter: none; }
.class-btn.active { filter: none; border-color: var(--c, var(--accent)); box-shadow: 0 0 8px var(--c); }

.tools { display: flex; gap: 6px; align-items: center; }
.level { display: flex; align-items: center; }
.level button, .icon-btn {
  height: 34px; min-width: 34px; border: 1px solid var(--line); background: var(--panel-2);
  border-radius: 4px; cursor: pointer;
}
.level button:hover, .icon-btn:hover { background: #2f2f2f; }
.level input {
  width: 52px; height: 34px; text-align: center; margin: 0 4px;
  background: #0d0d0d; border: 1px solid var(--line); border-radius: 4px;
}
.icon-btn.on { background: #5a1d1d; border-color: #c33; }

/* ---------- Calculateur ---------- */
.calc { margin-top: 16px; }
.calc-head { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; }
.calc-head h2 { margin: 0; font-size: 20px; }
.search {
  display: flex; align-items: center; gap: 6px; flex: 0 1 320px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 0 8px;
}
.search input { flex: 1; min-width: 0; height: 32px; background: none; border: 0; outline: none; }

.summary { display: flex; flex-wrap: wrap; gap: 18px; justify-content: flex-end; margin: 10px 0; color: var(--muted); }
.summary b { color: var(--text); }
.summary .spread { margin-right: auto; color: var(--gold); font-weight: 600; }

.trees { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.tree { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; display: flex; flex-direction: column; }
.tree-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--panel-2); }
.tree-head img { width: 26px; height: 26px; border-radius: 50%; border: 1px solid #000; }
.tree-head .name { font-weight: 600; flex: 1; }
.tree-head .pts { color: var(--muted); font-variant-numeric: tabular-nums; }
.tree-head .pts.has { color: var(--gold); }

.tree-body {
  position: relative; flex: 1;
  display: flex; justify-content: center; padding: 14px 0;
  background:
    radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--c) 30%, transparent), transparent 70%),
    linear-gradient(180deg, color-mix(in srgb, var(--c) 12%, #151515), #0e0e0e);
}
.grid { position: relative; width: calc(var(--cell) * 4); height: calc(var(--cell) * 7); }

.tree-foot { padding: 8px; }
.tree-foot button {
  width: 100%; height: 32px; border: 1px solid var(--line); background: var(--panel-2);
  border-radius: 4px; cursor: pointer; color: var(--muted);
}
.tree-foot button:hover { color: var(--text); background: #2f2f2f; }

/* Flèches de prérequis */
.arrow { --ac: #555; position: absolute; background: var(--ac); z-index: 1; }
.arrow.ok { --ac: var(--gold); box-shadow: 0 0 4px rgba(255, 209, 0, .5); }
/* pointe de flèche (triangle en bordure CSS) */
.arrow.v::after, .arrow.h.right::after, .arrow.h.left::after {
  content: ""; position: absolute; border: 7px solid transparent;
}
.arrow.v::after { left: -4px; bottom: -12px; border-top: 8px solid var(--ac); border-bottom: 0; }
.arrow.h.right::after { right: -12px; top: -4px; border-left: 8px solid var(--ac); border-right: 0; }
.arrow.h.left::after { left: -12px; top: -4px; border-right: 8px solid var(--ac); border-left: 0; }

/* Talents */
.talent {
  position: absolute; z-index: 2; width: var(--icon); height: var(--icon);
  border: 2px solid #4a4a4a; border-radius: 5px; padding: 0; cursor: pointer;
  background: #000 center/cover no-repeat; user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}
.talent::before { /* voile sur les talents verrouillés */
  content: ""; position: absolute; inset: 0; border-radius: 3px; background: rgba(0,0,0,.0); transition: background .15s;
}
.talent.locked { filter: grayscale(1); }
.talent.locked::before { background: rgba(0,0,0,.45); }
.talent.avail { border-color: var(--green); }
.talent.partial { border-color: var(--green); box-shadow: 0 0 6px rgba(64,191,64,.6); }
.talent.max { border-color: var(--gold); box-shadow: 0 0 6px rgba(255,209,0,.6); }
.talent:hover { outline: 1px solid #fff; }
.talent.match { outline: 2px solid #ff4fd8; outline-offset: 2px; }
.talent.dim { opacity: .3; }
.talent .rank {
  position: absolute; right: -8px; bottom: -8px; min-width: 26px; padding: 0 3px;
  font-size: 11px; line-height: 15px; text-align: center; font-weight: 600;
  background: #0b0b0b; border: 1px solid #555; border-radius: 3px; color: var(--muted);
}
.talent.avail .rank, .talent.partial .rank { color: var(--green); border-color: var(--green); }
.talent.max .rank { color: var(--gold); border-color: var(--gold); }
.talent.flash { animation: flash .35s; }
@keyframes flash { from { box-shadow: 0 0 0 4px rgba(255,60,60,.8); } }

.hint { color: var(--muted); font-size: 12px; text-align: center; margin: 10px 0 16px; }

/* Panneau ordre des talents */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 0 12px; }
.panel summary { cursor: pointer; padding: 12px 0; font-weight: 600; font-size: 16px; }
.order { margin: 0 0 12px; padding: 0; list-style: none; columns: 3 240px; column-gap: 16px; }
.order li { display: flex; gap: 8px; align-items: center; padding: 3px 0; break-inside: avoid; }
.order li .lv { width: 34px; color: var(--muted); font-variant-numeric: tabular-nums; }
.order li img { width: 20px; height: 20px; border-radius: 3px; }
.order li .rk { color: var(--muted); margin-left: auto; }
.empty { color: var(--muted); margin: 0 0 12px; }

.welcome { margin-top: 40px; text-align: center; color: var(--muted); }

/* Infobulle */
.tooltip {
  position: fixed; z-index: 100; max-width: 340px; pointer-events: none;
  background: rgba(8, 12, 30, .96); border: 1px solid #5a6a8a; border-radius: 4px;
  padding: 8px 10px; font-size: 13px; box-shadow: 0 4px 18px rgba(0,0,0,.6);
}
.tooltip .tt-name { font-size: 15px; font-weight: 600; color: #fff; }
.tooltip .tt-rank { color: var(--muted); }
.tooltip .tt-req { color: #ff4040; }
.tooltip .tt-desc { color: var(--gold); margin-top: 4px; }
.tooltip .tt-next { color: #fff; margin-top: 8px; }
.tooltip .tt-hint { margin-top: 8px; font-size: 12px; }
.tooltip .tt-hint.add { color: var(--green); }
.tooltip .tt-hint.rem { color: #ff6060; }
.tooltip table { border-collapse: collapse; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 101;
  background: #2a2a2a; border: 1px solid var(--line); border-radius: 4px; padding: 8px 14px;
}

/* ---------- Responsive ---------- */
@media (max-width: 920px) {
  .trees { grid-template-columns: 1fr; }
  .tree-body { padding: 12px 0; }
}
@media (max-width: 400px) {
  :root { --cell: 56px; --icon: 40px; }
}
