const video = document.getElementById('videoPlayer');
const endOverlay = document.getElementById('endOverlay');
const playButton = document.getElementById('playButton');
const thumbnail = document.getElementById('thumbnailImage');

playButton.addEventListener('click', () => {
    playButton.classList.add('hidden');
    thumbnail.classList.add('hidden');
    endOverlay.classList.add('hidden');
    video.classList.remove('hidden');
    video.play();
});

function endVideo() {
    video.pause();
    video.currentTime = 0;
    video.classList.add('hidden');
    thumbnail.classList.remove('hidden');
    endOverlay.classList.remove('hidden');
}
document.getElementById("bannerContainer").classList.remove("hidden");
video.addEventListener('ended', endVideo);
video.addEventListener('timeupdate', () => {
    if (video.currentTime >= 10) {
        endVideo();
    }
});

// User counter simulation
let userCount = 5000;
const userCountSpan = document.getElementById("userCount");
setInterval(() => {
    const change = Math.floor(Math.random() * 3) - 1;
    userCount = Math.max(1, userCount + change);
    userCountSpan.textContent = userCount;
}, 4000);