Qualtrics.SurveyEngine.addOnload(function() {
  // 0) nuke the default “Click to write the question text” placeholder
  const placeholder = this.questionContainer.querySelector('.QuestionText');
  if (placeholder) placeholder.remove();

  // 1) Disable & hide Next/Continue
  try { Qualtrics.SurveyEngine.disableNextButton(); } catch(e){}
  const hideSel = [
    '#NextButton',
    'input[name="NextButton"]',
    'input[value*="Next"]',
    'input[value*="Continue"]',
    'button[name="NextButton"]',
    'button[value*="Next"]',
    'button[value*="Continue"]'
  ].join(',');
  document.querySelectorAll(hideSel).forEach(btn=>{
    btn.style.setProperty('display','none','important');
    btn.style.setProperty('visibility','hidden','important');
  });

  // 2) Build “thank you” banner
  const banner = document.createElement('div');
  banner.innerHTML = `
    <h1 style="font-size:32px; margin-bottom:12px;">
      Thank you for completing the survey!
    </h1>
    <p style="font-size:20px; line-height:1.4;">
      You may revisit this survey at any time.<br/>
      <strong>Please close this tab now.</strong>
    </p>
  `;
  banner.style.cssText = `
    background-color: #e9f7ff;
    border: 3px solid #0056b3;
    border-radius: 8px;
    padding: 24px;
    max-width: 800px;
    margin: 40px auto;
    text-align: center;
  `;

  // 3) Inject at top of the question container
  this.questionContainer.insertBefore(banner, this.questionContainer.firstChild);
});
