document.addEventListener('DOMContentLoaded', () => { const questions = [ "Given the choice of anyone in the world, whom would your character want as a dinner guest?", "Would your character like to be famous? In what way?", "Before making a phone call, does your character ever rehearse what they're going to say? Why?", "What would constitute a perfect day for your character?", "When did your character last sing to themself? To someone else?", "If your character were able to live to the age of 90 and retain either the mind or body of a 30-year-old for the last 60 years of their life, which would they choose?", "Does your character have a secret hunch about how they will die?", "Name three things your character and their current partner (or future partner) appear to have in common.", "For what in their life does your character feel most grateful?", "If your character could change anything about the way they were raised, what would it be?", "Take four minutes and tell your character's life story in as much detail as possible.", "If your character could wake up tomorrow having gained any one quality or ability, what would it be?", "If a crystal ball could tell your character the truth about themself, their life, the future, or anything else, what would they want to know?", "Is there something that your character has dreamed of doing for a long time? Why haven't they done it?", "What is the greatest accomplishment of your character's life?", "What does your character most value in a friendship?", "What is your character's most treasured memory?", "What is your character's most terrible memory?", "If your character knew that in one year they would die suddenly, would they change anything about the way they are now living? Why?", "What does friendship mean to your character?", "What roles do love and affection play in your character's life?", "Alternate sharing something your character considers a positive characteristic of themselves. Share a total of five items.", "How close and warm is your character's family? Do they feel their childhood was happier than most other people's?", "How does your character feel about their relationship with their mother?", "Make three true 'we' statements each about your character. For instance, 'We are both in this room feeling...'", "Complete this sentence for your character: 'I wish I had someone with whom I could share...'", "If your character were going to become a close friend with someone, what is important for that person to know?", "Tell what your character likes about the other; be honest this time, saying things that they might not say to someone they've just met.", "Share with the other an embarrassing moment in your character's life.", "When did your character last cry in front of another person? By themself?", "Tell what your character already likes about the other.", "What, if anything, is too serious to be joked about for your character?", "If your character were to die this evening with no opportunity to communicate with anyone, what would they most regret not having told someone? Why haven't they told them yet?", "Your character's house, containing everything they own, catches fire. After saving their loved ones and pets, they have time to safely make a final dash to save any one item. What would it be? Why?", "Of all the people in your character's family, whose death would they find most disturbing? Why?", "Share a personal problem your character has and ask the other's advice on how they might handle it." ]; const homeScreen = document.getElementById('home-screen'); const questionScreen = document.getElementById('question-screen'); const resultScreen = document.getElementById('result-screen'); const questionText = document.getElementById('question-text'); const answerInput = document.getElementById('answer-input'); const progressText = document.getElementById('progress'); const progressBar = document.getElementById('progress-bar'); const profileSummary = document.getElementById('profile-summary'); const startBtn = document.getElementById('start-btn'); const prevBtn = document.getElementById('prev-btn'); const nextBtn = document.getElementById('next-btn'); const homeBtn = document.getElementById('home-btn'); const resetBtn = document.getElementById('reset-btn'); const restartBtn = document.getElementById('restart-btn'); let currentQuestion = 0; const answers = Array(questions.length).fill(''); function showHomeScreen() { homeScreen.classList.remove('hidden'); questionScreen.classList.add('hidden'); resultScreen.classList.add('hidden'); currentQuestion = 0; } function showQuestionScreen() { homeScreen.classList.add('hidden'); questionScreen.classList.remove('hidden'); resultScreen.classList.add('hidden'); updateQuestion(); } function showResultScreen() { homeScreen.classList.add('hidden'); questionScreen.classList.add('hidden'); resultScreen.classList.remove('hidden'); generateProfile(); } function updateQuestion() { questionText.textContent = questions[currentQuestion]; answerInput.value = answers[currentQuestion]; progressText.textContent = `Question ${currentQuestion + 1}/${questions.length}`; progressBar.style.width = `${((currentQuestion + 1) / questions.length) * 100}%`; prevBtn.disabled = currentQuestion === 0; } function saveAnswer() { answers[currentQuestion] = answerInput.value; } async function generateProfile() { let profileHTML = `
${qa.answer}
Failed to generate AI-enhanced profile. Showing basic responses instead.