                      } else {
                            pinError.textContent = `Invalid PIN. ${data.attemptsLeft} attempts remaining.`;
                        }
                        clearPinInputs();
                    }
                } catch (err) {
                    console.error('Error verifying PIN:', err);
                    pinError.textContent = 'Error verifying PIN';
                    clearPinInputs();
                }
            };

            // Theme toggle handler
            c