Why are line spectra only seen in gases?

In liquids and solids the difference in energy between energy levels becomes very small, due to the electron clouds of several atoms bein in very close proximity of one another. These similar energy levels will form 'bands' of indistinguishable spectral lines.

In gases however, atoms will be spaced loosely enough such that the interaction between atoms will be minimal. This allows the energy levels to have sufficient difference in energy for distinct lines to be formed.

You see line spectra usually only in gases because there the interaction between the atoms can be neglected. In gases with high pressures you get the so-called collision broadening of the lines which eventually become bands. Similarly, in liquids and solid the atoms are so close that the interaction between them leads to the discrete spectral lines becoming bands.

It's a good question, it's not stupid. Actually, this phenomena can be observed with liquids and solids as well. Each element has its own distinct spectral line and this fact can and has been used to identify an element. However, it is much more difficult to observe the spectral lines of liquids and solids due to how close together the atoms are. Also, tables of the spectral lines of elements only seem to go up to the 99th element, Einsteinium (not including Astatine (At, 85) and Francium (Fr, 87).

I could not find any data as to why this may be, however, I believe it is simply because we could not test for the spectral lines of the heavier elements due to their instability and scarcity. It's incredible because some of the heavier and more unstable elements have insanely short half lives ranging from 100.5 days (the most stable isotope of fermium (Fm, 100)), to 0.69 microseconds (0.00069 milliseconds) (Oganesson (Og, 118)). This would make measuring their spectral lines nearly impossible. This isn't even considering how much this would cost. These heavier elements likely have their own spectral lines, however, due to all I stated above, it isn't exactly possible to measure.

I hope this helped,

You can see a list of of all the known spectral lines of elements on Wikipedia since it seems to have the most updated table. mostly all textbooks on the spectral lines of elements tend to only go up to uranium, however, textbooks go into much more detail for each element.