Rinse and drain the rice. Place in a pot with 2 cups water, a pinch of salt, and pandan leaves, if using. Bring to a boil over medium-high heat. Lower the heat to low, cover, and cook for 15–20 minutes or until the water is absorbed. Turn off the heat, uncover, and remove the pandan leaves. Let cool.
Lightly grease an 8×8-inch baking dish. Line with banana leaves or parchment, if using.
Reserve 1 cup coconut milk for the topping. Combine the rest with sugar and a pinch of salt in a nonstick pan. Cook over medium-high heat for about 10 minutes, stirring occasionally, until slightly thickened.
Add the cooled rice. Cook over medium heat for 15–20 minutes, stirring constantly, until thick, sticky, and harder to stir. Lower the heat if it starts sticking.
Spread evenly in the prepared dish. Preheat the oven to 350°F (175°C).
Combine the reserved coconut milk, brown sugar, and a pinch of salt in a small pan. Cook over medium-high heat for about 10 minutes, stirring constantly, until thick and syrupy.
Spread the topping over the rice. Bake for 30 minutes, until set and lightly caramelized. Broil on low if needed to brown the top. Watch closely.
Cool completely before cutting.