Stacks of counters (counters with the same x,y coordinate) can be shown in two different ways. This is set by the variable Counter::haveOffset which is either true or false.
bool Counter::haveOffset = true; // true = unopened stack has offset
If true each counter in the stack has an offset relative to the counter below it. The amount of this offset is set by the variable Counter::stackOffset.
int Counter::stackOffset = 5;
The offset is set to 5 pixels as shown here with a stack of 3:

If Counter::haveOffset is false, the stack has no offset but instead a number in the upper right corner that tells how many counters there are in the stack. A single-counter stack has no number:

Hoovering over a stack for 1 second will always display the contents of the stack in a separate popup window (together with an image of the map below the stack):

Opening a stack means you can access the individual counters. There are two ways to open a stack. This is set by the flag CentralFrame::openStackoffset.
bool CentralFrame::openStackoffset = true; // true = open stack with offset method
If true the stack is opened by increasing the offset between counters by a factor given by
int openFactor
An openFactor of 3 will look like this:

Note: a stack can be opened with double leftclick or CTRL-leftclick, the only difference being that
double leftclick also select the top counter.
Note: only one offsetless stack can be opened at a time, stacks with offset can have multiple opened
stacks at a time.
Note: all open stacks are closed by hitting the Esc button.
An open stack with Counter::haveOffset = true has two abilities:
Left-clicking an unopened stack will select the whole stack. Right-clicking an unopened stack will open the menu for the top counter (unless you can aim at a counter below the top).
If you open a stack by CTRL-rightclick (not CRTL-leftclick), you open it in the opposite direction facing down left. This can be useful if for some reason opening a stack up right will block something.

Setting CentralFrame::openStackoffset to false will open the stack in a popup window similar to hoovering except that this popup window is persistent and must be closed.

You close the popup window by left-clicking anywhere on the map or hitting Esc.
In the stack popup window you can do two things:
Note: you can not right-click counters in the popup window.
Note: while the popup window is opened the stack itself is disabled (every counter has disabled = true). When a counter is disabled it can not be moved, selected or right-clicked.
You can bring up the right-click menu of any counter in the stack by first selecting it in the popup window, closing the popup window and then right-clicking.

Note: if more than one counter is selected in a stack, then the right-click action will be applied to all the selected counters in the stack (actually all selected counters wherever they are) at once.

The combination Counter::haveOffset = false and CentralFrame::openStackoffset = true has no meaning. The stack will not open.
You can freely reorder the counters in a stack with Counter::haveOffset = true. A counter that is reordered must first be selected. You can select multiple counters by holding down the SHIFT key.

You drag the selected counters to their new position in the stack. They will drop in order.

Multiple stacks are selected by holding down the SHIFT key.

If you drag multiple selected stacks and one of them is moved beyond the map frame, only those stacks still on the map are dropped.

Dragging selected counters from multiple opened stacks must maintain their relative distance when dropped.

The relative distance from the left-top corner of the source stacks are the same as the relative distance between the dropped counters (the red and blue lines remain the same).
Code can be found in a new branch prototype5
CPLUS_INCLUDE_PATH=/home/me/Qt/6.6.2/gcc_64/include;export CPLUS_INCLUDE_PATH
LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:/home/me/Qt/6.6.2/gcc_64/lib;export LD_LIBRARY_PATH
g++ -Wall -o main main.cpp luau.cpp counter.cpp window.cpp frame.cpp overlay.cpp io.cpp scale.cpp -I/home/me/luau/VM/include -I/home/me/luau/Compiler/include -I/home/me/Qt/6.6.2/gcc_64/include/QtWidgets -Wl,--copy-dt-needed-entries -L/home/me/Qt/6.6.2/gcc_64/lib -lQt6Core -lQt6Widgets -L/home/me/luau -lLuau.VM -lLuau.Compiler -lLuau.Ast -lisocline