3x3x3 led cube

I’m building a 3x3x3 rgb led cube controlled by arduino MEGA 1… 54 ports. Since arduino’s power isn’t enough , I’m using a 1 A external power supply. I thought to use PNP transistors for controlling the current flow , if a port is in OFF state , led will glow red or blue. It’s currently working, I’ve tested all 27 leds an actually works. The problem is the number of wires (54+3x27) . Is there a better way to organize the circuit so I need less wires ? I mean, I know I can solder the leds to a board but I would still have 27 wires coming out from each level of my cube. Can somebody suggest a smarter solution ?

Several optimizations are possible. You can use multiplexing with 5+6 wires (rows+columns), or port expanders which can not only reduce the wires to 4, but also can drive the LEDs directly, or some sophisticated LED driver chip.

Thank vou for the ideas !