*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

body {
  background: #0D1317;
  color: #E0E8F0;
  font-family: 'Inter', system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

#world {
  position: fixed; inset: 0;
  cursor: grab;
}
#world:active { cursor: grabbing; }

#bg-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

#tree-svg {
  position: absolute; top: 0; left: 0;
  overflow: visible;
  will-change: transform;
  font-family: 'Inter', system-ui, sans-serif;
}

/* ── Edges ─────────────────────────────── */
.edge {
  stroke: #2A2A2A;
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke 0.4s;
  pointer-events: none;
}
.edge.active {
  stroke-width: 3.5;
  filter: url(#glow);
}

/* ── Nodes ─────────────────────────────── */
.node { cursor: pointer; }

.node-bg {
  fill: #0D1317;
  stroke: none;
}
.node-ring {
  fill: none;
  stroke: #333;
  stroke-width: 3.5;
  transition: stroke 0.3s, filter 0.3s;
}
.node.on .node-ring { stroke-width: 4; }
.node.avail .node-ring { stroke: #8899AA; stroke-dasharray: 4 3; }

.node-inner {
  transition: transform 0.2s;
  transform-origin: 0 0;
}
.node:hover .node-inner {
  transform: scale(1.15);
}
.node-icon {
  pointer-events: none;
  opacity: 0.55;
  transition: opacity 0.3s;
}
.node.on .node-icon { opacity: 1; }
.node.avail .node-icon { opacity: 0.7; }
.node:hover .node-icon { opacity: 0.9; }
.node-label {
  pointer-events: none;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.node.on .node-label { opacity: 1; fill: #CDD; }
.node:hover .node-label { opacity: 1; }

/* ── HUD ───────────────────────────────── */
.hud {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 20px; z-index: 100;
  background: rgba(13,19,23,0.85);
  border: 1px solid #222;
  border-radius: 10px;
  padding: 10px 22px;
  backdrop-filter: blur(8px);
  font-size: 13px;
}
.hud-item { display: flex; align-items: center; gap: 6px; }
.hud-label { color: #667; text-transform: uppercase; letter-spacing: 1px; font-size: 10px; }
.hud-val { font-weight: 600; font-size: 16px; }
.hud-val.pts { color: #F7D14E; }
.hud-val.cnt { color: #40C8B8; }
.hud-btn {
  background: none; border: 1px solid #333; color: #888;
  font-size: 11px; padding: 4px 10px; border-radius: 6px;
  cursor: pointer; font-family: inherit;
  display: flex; align-items: center; gap: 5px;
  transition: border-color 0.2s, color 0.2s;
}
.hud-btn:hover { border-color: #555; color: #bbb; }

/* ── Tooltip ───────────────────────────── */
#tooltip {
  position: fixed;
  background: rgba(10,14,18,0.95);
  border: 1px solid #2A2A2A;
  border-radius: 10px;
  padding: 14px 16px;
  min-width: 220px;
  max-width: 280px;
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s, transform 0.2s;
}
#tooltip.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }

.tt-btn {
  display: block; width: 100%;
  padding: 8px 0; margin-top: 8px;
  border: none; border-radius: 6px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.tt-btn.unlock { background: #40C840; color: #000; }
.tt-btn.unlock:hover { background: #50E050; }
.tt-btn.locked { background: #222; color: #555; cursor: default; }
.tt-btn.remove { background: #442; color: #E84040; margin-top: 6px; }
.tt-btn.remove:hover { background: #553; }

/* ── Zoom controls ─────────────────────── */
.zoom-ctrl {
  position: fixed; bottom: 52px; right: 12px;
  display: flex; flex-direction: column; gap: 4px;
  z-index: 100;
}
.zoom-ctrl button {
  width: 36px; height: 36px;
  background: rgba(13,19,23,0.8);
  border: 1px solid #2A2A2A;
  color: #AAB;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
  font-family: inherit;
}
.zoom-ctrl button:hover { background: #1A2028; }

/* ── Reset modal ───────────────────────── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: none; align-items: center; justify-content: center;
  z-index: 500;
}
.modal.visible { display: flex; }
.modal-box {
  background: #121820;
  border: 1px solid #2A2A2A;
  border-radius: 12px;
  padding: 28px 32px;
  max-width: 340px; text-align: center;
}
.modal-box h3 { margin-bottom: 12px; font-size: 16px; }
.modal-box p { color: #88A; font-size: 13px; margin-bottom: 20px; }
.modal-box .btns { display: flex; gap: 10px; justify-content: center; }
.modal-box .btns button {
  padding: 8px 18px; border-radius: 6px; border: none;
  font-size: 12px; font-weight: 600; cursor: pointer;
  font-family: inherit;
}
.modal-box .btns .cancel { background: #222; color: #AAB; }
.modal-box .btns .confirm { background: #E84040; color: #FFF; }

/* ── Bottom hint ───────────────────────── */
.hint {
  position: fixed; bottom: 50px; left: 50%; transform: translateX(-50%);
  color: #334; font-size: 10px; z-index: 80;
  letter-spacing: 0.5px;
}

/* ── Skills panel (side menu) ──────────── */
.skills-panel {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 340px;
  background: rgba(13,19,23,0.96);
  border-right: 1px solid #222;
  z-index: 400;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  backdrop-filter: blur(12px);
}
.skills-panel.open { transform: translateX(0); }
.sp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid #1A2028;
}
.sp-title {
  font-size: 14px; font-weight: 600; color: #CDD;
  letter-spacing: 0.5px;
}
.sp-close {
  background: none; border: none; color: #667; font-size: 22px;
  cursor: pointer; padding: 0 4px; line-height: 1;
}
.sp-close:hover { color: #E84040; }
.sp-search {
  margin: 8px 12px; padding: 7px 12px;
  background: #111820; border: 1px solid #222; border-radius: 6px;
  color: #CDD; font-size: 12px; font-family: inherit;
  outline: none;
}
.sp-search::placeholder { color: #445; }
.sp-search:focus { border-color: #444; }
.sp-list {
  flex: 1; overflow-y: auto; padding: 4px 0;
}
.sp-list::-webkit-scrollbar { width: 4px; }
.sp-list::-webkit-scrollbar-track { background: transparent; }
.sp-list::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }
.sp-sector {
  padding: 8px 16px 4px;
  font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px;
  font-weight: 600;
}
.sp-skill {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 16px; cursor: pointer;
  transition: background 0.15s;
  border-left: 3px solid transparent;
}
.sp-skill:hover { background: rgba(255,255,255,0.03); }
.sp-skill.unlocked { border-left-color: currentColor; }
.sp-skill-icon {
  width: 28px; height: 28px; border-radius: 50%;
  background: #111820; border: 2px solid #333;
  flex-shrink: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.sp-skill-icon img {
  width: 100%; height: 100%; object-fit: cover;
}
.sp-skill.unlocked .sp-skill-icon { border-color: currentColor; }
.sp-skill-icon.oct { border-radius: 4px; }
.sp-skill-info { min-width: 0; flex: 1; }
.sp-skill-name {
  font-size: 12px; font-weight: 500; color: #99A;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sp-skill.unlocked .sp-skill-name { color: #DDE; }
.sp-skill-desc {
  font-size: 10px; color: #445; line-height: 1.4;
  margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.sp-skill-passive {
  font-size: 10px; color: #D0A030; line-height: 1.3;
  margin-top: 3px; padding: 3px 6px;
  background: rgba(208,160,48,0.06); border: 1px solid rgba(208,160,48,0.18);
  border-radius: 4px;
}
.sp-skill-stats {
  display: flex; gap: 4px; margin-top: 3px;
}
.sp-skill-badge {
  font-size: 9px; padding: 1px 5px; border-radius: 3px;
  white-space: nowrap;
}
.sp-skill.hidden { display: none; }

/* ── Stats bar (bottom) ───────────────── */
.stats-panel {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(13,19,23,0.92);
  border-top: 1px solid #222;
  padding: 8px 20px;
  z-index: 100;
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  gap: 6px;
}
.stats-title {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #445;
  margin-right: 4px;
  white-space: nowrap;
}
.stat-row {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1;
  min-width: 0;
  position: relative;
}
.stat-name {
  font-size: 10px;
  white-space: nowrap;
}
.stat-bar-bg {
  flex: 1;
  height: 5px;
  background: #1A2028;
  border-radius: 3px;
  overflow: hidden;
  min-width: 24px;
}
.stat-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 0;
  position: relative;
}
.stat-bar-glow {
  animation: barGlow 0.8s ease-out;
}
.stat-val {
  width: 18px;
  text-align: right;
  font-weight: 600;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  transition: color 0.2s;
}
.stat-pop {
  animation: statPop 0.5s cubic-bezier(0.2, 0, 0, 1.4);
}
.stat-float {
  position: absolute;
  font-size: 13px;
  font-weight: 700;
  pointer-events: none;
  animation: floatUp 0.9s ease-out forwards;
  white-space: nowrap;
  text-shadow: 0 0 6px currentColor;
  transform: translateX(-50%);
}

/* ── Toast ─────────────────────────────── */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(13,19,23,0.95);
  border: 1px solid #40C840;
  color: #C0E8C0;
  padding: 10px 24px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  backdrop-filter: blur(8px);
}
.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Animation ─────────────────────────── */
@keyframes burst {
  0%   { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(3); opacity: 0; }
}
@keyframes statPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.5); }
  100% { transform: scale(1); }
}
@keyframes floatUp {
  0%   { opacity: 1; transform: translateX(-50%) translateY(0); }
  70%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-36px); }
}
@keyframes barGlow {
  0%   { box-shadow: 0 0 8px 2px currentColor; filter: brightness(1.6); }
  100% { box-shadow: none; filter: brightness(1); }
}

/* ── Scrollbar ─────────────────────────── */
::-webkit-scrollbar { display: none; }
