`;
if (type === 'correct') {
correctAnswers++;
selectedButton.style.backgroundColor = 'var(--crg-success-color)'; // Highlight correct
selectedButton.style.color = 'var(--crg-white)';
selectedButton.style.borderColor = 'var(--crg-success-color)';
} else {
selectedButton.style.backgroundColor = 'var(--crg-danger-color)'; // Highlight incorrect
selectedButton.style.color = 'var(--crg-white)';
selectedButton.style.borderColor = 'var(--crg-danger-color)';
}
nextBtn.style.display = 'inline-block'; // Show next button
}
function handleNext() {
currentScenarioIndex++;
if (currentScenarioIndex < scenarios.length) {
displayScenario();
} else {
showResults();
}
}
function showResults() {
resultsCorrect.textContent = correctAnswers;
resultsTotal.textContent = scenarios.length;
showScreen(resultsScreen);
}
function downloadPrinciplesPDF() {
if (typeof window.jspdf === 'undefined' || typeof window.jspdf.jsPDF.autoTable === 'undefined') {
alert("Error: PDF library could not be loaded. Please try again.");
return;
}
const { jsPDF } = window.jspdf;
const doc = new jsPDF();
const principles = [
["Competing", "Assertive & Uncooperative", "Win-lose. Pursuing own concerns at the other's expense.", "Quick action needed; unpopular decision; protect self."],
["Accommodating", "Unassertive & Cooperative", "Lose-win. Neglecting own concerns to satisfy others.", "Build goodwill; issue more important to other; preserve harmony."],
["Avoiding", "Unassertive & Uncooperative", "Lose-lose. Sidestepping or postponing the conflict.", "Issue is trivial; no chance of winning; let people cool down."],
["Collaborating", "Assertive & Cooperative", "Win-win. Working together to find a solution satisfying both.", "Integrate concerns; learn; merge insights; gain commitment."],
["Compromising", "Intermediate Assertiveness & Cooperativeness", "Partial win/lose for both. Finding an acceptable middle ground.", "Goals moderately important; temporary settlement; time pressure."]
];
doc.setFontSize(18);
doc.text("Conflict Resolution Principles", 14, 22);
doc.autoTable({
startY: 30,
head: [['Style', 'Approach', 'Goal', 'When Useful']],
body: principles,
theme: 'striped',
headStyles: { fillColor: [0, 123, 255] },
});
doc.save('Conflict_Resolution_Principles.pdf');
}
// --- 5. EVENT LISTENERS ---
startBtn.addEventListener('click', startGame);
nextBtn.addEventListener('click', handleNext);
restartBtn.addEventListener('click', startGame);
pdfBtn.addEventListener('click', downloadPrinciplesPDF);
});
