<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>Countdown Timer with Live Clock</title>
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    <style>
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        :root {
            --size: 20px;
        }

        body {
            display: grid;
            place-items: center;
            min-height: 100vh;
            background: hsl(0 0% 6%);
            margin: 0;
            position: relative;
            font-family: sans-serif;
            color: #fff;
            overflow: hidden;
        }

        /* Background Animation */
        .el {
            background: conic-gradient(from 180deg at 50% 70%, hsla(0, 0%, 98%, 1) 0deg, #eec32d 72.0000010728836deg, #ec4b4b 144.0000021457672deg, #709ab9 216.00000858306885deg, #4dffbf 288.0000042915344deg, hsla(0, 0%, 98%, 1) 1turn);
            width: 100%;
            height: 100%;
            mask:
                radial-gradient(circle at 50% 50%, white 2px, transparent 2.5px) 50% 50% / var(--size) var(--size),
                url("https://assets.codepen.io/605876/noise-mask.png") 256px 50% / 256px 256px;
            mask-composite: intersect;
            animation: flicker 20s infinite linear;
            position: absolute;
            top: 0;
            left: 0;
        }

        @keyframes flicker {
            to {
                mask-position: 50% 50%, 0 50%;
            }
        }

        .container {
            text-align: center;
            padding: 40px;
            border-radius: 15px;
            background-color: #2f343d;
            box-shadow: 0px 10px 30px rgba(0, 0, 0, 0.3);
            max-width: 900px;
            width: 100%;
        }

        .countdown {
            font-size: 1.8em;
            font-weight: 500;
            margin-top: 20px;
            color: #ecf0f1;
            letter-spacing: 1px;
            text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
            line-height: 1.4;
        }

        /* Progress Bar Styles */
        .progress {
            height: 20px;
            margin-top: 20px;
            background-color: #444;
            border-radius: 10px;
            box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.5);
        }

        .progress-bar {
            height: 100%;
            background-color: #eec32d;
            border-radius: 10px;
            text-align: center;
            line-height: 20px;
            color: white;
        }
    </style>
</head>
<body>
    <!-- Background Element -->
    <div class="el"></div>

    <div class="container">
        <h1>Countdown Timer</h1>
        <iframe scrolling="no" frameborder="no" clocktype="html5" style="overflow:hidden;border:0;margin:0;padding:0;width:227px;height:75px;" src="https://www.clocklink.com/html5embed.php?clock=008&timezone=USA_Albany&color=black&size=227&Title=&Message=&Target=&From=2025,1,1,0,0,0&Color=black"></iframe>
        <div class="countdown" id="countdown">Loading countdown...</div>

        <!-- Progress Bar -->
        <div class="progress">
            <div class="progress-bar" id="progress-bar">0%</div>
        </div>
    </div>

    <script>
        const startTime = new Date();
        startTime.setHours(9, 20, 0, 0); // 9:20 AM
        const endTime = new Date();
        endTime.setHours(16, 5, 0, 0); // 4:05 PM

        function updateClock() {
            const currentTime = new Date();
            const remainingTime = endTime - currentTime;
            const totalTime = endTime - startTime;

            if (currentTime >= startTime && currentTime <= endTime) {
                const hoursLeft = Math.floor(remainingTime / (1000 * 60 * 60));
                const minutesLeft = Math.floor((remainingTime % (1000 * 60 * 60)) / (1000 * 60));
                const secondsLeft = Math.floor((remainingTime % (1000 * 60)) / 1000);
                const millisecondsLeft = remainingTime % 1000;

                const countdownElement = document.getElementById('countdown');
                countdownElement.textContent = `Time Left: ${hoursLeft}h ${minutesLeft}m ${secondsLeft}s ${millisecondsLeft}ms`;

                // Update Progress Bar
                const progressBar = document.getElementById('progress-bar');
                const progress = ((totalTime - remainingTime) / totalTime) * 100;
                progressBar.style.width = `${progress}%`;
                progressBar.textContent = `${Math.floor(progress)}%`;
            } else {
                document.getElementById('countdown').textContent = "Outside working hours.";
                document.getElementById('progress-bar').style.width = "100%";
                document.getElementById('progress-bar').textContent = "100%";
            }
        }

        setInterval(updateClock, 1);
        updateClock();
    </script>
</body>
</html>
