What 蛋 is referring to in "完蛋了"
The following text was copied from 重編國語辭典修訂本 website (http://dict.revised.moe.edu.tw/cgi-bin/cbdic/gsweb.cgi?o=dcbdic&amp;searchid=W00000002040), licensed under Creative Commons Attribution-NoDerivs 3.0 Taiwan, with the attribution to the Ministry of Education, R.O.C.



蛋


  [名]


[noun]


  1 鳥類和爬蟲類所生帶有硬殼的卵，受精之後可孵出小動物。如：「雞蛋」、「蛇蛋」、「下蛋」。


The hard-shell oval from birds or reptiles, which can produce small animals after fertilization. e.g. 雞蛋 (chicken egg), 蛇蛋 (snake egg), 下蛋 (to lay eggs).


  2 形狀像蛋的東西。如：「臉蛋兒」、「山藥蛋」。


An egg-shaped thing. e.g. 臉蛋兒 (face), 山藥蛋 (potato).


  3 斥責或罵人的話。用以比喻人或動作。如：「渾蛋」、「笨蛋」、「壞蛋」、「滾蛋」、「完蛋」、「糊塗蛋」。


A word to insult people, used as a metaphor for the action of humans. e.g. 渾蛋 (fucking asshole), 笨蛋 (stupid asshole), 壞蛋 (scoundrel asshole), 滾蛋 (Go fucking away!), 完蛋 (to be fucking finished), 糊塗蛋 (confused asshole).


  4 中國南方沿海少數民族之一。同「蜑」。如：「胡夷蛋蠻」。《宋史．卷三一．高宗本紀八》：「閏月丙午，罷廉州貢珠，縱蛋丁自便。」


A minor ethnicity in coastal South China, also written as 蜑. e.g. 胡夷蛋蠻.







蛋 in 完蛋 is definitely the third meaning: a word to insult people, used as a metaphor for the action of humans. This meaning is similar to ‘balls’ in English, the slang term of ‘testicles’.