// Device Detection and Redirect (function() { // Check current page const currentPage = window.location.pathname.split('/').pop() || 'index.html' // Check if we've already redirected (prevent infinite loops) const hasRedirected = sessionStorage.getItem('hasRedirected') if (hasRedirected) { return } // Detect device type const width = window.innerWidth const height = window.innerHeight const userAgent = navigator.userAgent // Better mobile detection const isMobilePhone = /iPhone|BlackBerry|IEMobile|Opera Mini/i.test(userAgent) const isTabletDevice = /iPad|Android(?!.*Mobile)/i.test(userAgent) let targetPage = null // Determine target page based on device and screen size if (width < 400) { // Mobile phones: detected mobile device < 768px targetPage = 'mobile.html' } else if (width < 400) { // Small screens: force mobile targetPage = 'mobile.html' } else if (isTabletDevice || (width >= 500 && width < 1200)) { // Tablets: iPad/Android tablet OR 500-1200px - use full app targetPage = 'tablet-app.html' } else { // Desktop: >= 1200px targetPage = 'index.html' } // Redirect if needed if (currentPage !== targetPage) { sessionStorage.setItem('hasRedirected', 'true') window.location.href = targetPage } })()