Preheat the oven to 350°F. Line a light-colored metal 8×8 baking pan with parchment paper, leaving an overhang on two sides so you can lift the bars out later. (If you only have a glass pan, plan to add 2 to 3 minutes to the bake time, since glass bakes slower and is the most common reason the center turns out underdone.)
In a large bowl, cream the butter, granulated sugar, and brown sugar together on medium speed until smooth and creamy (about 2 minutes). Add the egg, vanilla extract, and almond extract (if using), and mix to combine.
1/2 cup butter, 1/2 cup granulated sugar, 2 tbsp brown sugar, 1 large egg, 2 tsp vanilla extract, 1/4 tsp almond extract
Mix in the flour, cornstarch, baking powder, and salt just until the flour disappears and a soft dough forms. Do not overmix. Press the dough evenly into the prepared pan, pushing it all the way into the corners so it bakes evenly.
1/2 tsp baking powder, 1 & 1/2 cup all purpose flour, 1 tbsp cornstarch, 1/4 tsp salt
Bake for 16 to 18 minutes, until the edges are set and pale golden and the center looks puffed and matte, not wet or shiny. The very center will still feel soft to the touch, and that is correct. A toothpick in the center should come out with a few moist crumbs, not wet batter. These bars finish setting as they cool, so it is better to pull them slightly early than to overbake.
Let the bars cool completely in the pan, at least 1 hour, before frosting or slicing. This step is not optional. They keep setting as they cool, so cutting in while they're warm is the number one reason the center seems gooey. Once fully cool, the center firms into a soft, chewy bar.
Frosting
In a large bowl, whip the softened butter and powdered sugar together until smooth.
4 tbsp butter, 1 & 1/2 cup powdered sugar
Add the vanilla extract and 1 tablespoon of cold heavy cream, whipping on high speed for 1–2 minutes until light and fluffy. (Add an extra tablespoon of cream only if needed for spreadability).
1 tsp vanilla extract, 2 tbsp heavy cream
Frost the cooled bars with a thick layer, then top with patriotic sprinkles while the frosting is still soft so they stick. Slice and serve, or chill for 20 to 30 minutes first if you want the cleanest squares and a firmer frosting.