function shuffleArray(array) {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
function handleCardClick(card) {
if (selectedCards.length >= 2 || card.classList
.contains('matched')) return;
card.textContent = card.dataset.content;
card.classList.add('selected');
selectedCards.push(card);
if (selectedCards.length === 2) {
setTimeout(checkMatch, 500);
const [card1, card2] = selectedCards;
const content1 = card1.dataset.content;
const content2 = card2.dataset.content;
if (isMatch(content1, content2)) {
card1.classList.add('matched');
card2.classList.add('matched');
if (matchedPairs === cards.length / 2) {
document.getElementById('result