Map<String, dynamic> toJson() => { 'rows': rows, 'cols': cols, 'grid': grid.map((row) => row.map((c) => c.toJson()).toList()).toList(), };