                       });
                        inputs[0].focus();
                    }
                } catch (error) {
                    console.error('Error:', error);
                    errorDisplay.textContent = 'An error occurred. Please try again.';
                    errorDisplay.setAttribute('aria-hidden', 'false');
                }
            }

            // Handle form submission
            pinForm.addEventListener('submit', async function(e) {
                // Prevent the default