function updateStats() const text = textarea.value; const charCount = text.length; const wordUnits = calculateWordsFromChars(text);
charSpan.textContent = charCount; wordSpan.textContent = wordUnits.toFixed(1);
// If text is empty, reset timer if (charCount === 0) startTime = null; timeSpan.textContent = '0'; wpmSpan.textContent = '0'; return;
.stats display: flex; flex-wrap: wrap; gap: 1rem; margin: 1rem 0; background: white; padding: 0.8rem; border-radius: 16px;
resetBtn.addEventListener('click', resetCounter);
const elapsedSeconds = (Date.now() - startTime) / 1000; timeSpan.textContent = Math.floor(elapsedSeconds);
);
button:hover background: #0f1720;