Intervals are scheduling requests

A callback is not guaranteed to execute at the exact requested millisecond, especially when the device sleeps.

Store the intended end time

Compute remaining time from the current clock and the phase deadline whenever the UI updates.

Handle system-clock changes

A manual clock change can affect wall-time timers. Important elapsed-time measurement should use monotonic clocks where available.

Notifications are optional

Audio and system notifications require user permission or interaction. The visible timer must remain useful without them.

Recalculate from an absolute phase deadline

A reliable implementation records the intended wall-clock deadline when a phase starts. Each paint computes deadline minus the current time; it does not subtract one second merely because an interval callback happened. If a background callback arrives 18 seconds late, the displayed remainder still loses the full 18 seconds. When auto-start is enabled, overdue transitions are advanced from their original deadlines in sequence, so a sleeping laptop can catch up instead of stretching every phase by the amount of throttling.

Understand clock changes and recovery

Absolute timestamps solve callback delay, but they still follow the device wall clock. Manually changing time, resuming after a long sleep, or restoring a tab from browser memory can move the apparent deadline. This timer recalculates when the page becomes visible and caps transition catch-up to prevent unbounded work after an extreme jump. Check the phase shown after wake, and reset if the system clock changed intentionally. Audio is only an alert; the visible state and your own session notes remain the auditable record.