3. The solution set of the equation $x^{2}+x-1=x \pi^{x^{2}-1}+\left(x^{2}-1\right) \pi^{x}$ is $A$ (where $\pi$ is an irrational number, $\pi=3.141 \cdots$, and $x$ is a real number), then the sum of the squares of all elements in $A$ is ( ).
A. 0
B. 1
C. 2
D. 4
3. C. Let $y=x^{2}-1$, then the original equation becomes $x+y=x \pi^{y}+y \pi^{x}$, i.e., $x\left(\pi^{y}-1\right)+y\left(\pi^{x}-1\right)=0$.

Since when $x>0$, $\pi^{x}-1>0$, i.e., $x$ and $\pi^{x}-1$ have the same sign. Similarly, $y$ and $\pi^{y}-1$ have the same sign, so when $x y \neq 0$, $x\left(\pi^{x}-1\right) \cdot y\left(\pi^{y}-1\right)>0$, i.e.,
$$
x\left(\pi^{y}-1\right) \cdot y\left(\pi^{x}-1\right)>0.
$$

Therefore, $x\left(\pi^{y}-1\right)$ and $y\left(\pi^{x}-1\right)$ have the same sign. Thus, from equation (1), we know $x=0$ or $y=0$.
The roots of the original equation are $-1,0,1$, i.e., $A=\{-1,0,1\}$, and the sum of the squares of its elements is $(-1)^{2}+0^{2}+1^{2}=2$.