Enjoy a 5% discount with your registration!

const portalButtons = document.querySelectorAll('.portal-btn');
const messageElement = document.getElementById('message');
const result = document.querySelector('.result');
let countdownElement = document.getElementById('countdown'); 

let countdown = 99;
let countdownTimer;

let clickCounter = 0;
let nextSuperSIPInterval = getRandomInterval();

function getRandomInterval() {
  return Math.floor(Math.random() * (9 - 5 + 1)) + 5;
}

function startCountdown() {
  countdown = 99;
  countdownElement.textContent = `Portal closing: ${countdown}s`;
  countdownTimer = setInterval(() => {
    countdown--;
    countdownElement.textContent = `Portal closing: ${countdown}s`;
    if (countdown <= 0) {
      shufflePortals();
    }
  }, 1000);
}

function resetCountdown() {
  clearInterval(countdownTimer);
  startCountdown();
}

function shufflePortals() {
  const container = document.querySelector('.portals');
  const buttonsArray = Array.from(portalButtons);

  buttonsArray.forEach(button => {
    container.removeChild(button);
  });

  buttonsArray.sort(() => Math.random() - 0.5);
  buttonsArray.forEach(button => {
    container.appendChild(button);
  });
}

function showMessage(code) {
  const combinations = {
    "11": "⚙️ 111",
    "1111": "✴️ 2222",
    "22": "🔱 444",
    "333": "❖ 666",
    "444": "⚜️ 777",
    "5555": "🔮 999",
    "6666": "☀️ 8888",
    "777": "⛧ 1212",
    "8888": "💠 1221"
  };
  const shouldRandomize = Math.random() > 0.5;
  let combination = shouldRandomize ? getRandomCombination() : combinations[code];
  messageElement.textContent = combination || "••••";
  result.style.display = "block";
  messageElement.style.opacity = "0";
  messageElement.style.animation = "fade-in 2s forwards";
}

function getRandomCombination() {
  const keys = Object.keys(combinations);
  const randomKey = keys[Math.floor(Math.random() * keys.length)];
  return combinations[randomKey];
}

function showSuperSIPMessage() {
  const superSIPMessages = [
    "SuperSIP: Time loops, yet you are outside it.",
    "SuperSIP: The veil is thin. The answer is closer than you think.",
    "SuperSIP: The cycle repeats, but your awareness grows.",
    "SuperSIP: What you seek lies beyond the dreamscape.",
    "SuperSIP: Between worlds, there is silence. Listen closely.",
    "SuperSIP: Not everything is what it seems, but you already know that.",
    "SuperSIP: Shadows are but reflections of your own consciousness.",
    "SuperSIP: The last stone unlocks the path ahead.",
    "SuperSIP: In darkness, you will find the brightest light.",
    "SuperSIP: The path is not straight, but you will reach your destination.",
    "SuperSIP: The hidden truth lies beneath the surface.",
    "SuperSIP: Time bends. Reality shifts. You remain still.",
    "SuperSIP: What has passed will come again, in new forms.",
    "SuperSIP: You are the key, but you must also find the lock.",
    "SuperSIP: Through the chaos, clarity awaits.",
    "SuperSIP: Every portal is a choice, but the outcome is uncertain.",
    "SuperSIP: What you seek is seeking you.",
    "SuperSIP: The silence speaks louder than the noise.",
    "SuperSIP: Every end is a new beginning in disguise.",
    "SuperSIP: The stars remember what we have forgotten.",
    "SuperSIP: The unseen is more real than what is visible.",
    "SuperSIP: When you close your eyes, you will truly see.",
    "SuperSIP: A single moment can contain eternity.",
    "SuperSIP: The patterns are there, hidden in plain sight.",
    "SuperSIP: The wheel turns, but you stand outside of time.",
    "SuperSIP: What lies ahead is not what you expect.",
    "SuperSIP: The question shapes the answer.",
    "SuperSIP: The light and shadow are part of the same truth.",
    "SuperSIP: What you are avoiding is the key to the next step.",
    "SuperSIP: The closer you look, the less you will see.",
    "SuperSIP: You are both the traveler and the destination.",
    "SuperSIP: A new path reveals itself with each choice you make.",
    "SuperSIP: Every thought echoes in eternity.",
    "SuperSIP: The answers have been within you all along.",
    "SuperSIP: To step forward, you must let go of the past.",
    "SuperSIP: Reality is the dream, and the dream is reality.",
    "SuperSIP: The cycles continue, but you are free to break them.",
    "SuperSIP: What once was lost can always be found.",
    "SuperSIP: The void holds more answers than the noise.",
    "SuperSIP: There are no wrong paths, only new ones.",
    "SuperSIP: The balance between light and dark is fragile.",
    "SuperSIP: Each portal opens to a reflection of your soul.",
    "SuperSIP: The deeper you go, the clearer it becomes.",
    "SuperSIP: Silence speaks the loudest when you listen.",
    "SuperSIP: Every moment is both an end and a beginning.",
    "SuperSIP: The labyrinth is not external, but within.",
    "SuperSIP: Not every mystery is meant to be solved.",
    "SuperSIP: The dream knows more than you realize.",
    "SuperSIP: The closer you come, the further you will feel.",
    "SuperSIP: All paths converge in the end.",
    "SuperSIP: The wheel of time turns for you.",
    "SuperSIP: Each moment changes everything.",
    "SuperSIP: What is known is but a shadow of what is unknown.",
    "SuperSIP: Even the stars have secrets they don't share.",
    "SuperSIP: Seek not the answer, but the next question.",
    "SuperSIP: The future whispers in dreams.",
    "SuperSIP: Between light and shadow, truth exists.",
    "SuperSIP: The portal reflects what you need, not what you want.",
    "SuperSIP: Every door opened is a door closed elsewhere.",
    "SuperSIP: Your past selves leave clues for the future.",
    "SuperSIP: You are the guide and the guided.",
    "SuperSIP: The unseen threads hold the universe together.",
    "SuperSIP: The end is only another starting point.",
    "SuperSIP: A step forward requires a leap of faith.",
    "SuperSIP: Time dances in circles, and you are the music.",
    "SuperSIP: The light you follow casts a shadow behind.",
    "SuperSIP: A single word can change the whole story.",
    "SuperSIP: The unknown calls, and you must answer.",
    "SuperSIP: What seems lost is never gone forever.",
    "SuperSIP: The truth hides in paradoxes.",
    "SuperSIP: The journey is as important as the destination.",
    "SuperSIP: The web of fate is woven in silence.",
    "SuperSIP: You are both the observer and the observed.",
    "SuperSIP: What you see is not what you get.",
    "SuperSIP: Time expands and contracts, yet you remain constant.",
    "SuperSIP: The cycles of time never truly end.",
    "SuperSIP: The universe listens, even when you don't speak.",
    "SuperSIP: What you feel is more important than what you think.",
    "SuperSIP: The deeper you dig, the higher you will rise.",
    "SuperSIP: The answers are hidden between the seconds.",
    "SuperSIP: Truths come to those who wait in stillness.",
    "SuperSIP: You already know what you seek.",
    "SuperSIP: The mystery is in the journey, not the destination.",
    "SuperSIP: The stars are the silent witnesses of time.",
    "SuperSIP: Look within, for there lies the key.",
    "SuperSIP: The void holds the answers that words cannot express.",
    "SuperSIP: Not all shadows are to be feared.",
    "SuperSIP: Time bends, but your path remains."
  ];
  const superSIPMessage = superSIPMessages[Math.floor(Math.random() * superSIPMessages.length)];
  messageElement.textContent = superSIPMessage;
  result.style.display = "block";
  messageElement.style.opacity = "0";
  messageElement.style.animation = "fade-in 2s forwards";
  resetCountdown();
}

portalButtons.forEach(button => {
  button.addEventListener('click', () => {
    const code = button.getAttribute('data-code');
    showMessage(code);
    shufflePortals();
    clickCounter++;
    if (clickCounter >= nextSuperSIPInterval) {
      showSuperSIPMessage();
      clickCounter = 0;
      nextSuperSIPInterval = getRandomInterval();
    }
  });
});

startCountdown();