Ha! That is so cool. I was super interested in the idea so tried doing it myself without looking at your solution and came up with a quite an elegant solution using only 8 formulas
and some named ranges (could be 4 if you inlined them more but I kept them separate for clarity).
https://docs.google.com/spreadsheets/d/1T3bv8ThluHc18ghI8u9m...
Thank you for the inspiration!