public CardPanel getCardPanel(int x, int y) {
        for (Row row : rows) {
            for (Stack stack : row) {
                for (CardPanel panel : stack) {
                    int panelX = panel.getCardX();
                    int panelY = panel.getCardY();
                    int panelWidth, panelHeight;
                    if (panel.tapped) {
                        panelWidth = panel.getCardHeight();
                        panelHeight = panel.getCardWidth();
                        panelY += panelWidth - panelHeight;
                    } else {
                        panelWidth = panel.getCardWidth();
                        panelHeight = panel.getCardHeight();
                    }
                    if (x > panelX && x < panelX + panelWidth) {
                        if (y > panelY && y < panelY + panelHeight) {
                            if (!panel.isDisplayEnabled()) return null;
                            return panel;
                        }
                    }
                }
            }
        }
        return null;
    }