That won’t work. You need to set the id in the post that is requesting the style sheet, not in the file that is generating the style sheet.
Here is a simple example
In the post:
<?php
$queried_object = get_queried_object();
$post_id = $queried_object->ID;
?>
<link rel="stylesheet" href="url/of/file.php?post_id=<?php echo $post_id; ?>" />
In the file generating the stylesheet:
$post_id = $_GET['post_id'];
include("../../../../wp-load.php");
header('Content-Type:text/css');