().startsWith(next) && w.y > bestY) { candidate = w; bestY = w.y; }
          }
          if (candidate) {
            state.buffer = next; state.correctChars++;
            state.targetId = candidate.id; candidate.typed = next.length;
            if (candidate.typed >= candidate.text.length) completeWord(candidate);
          } else {
            flashMiss();
          }
          updateHUD();
        }

        function handleBackspace() {
          if (!state.running || state.paused) return;
          if